Skip to content

Commit 7912da4

Browse files
authored
Merge pull request #19277 from compnerd/msvc-shims
stdlib: adjust the shims for MSVC mode compilation
2 parents 5ace38b + d8efe22 commit 7912da4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

stdlib/public/SwiftShims/RefCount.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,11 +1406,20 @@ typedef swift::InlineRefCounts InlineRefCounts;
14061406
#endif
14071407

14081408
// These assertions apply to both the C and the C++ declarations.
1409+
#if defined(_MSC_VER) && !defined(__clang__)
1410+
static_assert(sizeof(InlineRefCounts) == sizeof(InlineRefCountsPlaceholder),
1411+
"InlineRefCounts and InlineRefCountsPlaceholder must match");
1412+
static_assert(sizeof(InlineRefCounts) == sizeof(__swift_uintptr_t),
1413+
"InlineRefCounts must be pointer-sized");
1414+
static_assert(__alignof(InlineRefCounts) == __alignof(__swift_uintptr_t),
1415+
"InlineRefCounts must be pointer-aligned");
1416+
#else
14091417
_Static_assert(sizeof(InlineRefCounts) == sizeof(InlineRefCountsPlaceholder),
14101418
"InlineRefCounts and InlineRefCountsPlaceholder must match");
14111419
_Static_assert(sizeof(InlineRefCounts) == sizeof(__swift_uintptr_t),
14121420
"InlineRefCounts must be pointer-sized");
14131421
_Static_assert(_Alignof(InlineRefCounts) == _Alignof(__swift_uintptr_t),
14141422
"InlineRefCounts must be pointer-aligned");
1423+
#endif
14151424

14161425
#endif

stdlib/public/SwiftShims/SwiftStdint.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,20 @@ typedef unsigned __INT8_TYPE__ __swift_uint8_t;
7070
#define __swift_intn_t(n) __swift_join3(__swift_int, n, _t)
7171
#define __swift_uintn_t(n) __swift_join3(__swift_uint, n, _t)
7272

73+
#if defined(_MSC_VER) && !defined(__clang__)
74+
#if defined(_WIN32)
75+
typedef __swift_int32_t __swift_intptr_t;
76+
typedef __swift_uint32_t __swift_uintptr_t;
77+
#elif defined(_WIN64)
78+
typedef __swift_int64_t __swift_intptr_t;
79+
typedef __swift_uint64_t __swift_uintptr_t;
80+
#else
81+
#error unknown windows pointer width
82+
#endif
83+
#else
7384
typedef __swift_intn_t(__INTPTR_WIDTH__) __swift_intptr_t;
7485
typedef __swift_uintn_t(__INTPTR_WIDTH__) __swift_uintptr_t;
7586
#endif
87+
#endif
7688

7789
#endif // SWIFT_STDLIB_SHIMS_SWIFT_STDINT_H

0 commit comments

Comments
 (0)