llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-libc Author: Connector Switch (c8ef) <details> <summary>Changes</summary> This PR move prctl behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md. --- Full diff: https://github.com/llvm/llvm-project/pull/243787.diff 3 Files Affected: - (modified) libc/src/sys/prctl/linux/CMakeLists.txt (+4-2) - (modified) libc/src/sys/prctl/linux/prctl.cpp (+13-9) - (modified) utils/bazel/llvm-project-overlay/libc/src/sys/prctl/BUILD.bazel (+1-1) ``````````diff diff --git a/libc/src/sys/prctl/linux/CMakeLists.txt b/libc/src/sys/prctl/linux/CMakeLists.txt index 735d22f83e615e..016dcac0a7e11c 100644 --- a/libc/src/sys/prctl/linux/CMakeLists.txt +++ b/libc/src/sys/prctl/linux/CMakeLists.txt @@ -5,7 +5,9 @@ add_entrypoint_object( HDRS ../prctl.h DEPENDS - libc.include.sys_syscall - libc.src.__support.OSUtil.osutil + libc.src.__support.OSUtil.linux.syscall_wrappers.prctl + libc.src.__support.common + libc.src.__support.libc_errno + libc.src.__support.macros.config libc.src.errno.errno ) diff --git a/libc/src/sys/prctl/linux/prctl.cpp b/libc/src/sys/prctl/linux/prctl.cpp index b2e6765631ec75..d20b0227da82c0 100644 --- a/libc/src/sys/prctl/linux/prctl.cpp +++ b/libc/src/sys/prctl/linux/prctl.cpp @@ -1,34 +1,38 @@ -//===---------- Linux implementation of the prctl function ----------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +/// +/// \file +/// Linux implementation of prctl. +/// +//===----------------------------------------------------------------------===// #include "src/sys/prctl/prctl.h" -#include "src/__support/OSUtil/syscall.h" // For internal syscall function. +#include "src/__support/OSUtil/linux/syscall_wrappers/prctl.h" +#include "src/__support/common.h" #include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" #include <stdarg.h> -#include <sys/syscall.h> // For syscall numbers. namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(int, prctl, (int option, ...)) { va_list vargs; va_start(vargs, option); - // Try to consume (and pass to syscall_impl) the maximum possible number of + // Try to consume (and pass to the syscall) the maximum possible number of // arguments, even though for some "option" values only few will be provided. unsigned long arg2 = va_arg(vargs, unsigned long); unsigned long arg3 = va_arg(vargs, unsigned long); unsigned long arg4 = va_arg(vargs, unsigned long); unsigned long arg5 = va_arg(vargs, unsigned long); va_end(vargs); - long ret = - LIBC_NAMESPACE::syscall_impl(SYS_prctl, option, arg2, arg3, arg4, arg5); + auto result = linux_syscalls::prctl(option, arg2, arg3, arg4, arg5); // The manpage states that "... return the nonnegative values described // above. All other option values return 0 on success. On error, // -1 is returned, and errno is set to indicate the error." @@ -36,11 +40,11 @@ LLVM_LIBC_FUNCTION(int, prctl, (int option, ...)) { // (https://github.com/torvalds/linux/blob/bee0e7762ad2c6025b9f5245c040fcc36ef2bde8/kernel/sys.c#L2442), // return value from the syscall is set to 0 on default so we do not need to // set the value on success manually. - if (ret < 0) { - libc_errno = static_cast<int>(-ret); + if (!result) { + libc_errno = result.error(); return -1; } - return static_cast<int>(ret); + return static_cast<int>(result.value()); } } // namespace LIBC_NAMESPACE_DECL diff --git a/utils/bazel/llvm-project-overlay/libc/src/sys/prctl/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/src/sys/prctl/BUILD.bazel index e94c60b40da72b..790fa3f770dba0 100644 --- a/utils/bazel/llvm-project-overlay/libc/src/sys/prctl/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/src/sys/prctl/BUILD.bazel @@ -26,7 +26,7 @@ libc_function( deps = [ "//libc/src/__support:common", "//libc/src/__support:libc_errno", - "//libc/src/__support/OSUtil:syscall", + "//libc/src/__support/OSUtil/linux/syscall_wrappers:prctl", "//libc/src/__support/macros:config", "//libc/src/errno", ], `````````` </details> https://github.com/llvm/llvm-project/pull/243787 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
