summaryrefslogtreecommitdiffstats
path: root/src/H5private.h
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-11-19 17:36:27 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-11-19 17:36:27 (GMT)
commit68bff3d352a5a8d87f582fb1a84361f3006b5ff4 (patch)
tree490fe50ff8f40d6ac0230cba0755e3c929594f0f /src/H5private.h
parent04979ec732605b34b956cc2c77e4d7fa75d59e47 (diff)
downloadhdf5-68bff3d352a5a8d87f582fb1a84361f3006b5ff4.zip
hdf5-68bff3d352a5a8d87f582fb1a84361f3006b5ff4.tar.gz
hdf5-68bff3d352a5a8d87f582fb1a84361f3006b5ff4.tar.bz2
[svn-r928] Changes since 19981118
---------------------- ./src/H5.c ./src/H5Smpio.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Tpublic.h ./src/H5detect.c ./src/H5private.h ./src/H5public.h ./test/big.c The `long long' type isn't quite as prevalent as we had hoped; there is at least one system that defines `__int64' but not `long long'. Therefore, I've temporarily changed all occurrences of `long long' to `long_long' and then #define that in H5private.h based on the existence of `long long' or `__int64'. This gets rid of some #ifdef's in other parts of the code. The semantics of the hdf5 types are: *int8_t Exactly one byte *int16_t At least two bytes. We favor 32-bit integers over 16-bit integers if the 16-bit integer is 4-bytes wide (Cray) *int32_t At least four bytes. *int64_t At least eight bytes long_long The widest integral integer type The H5Smpio.c contains debugging code which is non-portable. ./tools/h5ls.c Changed the order native types are detected so we favor the name `int' over `short' or `long' if two of them are the same. ./config/conclude.in Added a rule to make test programs depend on the hdf5 library. This fixes a minor bug where changing H5detect.c and then running `make test' caused H5Tinit.c to not be recompiled and therefore the test files are not relinked.
Diffstat (limited to 'src/H5private.h')
-rw-r--r--src/H5private.h219
1 files changed, 142 insertions, 77 deletions
diff --git a/src/H5private.h b/src/H5private.h
index f9e16f4..87d973a 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -196,94 +196,159 @@
#endif
/*
+ * Although `long long' is part of the revised ANSI-C some compilers don't
+ * support it yet. We define `long_long' as the longest integral integer type
+ * supported by the compiler, usually 64 bits. It must be legal to qualify
+ * `long_long' with `unsigned'.
+ */
+#if SIZEOF_LONG_LONG>0
+# define long_long long long
+#elif SIZEOF___INT64>0
+# define long_long __int64 /*Win32*/
+# undef SIZEOF_LONG_LONG
+# define SIZEOF_LONG_LONG SIZEOF___INT64
+#else
+# define long_long long int
+# undef SIZEOF_LONG_LONG
+# define SIZEOF_LONG_LONG SIZEOF_LONG
+#endif
+
+/*
* Numeric data types. Some of these might be defined in Posix.1g, otherwise
* we define them with the closest available type which is at least as large
- * as the number of bits indicated in the type name.
+ * as the number of bits indicated in the type name. The `int8' types *must*
+ * be exactly one byte wide because we use it for pointer calculations to
+ * void* memory.
+ *
+ * For int16_t and uint16_t we use `short' only if it's exactly 2 bytes.
+ * Otherwise we use `int' because it's probably faster.
*/
#if SIZEOF_INT8_T==0
-typedef signed char int8_t;
+ typedef signed char int8_t;
+# undef SIZEOF_INT8_T
+# define SIZEOF_INT8_T SIZEOF_CHAR
+#elif SIZEOF_INT8_T==1
+#else
+# error "the int8_t type must be 1 byte wide"
#endif
#if SIZEOF_UINT8_T==0
-typedef unsigned char uint8_t;
-#endif
-
-#if SIZEOF_INT16_T==0
-# if SIZEOF_SHORT==2
-typedef short int16_t;
-# else
-typedef int int16_t; /*not really */
-# endif
-#endif
-
-#if SIZEOF_UINT16_T==0
-# if SIZEOF_SHORT==2
-typedef unsigned short uint16_t;
-# else
-typedef unsigned uint16_t; /*not really */
-# endif
-#endif
-
-#if SIZEOF_INT32_T==0
-# if SIZEOF_INT==4
-typedef int int32_t;
-# elif SIZEOF_LONG==4
-typedef long int32_t;
-# else
-typedef int int32_t; /*not really */
-# endif
-#endif
-
-#if SIZEOF_UINT32_T==0
-# if SIZEOF_INT==4
-typedef unsigned int uint32_t;
-# elif SIZEOF_LONG==4
-typedef unsigned long uint32_t;
-# else
-typedef unsigned uint32_t; /*not really */
-# endif
-#endif
-
-#if SIZEOF_INT64_T==0
-# if SIZEOF_INT==8
-typedef int int64_t;
-# elif SIZEOF_LONG==8
-typedef long int64_t;
-# elif SIZEOF_LONG_LONG==8
-typedef long long int64_t;
-# elif SIZEOF___INT64==8
-typedef __int64 int64_t;
-# else
-# error "no signed 64-bit integer type"
-# endif
-#endif
-
-#if SIZEOF_UINT64_T==0
-# if SIZEOF_INT==8
-typedef unsigned uint64_t;
-# elif SIZEOF_LONG==8
-typedef unsigned long uint64_t;
-# elif SIZEOF_LONG_LONG==8
-typedef unsigned long long uint64_t;
-# elif SIZEOF___INT64==8
-typedef unsigned __int64 uint64_t;
-# else
-# error "no unsigned 64-bit integer type"
-# endif
-#endif
-
-#if SIZEOF_FLOAT==4
+ typedef unsigned char uint8_t;
+# undef SIZEOF_UINT8_T
+# define SIZEOF_UINT8_T SIZEOF_CHAR
+#elif SIZEOF_UINT8_T==1
+#else
+# error "the uint8_t type must be 1 byte wide"
+#endif
+
+#if SIZEOF_INT16_T>=2
+#elif SIZEOF_SHORT==2
+ typedef short int16_t
+# undef SIZEOF_INT16_T
+# define SIZEOF_INT16_T SIZEOF_SHORT
+#elif SIZEOF_INT>=2
+ typedef int int16_t
+# undef SIZEOF_INT16_T
+# define SIZEOF_INT16_T SIZEOF_INT
+#else
+# error "nothing appropriate for int16_t"
+#endif
+
+#if SIZEOF_UINT16_T>=2
+#elif SIZEOF_SHORT>=2
+ typedef unsigned short uint16_t;
+# undef SIZEOF_UINT16_T
+# define SIZEOF_UINT16_T SIZEOF_SHORT
+#elif SIZEOF_INT>=2
+ typedef unsigned uint16_t;
+# undef SIZEOF_UINT16_T
+# define SIZEOF_UINT16_T SIZEOF_INT
+#else
+# error "nothing appropriate for uint16_t"
+#endif
+
+#if SIZEOF_INT32_T>=4
+#elif SIZEOF_SHORT>=4
+ typedef short int32_t
+# undef SIZEOF_INT32_T
+# define SIZEOF_INT32_T SIZEOF_SHORT
+#elif SIZEOF_INT>=4
+ typedef int int32_t;
+# undef SIZEOF_INT32_T
+# define SIZEOF_INT32_T SIZEOF_INT
+#elif SIZEOF_LONG>=4
+ typedef long int32_t;
+# undef SIZEOF_INT32_T
+# define SIZEOF_INT32_T SIZEOF_LONG
+#else
+# error "nothing appropriate for int32_t"
+#endif
+
+#if SIZEOF_UINT32_T>=4
+#elif SIZEOF_SHORT>=4
+ typedef short uint32_t;
+# undef SIZEOF_UINT32_T
+# define SIZEOF_UINT32_T SIZEOF_SHORT
+#elif SIZEOF_INT>=4
+ typedef unsigned int uint32_t;
+# undef SIZEOF_UINT32_T
+# define SIZEOF_UINT32_T SIZEOF_INT
+#elif SIZEOF_LONG>=4
+ typedef unsigned long uint32_t;
+# undef SIZEOF_UINT32_T
+# define SIZEOF_UINT32_T SIZEOF_LONG
+#else
+# error "nothing appropriate for uint32_t"
+#endif
+
+#if SIZEOF_INT64_T>=8
+#elif SIZEOF_INT>=8
+ typedef int int64_t;
+# undef SIZEOF_INT64_T
+# define SIZEOF_INT64_T SIZEOF_INT
+#elif SIZEOF_LONG>=8
+ typedef long int64_t;
+# undef SIZEOF_INT64_T
+# define SIZEOF_INT64_T SIZEOF_LONG
+#elif SIZEOF_LONG_LONG>=8
+ typedef long_long int64_t;
+# undef SIZEOF_INT64_T
+# define SIZEOF_INT64_T SIZEOF_LONG_LONG
+#else
+# error "nothing appropriate for int64_t"
+#endif
+
+#if SIZEOF_UINT64_T>=8
+#elif SIZEOF_INT>=8
+ typedef unsigned uint64_t;
+# undef SIZEOF_UINT64_T
+# define SIZEOF_UINT64_T SIZEOF_INT
+#elif SIZEOF_LONG>=8
+ typedef unsigned long uint64_t;
+# undef SIZEOF_UINT64_T
+# define SIZEOF_UINT64_T SIZEOF_LONG
+#elif SIZEOF_LONG_LONG>=8
+ typedef unsigned long_long uint64_t;
+# undef SIZEOF_UINT64_T
+# define SIZEOF_UINT64_T SIZEOF_LONG_LONG
+#else
+# error "nothing appropriate for uint64_t"
+#endif
+
+#if SIZEOF_FLOAT>=4
typedef float float32;
+#elif SIZEOF_DOUBLE>=4
+typedef double float32;
#else
-typedef float float32; /*not really */
+# error "nothing appropriate for float32"
#endif
-#if SIZEOF_FLOAT==8
+#if SIZEOF_FLOAT>=8
typedef float float64;
-#elif SIZEOF_DOUBLE==8
+#elif SIZEOF_DOUBLE>=8
typedef double float64;
#else
-# error "no 64-bit floating point type"
+# error "nothing appropriate for float64"
#endif
/*
@@ -307,9 +372,9 @@ typedef struct {
* most part.
*/
#ifndef LLONG_MAX
-# define LLONG_MAX ((long long)(((unsigned long long)1 \
- <<(8*sizeof(long long)-1))-1))
-# define ULLONG_MAX ((unsigned long long)((long long)(-1)))
+# define LLONG_MAX ((long_long)(((unsigned long_long)1 \
+ <<(8*sizeof(long_long)-1))-1))
+# define ULLONG_MAX ((unsigned long_long)((long_long)(-1)))
#endif
#ifndef SIZET_MAX
# define SIZET_MAX ((hsize_t)(size_t)(ssize_t)(-1))