Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/MacroModel/fast_io
Browse files Browse the repository at this point in the history
  • Loading branch information
MacroModel committed Dec 7, 2024
2 parents 258dcf1 + 827583c commit 4573181
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/fast_io_hosted/platforms/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,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 <bool always_terminate = false>
inline int my_posix_openat(int dirfd, char const *pathname, int flags, mode_t mode)
Expand Down Expand Up @@ -1378,7 +1382,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;
Expand Down
8 changes: 5 additions & 3 deletions include/fast_io_hosted/process/process/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<char *const *>(argv), const_cast<char *const *>(envp));
::fast_io::posix::libc_fexecve(fd, const_cast<char *const *>(args), const_cast<char *const *>(envp));
}
t_errno = errno;
noexcept_call(::_exit, 127);
::fast_io::posix::libc_exit(127);
#endif
__builtin_unreachable();
}
Expand Down

0 comments on commit 4573181

Please sign in to comment.