Main Page   Modules   Data Structures   File List   Data Fields   Globals  

integers.h

Go to the documentation of this file.
00001 /*
00002  * integers.h
00003  * Created on 13 Feb 2005
00004  * Authors:
00005  *    Wesley Leggette <wleggette@kaylix.net>
00006  * 
00007  *    Adapted from integers.hpp / libdar by Denis Corbin
00008  * 
00009  * 
00010  * libdarc
00011  * 
00012  * 
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  * 
00027  * $Id: integers_8h-source.html 708 2005-03-21 12:30:37Z leggwes $
00028  */
00029 
00037 #ifndef INTEGERS_H
00038 #define INTEGERS_H
00039 
00040 /* internal config.h */
00041 #ifdef HAVE_CONFIG_H
00042 #include "../config.h"
00043 #endif
00044 
00045 /* external config.h that will be installed */
00046 #include "config.h"
00047 
00048 
00049 
00050 #define U_8_MIN   0
00051 #define U_8_MAX   255
00052 #define U_16_MIN  0
00053 #define U_16_MAX  65535
00054 #define U_32_MIN  0
00055 #define U_32_MAX  4294967295U
00056 #define U_64_MIN  0
00057 #define U_64_MAX 18446744073709551615ULL
00058 
00059 #define S_8_MIN   (-128)
00060 #define S_8_MAX   127
00061 #define S_16_MIN  0x8000
00062 #define S_16_MAX  0x7FFF
00063 #define S_32_MIN  0x80000000L
00064 #define S_32_MAX  0x7FFFFFFFL
00065 #define S_64_MIN  0x8000000000000000LL
00066 #define S_64_MAX  0x7FFFFFFFFFFFFFFFLL
00067 
00068 
00069 
00070 
00071 #ifndef LIBDARC_OS_BITS
00072 
00073 #if LIBDARC_HAVE_INTTYPES_H
00074 
00075 
00076 #ifdef __cplusplus
00077 extern "C"
00078 {
00079 #endif
00080 
00081 #include <inttypes.h>
00082 
00083 
00084 #ifndef __WORDSIZE
00085 #ifdef _WIN32
00086 # define __WORDSIZE 32
00087 #else
00088 #  ifdef _WIN64
00089 #   define __WORDSIZE 64
00090 #  endif
00091 #endif
00092 #endif
00093 
00094 #ifndef __WORDSIZE
00095 # ifdef LIBDARC_SIZEOF_INTPTR_T
00096 #  if LIBDARC_SIZEOF_INTPTR_T == 4
00097 #    define __WORDSIZE 32
00098 #  else
00099 #  if LIBDARC_SIZEOF_INTPTR_T == 8
00100 #    define __WORDSIZE 64
00101 #  endif
00102 #  endif
00103 # endif
00104 #endif
00105 
00106 #ifndef __WORDSIZE
00107 #error "Cannot determine wordsize, perhaps host is not Unix or Windows? Use --enable-os-bits=... with the 'configure' script according to your system's CPU register size"
00108 #endif
00109 
00110 
00111 #ifdef __cplusplus
00112 } /* end extern "C" */
00113 
00114 namespace libdar
00115 {
00116 #endif
00117 
00118     typedef unsigned char U_8;
00119     typedef uint16_t U_16;
00120     typedef uint32_t U_32;
00121     typedef uint64_t U_64;
00122     typedef unsigned int U_I;
00123     typedef signed char S_8;
00124     typedef int16_t S_16;
00125     typedef int32_t S_32;
00126     typedef int64_t S_64;
00127     typedef signed int S_I;
00128 
00129 #ifdef __cplusplus
00130 }
00131 #endif
00132 
00133 #else /* LIBDARC_HAS_INTTYPES_H */
00134 #error "Cannot determine integer types, use --enable-os-bits=... with the 'configure' script according to your system's CPU register size"
00135 #endif /* !LIBDARC_HAS_INTTYPES_H */
00136 
00137 #else  /*  !LIBDARC_OS_BITS not defined */
00138 #if LIBDARC_OS_BITS == 32
00139 #define __WORDSIZE 32
00140 
00141 #ifdef __cplusplus
00142 namespace libdar
00143 {
00144 #endif
00145 
00146     typedef unsigned char U_8;
00147     typedef unsigned short U_16;
00148     typedef unsigned long U_32;
00149     typedef unsigned long long U_64;
00150     typedef unsigned int U_I;
00151     typedef signed char S_8;
00152     typedef signed short S_16;
00153     typedef signed long S_32;
00154     typedef signed long long S_64;
00155     typedef signed int S_I;
00156     
00157     typedef int intptr_t;
00158     
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162 
00163 #else
00164 #if LIBDARC_OS_BITS == 64
00165 #define __WORDSIZE 64
00166 
00167 #ifdef __cplusplus
00168 namespace libdar
00169 {
00170 #endif
00171 
00172     typedef unsigned char U_8;
00173     typedef unsigned short U_16;
00174     typedef unsigned int U_32;
00175     typedef unsigned long long U_64;
00176     typedef unsigned int U_I;
00177     typedef signed char S_8;
00178     typedef signed short S_16;
00179     typedef signed int S_32;
00180     typedef signed long long S_64;
00181     typedef signed int S_I;
00182     
00183     typedef long int intptr_t;
00184 
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188 
00189 #else
00190 #error "unknown value given to --enable-os-bits=... check the 'configure' script arguments"
00191     /* unknown LIBDARC_OS_BITS value ! use --enable-os-bits=... option to configure script
00192      *
00193      * the previous line should not compile, this is the expected behaviour
00194      */
00195 
00196 #endif /* LIBDARC_OS_BITS == 64 */
00197 #endif /* LIBDARC_OS_BITS == 32 */
00198 #endif /* LIBDARC_OS_BITS not defined */
00199 
00200 #endif /* header file multiple inclusion protection */