[libc-commits] [libc] [libc] Implement getsockopt and setsockopt on linux (PR #192237)
via libc-commits
libc-commits at lists.llvm.org
Wed Apr 15 06:47:17 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h libc/src/sys/socket/getsockopt.h libc/src/sys/socket/linux/getsockopt.cpp libc/src/sys/socket/linux/setsockopt.cpp libc/src/sys/socket/setsockopt.h libc/test/src/sys/socket/linux/socketopt_test.cpp libc/include/llvm-libc-macros/linux/sys-socket-macros.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h
index 6af11e6b2..623ba58eb 100644
--- a/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h
@@ -24,16 +24,15 @@ namespace linux_syscalls {
LIBC_INLINE ErrorOr<int> getsockopt(int sockfd, int level, int optname,
void *optval, socklen_t *optlen) {
#ifdef SYS_getsockopt
- int ret = syscall_impl<int>(SYS_getsockopt, sockfd, level,
- optname, optval, optlen);
+ int ret =
+ syscall_impl<int>(SYS_getsockopt, sockfd, level, optname, optval, optlen);
#elif defined(SYS_socketcall)
unsigned long sockcall_args[5] = {static_cast<unsigned long>(sockfd),
static_cast<unsigned long>(level),
static_cast<unsigned long>(optname),
reinterpret_cast<unsigned long>(optval),
reinterpret_cast<unsigned long>(optlen)};
- int ret = syscall_impl<int>(SYS_socketcall, SYS_GETSOCKOPT,
- sockcall_args);
+ int ret = syscall_impl<int>(SYS_socketcall, SYS_GETSOCKOPT, sockcall_args);
#else
#error "getsockopt and socketcall syscalls unavailable for this platform."
#endif
diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h
index 18b2d47b1..d16c397bb 100644
--- a/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h
@@ -24,16 +24,15 @@ namespace linux_syscalls {
LIBC_INLINE ErrorOr<int> setsockopt(int sockfd, int level, int optname,
const void *optval, socklen_t optlen) {
#ifdef SYS_setsockopt
- int ret = syscall_impl<int>(SYS_setsockopt, sockfd, level,
- optname, optval, optlen);
+ int ret =
+ syscall_impl<int>(SYS_setsockopt, sockfd, level, optname, optval, optlen);
#elif defined(SYS_socketcall)
unsigned long sockcall_args[5] = {static_cast<unsigned long>(sockfd),
static_cast<unsigned long>(level),
static_cast<unsigned long>(optname),
reinterpret_cast<unsigned long>(optval),
static_cast<unsigned long>(optlen)};
- int ret = syscall_impl<int>(SYS_socketcall, SYS_SETSOCKOPT,
- sockcall_args);
+ int ret = syscall_impl<int>(SYS_socketcall, SYS_SETSOCKOPT, sockcall_args);
#else
#error "setsockopt and socketcall syscalls unavailable for this platform."
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/192237
More information about the libc-commits
mailing list