00001 /* -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 00002 /********************************************************************* 00003 * 00004 * Filename : inttypes.h (base) 00005 * C header. 00006 * 00007 * Definition of integer types. Basically a wrapper for different 00008 * includes + basic size computation in int units. 00009 * 00010 * This file is a part of the UPPAAL toolkit. 00011 * Copyright (c) 1995 - 2003, Uppsala University and Aalborg University. 00012 * All right reserved. 00013 * 00014 * v 1.2 reviewed. 00015 * $Id: inttypes.h,v 1.11 2005/04/22 15:20:10 adavid Exp $ 00016 * 00017 *********************************************************************/ 00018 00019 #ifndef INCLUDE_BASE_INTTYPES_H 00020 #define INCLUDE_BASE_INTTYPES_H 00021 00022 /** Note on availability of headers: 00023 * - Linux has inttypes.h and stdint.h 00024 * - Solaris has inttypes.h only 00025 * - Mingwing has stdint.h 00026 * - Microsoft has none of them 00027 * temporary solution: define here. 00028 * 00029 * config.h knows about availability: 00030 */ 00031 #include "config.h" 00032 #include "base/platform.h" 00033 00034 #ifdef HAVE_INTTYPES_H 00035 #include <inttypes.h> 00036 #elif defined(HAVE_STDINT_H) 00037 #include <stdint.h> 00038 #else 00039 #error "No inttypes.h or stdint.h" 00040 #endif 00041 00042 /** Size computation in "int" units to avoid any alignment problem. 00043 * intsizeof : as sizeof but result in "int" units 00044 * bits2intsize : convert # of bits to # of int (size+31)/32 00045 * bytes2intsize: convert # of bytes to # of int (size+3)/4 00046 */ 00047 #define bits2intsize(X) (((X) + 31) >> 5) 00048 #define bytes2intsize(X) (((X) + 3) >> 2) 00049 #define intsizeof(X) bytes2intsize(sizeof(X)) 00050 00051 00052 /** Hack to get around icc failure to recognize property 00053 * POD types (plain old data): if TYPE is a class, then 00054 * TYPE* is not considered as POD. 00055 * Here we allocate on the stack an array of (icc-non POD) 00056 * TYPE* via a cast. 00057 */ 00058 #ifdef __INTEL_COMPILER 00059 #define POINTERS_OF(_TYPE, _NAME, _SIZE) \ 00060 uintptr_t _alloc_##_NAME[_SIZE]; \ 00061 _TYPE **_NAME = (_TYPE**) _alloc_##_NAME 00062 #else 00063 #define POINTERS_OF(_TYPE, _NAME, _SIZE) \ 00064 _TYPE *_NAME[_SIZE] 00065 #endif 00066 00067 #ifndef _WIN32 00068 00069 /** Define BOOL for C compilers. 00070 * NOTE: we could define bool for C compilers only but 00071 * the type may not be compatible with the C++ compiler 00072 * (as defined in stdbool.h). 00073 */ 00074 #ifdef ARCH_APPLE_DARWIN 00075 #ifndef FALSE 00076 #define FALSE 0 00077 #endif 00078 #ifndef TRUE 00079 #define TRUE 1 00080 #endif 00081 typedef int BOOL; 00082 #else 00083 typedef enum { FALSE=0, TRUE=1 } BOOL; 00084 #endif 00085 00086 #else 00087 #include <windows.h> 00088 /* big trouble */ 00089 #if !defined(__cplusplus) && !defined(__GNUC__) 00090 #define inline __inline 00091 #endif 00092 #endif 00093 00094 /** Type for indices (variables and clocks). 00095 */ 00096 typedef uint32_t cindex_t; 00097 00098 #endif /* INCLUDE_BASE_INTTYPES_H */