this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[xtrace] Convert All Source Files To CPP

* Changed all sources files from `c` to `cpp`.
* Updated header files to include `extern "C"`.
* Added a few more C-styled casts.
* Fail build if hook struct is not implemented for arch.
* Misc formatting.

Thomas A 38f24ca0 a12ec5d2

+116 -77
+6 -6
src/xtrace/CMakeLists.txt
··· 9 9 ) 10 10 11 11 set(xtrace_sources 12 - xtracelib.c 12 + xtracelib.cpp 13 13 trampoline.S 14 14 mach_trace.cpp 15 15 bsd_trace.cpp 16 - mig_trace.c 17 - tls.c 18 - malloc.c 19 - lock.c 20 - posix_spawn_args.c 16 + mig_trace.cpp 17 + tls.cpp 18 + malloc.cpp 19 + lock.cpp 20 + posix_spawn_args.cpp 21 21 ) 22 22 23 23 if (TARGET_x86_64)
+5 -4
src/xtrace/base.h
··· 6 6 #define XTRACE_INLINE static __attribute__((always_inline)) 7 7 8 8 #ifdef __cplusplus 9 - #define XTRACE_DECLARATIONS_BEGIN extern "C" { 9 + #define XTRACE_DECLARATIONS_C_BEGIN extern "C" { 10 + #define XTRACE_CPP __cplusplus 10 11 #else 11 - #define XTRACE_DECLARATIONS_BEGIN 12 + #define XTRACE_DECLARATIONS_C_BEGIN 12 13 #endif 13 14 14 15 #ifdef __cplusplus 15 - #define XTRACE_DECLARATIONS_END } 16 + #define XTRACE_DECLARATIONS_C_END } 16 17 #else 17 - #define XTRACE_DECLARATIONS_END 18 + #define XTRACE_DECLARATIONS_C_END 18 19 #endif 19 20 20 21 #endif // _XTRACE_BASE_H_
+8 -6
src/xtrace/bsd_trace.h
··· 1 - #ifdef __cplusplus 2 - extern "C" { 3 - #endif 1 + #ifndef XTRACE_BSD_TRACE 2 + #define XTRACE_BSD_TRACE 3 + 4 + #include "base.h" 5 + 6 + XTRACE_DECLARATIONS_C_BEGIN 4 7 5 8 extern void xtrace_print_string_literal(const char* str); 6 9 7 - #ifdef __cplusplus 8 - } 9 - #endif 10 + XTRACE_DECLARATIONS_C_END 10 11 12 + #endif // XTRACE_BSD_TRACE
+11
src/xtrace/include/xtrace/xtrace-mig-types.h
··· 1 + #ifndef XTRACE_XTRACE_MIG_TYPES 2 + #define XTRACE_XTRACE_MIG_TYPES 3 + 1 4 #include <mach/message.h> 5 + 6 + #include "../base.h" 7 + 8 + XTRACE_DECLARATIONS_C_BEGIN 2 9 3 10 struct xtrace_mig_callbacks { 4 11 void (*add_raw_arg)(const char *format, ...) __attribute__((format(printf, 1, 2))); ··· 35 42 unsigned long routine_cnt; 36 43 const struct xtrace_mig_routine_desc *routines; 37 44 }; 45 + 46 + XTRACE_DECLARATIONS_C_END 47 + 48 + #endif // XTRACE_XTRACE_MIG_TYPES
+7 -4
src/xtrace/lock.c src/xtrace/lock.cpp
··· 49 49 return expected; 50 50 }; 51 51 52 + extern "C" 52 53 void xtrace_lock_lock(xtrace_lock_t* _lock) { 53 54 xtrace_lock_internal_t* lock = (xtrace_lock_internal_t*)_lock; 54 55 ··· 70 71 xtrace_lock_debug("going to wait"); 71 72 // do the actual sleeping 72 73 // we expect `xtrace_lock_state_locked_contended` because we don't want to sleep if it's not contended 73 - __linux_futex_reterr(&lock->state, FUTEX_WAIT, xtrace_lock_state_locked_contended, NULL, 0, 0); 74 + __linux_futex_reterr((int*)&lock->state, FUTEX_WAIT, xtrace_lock_state_locked_contended, nullptr, 0, 0); 74 75 xtrace_lock_debug("awoken"); 75 76 } 76 77 ··· 83 84 xtrace_lock_debug("lock acquired"); 84 85 }; 85 86 87 + extern "C" 86 88 void xtrace_lock_unlock(xtrace_lock_t* _lock) { 87 89 xtrace_lock_internal_t* lock = (xtrace_lock_internal_t*)_lock; 88 90 ··· 95 97 // if it was previously contended, then we need to wake someone up 96 98 if (prev == xtrace_lock_state_locked_contended) { 97 99 xtrace_lock_debug("waking someone up"); 98 - __linux_futex_reterr(&lock->state, FUTEX_WAKE, 1, NULL, 0, 0); 100 + __linux_futex_reterr((int*)&lock->state, FUTEX_WAKE, 1, NULL, 0, 0); 99 101 } 100 102 }; 101 103 ··· 123 125 xtrace_once_state_completed = 3, 124 126 }; 125 127 128 + extern "C" 126 129 void xtrace_once(xtrace_once_t* _once, xtrace_once_callback callback) { 127 130 xtrace_once_internal_t* once = (xtrace_once_internal_t*)_once; 128 131 ··· 152 155 case xtrace_once_state_triggered_contended: { 153 156 xtrace_once_debug("waking up all waiters..."); 154 157 // otherwise, we have to wake someone up 155 - __linux_futex_reterr(&once->state, FUTEX_WAKE, INT_MAX, NULL, 0, 0); 158 + __linux_futex_reterr((int*)&once->state, FUTEX_WAKE, INT_MAX, NULL, 0, 0); 156 159 } break; 157 160 } 158 161 ··· 184 187 // somebody is already performing the callback and there are already waiters; 185 188 // let's wait 186 189 xtrace_once_debug("someone is already performing the callback with waiters; going to wait..."); 187 - __linux_futex_reterr(&once->state, FUTEX_WAIT, prev, NULL, 0, 0); 190 + __linux_futex_reterr((int*)&once->state, FUTEX_WAIT, prev, NULL, 0, 0); 188 191 189 192 xtrace_once_debug("woken up"); 190 193
+2 -2
src/xtrace/lock.h
··· 9 9 // we also have to implement our own locks, because we can't rely on libplatform's or libpthread's locks 10 10 // so we implement our own on top of Linux futexes 11 11 12 - XTRACE_DECLARATIONS_BEGIN; 12 + XTRACE_DECLARATIONS_C_BEGIN 13 13 14 14 // 15 15 // lock ··· 48 48 49 49 void xtrace_once(xtrace_once_t* once, xtrace_once_callback callback); 50 50 51 - XTRACE_DECLARATIONS_END; 51 + XTRACE_DECLARATIONS_C_END 52 52 53 53 #endif // _XTRACE_LOCK_H_
+8 -6
src/xtrace/mach_trace.h
··· 1 - #ifdef __cplusplus 2 - extern "C" { 3 - #endif 1 + #ifndef XTRACE_MACH_TRACE 2 + #define XTRACE_MACH_TRACE 3 + 4 + #include "base.h" 5 + 6 + XTRACE_DECLARATIONS_C_BEGIN 4 7 5 8 const char* xtrace_msg_type_to_str(mach_msg_type_name_t type_name, int full); 6 9 void xtrace_print_kern_return(kern_return_t kr); 7 10 8 - #ifdef __cplusplus 9 - } 10 - #endif 11 + XTRACE_DECLARATIONS_C_END 11 12 13 + #endif // XTRACE_MACH_TRACE
+6 -3
src/xtrace/malloc.c src/xtrace/malloc.cpp
··· 186 186 if (viable_fragment == NULL) { 187 187 // ...allocate some memory 188 188 size_t allocation_size = round_up(required_size, BLOCK_SIZE_MULTIPLE); 189 - xtrace_memory_block_t block = _mmap_for_xtrace(NULL, allocation_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); 189 + xtrace_memory_block_t block = (xtrace_memory_block_t)_mmap_for_xtrace(NULL, allocation_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); 190 190 191 191 xtrace_malloc_debug("mmap for %llu bytes returned %p", allocation_size, block); 192 192 ··· 414 414 // api functions 415 415 // 416 416 417 + extern "C" 417 418 void* xtrace_malloc(size_t size) { 418 419 if (size == 0) { 419 420 return NULL; ··· 425 426 return fragment->memory; 426 427 }; 427 428 429 + extern "C" 428 430 void xtrace_free(void* pointer) { 429 431 if (pointer == NULL) { 430 432 return; 431 433 } 432 - xtrace_memory_fragment_t fragment = __container_of(pointer, struct xtrace_memory_fragment, memory); 434 + xtrace_memory_fragment_t fragment = __container_of((const char (*)[])pointer, struct xtrace_memory_fragment, memory); 433 435 release_fragment(fragment); 434 436 }; 435 437 438 + extern "C" 436 439 void* xtrace_realloc(void* old_pointer, size_t new_size) { 437 - xtrace_memory_fragment_t fragment = __container_of(old_pointer, struct xtrace_memory_fragment, memory); 440 + xtrace_memory_fragment_t fragment = __container_of((const char (*)[])old_pointer, struct xtrace_memory_fragment, memory); 438 441 size_t old_size = xtrace_memory_fragment_size(fragment); 439 442 440 443 xtrace_lock_lock(&free_lock);
+2 -2
src/xtrace/malloc.h
··· 4 4 #include <stddef.h> 5 5 #include "base.h" 6 6 7 - XTRACE_DECLARATIONS_BEGIN; 7 + XTRACE_DECLARATIONS_C_BEGIN 8 8 9 9 void* xtrace_malloc(size_t size); 10 10 void xtrace_free(void* pointer); 11 11 void* xtrace_realloc(void* old_pointer, size_t new_size); 12 12 13 - XTRACE_DECLARATIONS_END; 13 + XTRACE_DECLARATIONS_C_END 14 14 15 15 #endif // _XTRACE_MALLOC_H_
+3 -1
src/xtrace/mig_trace.c src/xtrace/mig_trace.cpp
··· 22 22 23 23 static mach_port_name_t host_port; 24 24 25 + extern "C" 25 26 void xtrace_setup_mig_tracing(void) 26 27 { 27 28 // This runs before the syscall tracing is enabled, so we can ··· 37 38 } 38 39 // Count the number of files, and allocate this many subsystem pointers; 39 40 for (struct dirent* dirent; (dirent = readdir(xtrace_mig_dir)) != NULL; subsystems_cnt++); 40 - subsystems = malloc(subsystems_cnt * sizeof(struct xtrace_mig_subsystem*)); 41 + subsystems = (xtrace_mig_subsystem**)malloc(subsystems_cnt * sizeof(struct xtrace_mig_subsystem*)); 41 42 42 43 rewinddir(xtrace_mig_dir); 43 44 for (size_t i = 0; i < subsystems_cnt; i++) ··· 322 323 return 0; 323 324 } 324 325 326 + extern "C" 325 327 void xtrace_print_mig_message(const mach_msg_header_t* message, mach_port_name_t request_port) 326 328 { 327 329 if (message == NULL)
+8 -6
src/xtrace/mig_trace.h
··· 1 + #ifndef XTRACE_MIG_TRACE 2 + #define XTRACE_MIG_TRACE 3 + 1 4 #include <mach/message.h> 5 + #include "base.h" 2 6 3 - #ifdef __cplusplus 4 - extern "C" { 5 - #endif 7 + XTRACE_DECLARATIONS_C_BEGIN 6 8 7 9 void xtrace_setup_mig_tracing(void); 8 10 void xtrace_print_mig_message(const mach_msg_header_t* message, mach_port_name_t request_port); 9 11 10 - #ifdef __cplusplus 11 - } 12 - #endif 12 + XTRACE_DECLARATIONS_C_END 13 + 14 + #endif // XTRACE_MIG_TRACE
+2 -1
src/xtrace/posix_spawn_args.c src/xtrace/posix_spawn_args.cpp
··· 12 12 13 13 #include "xtracelib.h" 14 14 15 - extern void print_open_flags(void* arg); 15 + extern "C" void print_open_flags(void* arg); 16 16 17 17 static struct { 18 18 unsigned short flag; ··· 35 35 #undef POSIX_SPAWN_ATTR_ENTRY 36 36 }; 37 37 38 + extern "C" 38 39 void print_arg_posix_spawn_args(void* arg) { 39 40 const struct _posix_spawn_args_desc* args = (const struct _posix_spawn_args_desc*)(arg); 40 41 bool is_first = true;
+6 -4
src/xtrace/tls.c src/xtrace/tls.cpp
··· 34 34 35 35 // TODO: also perform TLS cleanup for other threads when doing a fork 36 36 37 + extern "C" 37 38 void xtrace_tls_thread_cleanup(void) { 38 - tls_table_t table = _pthread_getspecific_direct(__PTK_XTRACE_TLS); 39 + tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_XTRACE_TLS); 39 40 if (!table) { 40 41 xtrace_tls_debug("no table to cleanup for this thread"); 41 42 return; ··· 53 54 xtrace_free(table); 54 55 }; 55 56 57 + extern "C" 56 58 void* xtrace_tls(void* key, size_t size, bool* created, xtrace_tls_destructor_f destructor) { 57 59 xtrace_tls_debug("looking up tls variable for key %p", key); 58 60 59 - tls_table_t table = _pthread_getspecific_direct(__PTK_XTRACE_TLS); 61 + tls_table_t table = (tls_table_t)_pthread_getspecific_direct(__PTK_XTRACE_TLS); 60 62 61 63 xtrace_tls_debug("got %p as table pointer from pthread", table); 62 64 63 65 // if the table doesn't exist yet, create it 64 66 if (table == NULL) { 65 67 xtrace_tls_debug("table is NULL, creating now..."); 66 - table = xtrace_malloc(sizeof(struct tls_table)); 68 + table = (tls_table_t)xtrace_malloc(sizeof(struct tls_table)); 67 69 if (table == NULL) { 68 70 xtrace_abort("xtrace: failed TLS table memory allocation"); 69 71 } ··· 90 92 } 91 93 table->table[index][0] = key; 92 94 table->table[index][1] = xtrace_malloc(size); 93 - table->table[index][2] = destructor; 95 + table->table[index][2] = (void*)destructor; 94 96 if (table->table[index][1] == NULL) { 95 97 xtrace_abort("xtrace: failed TLS variable memory allocation"); 96 98 }
+2 -2
src/xtrace/tls.h
··· 6 6 #include <mach/port.h> 7 7 #include "base.h" 8 8 9 - XTRACE_DECLARATIONS_BEGIN; 9 + XTRACE_DECLARATIONS_C_BEGIN 10 10 11 11 typedef void (*xtrace_tls_destructor_f)(void* value); 12 12 ··· 47 47 void* xtrace_tls(void* key, size_t size, bool* created, xtrace_tls_destructor_f destructor); 48 48 void xtrace_tls_thread_cleanup(void); 49 49 50 - XTRACE_DECLARATIONS_END; 50 + XTRACE_DECLARATIONS_C_END 51 51 52 52 #endif // _XTRACE_TLS_H_
+36 -24
src/xtrace/xtracelib.c src/xtrace/xtracelib.cpp
··· 17 17 #include <signal.h> 18 18 19 19 // Defined in assembly 20 - extern void darling_mach_syscall_entry_trampoline(void); 21 - extern void darling_mach_syscall_exit_trampoline(void); 22 - extern void darling_bsd_syscall_entry_trampoline(void); 23 - extern void darling_bsd_syscall_exit_trampoline(void); 24 - extern int sys_thread_selfid(void); 20 + extern "C" void darling_mach_syscall_entry_trampoline(void); 21 + extern "C" void darling_mach_syscall_exit_trampoline(void); 22 + extern "C" void darling_bsd_syscall_entry_trampoline(void); 23 + extern "C" void darling_bsd_syscall_exit_trampoline(void); 24 + extern "C" int sys_thread_selfid(void); 25 25 26 26 static void xtrace_thread_exit_hook(void); 27 27 static void xtrace_execve_inject_hook(const char*** envp_ptr); 28 28 static void xtrace_postfork_child_hook(void); 29 29 30 30 #ifdef __x86_64__ 31 - struct hook 32 - { 31 + struct hook { 33 32 uint8_t movabs[2]; 34 33 uint64_t addr; 35 34 uint8_t call[3]; 36 - } 37 - __attribute__((packed)); 35 + } __attribute__((packed)); 38 36 #elif defined(__i386__) 39 37 struct hook { 40 38 uint8_t mov; 41 39 uint32_t addr; 42 40 uint8_t call[2]; 43 41 } __attribute__((packed)); 42 + #else 43 + #error "Missing hook struct for arch" 44 44 #endif 45 45 46 46 // Defined in libsystem_kernel ··· 49 49 extern struct hook* _darling_bsd_syscall_entry; 50 50 extern struct hook* _darling_bsd_syscall_exit; 51 51 52 - extern void _xtrace_thread_exit(void); 53 - extern void _xtrace_execve_inject(const char*** envp_ptr); 54 - extern void _xtrace_postfork_child(void); 52 + extern "C" void _xtrace_thread_exit(void); 53 + extern "C" void _xtrace_execve_inject(const char*** envp_ptr); 54 + extern "C" void _xtrace_postfork_child(void); 55 55 56 56 static void xtrace_setup_mach(void); 57 57 static void xtrace_setup_bsd(void); ··· 66 66 #define SIGALTSTACK_GUARD 1 67 67 68 68 __attribute__((constructor)) 69 + extern "C" 69 70 void xtrace_setup() 70 71 { 71 72 xtrace_setup_options(); ··· 168 169 hook->addr = (uintptr_t)fnptr; 169 170 hook->call[0] = 0xff; 170 171 hook->call[1] = jump ? 0xe1 : 0xd1; 172 + #else 173 + #error "Missing hook implementation for arch 171 174 #endif 172 175 } 173 176 ··· 184 187 185 188 mprotect((void*) area, bytes, PROT_READ | PROT_WRITE | PROT_EXEC); 186 189 187 - setup_hook(_darling_mach_syscall_entry, darling_mach_syscall_entry_trampoline, false); 188 - setup_hook(_darling_mach_syscall_exit, darling_mach_syscall_exit_trampoline, false); 190 + setup_hook(_darling_mach_syscall_entry, (void*)darling_mach_syscall_entry_trampoline, false); 191 + setup_hook(_darling_mach_syscall_exit, (void*)darling_mach_syscall_exit_trampoline, false); 189 192 190 193 mprotect((void*) area, bytes, PROT_READ | PROT_EXEC); 191 194 } ··· 203 206 204 207 mprotect((void*) area, bytes, PROT_READ | PROT_WRITE | PROT_EXEC); 205 208 206 - setup_hook(_darling_bsd_syscall_entry, darling_bsd_syscall_entry_trampoline, false); 207 - setup_hook(_darling_bsd_syscall_exit, darling_bsd_syscall_exit_trampoline, false); 209 + setup_hook(_darling_bsd_syscall_entry, (void*)darling_bsd_syscall_entry_trampoline, false); 210 + setup_hook(_darling_bsd_syscall_exit, (void*)darling_bsd_syscall_exit_trampoline, false); 208 211 209 212 mprotect((void*) area, bytes, PROT_READ | PROT_EXEC); 210 213 } ··· 228 231 }; 229 232 230 233 static void xtrace_setup_misc_hooks(void) { 231 - setup_hook_with_perms((void*)&_xtrace_thread_exit, xtrace_thread_exit_hook, true); 232 - setup_hook_with_perms((void*)&_xtrace_execve_inject, xtrace_execve_inject_hook, true); 233 - setup_hook_with_perms((void*)&_xtrace_postfork_child, xtrace_postfork_child_hook, true); 234 + setup_hook_with_perms((hook*)&_xtrace_thread_exit, (void*)xtrace_thread_exit_hook, true); 235 + setup_hook_with_perms((hook*)&_xtrace_execve_inject, (void*)xtrace_execve_inject_hook, true); 236 + setup_hook_with_perms((hook*)&_xtrace_postfork_child, (void*)xtrace_postfork_child_hook, true); 234 237 }; 235 238 239 + extern "C" 236 240 void xtrace_set_gray_color(void) 237 241 { 238 242 if (xtrace_no_color) ··· 241 245 xtrace_log("\033[37m"); 242 246 } 243 247 248 + extern "C" 244 249 void xtrace_reset_color(void) 245 250 { 246 251 if (xtrace_no_color) ··· 249 254 xtrace_log("\033[0m"); 250 255 } 251 256 257 + extern "C" 252 258 void xtrace_start_line(int indent) 253 259 { 254 260 xtrace_set_gray_color(); ··· 289 295 290 296 DEFINE_XTRACE_TLS_VAR(struct nested_call_struct, nested_call, (struct nested_call_struct) {0}, NULL); 291 297 298 + extern "C" 292 299 void handle_generic_entry(const struct calldef* defs, const char* type, int nr, void* args[]) 293 300 { 294 301 if (xtrace_ignore) ··· 320 327 get_ptr_nested_call()->previous_level = get_ptr_nested_call()->current_level++; 321 328 } 322 329 323 - 330 + extern "C" 324 331 void handle_generic_exit(const struct calldef* defs, const char* type, uintptr_t retval, int force_split) 325 332 { 326 333 if (xtrace_ignore) ··· 354 361 xtrace_log("0x%lx\n", retval); 355 362 } 356 363 364 + extern "C" 357 365 void xtrace_log(const char* format, ...) { 358 366 va_list args; 359 367 va_start(args, format); ··· 402 410 set_xtrace_per_thread_logfile(fd); 403 411 }; 404 412 413 + extern "C" 405 414 void xtrace_log_v(const char* format, va_list args) { 406 415 if (xtrace_kprintf) { 407 416 char real_format[512] = "xtrace: "; ··· 417 426 } 418 427 }; 419 428 429 + extern "C" 420 430 void xtrace_error(const char* format, ...) { 421 431 va_list args; 422 432 va_start(args, format); ··· 424 434 va_end(args); 425 435 }; 426 436 437 + extern "C" 427 438 void xtrace_error_v(const char* format, va_list args) { 428 439 if (xtrace_kprintf) { 429 440 char real_format[512] = "xtrace: "; ··· 439 450 } 440 451 }; 441 452 453 + extern "C" 442 454 void xtrace_abort(const char* message) { 443 455 _abort_with_payload_for_xtrace(0, 0, NULL, 0, message, 0); 444 456 __builtin_unreachable(); ··· 481 493 static const char* envp_make_entry(const char* key, const char* value) { 482 494 size_t key_length = strlen(key); 483 495 size_t value_length = strlen(value); 484 - char* entry = xtrace_malloc(key_length + value_length + 2); 496 + char* entry = (char*)xtrace_malloc(key_length + value_length + 2); 485 497 memcpy(entry, key, key_length); 486 498 entry[key_length] = '='; 487 499 memcpy(&entry[key_length + 1], value, value_length); ··· 493 505 const char** envp = *envp_ptr; 494 506 495 507 if (!envp) { 496 - *envp_ptr = envp = xtrace_malloc(sizeof(const char*) * 2); 508 + *envp_ptr = envp = (const char**)xtrace_malloc(sizeof(const char*) * 2); 497 509 envp[0] = envp_make_entry(key, value); 498 510 envp[1] = NULL; 499 511 *allocated = true; ··· 504 516 *entry_ptr = envp_make_entry(key, value); 505 517 } else { 506 518 size_t count = envp_count(envp); 507 - const char** new_envp = xtrace_malloc(sizeof(const char*) * (count + 2)); 519 + const char** new_envp = (const char**)xtrace_malloc(sizeof(const char*) * (count + 2)); 508 520 509 521 memcpy(new_envp, envp, sizeof(const char*) * count); 510 522 ··· 544 556 545 557 const char* insert_libraries = envp_get(*envp_ptr, "DYLD_INSERT_LIBRARIES"); 546 558 size_t insert_libraries_length = insert_libraries ? strlen(insert_libraries) : 0; 547 - char* new_value = xtrace_malloc(insert_libraries_length + (insert_libraries_length == 0 ? 0 : 1) + LIBRARY_PATH_LENGTH + 1); 559 + char* new_value = (char*)xtrace_malloc(insert_libraries_length + (insert_libraries_length == 0 ? 0 : 1) + LIBRARY_PATH_LENGTH + 1); 548 560 size_t offset = 0; 549 561 550 562 if (insert_libraries && insert_libraries_length > 0) {
+4 -6
src/xtrace/xtracelib.h
··· 3 3 #include <stdint.h> 4 4 #include <darling/emulation/simple.h> 5 5 6 + #include "base.h" 7 + 6 8 struct calldef 7 9 { 8 10 const char* name; ··· 10 12 void (*print_retval)(int nr, uintptr_t rv); 11 13 }; 12 14 13 - #ifdef __cplusplus 14 - extern "C" { 15 - #endif 15 + XTRACE_DECLARATIONS_C_BEGIN 16 16 17 17 void handle_generic_entry(const struct calldef* defs, const char* type, int nr, void* args[]); 18 18 void handle_generic_exit(const struct calldef* defs, const char* type, uintptr_t retval, int force_split); ··· 30 30 31 31 void xtrace_abort(const char* message) __attribute__((noreturn)); 32 32 33 - #ifdef __cplusplus 34 - } 35 - #endif 33 + XTRACE_DECLARATIONS_C_END 36 34 37 35 #endif 38 36