Skip to content

Commit c0a4b09

Browse files
authored
[5.7][stdlib] Fix nullability logic of memcmp (#42359)
* Fix type of `memcmp` on Windows * Improve `memcmp` extern logic
1 parent b62defb commit c0a4b09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

stdlib/public/SwiftShims/LibcShims.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ static inline __swift_size_t _swift_stdlib_strlen_unsigned(const unsigned char *
6060
SWIFT_READONLY
6161
static inline int _swift_stdlib_memcmp(const void *s1, const void *s2,
6262
__swift_size_t n) {
63-
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
64-
extern int memcmp(const void * _Nullable, const void * _Nullable, __swift_size_t);
63+
// FIXME: Is there a way to identify Glibc specifically?
64+
#if defined(__gnu_linux__)
65+
extern int memcmp(const void * _Nonnull, const void * _Nonnull, __swift_size_t);
6566
#else
66-
extern int memcmp(const void *, const void *, __swift_size_t);
67+
extern int memcmp(const void * _Null_unspecified, const void * _Null_unspecified, __swift_size_t);
6768
#endif
6869
return memcmp(s1, s2, n);
6970
}

0 commit comments

Comments
 (0)