Tactility/Modules/app-posix-module/source/stdio_wrap_apple.cpp
Ken Van Hoeylandt f8172446fd
App loading improvements and more (#675)
- External apps can opt into automatic cleanup when they exit, including tracked tasks, threads, files, directories, and memory.
- App-relative file paths resolve against the app’s working directory, with `.` and `..` normalized.
- The shell identifies ELF binaries that cannot be executed instead of treating them as scripts.
- Shared icon fonts now offer distinct default and large sizes, with updated icons across the interface.
- ESP32 apps can load additional ELF formats when address mirroring is enabled.
- Terminal colors render clearly on monochrome displays, and toolbar buttons have cleaner styling.
- GPS settings safely refresh their device list when their window is hidden or its widgets are destroyed.
2026-10-06 07:45:58 +02:00

62 lines
2.2 KiB
C++

// SPDX-License-Identifier: Apache-2.0
#ifdef __APPLE__
#include <app_posix/stdio_wrap.h>
#include <cstdlib>
#include <sys/ioctl.h>
#include <unistd.h>
// <mach-o/dyld-interposing.h> 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__