[libc-commits] [PATCH] D146145: [libc] Enable spawn lib in riscv
Mikhail Ramalho via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Mar 15 09:34:28 PDT 2023
mikhail.ramalho updated this revision to Diff 505536.
mikhail.ramalho added a comment.
Fixed header include
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.setjmp
libc.include.stdio
libc.include.stdlib
Index: libc/config/linux/riscv64/entrypoints.txt
===================================================================
--- libc/config/linux/riscv64/entrypoints.txt
+++ libc/config/linux/riscv64/entrypoints.txt
@@ -435,6 +435,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.505536.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230315/4c9216b6/attachment.bin>
More information about the libc-commits
mailing list