Skip to content

Commit ab27537

Browse files
authored
Merge pull request #85979 from egorzhdan/egorzhdan/android-ptrauth
[cxx-interop] Handle missing `<ptrauth.h>`
2 parents 22d1825 + 063b906 commit ab27537

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <functional>
33
#include <string>
44
#include <type_traits>
5+
#if __has_include(<ptrauth.h>)
56
#include <ptrauth.h>
7+
#endif
68

79
/// Used for std::string conformance to Swift.Hashable
810
typedef std::hash<std::string> __swift_interopHashOfString;
@@ -68,10 +70,16 @@ struct __SwiftFunctionWrapper {
6870
__swift_interop_closure closure;
6971

7072
Result operator()(Args... args) const {
73+
#if __has_include(<ptrauth.h>)
7174
return ((LoweredFunction *)ptrauth_auth_and_resign(
7275
closure.func, ptrauth_key_asia, PtrAuthTypeDiscriminator,
7376
ptrauth_key_function_pointer, 0))(std::forward<Args>(args)...,
7477
closure.context);
78+
#else
79+
// Android NDK 28 does not define the ptrauth macros.
80+
return ((LoweredFunction *)closure.func)(std::forward<Args>(args)...,
81+
closure.context);
82+
#endif
7583
}
7684

7785
// A memberwise constructor is synthesized by Swift.

0 commit comments

Comments
 (0)