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

more/lang/stdint.h

Go to the documentation of this file.
00001 
00002 //  Copyright (C) 2001  Petter Urkedal (petter.urkedal@matfys.lth.se)
00003 //
00004 //  This file is free software; you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation; either version 2 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This file is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program; if not, write to the Free Software
00016 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 //
00018 //  As a special exception, you may use this file as part of a free
00019 //  software library without restriction.  Specifically, if other files
00020 //  instantiate templates or use macros or inline functions from this
00021 //  file, or you compile this file and link it with other files to
00022 //  produce an executable, this file does not by itself cause the
00023 //  resulting executable to be covered by the GNU General Public
00024 //  License.  This exception does not however invalidate any other
00025 //  reasons why the executable file might be covered by the GNU General
00026 //  Public License.
00027 //
00028 //  $Id: stdint.h,v 1.1 2002/05/30 18:01:37 petter_urkedal Exp $
00029 
00030 
00031 #ifndef MORE_STDINT_H
00032 #define MORE_STDINT_H
00033 
00034 #include <more/bits/config.h>
00035 
00036 #ifdef HAVE_STDINT_H
00037 #include <stdint.h>
00038 
00039 namespace more {
00040 namespace lang {
00041 
00042   using ::uint8_t;
00043   using ::int8_t;
00044   using ::uint16_t;
00045   using ::int16_t;
00046   using ::uint32_t;
00047   using ::int32_t;
00048   using ::uint64_t;
00049   using ::int64_t;
00050 
00051   using ::uint_least8_t;
00052   using ::int_least8_t;
00053   using ::uint_least16_t;
00054   using ::int_least16_t;
00055   using ::uint_least32_t;
00056   using ::int_least32_t;
00057   using ::uint_least64_t;
00058   using ::int_least64_t;
00059 
00060   using ::uint_fast8_t;
00061   using ::int_fast8_t;
00062   using ::uint_fast16_t;
00063   using ::int_fast16_t;
00064   using ::uint_fast32_t;
00065   using ::int_fast32_t;
00066   using ::uint_fast64_t;
00067   using ::int_fast64_t;
00068 
00069   using ::intmax_t;
00070   using ::uintmax_t;
00071 
00072   using ::intptr_t;
00073   using ::uintptr_t;
00074 
00075 }}
00076 
00077 #else
00078 
00079 namespace more {
00080 namespace lang {
00081 
00082 
00083 #if SIZEOF_CHAR < 1
00084 #  error "Oops, SIZEOF_CHAR < 1!  Problems with the configuration?"
00085 #endif
00086 
00087   /** an unsigned integer at least 8 bits wide */
00088   typedef unsigned char uint_least8_t;
00089   /** a signed integer at least 8 bits wide */
00090   typedef signed char int_least8_t;
00091 
00092 #if SIZEOF_SHORT >= 2
00093   typedef unsigned short uint_least16_t;
00094   typedef short int_least16_t;
00095 #else
00096 #  error "Short should be at least 16 bits wide, check configuration."
00097 #endif
00098 
00099 #if SIZEOF_SHORT >= 4
00100   typedef unsigned short uint_least32_t;
00101   typedef short int_least32_t;
00102 #elif SIZEOF_INT >= 4
00103   typedef unsigned int uint_least32_t;
00104   typedef int int_least32_t;
00105 #elif SIZEOF_LONG >= 4
00106   typedef unsigned long uint_least32_t;
00107   typedef long int_least32_t;
00108 #else
00109 #  error "Could not find a >=32 bit wide integer, check configuration."
00110 #endif
00111 
00112 #if SIZEOF_INT >= 8
00113 #  define MORE_HAVE_INT_LEAST64_T
00114   typedef unsigned int uint_least64_t;
00115   typedef int int_least64_t;
00116 #elif SIZEOF_LONG >= 8
00117 #  define MORE_HAVE_INT_LEAST64_T
00118   typedef unsigned long uint_least64_t;
00119   typedef long int_least64_t;
00120 #elif SIZEOF_LONG_LONG >= 8
00121 #  define MORE_HAVE_INT_LEAST64_T
00122   typedef unsigned long long uint_least64_t;
00123   typedef long long int_least64_t;
00124 #endif
00125 
00126   // If stdint.h is not available, we don't know which types are fast,
00127   // so use small types as a fallback.  Use also the same for the
00128   // default types.
00129   typedef uint_least8_t uint_fast8_t;
00130   typedef int_least8_t int_fast8_t;
00131   typedef uint_least8_t uint8_t;
00132   typedef int_least8_t int8_t;
00133 
00134   typedef uint_least16_t uint_fast16_t;
00135   typedef int_least16_t int_fast16_t;
00136   typedef uint_least16_t uint16_t;
00137   typedef int_least16_t int16_t;
00138 
00139   typedef uint_least32_t uint_fast32_t;
00140   typedef int_least32_t int_fast32_t;
00141   typedef uint_least32_t uint32_t;
00142   typedef int_least32_t int32_t;
00143 
00144 #ifdef MORE_HAVE_INT_LEAST64_T
00145   typedef uint_least64_t uint_fast64_t;
00146   typedef int_least64_t int_fast64_t;
00147   typedef uint_least64_t uint64_t;
00148   typedef int_least64_t int64_t;
00149 #endif
00150 
00151 #ifdef CXX_HAVE_LONG_LONG
00152 //#  define SIZEOF_UINTWIDEST SIZEOF_LONG_LONG
00153   typedef long long intmax_t;
00154   typedef unsigned long long uintmax_t;
00155 #else
00156 //#  define SIZEOF_UINTWIDEST SIZEOF_LONG
00157   typedef long intmax_t;
00158   typedef unsigned long uintmax_t;
00159 #endif
00160 
00161 #if SIZEOF_VOIDP <= SIZEOF_INT
00162   typedef unsigned int uintptr_t;
00163   typedef int intptr_t;
00164 #elif SIZEOF_VOIDP <= SIZEOF_LONG
00165   typedef unsigned long uintptr_t;
00166   typedef long intptr_t;
00167 #elif SIZEOF_VOIDP <= SIZEOF_LONG_LONG
00168   typedef unsigned long long uintptr_t;
00169   typedef long long intptr_t;
00170 #else
00171 #  error "No integer has the width of a pointer, check configuration."
00172 #endif
00173 
00174 }}
00175 
00176 #endif // HAVE_STDINT_H
00177 
00178 
00179 // namespace more {
00180 // namespace lang {
00181 // Integers which can hold at least the given number of bits and a pointer
00182 // OBS. These are not in stdint.h
00183 // #if SIZEOF_UINTWIDEST < SIZEOF_VOIDP
00184 // #  error "No integer has the width of a pointer, check configuration."
00185 // #endif
00186 // #if SIZEOF_VOIDP <= 4
00187 //   typedef uint_least32_t uint32ptr_t;
00188 // #  ifdef MORE_HAVE_INT_LEAST64_T
00189 //   typedef uint_least64_t uint64ptr_t;
00190 // #  endif
00191 // #elif SIZEOF_VOIDP <= 8
00192 //   typedef uint_least64_t uint32ptr_t;
00193 //   typedef uint_least64_t uint64ptr_t;
00194 // #else
00195 //   typedef uintmax_t uint32ptr_t;
00196 //   typedef uintmax_t uint64ptr_t;
00197 // #endif
00198 // }}
00199 
00200 #endif

Generated on Sat Sep 7 19:11:17 2002 for more with Doxygen 1.2.13.1. Doxygen 1.2.13.1 is written and copyright 1997-2002 by Dimitri van Heesch.