// SPDX-License-Identifier: Apache-2.0 #ifdef __APPLE__ #include #include #include #include // isn't a public SDK header, so reimplemented locally. #define TT_DYLD_INTERPOSE(replacement, replacee) \ __attribute__((used)) static struct { const void* replacement; const void* replacee; } \ tt_interpose_##replacee __attribute__((section("__DATA,__interpose"))) = { \ (const void*)(unsigned long)&(replacement), (const void*)(unsigned long)&(replacee) \ }; TT_DYLD_INTERPOSE(__wrap_read, read) TT_DYLD_INTERPOSE(__wrap_write, write) TT_DYLD_INTERPOSE(__wrap_ioctl, ioctl) TT_DYLD_INTERPOSE(__wrap_close, close) TT_DYLD_INTERPOSE(__wrap_getcwd, getcwd) TT_DYLD_INTERPOSE(__wrap_chdir, chdir) TT_DYLD_INTERPOSE(__wrap_fstat, fstat) TT_DYLD_INTERPOSE(__wrap_poll, poll) TT_DYLD_INTERPOSE(__wrap_tcgetattr, tcgetattr) TT_DYLD_INTERPOSE(__wrap_tcsetattr, tcsetattr) TT_DYLD_INTERPOSE(__wrap_exit, exit) TT_DYLD_INTERPOSE(__wrap_signal, signal) TT_DYLD_INTERPOSE(__wrap_kill, kill) TT_DYLD_INTERPOSE(__wrap_getpid, getpid) TT_DYLD_INTERPOSE(__wrap_getppid, getppid) TT_DYLD_INTERPOSE(__wrap_usleep, usleep) TT_DYLD_INTERPOSE(__wrap_sleep, sleep) TT_DYLD_INTERPOSE(__wrap_open, open) TT_DYLD_INTERPOSE(__wrap_fopen, fopen) TT_DYLD_INTERPOSE(__wrap_stat, stat) TT_DYLD_INTERPOSE(__wrap_lstat, lstat) TT_DYLD_INTERPOSE(__wrap_access, access) TT_DYLD_INTERPOSE(__wrap_unlink, unlink) TT_DYLD_INTERPOSE(__wrap_remove, remove) TT_DYLD_INTERPOSE(__wrap_rename, rename) TT_DYLD_INTERPOSE(__wrap_mkdir, mkdir) TT_DYLD_INTERPOSE(__wrap_rmdir, rmdir) TT_DYLD_INTERPOSE(__wrap_opendir, opendir) TT_DYLD_INTERPOSE(__wrap_truncate, truncate) TT_DYLD_INTERPOSE(__wrap_vprintf, vprintf) TT_DYLD_INTERPOSE(__wrap_printf, printf) TT_DYLD_INTERPOSE(__wrap_vfprintf, vfprintf) TT_DYLD_INTERPOSE(__wrap_fprintf, fprintf) TT_DYLD_INTERPOSE(__wrap_puts, puts) TT_DYLD_INTERPOSE(__wrap_fputs, fputs) TT_DYLD_INTERPOSE(__wrap_putchar, putchar) TT_DYLD_INTERPOSE(__wrap_fputc, fputc) TT_DYLD_INTERPOSE(__wrap_fwrite, fwrite) TT_DYLD_INTERPOSE(__wrap_getchar, getchar) TT_DYLD_INTERPOSE(__wrap_fgetc, fgetc) TT_DYLD_INTERPOSE(__wrap_fgets, fgets) #endif // __APPLE__