]>
Commit | Line | Data |
---|---|---|
729e4ab9 A |
1 | /* |
2 | ****************************************************************************** | |
3 | * | |
51004dcb | 4 | * Copyright (C) 1997-2012, International Business Machines |
729e4ab9 A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ****************************************************************************** | |
8 | * | |
9 | * FILE NAME : ptypes.h | |
10 | * | |
11 | * Date Name Description | |
12 | * 05/13/98 nos Creation (content moved here from ptypes.h). | |
13 | * 03/02/99 stephen Added AS400 support. | |
14 | * 03/30/99 stephen Added Linux support. | |
15 | * 04/13/99 stephen Reworked for autoconf. | |
16 | * 09/18/08 srl Moved basic types back to ptypes.h from platform.h | |
17 | ****************************************************************************** | |
18 | */ | |
19 | ||
51004dcb A |
20 | /** |
21 | * \file | |
22 | * \brief C API: Definitions of integer types of various widths | |
23 | */ | |
24 | ||
729e4ab9 A |
25 | #ifndef _PTYPES_H |
26 | #define _PTYPES_H | |
27 | ||
4388f060 A |
28 | /** |
29 | * \def __STDC_LIMIT_MACROS | |
30 | * According to the Linux stdint.h, the ISO C99 standard specifies that in C++ implementations | |
31 | * macros like INT32_MIN and UINTPTR_MAX should only be defined if explicitly requested. | |
32 | * We need to define __STDC_LIMIT_MACROS before including stdint.h in C++ code | |
33 | * that uses such limit macros. | |
34 | * @internal | |
35 | */ | |
36 | #ifndef __STDC_LIMIT_MACROS | |
37 | #define __STDC_LIMIT_MACROS | |
38 | #endif | |
39 | ||
40 | /* NULL, size_t, wchar_t */ | |
41 | #include <stddef.h> | |
42 | ||
43 | /* | |
44 | * If all compilers provided all of the C99 headers and types, | |
45 | * we would just unconditionally #include <stdint.h> here | |
46 | * and not need any of the stuff after including platform.h. | |
47 | */ | |
729e4ab9 | 48 | |
4388f060 | 49 | /* Find out if we have stdint.h etc. */ |
729e4ab9 A |
50 | #include "unicode/platform.h" |
51 | ||
52 | /*===========================================================================*/ | |
53 | /* Generic data types */ | |
54 | /*===========================================================================*/ | |
55 | ||
4388f060 A |
56 | /* If your platform does not have the <stdint.h> header, you may |
57 | need to edit the typedefs in the #else section below. | |
58 | Use #if...#else...#endif with predefined compiler macros if possible. */ | |
59 | #if U_HAVE_STDINT_H | |
729e4ab9 | 60 | |
4388f060 A |
61 | /* |
62 | * We mostly need <stdint.h> (which defines the standard integer types) but not <inttypes.h>. | |
63 | * <inttypes.h> includes <stdint.h> and adds the printf/scanf helpers PRId32, SCNx16 etc. | |
64 | * which we almost never use, plus stuff like imaxabs() which we never use. | |
65 | */ | |
66 | #include <stdint.h> | |
67 | ||
68 | #if U_PLATFORM == U_PF_OS390 | |
729e4ab9 A |
69 | /* The features header is needed to get (u)int64_t sometimes. */ |
70 | #include <features.h> | |
4388f060 | 71 | /* z/OS has <stdint.h>, but some versions are missing uint8_t (APAR PK62248). */ |
729e4ab9 A |
72 | #if !defined(__uint8_t) |
73 | #define __uint8_t 1 | |
74 | typedef unsigned char uint8_t; | |
75 | #endif | |
4388f060 A |
76 | #endif /* U_PLATFORM == U_PF_OS390 */ |
77 | ||
78 | #elif U_HAVE_INTTYPES_H | |
729e4ab9 | 79 | |
4388f060 | 80 | # include <inttypes.h> |
729e4ab9 | 81 | |
4388f060 | 82 | #else /* neither U_HAVE_STDINT_H nor U_HAVE_INTTYPES_H */ |
729e4ab9 A |
83 | |
84 | #if ! U_HAVE_INT8_T | |
85 | typedef signed char int8_t; | |
86 | #endif | |
87 | ||
88 | #if ! U_HAVE_UINT8_T | |
89 | typedef unsigned char uint8_t; | |
90 | #endif | |
91 | ||
92 | #if ! U_HAVE_INT16_T | |
93 | typedef signed short int16_t; | |
94 | #endif | |
95 | ||
96 | #if ! U_HAVE_UINT16_T | |
97 | typedef unsigned short uint16_t; | |
98 | #endif | |
99 | ||
100 | #if ! U_HAVE_INT32_T | |
101 | typedef signed int int32_t; | |
102 | #endif | |
103 | ||
104 | #if ! U_HAVE_UINT32_T | |
105 | typedef unsigned int uint32_t; | |
106 | #endif | |
107 | ||
108 | #if ! U_HAVE_INT64_T | |
4388f060 A |
109 | #ifdef _MSC_VER |
110 | typedef signed __int64 int64_t; | |
111 | #else | |
729e4ab9 | 112 | typedef signed long long int64_t; |
4388f060 | 113 | #endif |
729e4ab9 A |
114 | #endif |
115 | ||
116 | #if ! U_HAVE_UINT64_T | |
4388f060 A |
117 | #ifdef _MSC_VER |
118 | typedef unsigned __int64 uint64_t; | |
119 | #else | |
729e4ab9 | 120 | typedef unsigned long long uint64_t; |
4388f060 | 121 | #endif |
729e4ab9 A |
122 | #endif |
123 | ||
4388f060 | 124 | #endif /* U_HAVE_STDINT_H / U_HAVE_INTTYPES_H */ |
729e4ab9 A |
125 | |
126 | #endif /* _PTYPES_H */ |