cel_stdint.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00004 //
00005 // (C) 2003-2006 Celartem Technology Inc. All rights reserved.
00006 //----------------------------------------------------------------------------
00007 
00008 #ifndef _cel_stdint_h_
00009 #define _cel_stdint_h_
00010 
00011 #include "cel_platform.h"
00012 
00013 #if CEL_ENV_POSIX
00014 //
00015 // POSIX platforms have stdint.h
00016 // The ISO C99 standard specifies that in C++ implementations macros
00017 // like SIZE_MAX should only be defined if explicitly requested by
00018 // difinition of __STDC_LIMIT_MACROS.
00019 #define __STDC_LIMIT_MACROS
00020 #include <stdint.h>
00021 #include <sys/types.h>
00022 
00023 #elif CEL_ENV_WINDOWS
00024 
00025 // It makes the global namespace little bit dirty but we need them here.
00026 #include <cstddef>
00027 
00028 //
00029 // VC7 currently does not support C99
00030 //
00031 typedef signed char int8_t;
00032 typedef short int16_t;
00033 typedef int int32_t;
00034 typedef __int64 int64_t;
00035 typedef unsigned char uint8_t;
00036 typedef unsigned short uint16_t;
00037 typedef unsigned int uint32_t;
00038 typedef unsigned __int64 uint64_t;
00039 
00040 #ifdef  _WIN64
00041 typedef __int64 ssize_t;
00042 #else
00043 typedef _W64 int ssize_t;
00044 #endif
00045 
00046 #else
00047 //
00048 // Unknown
00049 //
00050 #error "The platform doesn't support C99, and I could not emulate stdint.h !"
00051 #endif
00052 
00053 //
00054 // Integer limits
00055 //
00056 #ifndef INT8_MIN
00057 #define INT8_MIN (-128)
00058 #endif
00059 
00060 #ifndef INT16_MIN
00061 #define INT16_MIN (-32768)
00062 #endif
00063 
00064 #ifndef INT32_MIN
00065 #define INT32_MIN (-2147483647-1)
00066 #endif
00067 
00068 #ifndef INT64_MIN
00069 #define INT64_MIN (-9223372036854775808)
00070 #endif
00071 
00072 #ifndef INT8_MAX
00073 #define INT8_MAX (127)
00074 #endif
00075 
00076 #ifndef INT16_MAX
00077 #define INT16_MAX (32767)
00078 #endif
00079 
00080 #ifndef INT32_MAX
00081 #define INT32_MAX (2147483647)
00082 #endif
00083 
00084 #ifndef INT64_MAX
00085 #define INT64_MAX (9223372036854775807)
00086 #endif
00087 
00088 #ifndef UINT8_MAX
00089 #define UINT8_MAX (255)
00090 #endif
00091 
00092 #ifndef UINT16_MAX
00093 #define UINT16_MAX (65535)
00094 #endif
00095 
00096 #ifndef UINT32_MAX
00097 #define UINT32_MAX (4294967295UL)
00098 #endif
00099 
00100 #ifndef UINT64_MAX
00101 #define UINT64_MAX (18446744073709551615ULL)
00102 #endif
00103 
00104 // Windows may not have SIZE_MAX and SSIZE_MAX/SSIZE_MIN definitions...
00105 #if CEL_ENV_WINDOWS
00106 
00107 #ifndef SIZE_MAX
00108 #ifdef _WIN64
00109 #define SIZE_MAX UINT64_MAX
00110 #else
00111 #define SIZE_MAX UINT32_MAX
00112 #endif
00113 #endif
00114 
00115 #ifndef SSIZE_MAX
00116 #ifdef _WIN64
00117 #define SSIZE_MAX INT64_MAX
00118 #else
00119 #define SSIZE_MAX INT32_MAX
00120 #endif
00121 #endif
00122 
00123 #endif
00124 
00125 // Amazing thing is that SSIZE_MIN is not defined in anywhere although we
00126 // sometimes need it.
00127 // This implementation is a dirty hack for this but I believe it works very
00128 // well on almost all platforms.
00129 #ifndef SSIZE_MIN
00130 #define SSIZE_MIN (-SSIZE_MAX -1)
00131 #endif
00132 
00133 #endif // _cel_stdint_h_

This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:21:54 2008.