From 827583c109396aad660bdcae480f8bbe2a70c49b Mon Sep 17 00:00:00 2001 From: MacroModel Date: Sat, 7 Dec 2024 20:49:17 +0800 Subject: [PATCH] fix darwin --- include/fast_io_hosted/platforms/posix.h | 6 +++++- include/fast_io_hosted/process/process/posix.h | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/fast_io_hosted/platforms/posix.h b/include/fast_io_hosted/platforms/posix.h index a66c07b7..81145dbb 100644 --- a/include/fast_io_hosted/platforms/posix.h +++ b/include/fast_io_hosted/platforms/posix.h @@ -903,7 +903,11 @@ inline int my_posix_openat(int, char const *, int, mode_t) } #else +#if defined(__DARWIN_C_LEVEL) || defined(__MSDOS__) +extern int my_posix_openat_noexcept(int fd, char const *path, int aflag, ... /*mode_t mode*/) noexcept __asm__("_openat"); +#else extern int my_posix_openat_noexcept(int fd, char const *path, int aflag, ... /*mode_t mode*/) noexcept __asm__("openat"); +#endif template inline int my_posix_openat(int dirfd, char const *pathname, int flags, mode_t mode) @@ -1370,7 +1374,7 @@ class basic_posix_family_pipe #elif (defined(__MSDOS__) || defined(__DJGPP__)) if (noexcept_call(::pipe, a2) == -1) #else - if (noexcept_call(::pipe, a2) == -1 || sys_fcntl(a2[0], F_SETFD, FD_CLOEXEC) == -1 || sys_fcntl(a2[1], F_SETFD, FD_CLOEXEC) == -1) + if (noexcept_call(::pipe, a2) == -1 || ::fast_io::details::sys_fcntl(a2[0], F_SETFD, FD_CLOEXEC) == -1 || ::fast_io::details::sys_fcntl(a2[1], F_SETFD, FD_CLOEXEC) == -1) #endif throw_posix_error(); pipes->fd = *a2; diff --git a/include/fast_io_hosted/process/process/posix.h b/include/fast_io_hosted/process/process/posix.h index 428bffb3..6334192b 100644 --- a/include/fast_io_hosted/process/process/posix.h +++ b/include/fast_io_hosted/process/process/posix.h @@ -12,10 +12,12 @@ namespace posix extern int libc_faccessat(int dirfd, char const *pathname, int mode, int flags) noexcept __asm__("_faccessat"); extern int libc_fexecve(int fd, char *const *argv, char *const *envp) noexcept __asm__("_fexecve"); extern int libc_kill(pid_t pid, int sig) noexcept __asm__("_kill"); +[[noreturn]] extern void libc_exit(int exit) noexcept __asm__("_exit"); #else extern int libc_faccessat(int dirfd, char const *pathname, int mode, int flags) noexcept __asm__("faccessat"); extern int libc_fexecve(int fd, char *const *argv, char *const *envp) noexcept __asm__("fexecve"); extern int libc_kill(pid_t pid, int sig) noexcept __asm__("kill"); +[[noreturn]] extern void libc_exit(int exit) noexcept __asm__("exit"); #endif } // namespace posix @@ -378,13 +380,13 @@ inline void execveat_inside_vfork(int dirfd, char const *cstr, char const *const } ::fast_io::fast_exit(127); #else - int fd{noexcept_call(::openat, dirfd, cstr, O_RDONLY | O_NOFOLLOW, 0644)}; + int fd{::fast_io::details::my_posix_openat_noexcept(dirfd, cstr, O_RDONLY | O_NOFOLLOW, 0644)}; if (fd != -1) [[likely]] { - ::fast_io::posix::libc_fexecve(fd, const_cast(argv), const_cast(envp)); + ::fast_io::posix::libc_fexecve(fd, const_cast(args), const_cast(envp)); } t_errno = errno; - noexcept_call(::_exit, 127); + ::fast_io::posix::libc_exit(127); #endif __builtin_unreachable(); }