diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2000-02-11 15:47:09 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2000-02-11 15:47:09 +0000 |
commit | 34068509c888623640b140b7aaa8299d285c21d9 (patch) | |
tree | 5ed8263749624e5f8298a451edc46925ec91bb5c | |
parent | 1cac40336824df625d468405459febc63effd292 (diff) |
Revu la configuration des entiers 64 bits
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2808 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | byterun/config.h | 9 | ||||
-rw-r--r-- | byterun/custom.c | 4 | ||||
-rw-r--r-- | byterun/ints.c | 9 | ||||
-rw-r--r-- | config/m-nt.h | 5 | ||||
-rw-r--r-- | config/m-templ.h | 17 | ||||
-rwxr-xr-x | configure | 11 |
6 files changed, 33 insertions, 22 deletions
diff --git a/byterun/config.h b/byterun/config.h index 8393a26be..e52cc1443 100644 --- a/byterun/config.h +++ b/byterun/config.h @@ -38,12 +38,9 @@ typedef short int32; typedef unsigned short uint32; #endif -#if SIZEOF_LONG == 8 -typedef long int64; -typedef unsigned long uint64; -#elif SIZEOF_LONG_LONG == 8 -typedef long long int64; -typedef unsigned long long uint64; +#if defined(ARCH_INT64_TYPE) && defined(ARCH_UINT64_TYPE) +typedef ARCH_INT64_TYPE int64; +typedef ARCH_UINT64_TYPE uint64; #else /* Int64.t will not be supported, and operations over it are not defined, but we must define the types int64 and uint64 as 64-bit placeholders. */ diff --git a/byterun/custom.c b/byterun/custom.c index c814f1d6f..30d667f7c 100644 --- a/byterun/custom.c +++ b/byterun/custom.c @@ -100,7 +100,7 @@ struct custom_operations * final_custom_operations(final_fun fn) } extern struct custom_operations int32_ops, nativeint_ops; -#if SIZEOF_LONG == 8 || SIZEOF_LONG_LONG == 8 +#ifdef ARCH_INT64_TYPE extern struct custom_operations int64_ops; #endif @@ -108,7 +108,7 @@ void init_custom_operations(void) { register_custom_operations(&int32_ops); register_custom_operations(&nativeint_ops); -#if SIZEOF_LONG == 8 || SIZEOF_LONG_LONG == 8 +#ifdef ARCH_INT64_TYPE register_custom_operations(&int64_ops); #endif } diff --git a/byterun/ints.c b/byterun/ints.c index f37240e15..afe347a78 100644 --- a/byterun/ints.c +++ b/byterun/ints.c @@ -241,7 +241,7 @@ value int32_of_string(value s) /* ML */ /* 64-bit integers */ -#if SIZEOF_LONG == 8 || SIZEOF_LONG_LONG == 8 +#ifdef ARCH_INT64_TYPE static int int64_compare(value v1, value v2) { @@ -346,12 +346,7 @@ value int64_format(value fmt, value arg) /* ML */ char * buffer; value res; - buffer = parse_format(fmt, -#if SIZEOF_LONG == 8 - "l", -#else - "ll", -#endif + buffer = parse_format(fmt, ARCH_INT64_PRINTF_FORMAT, format_string, default_format_buffer); sprintf(buffer, format_string, Int64_val(arg)); res = copy_string(buffer); diff --git a/config/m-nt.h b/config/m-nt.h index fc8cbc1f5..ad3c6eb8e 100644 --- a/config/m-nt.h +++ b/config/m-nt.h @@ -12,7 +12,7 @@ /* $Id$ */ -/* Machine configuration, Intel x86 processors, Windows NT */ +/* Machine configuration, Intel x86 processors, Win32, Visual C++ compiler */ #undef ARCH_SIXTYFOUR #undef ARCH_BIG_ENDIAN @@ -20,4 +20,7 @@ #define SIZEOF_INT 4 #define SIZEOF_LONG 4 #define SIZEOF_SHORT 2 +#define ARCH_INT64_TYPE __int64 +#define ARCH_UINT64_TYPE unsigned __int64 +#define ARCH_INT64_PRINTF_FORMAT "I64" diff --git a/config/m-templ.h b/config/m-templ.h index 480bd952a..b85ad5714 100644 --- a/config/m-templ.h +++ b/config/m-templ.h @@ -48,7 +48,18 @@ /* Define SIZEOF_INT, SIZEOF_LONG and SIZEOF_SHORT to the sizes in byte of the C types "int", "long" and "short", respectively. */ -#define SIZEOF_LONG_LONG 8 +#define ARCH_INT64_TYPE long long +#define ARCH_UINT64_TYPE unsigned long long -/* Define SIZEOF_LONG_LONG to the size in byte of the C type "long long", - if supported by the C compiler. Otherwise, define SIZEOF_LONG_LONG as 0. */ +/* Define ARCH_INT64_TYPE and ARCH_UINT64_TYPE to 64-bit integer types, + typically "long long" and "unsigned long long" on 32-bit platforms, + and "long" and "unsigned long" on 64-bit platforms. + If the C compiler doesn't support any 64-bit integer type, + leave both ARCH_INT64_TYPE and ARCH_UINT64_TYPE undefined. */ + +#define ARCH_INT64_PRINTF_FORMAT "ll" + +/* Define ARCH_INT64_PRINTF_FORMAT to the printf format used for formatting + values of type ARCH_INT64_TYPE. This is usually "ll" on 32-bit + platforms and "l" on 64-bit platforms. + Leave undefined if ARCH_INT64_TYPE is undefined. */ @@ -261,13 +261,18 @@ echo "#define SIZEOF_INT $1" >> m.h echo "#define SIZEOF_LONG $2" >> m.h echo "#define SIZEOF_SHORT $4" >> m.h -if test $1 != 8; then +if test $1 = 8; then + echo "#define ARCH_INT64_TYPE long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h + echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h +else sh ./runtest longlong.c case $? in 0) echo "64-bit \"long long\" integer type found." - echo "#define SIZEOF_LONG_LONG 8" >> m.h;; + echo "#define ARCH_INT64_TYPE long long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h + echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h;; *) echo "No suitable 64-bit integer type found, Int64.t will not be supported." - echo "#define SIZEOF_LONG_LONG 0" >> m.h;; esac fi |