Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

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

Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.