Skip to content

Commit 387ecad

Browse files
committed
Cleanup redundant #ifdefs working around libc's stdint.h implementation pulling in Darwin
1 parent 3a96ded commit 387ecad

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

stdlib/public/SwiftShims/SwiftStddef.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
#ifndef SWIFT_STDLIB_SHIMS_SWIFT_STDDEF_H
1414
#define SWIFT_STDLIB_SHIMS_SWIFT_STDDEF_H
1515

16+
// stddef.h is provided by Clang, but it dispatches to libc's stddef.h. As a
17+
// result, using stddef.h here would pull in Darwin module (which includes
18+
// libc). This creates a dependency cycle, so we can't use stddef.h in
19+
// SwiftShims.
20+
#if !defined(__APPLE__)
21+
#include <stddef.h>
22+
typedef size_t __swift_size_t;
23+
#else
1624
typedef __SIZE_TYPE__ __swift_size_t;
25+
#endif
1726

1827
#endif // SWIFT_STDLIB_SHIMS_SWIFT_STDDEF_H
19-

stdlib/public/SwiftShims/SwiftStdint.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@
2020

2121
// Clang has been defining __INTxx_TYPE__ macros for a long time.
2222
// __UINTxx_TYPE__ are defined only since Clang 3.5.
23-
23+
#if !defined(__APPLE__)
24+
#include <stdint.h>
25+
typedef int64_t __swift_int64_t;
26+
typedef uint64_t __swift_uint64_t;
27+
typedef int32_t __swift_int32_t;
28+
typedef uint32_t __swift_uint32_t;
29+
typedef int16_t __swift_int16_t;
30+
typedef uint16_t __swift_uint16_t;
31+
typedef int8_t __swift_int8_t;
32+
typedef uint8_t __swift_uint8_t;
33+
typedef intptr_t __swift_intptr_t;
34+
typedef uintptr_t __swift_uintptr_t;
35+
#else
2436
typedef __INT64_TYPE__ __swift_int64_t;
2537
#ifdef __UINT64_TYPE__
2638
typedef __UINT64_TYPE__ __swift_uint64_t;
@@ -56,6 +68,6 @@ typedef unsigned __INT8_TYPE__ __swift_uint8_t;
5668

5769
typedef __swift_intn_t(__INTPTR_WIDTH__) __swift_intptr_t;
5870
typedef __swift_uintn_t(__INTPTR_WIDTH__) __swift_uintptr_t;
71+
#endif
5972

6073
#endif // SWIFT_STDLIB_SHIMS_SWIFT_STDINT_H
61-

0 commit comments

Comments
 (0)