[libc-commits] [libc] Use execve syscall wrapper in execv.cpp (PR #223181)

Bhavesh M via libc-commits libc-commits at lists.llvm.org
Sat Sep 12 14:50:03 PDT 2026


https://github.com/beamandala created https://github.com/llvm/llvm-project/pull/223181

None

>From 03e5b468b5822ccce088cc5c30b57b66462d3e9a Mon Sep 17 00:00:00 2001
From: Bhavesh Mandalapu <mandalapubhavesh at gmail.com>
Date: Sat, 12 Sep 2026 16:48:56 -0500
Subject: [PATCH] Use execve syscall wrapper in execv.cpp

---
 libc/src/unistd/linux/CMakeLists.txt |  6 ++++--
 libc/src/unistd/linux/execv.cpp      | 13 ++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt
index 4ea7c8a2078d8..27bd9c26ee88b 100644
--- a/libc/src/unistd/linux/CMakeLists.txt
+++ b/libc/src/unistd/linux/CMakeLists.txt
@@ -213,8 +213,10 @@ add_entrypoint_object(
   HDRS
     ../execv.h
   DEPENDS
-    libc.include.sys_syscall
-    libc.src.__support.OSUtil.osutil
+    libc.src.__support.common
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.config
+    libc.src.__support.OSUtil.linux.syscall_wrappers.execve
     libc.src.errno.errno
     libc.src.unistd.environ
 )
diff --git a/libc/src/unistd/linux/execv.cpp b/libc/src/unistd/linux/execv.cpp
index d4f2bd9a51653..496bf81f750ed 100644
--- a/libc/src/unistd/linux/execv.cpp
+++ b/libc/src/unistd/linux/execv.cpp
@@ -10,25 +10,24 @@
 #include "src/__support/macros/config.h"
 #include "src/unistd/environ.h"
 
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/OSUtil/linux/syscall_wrappers/execve.h"
 #include "src/__support/common.h"
 
 #include "src/__support/libc_errno.h"
-#include <sys/syscall.h> // For syscall numbers.
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, execv, (const char *path, char *const argv[])) {
-  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_execve, path, argv,
-                                              LIBC_NAMESPACE::environ);
-  if (ret < 0) {
-    libc_errno = -ret;
+  auto ret = linux_syscalls::execve(
+      path, argv, const_cast<char *const *>(LIBC_NAMESPACE::environ));
+  if (!ret) {
+    libc_errno = ret.error();
     return -1;
   }
 
   // Control will not reach here on success but have a return statement will
   // keep the compilers happy.
-  return ret;
+  return *ret;
 }
 
 } // namespace LIBC_NAMESPACE_DECL



More information about the libc-commits mailing list