[libc-commits] [PATCH] D146145: [libc] Enable spawn lib in riscv
Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 16 02:18:08 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe99de31d949: [libc] Enable spawn lib in riscv (authored by Mikhail R. Gadelha <mikhail at igalia.com>).
Changed prior to commit:
https://reviews.llvm.org/D146145?vs=505536&id=505730#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146145/new/
https://reviews.llvm.org/D146145
Files:
libc/config/linux/riscv64/entrypoints.txt
libc/config/linux/riscv64/headers.txt
libc/src/spawn/linux/posix_spawn.cpp
Index: libc/src/spawn/linux/posix_spawn.cpp
===================================================================
--- libc/src/spawn/linux/posix_spawn.cpp
+++ libc/src/spawn/linux/posix_spawn.cpp
@@ -14,6 +14,7 @@
#include "src/spawn/file_actions.h"
#include <fcntl.h>
+#include <signal.h> // For SIGCHLD
#include <spawn.h>
#include <sys/syscall.h> // For syscall numbers.
@@ -50,8 +51,15 @@
void close(int fd) { __llvm_libc::syscall_impl(SYS_close, fd); }
+// We use dup3 if dup2 is not available, similar to our implementation of dup2
bool dup2(int fd, int newfd) {
+#ifdef SYS_dup2
long ret = __llvm_libc::syscall_impl(SYS_dup2, fd, newfd);
+#elif defined(SYS_dup3)
+ long ret = __llvm_libc::syscall_impl(SYS_dup3, fd, newfd, 0);
+#else
+#error "SYS_dup2 and SYS_dup3 not available for the target."
+#endif
return ret < 0 ? false : true;
}
Index: libc/config/linux/riscv64/headers.txt
===================================================================
--- libc/config/linux/riscv64/headers.txt
+++ libc/config/linux/riscv64/headers.txt
@@ -9,6 +9,7 @@
libc.include.pthread
libc.include.sched
libc.include.signal
+ libc.include.spawn
libc.include.stdio
libc.include.stdlib
libc.include.string
Index: libc/config/linux/riscv64/entrypoints.txt
===================================================================
--- libc/config/linux/riscv64/entrypoints.txt
+++ libc/config/linux/riscv64/entrypoints.txt
@@ -431,6 +431,14 @@
libc.src.signal.sigfillset
libc.src.signal.signal
+ # spawn.h entrypoints
+ libc.src.spawn.posix_spawn
+ libc.src.spawn.posix_spawn_file_actions_addclose
+ libc.src.spawn.posix_spawn_file_actions_adddup2
+ libc.src.spawn.posix_spawn_file_actions_addopen
+ libc.src.spawn.posix_spawn_file_actions_destroy
+ libc.src.spawn.posix_spawn_file_actions_init
+
# threads.h entrypoints
libc.src.threads.call_once
libc.src.threads.cnd_broadcast
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146145.505730.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230316/873655aa/attachment.bin>
More information about the libc-commits
mailing list