mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85979 from egorzhdan/egorzhdan/android-ptrauth
[cxx-interop] Handle missing `<ptrauth.h>`
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#if __has_include(<ptrauth.h>)
|
||||||
#include <ptrauth.h>
|
#include <ptrauth.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Used for std::string conformance to Swift.Hashable
|
/// Used for std::string conformance to Swift.Hashable
|
||||||
typedef std::hash<std::string> __swift_interopHashOfString;
|
typedef std::hash<std::string> __swift_interopHashOfString;
|
||||||
@@ -68,10 +70,16 @@ struct __SwiftFunctionWrapper {
|
|||||||
__swift_interop_closure closure;
|
__swift_interop_closure closure;
|
||||||
|
|
||||||
Result operator()(Args... args) const {
|
Result operator()(Args... args) const {
|
||||||
|
#if __has_include(<ptrauth.h>)
|
||||||
return ((LoweredFunction *)ptrauth_auth_and_resign(
|
return ((LoweredFunction *)ptrauth_auth_and_resign(
|
||||||
closure.func, ptrauth_key_asia, PtrAuthTypeDiscriminator,
|
closure.func, ptrauth_key_asia, PtrAuthTypeDiscriminator,
|
||||||
ptrauth_key_function_pointer, 0))(std::forward<Args>(args)...,
|
ptrauth_key_function_pointer, 0))(std::forward<Args>(args)...,
|
||||||
closure.context);
|
closure.context);
|
||||||
|
#else
|
||||||
|
// Android NDK 28 does not define the ptrauth macros.
|
||||||
|
return ((LoweredFunction *)closure.func)(std::forward<Args>(args)...,
|
||||||
|
closure.context);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// A memberwise constructor is synthesized by Swift.
|
// A memberwise constructor is synthesized by Swift.
|
||||||
|
|||||||
Reference in New Issue
Block a user