diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h index 724a3f65414bf..6a59461a41b87 100644 --- a/stdlib/public/SwiftShims/LibcShims.h +++ b/stdlib/public/SwiftShims/LibcShims.h @@ -70,7 +70,11 @@ static inline __swift_size_t _swift_stdlib_strlen_unsigned(const unsigned char * SWIFT_READONLY static inline int _swift_stdlib_memcmp(const void *s1, const void *s2, __swift_size_t n) { +#if defined(__APPLE__) + extern int memcmp(const void * _Nullable, const void * _Nullable, __swift_size_t); +#else extern int memcmp(const void *, const void *, __swift_size_t); +#endif return memcmp(s1, s2, n); } diff --git a/validation-test/ClangImporter/memcmp-definitions.swift b/validation-test/ClangImporter/memcmp-definitions.swift new file mode 100644 index 0000000000000..2d0c0df212442 --- /dev/null +++ b/validation-test/ClangImporter/memcmp-definitions.swift @@ -0,0 +1,12 @@ +/// rdar://69876253 +// REQUIRES: VENDOR=apple +// RUN: %target-build-swift %s -o %t.out + +import SwiftShims +import Foundation + +func foo () { + let a = UnsafeMutableRawPointer.allocate(byteCount: 4, alignment: 4) + let b = UnsafeMutableRawPointer.allocate(byteCount: 4, alignment: 4) + memcmp(a, b, 4) +}