[libc-commits] [PATCH] D148371: [libc] Add support to compile some syscalls on 32 bit platform

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Jun 5 12:46:03 PDT 2023


michaelrj added inline comments.


================
Comment at: libc/src/sys/wait/linux/wait.cpp:26
 LLVM_LIBC_FUNCTION(pid_t, wait, (int *wait_status)) {
-  pid_t pid = __llvm_libc::syscall_impl(SYS_wait4, -1, wait_status, 0, 0);
-  if (pid < 0) {
-    // Error case, a child process was not created.
-    libc_errno = -pid;
-    return -1;
-  }
-
-  return pid;
+  return wait4(-1, wait_status, 0, 0);
 }
----------------
we generally don't allow calling public libc functions from other libc functions, so `wait4` should be moved to a shared internal function. This allows platforms to include functions without having to deal with dependency chains. You can see how this is generally done with the string to integer functions that all include `strtointeger`, though in this case it probably doesn't need to go in `__support`.


================
Comment at: libc/src/sys/wait/linux/wait4.cpp:70
   if (pid < 0) {
     libc_errno = -pid;
     return -1;
----------------
We generally try to avoid setting errno in internal functions, so if you move `wait4` to be an internal function you'll probably have to change its return type to `ErrorOr<pid_t>` and set errno after the call. This will be similar to how `fseek` works..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148371/new/

https://reviews.llvm.org/D148371



More information about the libc-commits mailing list