2 #if __has_feature(ptrauth_calls)
6 typedef unsigned long long uint64_t;
7 extern int printf(const char*, ...);
12 #endif /* __cplusplus */
13 __attribute__((format(printf
, 3, 4)))
14 __attribute__ ((noreturn
))
15 extern void _PASS(const char* file
, unsigned line
, const char* format
, ...);
17 __attribute__((format(printf
, 3, 4)))
18 __attribute__ ((noreturn
))
19 extern void _FAIL(const char* file
, unsigned line
, const char* format
, ...);
21 __attribute__((format(printf
, 3, 4)))
22 extern void _LOG(const char* file
, unsigned line
, const char* format
, ...);
24 extern void _TIMEOUT(const char* file
, unsigned line
, uint64_t seconds
);
27 #endif /* __cplusplus */
29 // The arm64e kernel/userland ABIs sign C function pointers differently.
30 // We aren't trying to test that ABI, so lets just force a different signature
31 #if __has_feature(ptrauth_calls)
32 # define PtrAuth __ptrauth(ptrauth_key_function_pointer, 1, 0xc671)
37 typedef struct TestRunnerFunctions
{
39 const struct mach_header
* mhs
[4];
40 const void* basePointers
[4];
41 PtrAuth
__typeof(&printf
) printf
;
42 PtrAuth
__typeof(&exit
) exit
;
43 PtrAuth
__typeof(&_PASS
) testPass
;
44 PtrAuth
__typeof(&_FAIL
) testFail
;
45 PtrAuth
__typeof(&_LOG
) testLog
;
46 PtrAuth
__typeof(&_TIMEOUT
) testTimeout
;
47 } TestRunnerFunctions
;
49 static const TestRunnerFunctions
* funcs
= 0;
51 #define PASS(...) funcs->testPass(__FILE__,__LINE__,__VA_ARGS__)
52 #define FAIL(...) funcs->testFail(__FILE__,__LINE__,__VA_ARGS__)
53 #define LOG(...) funcs->testLog(__FILE__,__LINE__,__VA_ARGS__)
54 #define TIMEOUT(seconds) funcs->testTimeout(__FILE__,__LINE__,seconds)
57 __attribute__((section(("__HIB, __text"))))
59 __attribute__((section(("__TEXT_EXEC, __text"))))
61 static inline void setFuncs(const TestRunnerFunctions
* v
) {