Skip to content

Commit ab4bcd8

Browse files
committedJun 20, 2019
AIX system headers need stdint.h and inttypes.h to be re-enterable
Summary: AIX system headers need stdint.h and inttypes.h to be re-enterable when macro _STD_TYPES_T is defined so that limit macro definitions such as UINT32_MAX can be found. This patch attempts to allow that on AIX. Reviewers: hubert.reinterpretcast, jasonliu, mclow.lists, EricWF Reviewed by: hubert.reinterpretcast, mclow.lists Subscribers: jfb, jsji, christof, cfe-commits, libcxx-commits, llvm-commits Tags: #LLVM, #clang, #libc++ Differential Revision: https://reviews.llvm.org/D59253 llvm-svn: 363939
1 parent 345473c commit ab4bcd8

File tree

5 files changed

+288
-0
lines changed

5 files changed

+288
-0
lines changed
 

Diff for: ‎clang/lib/Headers/inttypes.h

+5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
\*===----------------------------------------------------------------------===*/
88

99
#ifndef __CLANG_INTTYPES_H
10+
// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
11+
// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
12+
// case the header guard macro is defined.
13+
#if !defined(_AIX) || !defined(_STD_TYPES_T)
1014
#define __CLANG_INTTYPES_H
15+
#endif
1116

1217
#if defined(_MSC_VER) && _MSC_VER < 1800
1318
#error MSVC does not have inttypes.h prior to Visual Studio 2013

Diff for: ‎clang/lib/Headers/stdint.h

+5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
\*===----------------------------------------------------------------------===*/
88

99
#ifndef __CLANG_STDINT_H
10+
// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T
11+
// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
12+
// case the header guard macro is defined.
13+
#if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__)
1014
#define __CLANG_STDINT_H
15+
#endif
1116

1217
/* If we're hosted, fall back to the system's stdint.h, which might have
1318
* additional definitions.

Diff for: ‎libcxx/include/inttypes.h

+5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
//===----------------------------------------------------------------------===//
99

1010
#ifndef _LIBCPP_INTTYPES_H
11+
// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
12+
// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
13+
// case the header guard macro is defined.
14+
#if !defined(_AIX) || !defined(_STD_TYPES_T)
1115
#define _LIBCPP_INTTYPES_H
16+
#endif // _STD_TYPES_T
1217

1318
/*
1419
inttypes.h synopsis

Diff for: ‎libcxx/include/stdint.h

+5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
//===----------------------------------------------------------------------===//
99

1010
#ifndef _LIBCPP_STDINT_H
11+
// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T
12+
// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
13+
// case the header guard macro is defined.
14+
#if !defined(_AIX) || !defined(_STD_TYPES_T)
1115
#define _LIBCPP_STDINT_H
16+
#endif // _STD_TYPES_T
1217

1318
/*
1419
stdint.h synopsis

Diff for: ‎libcxx/test/std/depr/depr.c.headers/stdint_h.sh.cpp

+268
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// AIX system headers need stdint.h to be re-enterable when macro _STD_TYPES_T
10+
// is defined. This test case tests that after including sys/types.h which
11+
// defines macro _STD_TYPES_T, includes stdint.h, and then undefines
12+
// _STD_TYPES_T, stdint.h can be entered to get to macros like UINT32_MAX.
13+
//
14+
// REQUIRES: aix
15+
// RUN: %compile -c
16+
// RUN: %compile -c -D_XOPEN_SOURCE=700
17+
18+
// test <stdint.h>
19+
//
20+
// Test that limits macros are available when <stdint.h> is included with
21+
// or without macro _XOPEN_SOURCE=700.
22+
23+
#include <sys/types.h>
24+
#include <stdint.h>
25+
26+
#ifndef INT8_MIN
27+
#error INT8_MIN not defined
28+
#endif
29+
30+
#ifndef INT16_MIN
31+
#error INT16_MIN not defined
32+
#endif
33+
34+
#ifndef INT32_MIN
35+
#error INT32_MIN not defined
36+
#endif
37+
38+
#ifndef INT64_MIN
39+
#error INT64_MIN not defined
40+
#endif
41+
42+
#ifndef INT8_MAX
43+
#error INT8_MAX not defined
44+
#endif
45+
46+
#ifndef INT16_MAX
47+
#error INT16_MAX not defined
48+
#endif
49+
50+
#ifndef INT32_MAX
51+
#error INT32_MAX not defined
52+
#endif
53+
54+
#ifndef INT64_MAX
55+
#error INT64_MAX not defined
56+
#endif
57+
58+
#ifndef UINT8_MAX
59+
#error UINT8_MAX not defined
60+
#endif
61+
62+
#ifndef UINT16_MAX
63+
#error UINT16_MAX not defined
64+
#endif
65+
66+
#ifndef UINT32_MAX
67+
#error UINT32_MAX not defined
68+
#endif
69+
70+
#ifndef UINT64_MAX
71+
#error UINT64_MAX not defined
72+
#endif
73+
74+
#ifndef INT_LEAST8_MIN
75+
#error INT_LEAST8_MIN not defined
76+
#endif
77+
78+
#ifndef INT_LEAST16_MIN
79+
#error INT_LEAST16_MIN not defined
80+
#endif
81+
82+
#ifndef INT_LEAST32_MIN
83+
#error INT_LEAST32_MIN not defined
84+
#endif
85+
86+
#ifndef INT_LEAST64_MIN
87+
#error INT_LEAST64_MIN not defined
88+
#endif
89+
90+
#ifndef INT_LEAST8_MAX
91+
#error INT_LEAST8_MAX not defined
92+
#endif
93+
94+
#ifndef INT_LEAST16_MAX
95+
#error INT_LEAST16_MAX not defined
96+
#endif
97+
98+
#ifndef INT_LEAST32_MAX
99+
#error INT_LEAST32_MAX not defined
100+
#endif
101+
102+
#ifndef INT_LEAST64_MAX
103+
#error INT_LEAST64_MAX not defined
104+
#endif
105+
106+
#ifndef UINT_LEAST8_MAX
107+
#error UINT_LEAST8_MAX not defined
108+
#endif
109+
110+
#ifndef UINT_LEAST16_MAX
111+
#error UINT_LEAST16_MAX not defined
112+
#endif
113+
114+
#ifndef UINT_LEAST32_MAX
115+
#error UINT_LEAST32_MAX not defined
116+
#endif
117+
118+
#ifndef UINT_LEAST64_MAX
119+
#error UINT_LEAST64_MAX not defined
120+
#endif
121+
122+
#ifndef INT_FAST8_MIN
123+
#error INT_FAST8_MIN not defined
124+
#endif
125+
126+
#ifndef INT_FAST16_MIN
127+
#error INT_FAST16_MIN not defined
128+
#endif
129+
130+
#ifndef INT_FAST32_MIN
131+
#error INT_FAST32_MIN not defined
132+
#endif
133+
134+
#ifndef INT_FAST64_MIN
135+
#error INT_FAST64_MIN not defined
136+
#endif
137+
138+
#ifndef INT_FAST8_MAX
139+
#error INT_FAST8_MAX not defined
140+
#endif
141+
142+
#ifndef INT_FAST16_MAX
143+
#error INT_FAST16_MAX not defined
144+
#endif
145+
146+
#ifndef INT_FAST32_MAX
147+
#error INT_FAST32_MAX not defined
148+
#endif
149+
150+
#ifndef INT_FAST64_MAX
151+
#error INT_FAST64_MAX not defined
152+
#endif
153+
154+
#ifndef UINT_FAST8_MAX
155+
#error UINT_FAST8_MAX not defined
156+
#endif
157+
158+
#ifndef UINT_FAST16_MAX
159+
#error UINT_FAST16_MAX not defined
160+
#endif
161+
162+
#ifndef UINT_FAST32_MAX
163+
#error UINT_FAST32_MAX not defined
164+
#endif
165+
166+
#ifndef UINT_FAST64_MAX
167+
#error UINT_FAST64_MAX not defined
168+
#endif
169+
170+
#ifndef INTPTR_MIN
171+
#error INTPTR_MIN not defined
172+
#endif
173+
174+
#ifndef INTPTR_MAX
175+
#error INTPTR_MAX not defined
176+
#endif
177+
178+
#ifndef UINTPTR_MAX
179+
#error UINTPTR_MAX not defined
180+
#endif
181+
182+
#ifndef INTMAX_MIN
183+
#error INTMAX_MIN not defined
184+
#endif
185+
186+
#ifndef INTMAX_MAX
187+
#error INTMAX_MAX not defined
188+
#endif
189+
190+
#ifndef UINTMAX_MAX
191+
#error UINTMAX_MAX not defined
192+
#endif
193+
194+
#ifndef PTRDIFF_MIN
195+
#error PTRDIFF_MIN not defined
196+
#endif
197+
198+
#ifndef PTRDIFF_MAX
199+
#error PTRDIFF_MAX not defined
200+
#endif
201+
202+
#ifndef SIG_ATOMIC_MIN
203+
#error SIG_ATOMIC_MIN not defined
204+
#endif
205+
206+
#ifndef SIG_ATOMIC_MAX
207+
#error SIG_ATOMIC_MAX not defined
208+
#endif
209+
210+
#ifndef SIZE_MAX
211+
#error SIZE_MAX not defined
212+
#endif
213+
214+
#ifndef WCHAR_MIN
215+
#error WCHAR_MIN not defined
216+
#endif
217+
218+
#ifndef WCHAR_MAX
219+
#error WCHAR_MAX not defined
220+
#endif
221+
222+
#ifndef WINT_MIN
223+
#error WINT_MIN not defined
224+
#endif
225+
226+
#ifndef WINT_MAX
227+
#error WINT_MAX not defined
228+
#endif
229+
230+
#ifndef INT8_C
231+
#error INT8_C not defined
232+
#endif
233+
234+
#ifndef INT16_C
235+
#error INT16_C not defined
236+
#endif
237+
238+
#ifndef INT32_C
239+
#error INT32_C not defined
240+
#endif
241+
242+
#ifndef INT64_C
243+
#error INT64_C not defined
244+
#endif
245+
246+
#ifndef UINT8_C
247+
#error UINT8_C not defined
248+
#endif
249+
250+
#ifndef UINT16_C
251+
#error UINT16_C not defined
252+
#endif
253+
254+
#ifndef UINT32_C
255+
#error UINT32_C not defined
256+
#endif
257+
258+
#ifndef UINT64_C
259+
#error UINT64_C not defined
260+
#endif
261+
262+
#ifndef INTMAX_C
263+
#error INTMAX_C not defined
264+
#endif
265+
266+
#ifndef UINTMAX_C
267+
#error UINTMAX_C not defined
268+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.