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