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

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.