From bae4afc9c3b2000b9d258aaf1ed3bc3b935cc0e7 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Wed, 15 Jul 2009 15:18:34 +0200 Subject: [PATCH] Teach ECL to detect the size of 'int' and 'long' --- src/aclocal.m4 | 21 +++++++++++++++++++-- src/configure | 23 +++++++++++++++++++++-- src/h/config.h.in | 2 ++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 32830f95a..2c092f410 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -605,6 +605,8 @@ AC_SUBST(CL_FIXNUM_TYPE) AC_SUBST(CL_FIXNUM_BITS) AC_SUBST(CL_FIXNUM_MAX) AC_SUBST(CL_FIXNUM_MIN) +AC_SUBST(CL_INT_BITS) +AC_SUBST(CL_LONG_BITS) AC_MSG_CHECKING(appropiate type for fixnums) if test -z "${CL_FIXNUM_TYPE}" ; then AC_RUN_IFELSE([AC_LANG_SOURCE([[#include @@ -641,10 +643,25 @@ int main() { fprintf(f,"CL_FIXNUM_MIN='%ld';",l); fprintf(f,"CL_FIXNUM_MAX='%ld';",-l); #endif - } else + } else { exit(1); + } fprintf(f,"CL_FIXNUM_TYPE='%s';",int_type); - fprintf(f,"CL_FIXNUM_BITS='%d'",bits); + fprintf(f,"CL_FIXNUM_BITS='%d';",bits); + { + unsigned int x = 1; + for (bits = 0; x; bits++) { + x <<= 1; + } + fprintf(f,"CL_INT_BITS='%d';",bits); + } + { + unsigned long x = 1; + for (bits = 0; x; bits++) { + x <<= 1; + } + fprintf(f,"CL_LONG_BITS='%d'",bits); + } exit(0); }]])],[eval "`cat conftestval`"],[],[]) fi diff --git a/src/configure b/src/configure index c3fb7b798..b61c1d0e0 100755 --- a/src/configure +++ b/src/configure @@ -648,6 +648,8 @@ ECL_FILE_CNT ECL_LONGJMP ECL_SETJMP ECL_STDINT_HEADER +CL_LONG_BITS +CL_INT_BITS CL_FIXNUM_MIN CL_FIXNUM_MAX CL_FIXNUM_BITS @@ -8023,6 +8025,8 @@ _ACEOF + + { $as_echo "$as_me:$LINENO: checking appropiate type for fixnums" >&5 $as_echo_n "checking appropiate type for fixnums... " >&6; } if test -z "${CL_FIXNUM_TYPE}" ; then @@ -8075,10 +8079,25 @@ int main() { fprintf(f,"CL_FIXNUM_MIN='%ld';",l); fprintf(f,"CL_FIXNUM_MAX='%ld';",-l); #endif - } else + } else { exit(1); + } fprintf(f,"CL_FIXNUM_TYPE='%s';",int_type); - fprintf(f,"CL_FIXNUM_BITS='%d'",bits); + fprintf(f,"CL_FIXNUM_BITS='%d';",bits); + { + unsigned int x = 1; + for (bits = 0; x; bits++) { + x <<= 1; + } + fprintf(f,"CL_INT_BITS='%d';",bits); + } + { + unsigned long x = 1; + for (bits = 0; x; bits++) { + x <<= 1; + } + fprintf(f,"CL_LONG_BITS='%d'",bits); + } exit(0); } _ACEOF diff --git a/src/h/config.h.in b/src/h/config.h.in index 60beb5761..60ae4e34d 100644 --- a/src/h/config.h.in +++ b/src/h/config.h.in @@ -123,6 +123,8 @@ * but the required headers are not present in all systems. Hence we * use autoconf to guess the following values. */ +#define ECL_INT_BITS @CL_INT_BITS@ +#define ECL_LONG_BITS @CL_LONG_BITS@ #define FIXNUM_BITS @CL_FIXNUM_BITS@ #define MOST_POSITIVE_FIXNUM ((cl_fixnum)@CL_FIXNUM_MAX@) #define MOST_NEGATIVE_FIXNUM ((cl_fixnum)@CL_FIXNUM_MIN@)