scint.h

00001 // This provides C99-like standard integer types.  It is based on boost.org
00002 // code which has been modified for inclusion in the SC Toolkit.
00003 
00004 //  (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
00005 //  and distribute this software is granted provided this copyright
00006 //  notice appears in all copies. This software is provided "as is" without
00007 //  express or implied warranty, and with no claim as to its suitability for
00008 //  any purpose.
00009 
00010 #ifndef util_misc_scint_h
00011 #define util_misc_scint_h
00012 
00013 #include <scconfig.h>
00014 
00015 #ifdef HAVE_STDINT_H
00016 
00017 #include <stdint.h>
00018 
00019 namespace sc {
00020 
00021 typedef int8_t         sc_int8_t;
00022 typedef int_least8_t   sc_int_least8_t;
00023 typedef int_fast8_t    sc_int_fast8_t;
00024 typedef uint8_t        sc_uint8_t;
00025 typedef uint_least8_t  sc_uint_least8_t;
00026 typedef uint_fast8_t   sc_uint_fast8_t;
00027                        
00028 typedef int16_t        sc_int16_t;
00029 typedef int_least16_t  sc_int_least16_t;
00030 typedef int_fast16_t   sc_int_fast16_t;
00031 typedef uint16_t       sc_uint16_t;
00032 typedef uint_least16_t sc_uint_least16_t;
00033 typedef uint_fast16_t  sc_uint_fast16_t;
00034                        
00035 typedef int32_t        sc_int32_t;
00036 typedef int_least32_t  sc_int_least32_t;
00037 typedef int_fast32_t   sc_int_fast32_t;
00038 typedef uint32_t       sc_uint32_t;
00039 typedef uint_least32_t sc_uint_least32_t;
00040 typedef uint_fast32_t  sc_uint_fast32_t;
00041                        
00042 typedef intmax_t       sc_intmax_t;
00043 typedef uintmax_t      sc_uintmax_t;
00044 typedef int64_t        sc_int64_t;
00045 typedef int_least64_t  sc_int_least64_t;
00046 typedef int_fast64_t   sc_int_fast64_t;
00047 typedef uint64_t       sc_uint64_t;
00048 typedef uint_least64_t sc_uint_least64_t;
00049 typedef uint_fast64_t  sc_uint_fast64_t;
00050 
00051 }
00052 
00053 #else
00054 
00055 //  This is not a complete implementation of the 1999 C Standard stdint.h
00056 //  header; it doesn't supply various macros which are not advisable for use in
00057 //  C++ programs.
00058 
00059 #include <limits.h> // implementation artifact; not part of interface
00060 
00061 namespace sc {
00062 
00063 //  These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
00064 //  platforms.  For other systems, they will have to be hand tailored.
00065 //  Because the fast types are assumed to be the same as the undecorated types,
00066 //  it may be possible to hand tailor a more efficient implementation.
00067 
00068 //  8-bit types  -------------------------------------------------------------//
00069 
00070 # if UCHAR_MAX == 0xff
00071      typedef signed char     sc_int8_t;
00072      typedef signed char     sc_int_least8_t;
00073      typedef signed char     sc_int_fast8_t;
00074      typedef unsigned char   sc_uint8_t;
00075      typedef unsigned char   sc_uint_least8_t;
00076      typedef unsigned char   sc_uint_fast8_t;
00077 # else
00078 #    error defaults not correct; you must hand modify scint.h
00079 # endif
00080 
00081 //  16-bit types  ------------------------------------------------------------//
00082 
00083 # if USHRT_MAX == 0xffff
00084      typedef short           sc_int16_t;
00085      typedef short           sc_int_least16_t;
00086      typedef short           sc_int_fast16_t;
00087      typedef unsigned short  sc_uint16_t;
00088      typedef unsigned short  sc_uint_least16_t;
00089      typedef unsigned short  sc_uint_fast16_t;
00090 # else
00091 #    error defaults not correct; you must hand modify scint.h
00092 # endif
00093 
00094 //  32-bit types  ------------------------------------------------------------//
00095 
00096 # if UINT_MAX == 0xffffffff
00097      typedef int             sc_int32_t;
00098      typedef int             sc_int_least32_t;
00099      typedef int             sc_int_fast32_t;
00100      typedef unsigned int    sc_uint32_t;
00101      typedef unsigned int    sc_uint_least32_t;
00102      typedef unsigned int    sc_uint_fast32_t;
00103 # elif ULONG_MAX == 0xffffffff
00104      typedef long            sc_int32_t;
00105      typedef long            sc_int_least32_t;
00106      typedef long            sc_int_fast32_t;
00107      typedef unsigned long   sc_uint32_t;
00108      typedef unsigned long   sc_uint_least32_t;
00109      typedef unsigned long   sc_uint_fast32_t;
00110 # else
00111 #    error defaults not correct; you must hand modify scint.h
00112 # endif
00113 
00114 //  64-bit types + intmax_t and uintmax_t  -----------------------------------//
00115 
00116 #if defined(ULONGLONG_MAX) && !defined(ULLONG_MAX)
00117 #    define ULLONG_MAX ULONGLONG_MAX
00118 #endif
00119 
00120 # ifdef ULLONG_MAX
00121 //#    if ULLONG_MAX == 18446744073709551615 // 2**64 - 1
00122 #    if ULLONG_MAX == (0xffffffffffffffffuLL) // uLL reqd for xlC
00123      typedef long long            sc_intmax_t;
00124      typedef unsigned long long   sc_uintmax_t;
00125      typedef long long            sc_int64_t;
00126      typedef long long            sc_int_least64_t;
00127      typedef long long            sc_int_fast64_t;
00128      typedef unsigned long long   sc_uint64_t;
00129      typedef unsigned long long   sc_uint_least64_t;
00130      typedef unsigned long long   sc_uint_fast64_t;
00131 #    else
00132 #       error defaults not correct; you must hand modify scint.h
00133 #    endif
00134 # elif ULONG_MAX != 0xffffffff
00135 
00136 #    if ULONG_MAX == 18446744073709551615 // 2**64 - 1
00137      typedef long                 sc_intmax_t;
00138      typedef unsigned long        sc_uintmax_t;
00139      typedef long                 sc_int64_t;
00140      typedef long                 sc_int_least64_t;
00141      typedef long                 sc_int_fast64_t;
00142      typedef unsigned long        sc_uint64_t;
00143      typedef unsigned long        sc_uint_least64_t;
00144      typedef unsigned long        sc_uint_fast64_t;
00145 #    else
00146 #       error defaults not correct; you must hand modify scint.h
00147 #    endif
00148 # else // assume no 64-bit integers
00149 #    error 64 bit integer types are required
00150      typedef sc_int32_t              sc_intmax_t;
00151      typedef sc_uint32_t             sc_uintmax_t;
00152 # endif
00153 
00154 }
00155 
00156 #endif
00157 
00158 #endif

Generated at Mon Dec 3 23:23:41 2007 for MPQC 2.3.1 using the documentation package Doxygen 1.5.2.