/* type_s32.h Define 32-bit integer data types, basec on user-supplied options of compiler-supplied #defines if available. Here is a partial list of compiler defines that can be used to figure out the size of pointer and long. They are used like this: #if (defined(__foo__) && defined(__bar__)) width defines 64 _AIX && __64BIT__ 64 __hpux && __LP64__ 32 __linux__ && __i386__ 64 __linux__ && __ia64__ 64 __linux__ && __x86_64__ 32 __linux__ && __powerpc__ 64 __linux__ && __powerpc64__ 32 __linux__ && __s390__ 64 __linux__ && __s390x__ 64 __osf__ 64 sinix && __LP64__ 64 _WIN64 32 _WIN32 In the cases when long is 64-bit, int is 32-bit. More notes about this are in type_s64.h */ /* First check user-supplied options */ #ifdef INT_IS_S32 typedef signed int s32; typedef unsigned int u32; # define HAVE_S32 #elif LONG_IS_S32 typedef signed long s32; typedef unsigned long u32; # define HAVE_S32 #endif /* If our compiler is GCC, int is almost certainly 32-bit. */ #ifdef __GNUC__ typedef signed int s32; typedef unsigned int u32; # define HAVE_S32 #endif /* %%% Perhaps I can MSFT and use something like __int32 */ /* Defaults */ #ifndef HAVE_S32 typedef signed int s32; typedef unsigned int u32; # define HAVE_S32 #endif /* This macro provides code that you can use at runtime (e.g. at the beginning of your main) to make sure s32 is actually 32 bits. It assumes is already included. We don't include stdio for you because perhaps you don't want to use this macro. */ #ifndef TYPE_S32_CHECK_SIZE # define TYPE_S32_CHECK_SIZE(procname) \ if (sizeof(s32) != 4) { \ printf("%s: s32 is not 4 bytes (got %d).\n", \ (procname), (int) sizeof(s32)); \ if (sizeof(int) == 4) { \ printf( \ " To fix this error, recompile with the flag -DINT_IS_S32\n"); \ } else if (sizeof(long) == 4) { \ printf( \ " To fix this error, recompile with the flag -DLONG_IS_S32\n"); \ } else { \ printf( \ " (presently, sizeof(int)==%d and sizeof(long)==%d)\n", \ (int) sizeof(int), (int) sizeof(long)); \ } \ exit(-1); \ } #endif