summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>1998-01-27 14:28:00 +0000
committerSteve Huston <shuston@riverace.com>1998-01-27 14:28:00 +0000
commitef35e58a729dd4dfd7638204e8f7f17223b4d817 (patch)
treeeec218838d8949dfe9c722853f7f10526517102f
parentb1f211b0ef21988902b29bffca299b1052ad61f5 (diff)
downloadATCD-ef35e58a729dd4dfd7638204e8f7f17223b4d817.tar.gz
Simplified the file by separating the ACE_SIZEOF... settings and the
ACE types for different widths. Also the config.h file can pre-specify the ACE_SIZEOF_... macros for situations where the preprocessor does not allow them to be calculated at compile time.
-rw-r--r--ace/Basic_Types.h430
1 files changed, 234 insertions, 196 deletions
diff --git a/ace/Basic_Types.h b/ace/Basic_Types.h
index 822705ff3ac..f19827c55c4 100644
--- a/ace/Basic_Types.h
+++ b/ace/Basic_Types.h
@@ -13,7 +13,9 @@
// David L. Levine
//
// = DESCRIPTION
-// #defines the following preprocessor macros:
+// #defines the list of preprocessor macros below. The config.h file can
+// pre-define any of these to short-cut the definitions. This is usually
+// only necessary if the preprocessor does all of its math using integers.
//
// Sizes of built-in types:
// ACE_SIZEOF_CHAR
@@ -55,219 +57,255 @@
#endif /* VXWORKS && ghs */
// The number of bytes in a short.
-#if (USHRT_MAX) == 255U
-# define ACE_SIZEOF_SHORT 1
-#elif (USHRT_MAX) == 65535U
-# define ACE_SIZEOF_SHORT 2
+#if !defined (ACE_SIZEOF_SHORT)
+# if (USHRT_MAX) == 255U
+# define ACE_SIZEOF_SHORT 1
+# elif (USHRT_MAX) == 65535U
+# define ACE_SIZEOF_SHORT 2
+# elif (USHRT_MAX) == 4294967295U
+# define ACE_SIZEOF_SHORT 4
+# elif (USHRT_MAX) == 18446744073709551615U
+# define ACE_SIZEOF_SHORT 8
+# else
+# error: unsupported short size, must be updated for this platform!
+# endif /* USHRT_MAX */
+#endif /* !defined (ACE_SIZEOF_SHORT) */
+
+// The number of bytes in an int.
+#if !defined (ACE_SIZEOF_INT)
+# if (UINT_MAX) == 65535U
+# define ACE_SIZEOF_INT 2
+# elif (UINT_MAX) == 4294967295U
+# define ACE_SIZEOF_INT 4
+# elif (UINT_MAX) == 18446744073709551615U
+# define ACE_SIZEOF_INT 8
+# else
+# error: unsupported int size, must be updated for this platform!
+# endif /* UINT_MAX */
+#endif /* !defined (ACE_SIZEOF_INT) */
+
+// The number of bytes in a long.
+// NOTE - since preprocessors only need to do integer math, this is a likely
+// place for a preprocessor to not properly support being able to figure out
+// the proper size. HP aC++ and GNU gcc have this difficulty so watch out.
+#if !defined (ACE_SIZEOF_LONG)
+# if (ULONG_MAX) == 65535UL
+# define ACE_SIZEOF_LONG 2
+# elif ((ULONG_MAX) == 4294967295UL)
+# define ACE_SIZEOF_LONG 4
+# elif ((ULONG_MAX) == 18446744073709551615UL)
+# define ACE_SIZEOF_LONG 8
+# else
+# error: unsupported long size, must be updated for this platform!
+# endif /* ULONG_MAX */
+#endif /* !defined (ACE_SIZEOF_LONG) */
+
+// The number of bytes in a long long.
+#if !defined (ACE_SIZEOF_LONG_LONG)
+# if defined (ACE_WIN32)
+# define ACE_SIZEOF_LONG_LONG 8
+ typedef unsigned __int64 ACE_UINT64;
+# elif !defined (ACE_LACKS_LONGLONG_T)
+ // Some compilers use ULLONG_MAX and others (e.g. Irix) use ULONGLONG_MAX
+# if defined (ULLONG_MAX) && !defined (__GNUG__)
+# if (ULLONG_MAX) == 18446744073709551615ULL
+# define ACE_SIZEOF_LONG_LONG 8
+# elif (ULLONG_MAX) == 4294967295ULL
+# define ACE_SIZEOF_LONG_LONG 4
+# else
+# error Unsupported long long size needs to be updated for this platform
+# endif
+# elif defined (ULONGLONG_MAX)
+ // Irix 6.x, for example.
+# if (ULONGLONG_MAX) == 18446744073709551615ULL
+# define ACE_SIZEOF_LONG_LONG 8
+# elif (ULONGLONG_MAX) == 4294967295ULL
+# define ACE_SIZEOF_LONG_LONG 4
+# else
+# error Unsupported long long size needs to be updated for this platform
+# endif
+# endif /* ULLONG_MAX && !__GNUG__ */
+# endif /* !defined (ACE_LACKS_LONG_LONG_T) */
+#endif /* !defined (ACE_SIZEOF_LONG_LONG) */
+
+
+// The sizes of the commonly implemented types are now known. Set up
+// typedefs for whatever we can. Some of these are needed for certain cases
+// of ACE_UINT64, so do them before the 64-bit stuff.
+
+#if ACE_SIZEOF_SHORT == 2
typedef short ACE_INT16;
typedef unsigned short ACE_UINT16;
-#elif (USHRT_MAX) == 4294967295U
-# define ACE_SIZEOF_SHORT 4
- typedef short ACE_INT32;
- typedef unsigned short ACE_UINT32;
-#elif (USHRT_MAX) == 18446744073709551615U
-# define ACE_SIZEOF_SHORT 8
+#elif ACE_SIZEOF_INT == 2
+ typedef int ACE_INT16;
+ typedef unsigned short ACE_UINT16;
#else
-# error: unsupported short size, must be updated for this platform!
-#endif /* USHRT_MAX */
+# error Have to add to the ACE_UINT16 type setting
+#endif
-// The number of bytes in an int.
-#if (UINT_MAX) == 65535U
-# define ACE_SIZEOF_INT 2
-# if ACE_SIZEOF_SHORT != 2
- typedef int ACE_INT16;
- typedef unsigned int ACE_UINT16;
-# endif /* ACE_SIZEOF_SHORT != 2 */
-#elif (UINT_MAX) == 4294967295U
-# define ACE_SIZEOF_INT 4
-# if ACE_SIZEOF_SHORT != 4
- typedef int ACE_INT32;
- typedef unsigned int ACE_UINT32;
-# endif /* ACE_SIZEOF_SHORT != 4 */
-#elif (UINT_MAX) == 18446744073709551615U
-# define ACE_SIZEOF_INT 8
- typedef unsigned int ACE_UINT64;
+#if ACE_SIZEOF_INT == 4
+ typedef int ACE_INT32;
+ typedef unsigned int ACE_UINT32;
+#elif ACE_SIZEOF_LONG == 4
+ typedef long ACE_INT32;
+ typedef unsigned long ACE_UINT32;
#else
-# error: unsupported int size, must be updated for this platform!
-#endif /* UINT_MAX */
+# error Have to add to the ACE_UINT32 type setting
+#endif
-// The number of bytes in a long.
-#if (ULONG_MAX) == 65535UL
-# define ACE_SIZEOF_LONG 2
-#elif (ULONG_MAX) == 4294967295UL
-# define ACE_SIZEOF_LONG 4
-# if ACE_SIZEOF_SHORT != 4 && ACE_SIZEOF_INT != 4
- typedef long ACE_INT32;
- typedef unsigned long ACE_UINT32;
-# endif /* ACE_SIZEOF_SHORT != 4 && ACE_SIZEOF_INT != 4 */
-#elif (ULONG_MAX) == 18446744073709551615UL
-# define ACE_SIZEOF_LONG 8
-# if ACE_SIZEOF_INT != 8
- typedef unsigned long ACE_UINT64;
-# endif /* ACE_SIZEOF_INT != 8 */
-#else
-# error: unsupported long size, must be updated for this platform!
-#endif /* ULONG_MAX */
+#if ACE_SIZEOF_LONG == 8
+ typedef unsigned long ACE_UINT64;
+# define ACE_UINT64_DEFINED
+#elif defined (ACE_SIZEOF_LONG_LONG)
+# if ACE_SIZEOF_LONG_LONG == 8
+ typedef unsigned long long ACE_UINT64;
+# define ACE_UINT64_DEFINED
+# endif /* ACE_SIZEOF_LONG_LONG == 8 */
+#endif /* defined (ACE_SIZEOF_LONG_LONG) */
-// The number of bytes in a long long.
-#if defined (ACE_WIN32)
-# define ACE_SIZEOF_LONG_LONG 8
- typedef unsigned __int64 ACE_UINT64;
-#elif defined (ULLONG_MAX) && !defined (__GNUG__) && \
- !defined (ACE_LACKS_LONGLONG_T)
-# if (ULLONG_MAX) == 18446744073709551615ULL
-# define ACE_SIZEOF_LONG_LONG 8
-# if ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8
- typedef unsigned long long ACE_UINT64;
-# endif /* ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8 */
-# elif (ULLONG_MAX) == 4294967295ULL
- // For some reason, this branch is taken if it appears first.
- // g++ can't deal with the ULL's at all. What's going on here?
-# define ACE_SIZEOF_LONG_LONG 4
-# if ACE_SIZEOF_SHORT != 4 && ACE_SIZEOF_INT != 4 && ACE_SIZEOF_LONG != 4
- typedef long long ACE_INT32;
- typedef unsigned long long ACE_UINT32;
-# endif /* ACE_SIZEOF_{SHORT,INT,LONG} != 4 */
-# else
-# error: unsupported long long size, must be updated for this platform!
-# endif /* ULLONG_MAX */
-#elif defined (ULONGLONG_MAX) && !defined (ACE_LACKS_LONGLONG_T)
- // Irix 6.x, for example.
-# if (ULONGLONG_MAX) == 18446744073709551615ULL
-# define ACE_SIZEOF_LONG_LONG 8
-# if ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8
+// If the platform lacks a long long, define one.
+#if defined (ACE_LACKS_LONGLONG_T)
+ class ACE_Export ACE_U_LongLong
+ // = TITLE
+ // Unsigned long long for platforms that don't have one.
+ //
+ // = DESCRIPTION
+ // Provide our own unsigned long long. This is intended to be
+ // use with ACE_High_Res_Timer, so the division operator assumes
+ // that the quotient fits into a u_long.
+ // Please note that the constructor takes (optionally) two values.
+ // The high one contributes 0x100000000 times its value. So,
+ // for example, (0, 2) is _not_ 20000000000, but instead
+ // 0x200000000. To emphasize this, the default values are expressed
+ // in hex, and dump () outputs the value in hex.
+ {
+ public:
+ // = Initialization and termination methods.
+ ACE_U_LongLong (const ACE_UINT32 lo = 0x0, const ACE_UINT32 hi = 0x0);
+ ACE_U_LongLong (const ACE_U_LongLong &);
+ ACE_U_LongLong &operator= (const ACE_U_LongLong &);
+ ~ACE_U_LongLong (void);
+
+ // = Overloaded relation operators.
+ int operator== (const ACE_U_LongLong &) const;
+ int operator!= (const ACE_U_LongLong &) const;
+ int operator< (const ACE_U_LongLong &) const;
+ int operator<= (const ACE_U_LongLong &) const;
+ int operator> (const ACE_U_LongLong &) const;
+ int operator>= (const ACE_U_LongLong &) const;
+
+ ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
+ ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
+
+ // Note that the following take ACE_UINT32 arguments. These are
+ // typical use cases, and easy to implement. But, they limit
+ // the return values to 32 bits as well. There are no checks
+ // for overflow.
+ ACE_UINT32 operator/ (const ACE_UINT32) const;
+ ACE_UINT32 operator% (const ACE_UINT32) const;
+
+ double operator/ (const double) const;
+
+ ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
+ ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
+ ACE_U_LongLong &operator++ ();
+ ACE_U_LongLong &operator-- ();
+
+ // = Helper methods.
+ void output (FILE * = stdout) const;
+ // Outputs the value to the FILE, in hex.
+
+ ACE_UINT32 hi (void) const;
+ ACE_UINT32 lo (void) const;
+
+ void hi (const ACE_UINT32 hi);
+ void lo (const ACE_UINT32 lo);
+
+ ACE_ALLOC_HOOK_DECLARE;
+
+ private:
+ ACE_UINT32 hi_;
+ ACE_UINT32 lo_;
+ };
+
+# define ACE_USES_ACE_U_LONGLONG
+# define ACE_SIZEOF_LONG_LONG 8
+
+#elif !defined (ACE_SIZEOF_LONG_LONG)
+ // If ACE_SIZEOF_LONG_LONG is not yet known, but the platform doesn't
+ // claim ACE_LACKS_LONGLONG_T, so assume it has 8-byte long longs.
+
+# define ACE_SIZEOF_LONG_LONG 8
+# if !defined (ACE_UINT64_DEFINED)
+# if defined (sun)
+ // sun #defines u_longlong_t, maybe other platforms do also.
+ // Use it, at least with g++, so that its -pedantic doesn't
+ // complain about no ANSI C++ long long.
+ typedef u_longlong_t ACE_UINT64;
+# define ACE_UINT64_DEFINED
+# else
+ // LynxOS 2.5.0 and Linux don't have u_longlong_t.
typedef unsigned long long ACE_UINT64;
-# endif /* ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8 */
+# define ACE_UINT64_DEFINED
+# endif /* sun */
+# endif /* !defined ACE_UINT64_DEFINED */
+#endif /* !defined ACE_SIZEOF_LONG_LONG */
+
+#if !defined (ACE_UINT64_DEFINED)
+# if defined (ACE_USES_ACE_U_LONGLONG)
+ typedef ACE_U_LongLong ACE_UINT64;
# else
-# error: unsupported long long size, must be updated for this platform!
-# endif /* ULLONG_MAX */
-#else /* ! ACE_WIN32 || (! ULLONG_MAX || __GNUG__) || ! ULONGLONG_MAX ||
- ACE_LACKS_LONGLONG_T */
-# if defined (ACE_LACKS_LONGLONG_T)
- class ACE_Export ACE_U_LongLong
- // = TITLE
- // Unsigned long long for platforms that don't have one.
- //
- // = DESCRIPTION
- // Provide our own unsigned long long. This is intended to be
- // use with ACE_High_Res_Timer, so the division operator assumes
- // that the quotient fits into a u_long.
- // Please note that the constructor takes (optionally) two values.
- // The high one contributes 0x100000000 times its value. So,
- // for example, (0, 2) is _not_ 20000000000, but instead
- // 0x200000000. To emphasize this, the default values are expressed
- // in hex, and dump () outputs the value in hex.
- {
- public:
- // = Initialization and termination methods.
- ACE_U_LongLong (const ACE_UINT32 lo = 0x0, const ACE_UINT32 hi = 0x0);
- ACE_U_LongLong (const ACE_U_LongLong &);
- ACE_U_LongLong &operator= (const ACE_U_LongLong &);
- ~ACE_U_LongLong (void);
-
- // = Overloaded relation operators.
- int operator== (const ACE_U_LongLong &) const;
- int operator!= (const ACE_U_LongLong &) const;
- int operator< (const ACE_U_LongLong &) const;
- int operator<= (const ACE_U_LongLong &) const;
- int operator> (const ACE_U_LongLong &) const;
- int operator>= (const ACE_U_LongLong &) const;
-
- ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
- ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
-
- // Note that the following take ACE_UINT32 arguments. These are
- // typical use cases, and easy to implement. But, they limit
- // the return values to 32 bits as well. There are no checks
- // for overflow.
- ACE_UINT32 operator/ (const ACE_UINT32) const;
- ACE_UINT32 operator% (const ACE_UINT32) const;
-
- double operator/ (const double) const;
-
- ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
- ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
- ACE_U_LongLong &operator++ ();
- ACE_U_LongLong &operator-- ();
-
- // = Helper methods.
- void output (FILE * = stdout) const;
- // Outputs the value to the FILE, in hex.
-
- ACE_UINT32 hi (void) const;
- ACE_UINT32 lo (void) const;
-
- void hi (const ACE_UINT32 hi);
- void lo (const ACE_UINT32 lo);
-
- ACE_ALLOC_HOOK_DECLARE;
-
- private:
- ACE_UINT32 hi_;
- ACE_UINT32 lo_;
- };
-
-# define ACE_USES_ACE_U_LONGLONG
-# define ACE_SIZEOF_LONG_LONG 8
-# if ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8
- typedef ACE_U_LongLong ACE_UINT64;
-# endif /* ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8 */
-# else /* ! ACE_LACKS_LONGLONG_T */
- // Assume that the platform has 8-byte long longs.
-# define ACE_SIZEOF_LONG_LONG 8
-# if ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8
-# if defined (sun)
- // sun #defines u_longlong_t, maybe other platforms do also.
- // Use it, at least with g++, so that its -pedantic doesn't
- // complain about no ANSI C++ long long.
- typedef u_longlong_t ACE_UINT64;
-# else
- // LynxOS 2.5.0 and Linux don't have u_longlong_t.
- typedef unsigned long long ACE_UINT64;
-# endif /* sun */
-# endif /* ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8 */
-# endif /* ! ACE_LACKS_LONGLONG_T */
-#endif /* ! ACE_WIN32 || (! ULLONG_MAX || __GNUG__) || ! ULONGLONG_MAX ||
- ACE_LACKS_LONGLONG_T */
+# error Have to add to the ACE_UINT64 type setting
+# endif /* ACE_USES_ACE_U_LONGLONG */
+#endif /* ACE_UINT64_DEFINED */
// The number of bytes in a void *.
+#ifndef ACE_SIZEOF_VOID_P
#define ACE_SIZEOF_VOID_P ACE_SIZEOF_LONG
+#endif /* ACE_SIZEOF_VOID_P */
// The number of bytes in a float.
-#if FLT_MAX_EXP == 128
-# define ACE_SIZEOF_FLOAT 4
-#elif FLT_MAX_EXP == 1024
-# define ACE_SIZEOF_FLOAT 8
-#else
-# error: unsupported float size, must be updated for this platform!
-#endif /* FLT_MAX */
+#ifndef ACE_SIZEOF_FLOAT
+# if FLT_MAX_EXP == 128
+# define ACE_SIZEOF_FLOAT 4
+# elif FLT_MAX_EXP == 1024
+# define ACE_SIZEOF_FLOAT 8
+# else
+# error: unsupported float size, must be updated for this platform!
+# endif /* FLT_MAX_EXP */
+#endif /* ACE_SIZEOF_FLOAT */
// The number of bytes in a double.
-#if DBL_MAX_EXP == 128
-# define ACE_SIZEOF_DOUBLE 4
-#elif DBL_MAX_EXP == 1024
-# define ACE_SIZEOF_DOUBLE 8
-#else
-# error: unsupported double size, must be updated for this platform!
-#endif /* DBL_MAX */
+#ifndef ACE_SIZEOF_DOUBLE
+# if DBL_MAX_EXP == 128
+# define ACE_SIZEOF_DOUBLE 4
+# elif DBL_MAX_EXP == 1024
+# define ACE_SIZEOF_DOUBLE 8
+# else
+# error: unsupported double size, must be updated for this platform!
+# endif /* DBL_MAX_EXP */
+#endif /* ACE_SIZEOF_DOUBLE */
// The number of bytes in a long double.
-#if defined (__sgi)
- // The Irix 6.x float.h doesn't allow us to distinguish between a
- // double and a long double. Gotta hard code this . . .
-# define ACE_SIZEOF_LONG_DOUBLE 16
-#elif LDBL_MAX_EXP == 128
-# define ACE_SIZEOF_LONG_DOUBLE 4
-#elif defined (i386) || defined (__i386__) || defined (_M_IX386) || \
- defined (ACE_NETBSD) || defined (__FreeBSD__)
-# define ACE_SIZEOF_LONG_DOUBLE 12
-#elif LDBL_MAX_EXP == 1024
-# define ACE_SIZEOF_LONG_DOUBLE 8
-#elif LDBL_MAX_EXP == 16384
-# define ACE_SIZEOF_LONG_DOUBLE 16
-#else
-# error: unsupported double size, must be updated for this platform!
-#endif /* LDBL_MAX_EXP */
+#ifndef ACE_SIZEOF_LONG_DOUBLE
+# if defined (__sgi)
+ // The Irix 6.x float.h doesn't allow us to distinguish between a
+ // double and a long double. Gotta hard code this . . .
+ // This should be added to the Irix config file...
+# define ACE_SIZEOF_LONG_DOUBLE 16
+# elif LDBL_MAX_EXP == 128
+# define ACE_SIZEOF_LONG_DOUBLE 4
+# elif defined (i386) || defined (__i386__) || defined (_M_IX386) || \
+ defined (ACE_NETBSD) || defined (__FreeBSD__)
+# define ACE_SIZEOF_LONG_DOUBLE 12
+# elif LDBL_MAX_EXP == 1024
+# define ACE_SIZEOF_LONG_DOUBLE 8
+# elif LDBL_MAX_EXP == 16384
+# define ACE_SIZEOF_LONG_DOUBLE 16
+# else
+# error: unsupported double size, must be updated for this platform!
+# endif /* LDBL_MAX_EXP */
+#endif /* ACE_SIZEOF_LONG_DOUBLE */
// Byte-order (endian-ness) determination.
#if defined (BYTE_ORDER)