1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef nptypes_h_ 7 #define nptypes_h_ 8 9 /* 10 * Header file for ensuring that C99 types ([u]int32_t, [u]int64_t and bool) and 11 * true/false macros are available. 12 */ 13 14 #if defined(WIN32) 15 /* 16 * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool 17 * is predefined tho, both in C and C++. 18 */ 19 typedef short int16_t; 20 typedef unsigned short uint16_t; 21 typedef int int32_t; 22 typedef unsigned int uint32_t; 23 typedef long long int64_t; 24 typedef unsigned long long uint64_t; 25 #elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX) 26 /* 27 * AIX and SunOS ship a inttypes.h header that defines [u]int32_t, 28 * but not bool for C. 29 */ 30 #include <inttypes.h> 31 32 #ifndef __cplusplus 33 typedef int bool; 34 #define true 1 35 #define false 0 36 #endif 37 #elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD) 38 /* 39 * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and 40 * u_int32_t. 41 */ 42 #include <sys/types.h> 43 44 /* 45 * BSD/OS ships no header that defines uint32_t, nor bool (for C) 46 */ 47 #if defined(bsdi) 48 typedef u_int32_t uint32_t; 49 typedef u_int64_t uint64_t; 50 51 #if !defined(__cplusplus) 52 typedef int bool; 53 #define true 1 54 #define false 0 55 #endif 56 #else 57 /* 58 * FreeBSD and OpenBSD define uint32_t and bool. 59 */ 60 #include <inttypes.h> 61 #include <stdbool.h> 62 #endif 63 #elif defined(BEOS) 64 #include <inttypes.h> 65 #else 66 /* 67 * For those that ship a standard C99 stdint.h header file, include 68 * it. Can't do the same for stdbool.h tho, since some systems ship 69 * with a stdbool.h file that doesn't compile! 70 */ 71 #include <stdint.h> 72 73 #ifndef __cplusplus 74 #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) 75 #include <stdbool.h> 76 #else 77 /* 78 * GCC 2.91 can't deal with a typedef for bool, but a #define 79 * works. 80 */ 81 #define bool int 82 #define true 1 83 #define false 0 84 #endif 85 #endif 86 #endif 87 88 #endif /* nptypes_h_ */ 89