From 840152fd2d0a26db041dc5e645f20eb67b157ae1 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 23 Jun 1998 13:39:54 +0000 Subject: [PATCH] Debut portage Cray T3E git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1992 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- byterun/lexing.c | 2 +- byterun/mlvalues.h | 12 +++++++-- byterun/parsing.c | 2 +- config/auto-aux/sizes.c | 3 ++- config/m-templ.h | 7 ++++++ configure | 55 ++++++++++++++++++++++------------------- 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/byterun/lexing.c b/byterun/lexing.c index 56033d51a..9105bce60 100644 --- a/byterun/lexing.c +++ b/byterun/lexing.c @@ -38,7 +38,7 @@ struct lexing_table { value lex_check; }; -#ifdef ARCH_BIG_ENDIAN +#if defined(ARCH_BIG_ENDIAN) || SIZEOF_SHORT != 2 #define Short(tbl,n) \ (*((unsigned char *)((tbl) + (n) * 2)) + \ (*((schar *)((tbl) + (n) * 2 + 1)) << 8)) diff --git a/byterun/mlvalues.h b/byterun/mlvalues.h index f862a4c4a..3f0c6d7b7 100644 --- a/byterun/mlvalues.h +++ b/byterun/mlvalues.h @@ -55,8 +55,16 @@ typedef unsigned int tag_t; /* Actually, an unsigned char */ typedef unsigned long color_t; typedef unsigned long mark_t; -typedef int int32; /* Not portable, but checked by autoconf. */ -typedef unsigned int uint32; /* Seems like a reasonable assumption anyway. */ +#if SIZEOF_INT == 4 +typedef int int32; +typedef unsigned int uint32; +#elif SIZEOF_LONG == 4 +typedef long int32; +typedef unsigned long uint32; +#elif SIZEOF_SHORT == 4 +typedef short int32; +typedef unsigned short uint32; +#endif /* Longs vs blocks. */ #define Is_long(x) (((x) & 1) != 0) diff --git a/byterun/parsing.c b/byterun/parsing.c index f4caea09b..4f586c9b2 100644 --- a/byterun/parsing.c +++ b/byterun/parsing.c @@ -57,7 +57,7 @@ struct parser_env { /* Mirrors parser_env in ../stdlib/parsing.ml */ value errflag; }; -#ifdef ARCH_BIG_ENDIAN +#if defined(ARCH_BIG_ENDIAN) || SIZEOF_SHORT != 2 #define Short(tbl,n) \ (*((unsigned char *)((tbl) + (n) * 2)) + \ (*((schar *)((tbl) + (n) * 2 + 1)) << 8)) diff --git a/config/auto-aux/sizes.c b/config/auto-aux/sizes.c index 8eb2018df..1a5e921fc 100644 --- a/config/auto-aux/sizes.c +++ b/config/auto-aux/sizes.c @@ -13,6 +13,7 @@ int main(int argc, char **argv) { - printf("%d %d %d\n", sizeof(int), sizeof(long), sizeof(long *)); + printf("%d %d %d %d\n", + sizeof(int), sizeof(long), sizeof(long *), sizeof(short)); return 0; } diff --git a/config/m-templ.h b/config/m-templ.h index af465910a..9cb73149f 100644 --- a/config/m-templ.h +++ b/config/m-templ.h @@ -39,3 +39,10 @@ /* Define ARCH_CODE32 if, on a 64-bit machine, code pointers fit in 32 bits, i.e. the code segment resides in the low 4G of the addressing space. ARCH_CODE32 is ignored on 32-bit machines. */ + +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_SHORT 2 + +/* Define SIZEOF_INT, SIZEOF_LONG and SIZEOF_SHORT to the sizes in byte + of the C types "int", "long" and "short", respectively. */ diff --git a/configure b/configure index 06bf10bfd..8ec96c9b7 100755 --- a/configure +++ b/configure @@ -187,32 +187,37 @@ esac echo "Checking the sizes of integers and pointers..." set `sh ./runtest sizes.c` -case "$1,$2,$3" in - 4,4,4) echo "OK, this is a regular 32 bit architecture." - echo "#undef ARCH_SIXTYFOUR" >> m.h;; - 4,8,8) echo "Wow! A 64 bit architecture!" - echo "#define ARCH_SIXTYFOUR" >> m.h - case "$bytecc,$host" in - gcc,alpha-*-osf*) echo "#define ARCH_CODE32" >> m.h;; - *) echo "#undef ARCH_CODE32" >> m.h;; - esac;; - 8,*,*) echo "Wow! A 64 bit architecture!" - echo "Unfortunately, Objective Caml does not handle the case" - echo "sizeof(int) = 8." - echo "Objective Caml won't run on this architecture." - exit 2;; - *,*,8) echo "Wow! A 64 bit architecture!" - echo "Unfortunately, Objective Caml cannot work in the case" - echo "sizeof(long) != sizeof(long *)." - echo "Objective Caml won't run on this architecture." - exit 2;; - *,*,*) echo "This architecture seems to be neither 32 bits nor 64 bits." - echo "Objective Caml won't run on this architecture." - exit 2;; - *) echo "Unable to compile the test program." - echo "Make sure the C compiler $cc is properly installed." - exit 2;; +case "$2,$3" in + 4,4) echo "OK, this is a regular 32 bit architecture." + echo "#undef ARCH_SIXTYFOUR" >> m.h;; + 8,8) echo "Wow! A 64 bit architecture!" + echo "#define ARCH_SIXTYFOUR" >> m.h + case "$bytecc,$host" in + gcc,alpha-*-osf*) echo "#define ARCH_CODE32" >> m.h;; + *) echo "#undef ARCH_CODE32" >> m.h;; + esac;; + *,8) echo "Wow! A 64 bit architecture!" + echo "Unfortunately, Objective Caml cannot work in the case" + echo "sizeof(long) != sizeof(long *)." + echo "Objective Caml won't run on this architecture." + exit 2;; + *,*) echo "This architecture seems to be neither 32 bits nor 64 bits." + echo "Objective Caml won't run on this architecture." + exit 2;; + *) echo "Unable to compile the test program." + echo "Make sure the C compiler $cc is properly installed." + exit 2;; esac +if test $1 != 4 && test $2 != 4 && test $4 != 4; then + echo "Sorry, we can't find a 32-bit integer type" + echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)" + echo "Objective Caml won't run on this architecture." + exit 2 +fi + +echo "#define SIZEOF_INT $1" >> m.h +echo "#define SIZEOF_LONG $2" >> m.h +echo "#define SIZEOF_SHORT $4" >> m.h # Determine endianness