Basic_Types.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Basic_Types.h
00006  *
00007  *  Basic_Types.h,v 4.137 2006/05/30 11:11:09 jwillemsen Exp
00008  *
00009  *  @author David L. Levine
00010  *
00011  *  #defines the list of preprocessor macros below.  The config.h file can
00012  *  pre-define any of these to short-cut the definitions.  This is usually
00013  *  only necessary if the preprocessor does all of its math using integers.
00014  *
00015  *  Sizes of built-in types:
00016  *    - ACE_SIZEOF_CHAR
00017  *    - ACE_SIZEOF_WCHAR
00018  *    - ACE_SIZEOF_SHORT
00019  *    - ACE_SIZEOF_INT
00020  *    - ACE_SIZEOF_LONG
00021  *    - ACE_SIZEOF_LONG_LONG
00022  *    - ACE_SIZEOF_VOID_P
00023  *    - ACE_SIZEOF_FLOAT
00024  *    - ACE_SIZEOF_DOUBLE
00025  *    - ACE_SIZEOF_LONG_DOUBLE
00026  *
00027  *  Wrappers for built-in types of specific sizes:
00028  *    - ACE_USHORT16 (For backward compatibility.  Use ACE_UINT16 instead.)
00029  *    - ACE_INT8
00030  *    - ACE_UINT8
00031  *    - ACE_INT16
00032  *    - ACE_UINT16
00033  *    - ACE_INT32
00034  *    - ACE_UINT32
00035  *    - ACE_UINT64
00036  *  (@note ACE_INT64 is partly defined, there is no ACE_LongLong for
00037  *   platforms that don't have a native 8-byte integer type.)
00038  *
00039  *  Byte-order (endian-ness) determination:
00040  *    ACE_BYTE_ORDER, to either ACE_BIG_ENDIAN or ACE_LITTLE_ENDIAN
00041  *
00042  *
00043  */
00044 //=============================================================================
00045 
00046 #include "ace/config-lite.h"
00047 
00048 #ifndef ACE_BASIC_TYPES_H
00049 # define ACE_BASIC_TYPES_H
00050 
00051 # include /**/ "ace/pre.h"
00052 
00053 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00054 #   pragma once
00055 # endif /* ACE_LACKS_PRAGMA_ONCE */
00056 
00057 // Pull in definitions
00058 # include "ace/os_include/os_limits.h"   // Integer limits
00059 # include "ace/os_include/os_float.h"    // Floating point limits
00060 # include "ace/os_include/os_stdlib.h"   // Other types
00061 # include "ace/os_include/os_stddef.h"   // Get ptrdiff_t - see further comments below
00062 
00063 # if defined(ACE_LACKS_LONGLONG_T)
00064 #   include "ace/os_include/os_stdarg.h" // LynxOS requires this before stdio.h
00065 #   include "ace/os_include/os_stdio.h"  // For long long emulation
00066 # endif  /* ACE_LACKS_LONGLONG_T */
00067 
00068 # include "ace/os_include/sys/os_types.h"
00069 
00070 # if !defined (ACE_LACKS_SYS_PARAM_H)
00071 #  include /**/ <sys/param.h>
00072 # endif /* ACE_LACKS_SYS_PARAM_H */
00073 
00074 # include "ace/ACE_export.h"
00075 
00076 # if !defined (ACE_LACKS_STDINT_H)
00077 #  include <stdint.h>
00078 # endif
00079 # if !defined (ACE_LACKS_INTTYPES_H)
00080 #  include <inttypes.h>
00081 # endif
00082 
00083 // A char always has 1 byte, by definition.
00084 # define ACE_SIZEOF_CHAR 1
00085 
00086 // Unfortunately, there isn't a portable way to determine the size of a wchar.
00087 // So we just define them on a platform basis. If the platform doesn't
00088 // define it and it's an XPG4 system, assume wchar_t is 4 bytes. Some code
00089 // uses ACE_SIZEOF_WCHAR in preprocessor statements, so sizeof() isn't valid.
00090 // If the platform config doesn't set this, and this guess is wrong,
00091 // Basic_Types_Test should catch the inconsistency.
00092 # if defined (ACE_HAS_WCHAR)
00093 #   if !defined (ACE_SIZEOF_WCHAR)
00094 #     if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00095 #       define ACE_SIZEOF_WCHAR 4
00096 #     else
00097 // 0 so the Basic_Types test will catch this.
00098 #       define ACE_SIZEOF_WCHAR 0
00099 #     endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */
00100 #   endif /* !ACE_SIZEOF_WCHAR */
00101 # endif /* ACE_HAS_WCHAR */
00102 
00103 // The number of bytes in a short.
00104 # if !defined (ACE_SIZEOF_SHORT)
00105 #   if (USHRT_MAX) == 255U
00106 #     define ACE_SIZEOF_SHORT 1
00107 #   elif (USHRT_MAX) == 65535U
00108 #     define ACE_SIZEOF_SHORT 2
00109 #   elif (USHRT_MAX) == 4294967295U
00110 #     define ACE_SIZEOF_SHORT 4
00111 #   elif (USHRT_MAX) == 18446744073709551615U
00112 #     define ACE_SIZEOF_SHORT 8
00113 #   else
00114 #     error: unsupported short size, must be updated for this platform!
00115 #   endif /* USHRT_MAX */
00116 # endif /* !defined (ACE_SIZEOF_SHORT) */
00117 
00118 // The number of bytes in an int.
00119 # if !defined (ACE_SIZEOF_INT)
00120 #   if (UINT_MAX) == 65535U
00121 #     define ACE_SIZEOF_INT 2
00122 #   elif (UINT_MAX) == 4294967295U
00123 #     define ACE_SIZEOF_INT 4
00124 #   elif (UINT_MAX) == 18446744073709551615U
00125 #     define ACE_SIZEOF_INT 8
00126 #   else
00127 #     error: unsupported int size, must be updated for this platform!
00128 #   endif /* UINT_MAX */
00129 # endif /* !defined (ACE_SIZEOF_INT) */
00130 
00131 // The number of bytes in a long.
00132 # if !defined (ACE_SIZEOF_LONG)
00133 #   if (ULONG_MAX) == 65535UL
00134 #     define ACE_SIZEOF_LONG 2
00135 #   elif ((ULONG_MAX) == 4294967295UL)
00136 #     define ACE_SIZEOF_LONG 4
00137 #   elif ((ULONG_MAX) == 18446744073709551615UL)
00138 #     define ACE_SIZEOF_LONG 8
00139 #   else
00140 #     error: unsupported long size, must be updated for this platform!
00141 #   endif /* ULONG_MAX */
00142 # endif /* !defined (ACE_SIZEOF_LONG) */
00143 
00144 // The number of bytes in a long long.
00145 # if !defined (ACE_SIZEOF_LONG_LONG)
00146 #   if defined (ACE_LACKS_LONGLONG_T)
00147 #     define ACE_SIZEOF_LONG_LONG 8
00148 #   elif defined (ULLONG_MAX)
00149 #     if ((ULLONG_MAX) == 4294967295ULL)
00150 #       define ACE_SIZEOF_LONG_LONG 4
00151 #     elif ((ULLONG_MAX) == 18446744073709551615ULL)
00152 #       define ACE_SIZEOF_LONG_LONG 8
00153 #     endif
00154 #   elif defined (ULONGLONG_MAX)
00155 #     if ((ULONGLONG_MAX) == 4294967295ULL)
00156 #       define ACE_SIZEOF_LONG_LONG 4
00157 #     elif ((ULONGLONG_MAX) == 18446744073709551615ULL)
00158 #       define ACE_SIZEOF_LONG_LONG 8
00159 #     endif
00160 #   endif
00161 #   // If we can't determine the size of long long, assume it is 8
00162 #   // instead of erroring out.  (Either ULLONG_MAX and ULONGLONG_MAX
00163 #   // may not be supported; or an extended C/C++ dialect may need to
00164 #   // be selected.  If this assumption is wrong, it can be addressed
00165 #   // in the platform-specific config header.
00166 #   if !defined (ACE_SIZEOF_LONG_LONG)
00167 #     define ACE_SIZEOF_LONG_LONG 8
00168 #   endif
00169 # endif /* !defined (ACE_SIZEOF_LONG_LONG) */
00170 
00171 
00172 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00173 
00174 // The sizes of the commonly implemented types are now known.  Set up
00175 // typedefs for whatever we can.  Some of these are needed for certain
00176 // cases of ACE_UINT64, so do them before the 64-bit stuff.
00177 
00178 #if defined (ACE_INT8_TYPE)
00179   typedef ACE_INT8_TYPE         ACE_INT8;
00180 #elif defined (ACE_HAS_INT8_T)
00181   typedef int8_t                ACE_INT8;
00182 #elif !defined (ACE_LACKS_SIGNED_CHAR)
00183   typedef signed char           ACE_INT8;
00184 #else
00185   typedef char                  ACE_INT8;
00186 #endif /* defined (ACE_INT8_TYPE) */
00187 
00188 #if defined (ACE_UINT8_TYPE)
00189   typedef ACE_UINT8_TYPE        ACE_UINT8;
00190 #elif defined (ACE_HAS_UINT8_T)
00191   typedef uint8_t               ACE_UINT8;
00192 #else
00193   typedef unsigned char         ACE_UINT8;
00194 #endif /* defined (ACE_UINT8_TYPE) */
00195 
00196 #if defined (ACE_INT16_TYPE)
00197   typedef ACE_INT16_TYPE        ACE_INT16;
00198 #elif defined (ACE_HAS_INT16_T)
00199   typedef int16_t               ACE_INT16;
00200 #elif ACE_SIZEOF_SHORT == 2
00201   typedef short                 ACE_INT16;
00202 #elif ACE_SIZEOF_INT == 2
00203   typedef int                   ACE_INT16;
00204 #else
00205 # error Have to add to the ACE_INT16 type setting
00206 #endif  /* defined (ACE_INT16_TYPE) */
00207 
00208 #if defined (ACE_UINT16_TYPE)
00209   typedef ACE_UINT16_TYPE       ACE_UINT16;
00210 #elif defined (ACE_HAS_UINT16_T)
00211   typedef uint16_t              ACE_UINT16;
00212 #elif ACE_SIZEOF_SHORT == 2
00213   typedef unsigned short        ACE_UINT16;
00214 #elif ACE_SIZEOF_INT == 2
00215   typedef unsigned int          ACE_UINT16;
00216 #else
00217 # error Have to add to the ACE_UINT16 type setting
00218 #endif /* defined (ACE_UINT16_TYPE) */
00219 
00220 #if defined (ACE_INT32_TYPE)
00221   typedef ACE_INT32_TYPE        ACE_INT32;
00222 #elif defined (ACE_HAS_INT32_T)
00223   typedef int32_t               ACE_INT32;
00224 #elif ACE_SIZEOF_INT == 4
00225   typedef int                   ACE_INT32;
00226 #elif ACE_SIZEOF_LONG == 4
00227   typedef long                  ACE_INT32;
00228 #else
00229 # error Have to add to the ACE_INT32 type setting
00230 #endif /* defined (ACE_INT32_TYPE) */
00231 
00232 #if defined (ACE_UINT32_TYPE)
00233   typedef ACE_UINT32_TYPE       ACE_UINT32;
00234 #elif defined (ACE_HAS_UINT32_T)
00235   typedef uint32_t              ACE_UINT32;
00236 #elif ACE_SIZEOF_INT == 4
00237   typedef unsigned int          ACE_UINT32;
00238 #elif ACE_SIZEOF_LONG == 4
00239   typedef unsigned long         ACE_UINT32;
00240 #else
00241 # error Have to add to the ACE_UINT32 type setting
00242 #endif /* defined (ACE_UINT32_TYPE) */
00243 
00244 #if defined (ACE_INT64_TYPE)
00245   typedef ACE_INT64_TYPE        ACE_INT64;
00246 #elif defined (ACE_HAS_INT64_T)
00247   typedef int64_t               ACE_INT64;
00248 #elif ACE_SIZEOF_LONG == 8
00249   typedef long                  ACE_INT64;
00250 #elif !defined (ACE_LACKS_LONGLONG_T) && ACE_SIZEOF_LONG_LONG == 8
00251   typedef long long             ACE_INT64;
00252 #endif /* defined (ACE_INT64_TYPE) */
00253 
00254 #if !(defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T))
00255 /* See matching #if around ACE_U_LongLong class declaration below */
00256 
00257 #  if defined (ACE_UINT64_TYPE)
00258   typedef ACE_UINT64_TYPE       ACE_UINT64;
00259 #  elif defined (ACE_HAS_UINT64_T)
00260   typedef uint64_t              ACE_UINT64;
00261 #  elif ACE_SIZEOF_LONG == 8
00262   typedef unsigned long         ACE_UINT64;
00263 #  elif ACE_SIZEOF_LONG_LONG == 8
00264   typedef unsigned long long    ACE_UINT64;
00265 #  endif /* defined (ACE_UINT64_TYPE) */
00266 #endif /* !(ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T) */
00267 
00268 
00269 typedef ACE_UINT16 ACE_USHORT16;  // @@ Backward compatibility.
00270 
00271 // Define a generic byte for use in codecs
00272 typedef unsigned char ACE_Byte;
00273 
00274 // Define a pseudo wide character type when wchar is not supported so we
00275 // can support basic wide character string operations.
00276 
00277 # if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00278 #   define ACE_WINT_T wint_t
00279 #   define ACE_WCHAR_T wchar_t
00280 # else
00281 #   define ACE_WINT_T ACE_UINT16
00282 #   define ACE_WCHAR_T ACE_UINT16
00283 # endif /* ACE_HAS_WCHAR */
00284 
00285 // The number of bytes in a void *.
00286 # ifndef ACE_SIZEOF_VOID_P
00287 #   define ACE_SIZEOF_VOID_P ACE_SIZEOF_LONG
00288 # endif /* ACE_SIZEOF_VOID_P */
00289 
00290 // Type for doing arithmetic on pointers ... as elsewhere, we assume
00291 // that unsigned versions of a type are the same size as the signed
00292 // version of the same type.
00293 # if defined (ACE_HAS_WINCE) && (_WIN32_WCE < 400)
00294 typedef unsigned long ptrdiff_t;    // evc3, PocketPC don't defined ptrdiff_t
00295 # endif
00296 
00297 ACE_END_VERSIONED_NAMESPACE_DECL
00298 
00299 // Byte-order (endian-ness) determination.
00300 # if defined (BYTE_ORDER)
00301 #   if (BYTE_ORDER == LITTLE_ENDIAN)
00302 #     define ACE_LITTLE_ENDIAN 0x0123
00303 #     define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN
00304 #   elif (BYTE_ORDER == BIG_ENDIAN)
00305 #     define ACE_BIG_ENDIAN 0x3210
00306 #     define ACE_BYTE_ORDER ACE_BIG_ENDIAN
00307 #   else
00308 #     error: unknown BYTE_ORDER!
00309 #   endif /* BYTE_ORDER */
00310 # elif defined (_BYTE_ORDER)
00311 #   if (_BYTE_ORDER == _LITTLE_ENDIAN)
00312 #     define ACE_LITTLE_ENDIAN 0x0123
00313 #     define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN
00314 #   elif (_BYTE_ORDER == _BIG_ENDIAN)
00315 #     define ACE_BIG_ENDIAN 0x3210
00316 #     define ACE_BYTE_ORDER ACE_BIG_ENDIAN
00317 #   else
00318 #     error: unknown _BYTE_ORDER!
00319 #   endif /* _BYTE_ORDER */
00320 # elif defined (__BYTE_ORDER)
00321 #   if (__BYTE_ORDER == __LITTLE_ENDIAN)
00322 #     define ACE_LITTLE_ENDIAN 0x0123
00323 #     define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN
00324 #   elif (__BYTE_ORDER == __BIG_ENDIAN)
00325 #     define ACE_BIG_ENDIAN 0x3210
00326 #     define ACE_BYTE_ORDER ACE_BIG_ENDIAN
00327 #   else
00328 #     error: unknown __BYTE_ORDER!
00329 #   endif /* __BYTE_ORDER */
00330 # else /* ! BYTE_ORDER && ! __BYTE_ORDER */
00331   // We weren't explicitly told, so we have to figure it out . . .
00332 #   if defined (i386) || defined (__i386__) || defined (_M_IX86) || \
00333      defined (vax) || defined (__alpha) || defined (__LITTLE_ENDIAN__) ||\
00334      defined (ARM) || defined (_M_IA64) || \
00335      defined (_M_AMD64) || defined (__amd64)
00336     // We know these are little endian.
00337 #     define ACE_LITTLE_ENDIAN 0x0123
00338 #     define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN
00339 #   else
00340     // Otherwise, we assume big endian.
00341 #     define ACE_BIG_ENDIAN 0x3210
00342 #     define ACE_BYTE_ORDER ACE_BIG_ENDIAN
00343 #   endif
00344 # endif /* ! BYTE_ORDER && ! __BYTE_ORDER */
00345 
00346 // Byte swapping macros to deal with differences between little endian
00347 // and big endian machines.  Note that "long" here refers to 32 bit
00348 // quantities.
00349 # define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \
00350             | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF))
00351 # define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8))
00352 
00353 # if defined (ACE_LITTLE_ENDIAN)
00354 #   define ACE_HTONL(X) ACE_SWAP_LONG (X)
00355 #   define ACE_NTOHL(X) ACE_SWAP_LONG (X)
00356 #   define ACE_IDL_NCTOHL(X) (X)
00357 #   define ACE_IDL_NSTOHL(X) (X)
00358 # else
00359 #   define ACE_HTONL(X) X
00360 #   define ACE_NTOHL(X) X
00361 #   define ACE_IDL_NCTOHL(X) (X << 24)
00362 #   define ACE_IDL_NSTOHL(X) ((X) << 16)
00363 # endif /* ACE_LITTLE_ENDIAN */
00364 
00365 # if defined (ACE_LITTLE_ENDIAN)
00366 #   define ACE_HTONS(x) ACE_SWAP_WORD(x)
00367 #   define ACE_NTOHS(x) ACE_SWAP_WORD(x)
00368 # else
00369 #   define ACE_HTONS(x) x
00370 #   define ACE_NTOHS(x) x
00371 # endif /* ACE_LITTLE_ENDIAN */
00372 
00373 #if defined (ACE_LACKS_LONGLONG_T)
00374   // This throws away the high 32 bits.  It's very unlikely that a
00375   // pointer will be more than 32 bits wide if the platform does not
00376   // support 64-bit integers.
00377 # define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \
00378   reinterpret_cast<PTR_TYPE> (L.lo ())
00379 #else  /* ! ACE_LACKS_LONGLONG_T */
00380 # define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \
00381   reinterpret_cast<PTR_TYPE> (static_cast<ptrdiff_t> (L))
00382 #endif /* ! ACE_LACKS_LONGLONG_T */
00383 
00384 // If the platform lacks an unsigned long long, define one.
00385 #if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00386 // Forward declaration for streams
00387 #   include "ace/iosfwd.h"
00388 
00389 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00390 
00391 /**
00392  * @class ACE_U_LongLong
00393  *
00394  * @brief Unsigned long long for platforms that don't have one.
00395  *
00396  * Provide our own unsigned long long.  This is intended to be
00397  * use with ACE_High_Res_Timer, so the division operator assumes
00398  * that the quotient fits into a u_long.
00399  * Please note that the constructor takes (optionally) two values.
00400  * The high one contributes 0x100000000 times its value.  So,
00401  * for example, (0, 2) is _not_ 20000000000, but instead
00402  * 0x200000000.  To emphasize this, the default values are expressed
00403  * in hex, and output () dumps the value in hex.
00404  */
00405   class ACE_Export ACE_U_LongLong
00406   {
00407   public:
00408     // = Initialization and termination methods.
00409 #if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00410     ACE_U_LongLong (const long long value = 0x0);
00411 #else
00412     ACE_U_LongLong (const ACE_UINT32 lo = 0x0, const ACE_UINT32 hi = 0x0);
00413 #endif
00414     ACE_U_LongLong (const ACE_U_LongLong &);
00415     ACE_U_LongLong &operator= (const ACE_U_LongLong &);
00416     ACE_U_LongLong &operator= (const ACE_INT32 &);
00417     ACE_U_LongLong &operator= (const ACE_UINT32 &);
00418     ~ACE_U_LongLong (void);
00419 
00420     // = Overloaded relation operators.
00421     bool operator== (const ACE_U_LongLong &) const;
00422     bool operator== (const ACE_UINT32) const;
00423     bool operator!= (const ACE_U_LongLong &) const;
00424     bool operator!= (const ACE_UINT32) const;
00425     bool operator< (const ACE_U_LongLong &) const;
00426     bool operator< (const ACE_UINT32) const;
00427     bool operator<= (const ACE_U_LongLong &) const;
00428     bool operator<= (const ACE_UINT32) const;
00429     bool operator> (const ACE_U_LongLong &) const;
00430     bool operator> (const ACE_UINT32) const;
00431     bool operator>= (const ACE_U_LongLong &) const;
00432     bool operator>= (const ACE_UINT32) const;
00433 
00434     ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
00435     ACE_U_LongLong operator+ (const ACE_UINT32) const;
00436     ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
00437     ACE_U_LongLong operator- (const ACE_UINT32) const;
00438     ACE_U_LongLong operator* (const ACE_UINT32) const;
00439     ACE_U_LongLong &operator*= (const ACE_UINT32);
00440 
00441     ACE_U_LongLong operator<< (const unsigned int) const;
00442     ACE_U_LongLong &operator<<= (const unsigned int);
00443     ACE_U_LongLong operator>> (const unsigned int) const;
00444     ACE_U_LongLong &operator>>= (const unsigned int);
00445 
00446     double operator/ (const double) const;
00447 
00448     ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
00449     ACE_U_LongLong &operator+= (const ACE_UINT32);
00450     ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
00451     ACE_U_LongLong &operator-= (const ACE_UINT32);
00452     ACE_U_LongLong &operator++ ();
00453     ACE_U_LongLong &operator-- ();
00454     const ACE_U_LongLong operator++ (int);
00455     const ACE_U_LongLong operator-- (int);
00456     ACE_U_LongLong &operator|= (const ACE_U_LongLong);
00457     ACE_U_LongLong &operator|= (const ACE_UINT32);
00458     ACE_U_LongLong &operator&= (const ACE_U_LongLong);
00459     ACE_U_LongLong &operator&= (const ACE_UINT32);
00460 
00461     // Note that the following take ACE_UINT32 arguments.  These are
00462     // typical use cases, and easy to implement.  But, they limit the
00463     // return values to 32 bits as well.  There are no checks for
00464     // overflow.
00465     ACE_UINT32 operator/ (const ACE_UINT32) const;
00466     ACE_UINT32 operator% (const ACE_UINT32) const;
00467 
00468     // The following only operate on the lower 32 bits (they take only
00469     // 32 bit arguments).
00470     ACE_UINT32 operator| (const ACE_INT32) const;
00471     ACE_UINT32 operator& (const ACE_INT32) const;
00472 
00473     // The following operators convert their arguments to
00474     // ACE_UINT32.  So, there may be information loss if they are
00475     // used.
00476     ACE_U_LongLong operator* (const ACE_INT32) const;
00477     ACE_U_LongLong &operator*= (const ACE_INT32);
00478     ACE_UINT32 operator/ (const ACE_INT32) const;
00479 #   if ACE_SIZEOF_INT == 4
00480     ACE_UINT32 operator/ (const unsigned long) const;
00481     ACE_UINT32 operator/ (const long) const;
00482 #   else  /* ACE_SIZEOF_INT != 4 */
00483     ACE_UINT32 operator/ (const unsigned int) const;
00484     ACE_UINT32 operator/ (const int) const;
00485 #   endif /* ACE_SIZEOF_INT != 4 */
00486 
00487     // = Helper methods.
00488     /// Outputs the value to the FILE, in hex.
00489     void output (FILE * = stdout) const;
00490 
00491     ACE_TCHAR *as_string (ACE_TCHAR *string,
00492                           unsigned int base = 10,
00493                           unsigned int uppercase = 0) const;
00494 
00495     ACE_UINT32 hi (void) const;
00496     ACE_UINT32 lo (void) const;
00497 
00498     void hi (const ACE_UINT32 hi);
00499     void lo (const ACE_UINT32 lo);
00500 
00501 #if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00502     long long to_int64 (void) const;
00503 #   endif
00504 
00505   private:
00506 
00507 #if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00508     long long data_;
00509 #else
00510   public:
00511     struct ace_hi_lo_correct_endian
00512     {
00513 #  if defined (ACE_BIG_ENDIAN)
00514       /// High 32 bits.
00515       ACE_UINT32 hi_;
00516       /// Low 32 bits.
00517       ACE_UINT32 lo_;
00518 
00519 #  else
00520 
00521       /// Low 32 bits.
00522       ACE_UINT32 lo_;
00523       /// High 32 bits.
00524       ACE_UINT32 hi_;
00525 #  endif /* ! ACE_BIG_ENDIAN */
00526     };
00527   private:
00528     union
00529     {
00530       struct ace_hi_lo_correct_endian data_;
00531 
00532       /// To ensure alignment on 8-byte boundary.
00533       double for_alignment_;
00534     };
00535 
00536     // @note  the following four accessors are inlined here in
00537     // order to minimize the extent of the data_ struct.  It's
00538     // only used here; the .i and .cpp files use the accessors.
00539 
00540     /// Internal utility function to hide access through struct.
00541     const ACE_UINT32 &h_ () const { return data_.hi_; }
00542 
00543     /// Internal utility function to hide access through struct.
00544     ACE_UINT32 &h_ () { return data_.hi_; }
00545 
00546     /// Internal utility function to hide access through struct.
00547     const ACE_UINT32 &l_ () const { return data_.lo_; }
00548 
00549     /// Internal utility function to hide access through struct.
00550     ACE_UINT32 &l_ () { return data_.lo_; }
00551 
00552     // @note  the above four accessors are inlined here in
00553     // order to minimize the extent of the data_ struct.  It's
00554     // only used here; the .i and .cpp files use the accessors.
00555 
00556     /// These functions are used to implement multiplication.
00557     ACE_UINT32 ul_shift (ACE_UINT32 a,
00558                          ACE_UINT32 c_in,
00559                          ACE_UINT32 *c_out) const;
00560     ACE_U_LongLong ull_shift (ACE_U_LongLong a,
00561                               ACE_UINT32 c_in,
00562                               ACE_UINT32 *c_out) const;
00563     ACE_U_LongLong ull_add (ACE_U_LongLong a,
00564                             ACE_U_LongLong b,
00565                             ACE_UINT32 *carry) const;
00566     ACE_U_LongLong ull_mult (ACE_U_LongLong a,
00567                              ACE_UINT32 b,
00568                              ACE_UINT32 *carry) const;
00569 #endif // ACE_LACKS_UNSIGNEDLONGLONG_T
00570   };
00571 
00572   typedef ACE_U_LongLong ACE_UINT64;
00573 
00574 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
00575   ostream &operator<< (ostream &, const ACE_U_LongLong &);
00576 #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
00577 
00578 ACE_END_VERSIONED_NAMESPACE_DECL
00579 
00580 # endif /* ACE_LACKS_LONGLONG_T */
00581 
00582 // Conversions from ACE_UINT64 to ACE_UINT32.  ACE_CU64_TO_CU32 should
00583 // be used on const ACE_UINT64's.
00584 # if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00585 #   define ACE_U64_TO_U32(n) ((n).lo ())
00586 #   define ACE_CU64_TO_CU32(n) ((n).lo ())
00587 # else  /* ! ACE_LACKS_LONGLONG_T */
00588 #   define ACE_U64_TO_U32(n) (static_cast<ACE_UINT32> (n))
00589 #   define ACE_CU64_TO_CU32(n) \
00590      (static_cast<ACE_CAST_CONST ACE_UINT32> (n))
00591 # endif /* ! ACE_LACKS_LONGLONG_T */
00592 
00593 // 64-bit literals require special marking on some platforms.
00594 # if defined (ACE_LACKS_LONGLONG_T)
00595     // Can only specify 32-bit arguments.
00596 #   define ACE_UINT64_LITERAL(n) n ## UL
00597       // This one won't really work, but it'll keep
00598       // some compilers happy until we have better support
00599 #   define ACE_INT64_LITERAL(n) n ## L
00600 # elif defined (ACE_WIN32)
00601 #  if defined (__IBMCPP__) && (__IBMCPP__ >= 400)
00602 #   define ACE_UINT64_LITERAL(n) n ## LL
00603 #   define ACE_INT64_LITERAL(n) n ## LL
00604 #  elif defined (__MINGW32__)
00605 #   define ACE_UINT64_LITERAL(n) n ## ull
00606 #   define ACE_INT64_LITERAL(n) n ## ll
00607 #  else
00608 #   define ACE_UINT64_LITERAL(n) n ## ui64
00609 #   define ACE_INT64_LITERAL(n) n ## i64
00610 #  endif /* defined (__IBMCPP__) && (__IBMCPP__ >= 400) */
00611 # elif defined (__TANDEM)
00612 #   define ACE_UINT64_LITERAL(n) n ## LL
00613 #   define ACE_INT64_LITERAL(n) n ## LL
00614 # else  /* ! ACE_WIN32  &&  ! ACE_LACKS_LONGLONG_T */
00615 #   define ACE_UINT64_LITERAL(n) n ## ull
00616 #   define ACE_INT64_LITERAL(n) n ## ll
00617 # endif /* ! ACE_WIN32  &&  ! ACE_LACKS_LONGLONG_T */
00618 
00619 #if !defined (ACE_INT8_FORMAT_SPECIFIER)
00620 #  if defined (PRId8)
00621 #    define ACE_INT8_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRId8)
00622 #  else
00623 #    define ACE_INT8_FORMAT_SPECIFIER ACE_LIB_TEXT ("%d")
00624 #  endif /* defined (PRId8) */
00625 #endif /* ACE_INT8_FORMAT_SPECIFIER */
00626 
00627 #if !defined (ACE_UINT8_FORMAT_SPECIFIER)
00628 #  if defined (PRIu8)
00629 #    define ACE_UINT8_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRIu8)
00630 #  else
00631 #    define ACE_UINT8_FORMAT_SPECIFIER ACE_LIB_TEXT ("%u")
00632 #  endif /* defined (PRIu8) */
00633 #endif /* ACE_UINT8_FORMAT_SPECIFIER */
00634 
00635 #if !defined (ACE_INT16_FORMAT_SPECIFIER)
00636 #  if defined (PRId16)
00637 #    define ACE_INT16_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRId16)
00638 #  else
00639 #    define ACE_INT16_FORMAT_SPECIFIER ACE_LIB_TEXT ("%d")
00640 #  endif /* defined (PRId16) */
00641 #endif /* ACE_INT16_FORMAT_SPECIFIER */
00642 
00643 #if !defined (ACE_UINT16_FORMAT_SPECIFIER)
00644 #  if defined (PRIu16)
00645 #    define ACE_UINT16_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRIu16)
00646 #  else
00647 #    define ACE_UINT16_FORMAT_SPECIFIER ACE_LIB_TEXT ("%u")
00648 #  endif /* defined (PRIu16) */
00649 #endif /* ACE_UINT16_FORMAT_SPECIFIER */
00650 
00651 #if !defined (ACE_INT32_FORMAT_SPECIFIER)
00652 #  if defined (PRId32)
00653 #    define ACE_INT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRId32)
00654 #  elif ACE_SIZEOF_INT == 4
00655 #    define ACE_INT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%d")
00656 #  else
00657 #    define ACE_INT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%ld")
00658 #  endif /* defined (PRId32) */
00659 #endif /* ACE_INT32_FORMAT_SPECIFIER */
00660 
00661 #if !defined (ACE_UINT32_FORMAT_SPECIFIER)
00662 #  if defined (PRIu32)
00663 #    define ACE_UINT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRIu32)
00664 #  elif ACE_SIZEOF_INT == 4
00665 #    define ACE_UINT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%u")
00666 #  else
00667 #    define ACE_UINT32_FORMAT_SPECIFIER ACE_LIB_TEXT ("%lu")
00668 #  endif /* defined (PRIu32) */
00669 #endif /* ACE_UINT32_FORMAT_SPECIFIER */
00670 
00671 #if !defined (ACE_INT64_FORMAT_SPECIFIER)
00672 #  if defined (PRId64)
00673 #    define ACE_INT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRId64)
00674 #  elif ACE_SIZEOF_LONG == 8
00675 #    define ACE_INT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%ld")
00676 #  else
00677 #    define ACE_INT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%lld")
00678 #  endif /* defined (PRId64) */
00679 #endif /* ACE_INT64_FORMAT_SPECIFIER */
00680 
00681 #if !defined (ACE_UINT64_FORMAT_SPECIFIER)
00682 #  if defined (PRIu64)
00683 #    define ACE_UINT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%") ACE_LIB_TEXT (PRIu64)
00684 #  elif ACE_SIZEOF_LONG == 8
00685 #    define ACE_UINT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%lu")
00686 #  else
00687 #    define ACE_UINT64_FORMAT_SPECIFIER ACE_LIB_TEXT ("%llu")
00688 #  endif /* defined (PRIu64) */
00689 #endif /* ACE_UINT64_FORMAT_SPECIFIER */
00690 
00691 #if !defined (ACE_SSIZE_T_FORMAT_SPECIFIER)
00692 # if defined (ACE_WIN64)
00693 #  define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_LIB_TEXT ("%I64d")
00694 # else
00695 #  define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_LIB_TEXT ("%d")
00696 # endif /* ACE_WIN64 */
00697 #endif /* ACE_SSIZE_T_FORMAT_SPECIFIER */
00698 
00699 #if !defined (ACE_SIZE_T_FORMAT_SPECIFIER)
00700 # if defined (ACE_WIN64)
00701 #  define ACE_SIZE_T_FORMAT_SPECIFIER ACE_LIB_TEXT ("%I64u")
00702 # else
00703 #  define ACE_SIZE_T_FORMAT_SPECIFIER ACE_LIB_TEXT ("%u")
00704 # endif /* ACE_WIN64 */
00705 #endif /* ACE_SIZE_T_FORMAT_SPECIFIER */
00706 
00707 // Cast from UINT64 to a double requires an intermediate cast to INT64
00708 // on some platforms.
00709 # if defined (ACE_LACKS_LONGLONG_T)
00710    // Only use the low 32 bits.
00711 #   define ACE_UINT64_DBLCAST_ADAPTER(n) ACE_U64_TO_U32 (n)
00712 # elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00713 #   define ACE_UINT64_DBLCAST_ADAPTER(n) ((n).to_int64 ())
00714 # elif defined (ACE_WIN32)
00715 #   define ACE_UINT64_DBLCAST_ADAPTER(n) static_cast<__int64> (n)
00716 # else  /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */
00717 #   define ACE_UINT64_DBLCAST_ADAPTER(n) (n)
00718 # endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */
00719 
00720 
00721 // The number of bytes in a float.
00722 # ifndef ACE_SIZEOF_FLOAT
00723 #   if FLT_MAX_EXP == 128
00724 #     define ACE_SIZEOF_FLOAT 4
00725 #   elif FLT_MAX_EXP == 1024
00726 #     define ACE_SIZEOF_FLOAT 8
00727 #   else
00728 #     error: unsupported float size, must be updated for this platform!
00729 #   endif /* FLT_MAX_EXP */
00730 # endif /* ACE_SIZEOF_FLOAT */
00731 
00732 // The number of bytes in a double.
00733 # ifndef ACE_SIZEOF_DOUBLE
00734 #   if DBL_MAX_EXP == 128
00735 #     define ACE_SIZEOF_DOUBLE 4
00736 #   elif DBL_MAX_EXP == 1024
00737 #     define ACE_SIZEOF_DOUBLE 8
00738 #   else
00739 #     error: unsupported double size, must be updated for this platform!
00740 #   endif /* DBL_MAX_EXP */
00741 # endif /* ACE_SIZEOF_DOUBLE */
00742 
00743 // The number of bytes in a long double.
00744 # ifndef ACE_SIZEOF_LONG_DOUBLE
00745 #   if LDBL_MAX_EXP == 128
00746 #     define ACE_SIZEOF_LONG_DOUBLE 4
00747 #   elif LDBL_MAX_EXP == 1024
00748 #     define ACE_SIZEOF_LONG_DOUBLE 8
00749 #   elif LDBL_MAX_EXP == 16384
00750 #     if defined (LDBL_DIG)  &&  LDBL_DIG == 18
00751 #       if defined (__ia64) || defined (__x86_64)
00752 #         define ACE_SIZEOF_LONG_DOUBLE 16
00753 #       else /* ! __ia64 */
00754 #       define ACE_SIZEOF_LONG_DOUBLE 12
00755 #       endif /* __ia64 */
00756 #     else  /* ! LDBL_DIG  ||  LDBL_DIG != 18 */
00757 #       define ACE_SIZEOF_LONG_DOUBLE 16
00758 #     endif /* ! LDBL_DIG  ||  LDBL_DIG != 18 */
00759 #   else
00760 #     error: unsupported double size, must be updated for this platform!
00761 #   endif /* LDBL_MAX_EXP */
00762 # endif /* ACE_SIZEOF_LONG_DOUBLE */
00763 
00764 // Max and min sizes for the ACE integer types.
00765 #define ACE_CHAR_MAX 0x7F
00766 #define ACE_CHAR_MIN -(ACE_CHAR_MAX)-1
00767 #define ACE_OCTET_MAX 0xFF
00768 #define ACE_INT16_MAX 0x7FFF
00769 #define ACE_INT16_MIN -(ACE_INT16_MAX)-1
00770 #define ACE_UINT16_MAX 0xFFFF
00771 #define ACE_WCHAR_MAX ACE_UINT16_MAX
00772 #define ACE_INT32_MAX 0x7FFFFFFF
00773 #define ACE_INT32_MIN -(ACE_INT32_MAX)-1
00774 #define ACE_UINT32_MAX 0xFFFFFFFF
00775 #define ACE_INT64_MAX ACE_INT64_LITERAL(0x7FFFFFFFFFFFFFFF)
00776 #define ACE_INT64_MIN -(ACE_INT64_MAX)-1
00777 #define ACE_UINT64_MAX ACE_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF)
00778 // These use ANSI/IEEE format.
00779 #define ACE_FLT_MAX 3.402823466e+38F
00780 #define ACE_DBL_MAX 1.7976931348623158e+308
00781 
00782 # if defined (__ACE_INLINE__)
00783 #   include "ace/Basic_Types.inl"
00784 # endif /* __ACE_INLINE__ */
00785 
00786 # include /**/ "ace/post.h"
00787 #endif /* ACE_BASIC_TYPES_H */

Generated on Thu Nov 9 09:41:47 2006 for ACE by doxygen 1.3.6