diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/accept.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/accept.h index e661f4df1daab..b25f0fac1f071 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/accept.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/accept.h @@ -16,7 +16,6 @@ #include "hdr/types/socklen_t.h" #include "hdr/types/struct_sockaddr.h" -#include // For SYS_ACCEPT socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { @@ -24,17 +23,12 @@ namespace linux_syscalls { LIBC_INLINE ErrorOr accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) { -#ifdef SYS_accept - int ret = - LIBC_NAMESPACE::syscall_impl(SYS_accept, sockfd, addr, addrlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(sockfd), - reinterpret_cast(addr), - reinterpret_cast(addrlen)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_ACCEPT, - sockcall_args); +#if defined(SYS_accept) + int ret = syscall_impl(SYS_accept, sockfd, addr, addrlen); +#elif defined(SYS_accept4) + int ret = syscall_impl(SYS_accept4, sockfd, addr, addrlen, 0); #else -#error "accept and socketcall syscalls unavailable for this platform." +#error "accept and accept4 syscalls unavailable for this platform." #endif if (ret < 0) diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/accept4.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/accept4.h index ebe82f189af50..69c316fb72766 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/accept4.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/accept4.h @@ -16,7 +16,6 @@ #include "hdr/types/socklen_t.h" #include "hdr/types/struct_sockaddr.h" -#include // For SYS_ACCEPT4 socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { @@ -24,20 +23,7 @@ namespace linux_syscalls { LIBC_INLINE ErrorOr accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) { -#ifdef SYS_accept4 - int ret = LIBC_NAMESPACE::syscall_impl(SYS_accept4, sockfd, addr, - addrlen, flags); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[4] = {static_cast(sockfd), - reinterpret_cast(addr), - reinterpret_cast(addrlen), - static_cast(flags)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_ACCEPT4, - sockcall_args); -#else -#error "accept4 and socketcall syscalls unavailable for this platform." -#endif - + int ret = syscall_impl(SYS_accept4, sockfd, addr, addrlen, flags); if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/connect.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/connect.h index 6974546630b00..9ddc4674e4d9f 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/connect.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/connect.h @@ -16,7 +16,6 @@ #include "hdr/types/socklen_t.h" #include "hdr/types/struct_sockaddr.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { @@ -24,19 +23,7 @@ namespace linux_syscalls { LIBC_INLINE ErrorOr connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { -#ifdef SYS_connect - int ret = - LIBC_NAMESPACE::syscall_impl(SYS_connect, sockfd, addr, addrlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(sockfd), - reinterpret_cast(addr), - static_cast(addrlen)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_CONNECT, - sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif - + int ret = syscall_impl(SYS_connect, sockfd, addr, addrlen); if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h index 623ba58ebb2ed..9a0c0570ad2b7 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/getsockopt.h @@ -15,7 +15,6 @@ #include "src/__support/macros/config.h" #include "hdr/types/socklen_t.h" -#include // For SYS_GETSOCKOPT socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { @@ -23,20 +22,8 @@ namespace linux_syscalls { LIBC_INLINE ErrorOr getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen) { -#ifdef SYS_getsockopt int ret = syscall_impl(SYS_getsockopt, sockfd, level, optname, optval, optlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[5] = {static_cast(sockfd), - static_cast(level), - static_cast(optname), - reinterpret_cast(optval), - reinterpret_cast(optlen)}; - int ret = syscall_impl(SYS_socketcall, SYS_GETSOCKOPT, sockcall_args); -#else -#error "getsockopt and socketcall syscalls unavailable for this platform." -#endif - if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/listen.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/listen.h index 9de54ce0a9a9f..e764c6b108432 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/listen.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/listen.h @@ -14,24 +14,13 @@ #include "src/__support/error_or.h" #include "src/__support/macros/config.h" -#include // For SYS_LISTEN socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { namespace linux_syscalls { LIBC_INLINE ErrorOr listen(int sockfd, int backlog) { -#ifdef SYS_listen - int ret = LIBC_NAMESPACE::syscall_impl(SYS_listen, sockfd, backlog); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[2] = {static_cast(sockfd), - static_cast(backlog)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_LISTEN, - sockcall_args); -#else -#error "listen and socketcall syscalls unavailable for this platform." -#endif - + int ret = syscall_impl(SYS_listen, sockfd, backlog); if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h index d16c397bba6ac..f1cfa8cd8e562 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/setsockopt.h @@ -15,7 +15,6 @@ #include "src/__support/macros/config.h" #include "hdr/types/socklen_t.h" -#include // For SYS_SETSOCKOPT socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { @@ -23,20 +22,8 @@ namespace linux_syscalls { LIBC_INLINE ErrorOr setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen) { -#ifdef SYS_setsockopt int ret = syscall_impl(SYS_setsockopt, sockfd, level, optname, optval, optlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[5] = {static_cast(sockfd), - static_cast(level), - static_cast(optname), - reinterpret_cast(optval), - static_cast(optlen)}; - int ret = syscall_impl(SYS_socketcall, SYS_SETSOCKOPT, sockcall_args); -#else -#error "setsockopt and socketcall syscalls unavailable for this platform." -#endif - if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/shutdown.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/shutdown.h index 2a9e92364f637..156905a408f1a 100644 --- a/libc/src/__support/OSUtil/linux/syscall_wrappers/shutdown.h +++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/shutdown.h @@ -14,24 +14,13 @@ #include "src/__support/error_or.h" #include "src/__support/macros/config.h" -#include // For SYS_SHUTDOWN socketcall number. #include // For syscall numbers namespace LIBC_NAMESPACE_DECL { namespace linux_syscalls { LIBC_INLINE ErrorOr shutdown(int sockfd, int how) { -#ifdef SYS_shutdown - int ret = LIBC_NAMESPACE::syscall_impl(SYS_shutdown, sockfd, how); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[2] = {static_cast(sockfd), - static_cast(how)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_SHUTDOWN, - sockcall_args); -#else -#error "shutdown and socketcall syscalls unavailable for this platform." -#endif - + int ret = syscall_impl(SYS_shutdown, sockfd, how); if (ret < 0) return Error(-static_cast(ret)); return ret; diff --git a/libc/src/sys/socket/linux/bind.cpp b/libc/src/sys/socket/linux/bind.cpp index 83a3d06f5380b..1b0a868f6b127 100644 --- a/libc/src/sys/socket/linux/bind.cpp +++ b/libc/src/sys/socket/linux/bind.cpp @@ -14,7 +14,6 @@ #include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. namespace LIBC_NAMESPACE_DECL { @@ -22,18 +21,7 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(int, bind, (int socket, const struct sockaddr *address, socklen_t address_len)) { -#ifdef SYS_bind - int ret = - LIBC_NAMESPACE::syscall_impl(SYS_bind, socket, address, address_len); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(socket), - reinterpret_cast(address), - static_cast(address_len)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_BIND, - sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + int ret = syscall_impl(SYS_bind, socket, address, address_len); if (ret < 0) { libc_errno = -ret; return -1; diff --git a/libc/src/sys/socket/linux/recv.cpp b/libc/src/sys/socket/linux/recv.cpp index baf4de1b5eb54..b7b208d454ffe 100644 --- a/libc/src/sys/socket/linux/recv.cpp +++ b/libc/src/sys/socket/linux/recv.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/recv.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/socklen_t.h" @@ -24,19 +23,12 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(ssize_t, recv, (int sockfd, void *buf, size_t len, int flags)) { #ifdef SYS_recv - ssize_t ret = - LIBC_NAMESPACE::syscall_impl(SYS_recv, sockfd, buf, len, flags); + ssize_t ret = syscall_impl(SYS_recv, sockfd, buf, len, flags); #elif defined(SYS_recvfrom) - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_recvfrom, sockfd, buf, len, flags, nullptr, nullptr); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[4] = { - static_cast(sockfd), reinterpret_cast(buf), - static_cast(len), static_cast(flags)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_RECV, - sockcall_args); + ssize_t ret = syscall_impl(SYS_recvfrom, sockfd, buf, len, flags, + nullptr, nullptr); #else -#error "socket and socketcall syscalls unavailable for this platform." +#error "recv or recvfrom syscalls unavailable for this platform." #endif if (ret < 0) { libc_errno = static_cast(-ret); diff --git a/libc/src/sys/socket/linux/recvfrom.cpp b/libc/src/sys/socket/linux/recvfrom.cpp index 3d8397b478cc4..ff4d5494fbeff 100644 --- a/libc/src/sys/socket/linux/recvfrom.cpp +++ b/libc/src/sys/socket/linux/recvfrom.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/recvfrom.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/socklen_t.h" @@ -34,21 +33,8 @@ LLVM_LIBC_FUNCTION(ssize_t, recvfrom, srcaddr_sz = *addrlen; (void)srcaddr_sz; // prevent "set but not used" warning -#ifdef SYS_recvfrom - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_recvfrom, sockfd, buf, len, flags, src_addr, addrlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[6] = {static_cast(sockfd), - reinterpret_cast(buf), - static_cast(len), - static_cast(flags), - reinterpret_cast(src_addr), - static_cast(addrlen)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_socketcall, SYS_RECVFROM, sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + ssize_t ret = syscall_impl(SYS_recvfrom, sockfd, buf, len, flags, + src_addr, addrlen); if (ret < 0) { libc_errno = static_cast(-ret); return -1; diff --git a/libc/src/sys/socket/linux/recvmsg.cpp b/libc/src/sys/socket/linux/recvmsg.cpp index bc6d072dbf9a1..e7650c508115c 100644 --- a/libc/src/sys/socket/linux/recvmsg.cpp +++ b/libc/src/sys/socket/linux/recvmsg.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/recvmsg.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/ssize_t.h" @@ -21,18 +20,7 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(ssize_t, recvmsg, (int sockfd, msghdr *msg, int flags)) { -#ifdef SYS_recvmsg - ssize_t ret = - LIBC_NAMESPACE::syscall_impl(SYS_recvmsg, sockfd, msg, flags); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(sockfd), - reinterpret_cast(msg), - static_cast(flags)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_socketcall, SYS_RECVMSG, sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + ssize_t ret = syscall_impl(SYS_recvmsg, sockfd, msg, flags); if (ret < 0) { libc_errno = static_cast(-ret); return -1; diff --git a/libc/src/sys/socket/linux/send.cpp b/libc/src/sys/socket/linux/send.cpp index 43b01e7e6e0f6..7e63e9e716433 100644 --- a/libc/src/sys/socket/linux/send.cpp +++ b/libc/src/sys/socket/linux/send.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/send.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/socklen_t.h" @@ -23,19 +22,12 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(ssize_t, send, (int sockfd, const void *buf, size_t len, int flags)) { #ifdef SYS_send - ssize_t ret = - LIBC_NAMESPACE::syscall_impl(SYS_send, sockfd, buf, len, flags); + ssize_t ret = syscall_impl(SYS_send, sockfd, buf, len, flags); #elif defined(SYS_sendto) - ssize_t ret = LIBC_NAMESPACE::syscall_impl(SYS_sendto, sockfd, buf, - len, flags, nullptr, 0); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[4] = { - static_cast(sockfd), reinterpret_cast(buf), - static_cast(len), static_cast(flags)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_SEND, - sockcall_args); + ssize_t ret = + syscall_impl(SYS_sendto, sockfd, buf, len, flags, nullptr, 0); #else -#error "socket and socketcall syscalls unavailable for this platform." +#error "send or sendto syscalls unavailable for this platform." #endif if (ret < 0) { libc_errno = static_cast(-ret); diff --git a/libc/src/sys/socket/linux/sendmsg.cpp b/libc/src/sys/socket/linux/sendmsg.cpp index b04783ebfe7e7..b4bbd7f78d433 100644 --- a/libc/src/sys/socket/linux/sendmsg.cpp +++ b/libc/src/sys/socket/linux/sendmsg.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/sendmsg.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/ssize_t.h" @@ -21,18 +20,7 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(ssize_t, sendmsg, (int sockfd, const struct msghdr *msg, int flags)) { -#ifdef SYS_sendmsg - ssize_t ret = - LIBC_NAMESPACE::syscall_impl(SYS_sendmsg, sockfd, msg, flags); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(sockfd), - reinterpret_cast(msg), - static_cast(flags)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_socketcall, SYS_SENDMSG, sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + ssize_t ret = syscall_impl(SYS_sendmsg, sockfd, msg, flags); if (ret < 0) { libc_errno = static_cast(-ret); return -1; diff --git a/libc/src/sys/socket/linux/sendto.cpp b/libc/src/sys/socket/linux/sendto.cpp index 9dda127f872d5..48450e22e9f48 100644 --- a/libc/src/sys/socket/linux/sendto.cpp +++ b/libc/src/sys/socket/linux/sendto.cpp @@ -8,7 +8,6 @@ #include "src/sys/socket/sendto.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. #include "hdr/types/socklen_t.h" @@ -23,21 +22,8 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(ssize_t, sendto, (int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)) { -#ifdef SYS_sendto - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_sendto, sockfd, buf, len, flags, dest_addr, addrlen); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[6] = {static_cast(sockfd), - reinterpret_cast(buf), - static_cast(len), - static_cast(flags), - reinterpret_cast(dest_addr), - static_cast(addrlen)}; - ssize_t ret = LIBC_NAMESPACE::syscall_impl( - SYS_socketcall, SYS_SENDTO, sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + ssize_t ret = syscall_impl(SYS_sendto, sockfd, buf, len, flags, + dest_addr, addrlen); if (ret < 0) { libc_errno = static_cast(-ret); return -1; diff --git a/libc/src/sys/socket/linux/socket.cpp b/libc/src/sys/socket/linux/socket.cpp index 69eb6cfa01ced..a2da75a0d7be0 100644 --- a/libc/src/sys/socket/linux/socket.cpp +++ b/libc/src/sys/socket/linux/socket.cpp @@ -14,24 +14,12 @@ #include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(int, socket, (int domain, int type, int protocol)) { -#ifdef SYS_socket - int ret = - LIBC_NAMESPACE::syscall_impl(SYS_socket, domain, type, protocol); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = {static_cast(domain), - static_cast(type), - static_cast(protocol)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_SOCKET, - sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + int ret = syscall_impl(SYS_socket, domain, type, protocol); if (ret < 0) { libc_errno = -ret; return -1; diff --git a/libc/src/sys/socket/linux/socketpair.cpp b/libc/src/sys/socket/linux/socketpair.cpp index 7ea8ca46cee58..a17850a3468fa 100644 --- a/libc/src/sys/socket/linux/socketpair.cpp +++ b/libc/src/sys/socket/linux/socketpair.cpp @@ -13,25 +13,13 @@ #include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" #include "src/__support/macros/sanitizer.h" -#include // For SYS_SOCKET socketcall number. #include // For syscall numbers. namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(int, socketpair, (int domain, int type, int protocol, int sv[2])) { -#ifdef SYS_socketpair - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketpair, domain, type, - protocol, sv); -#elif defined(SYS_socketcall) - unsigned long sockcall_args[3] = { - static_cast(domain), static_cast(type), - static_cast(protocol), static_cast(sv)}; - int ret = LIBC_NAMESPACE::syscall_impl(SYS_socketcall, SYS_SOCKETPAIR, - sockcall_args); -#else -#error "socket and socketcall syscalls unavailable for this platform." -#endif + int ret = syscall_impl(SYS_socketpair, domain, type, protocol, sv); if (ret < 0) { libc_errno = -ret; return -1;