klibc-bot for Ben Hutchings
2024-Oct-07 21:36 UTC
[klibc] [klibc:master] syscalls: Remove support for socketcall()
Commit-ID: bf11cb682b2c1e817feb69331f115bf40d9e92ea Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=bf11cb682b2c1e817feb69331f115bf40d9e92ea Author: Ben Hutchings <ben at decadent.org.uk> AuthorDate: Tue, 1 Oct 2024 22:04:37 +0200 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Wed, 2 Oct 2024 03:00:52 +0200 [klibc] syscalls: Remove support for socketcall() All architectures that implement socketcall() now also have separate system calls: - arm: added in 2.6.12 - i386: added in 4.3 - m68k: added in 4.3 - mips, mips64: added in 2.1.44 - parisc: always had both - ppc, ppc64: added in 2.6.37 - s390, s390x: added in 4.3 - sh: added in 2.6.37 - sparc, sparc64: added in 4.4 and 4.20 We can therefore unconditionally use the separate system calls, except for accept() which may need to be a wrapper for accept4(). Remove support for socketcall(), and move the socket system call definitions into SYSCALLS.def. Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/klibc/Kbuild | 2 - usr/klibc/SOCKETCALLS.def | 22 ---------- usr/klibc/SYSCALLS.def | 21 ++++++++-- usr/klibc/accept.c | 2 +- usr/klibc/socketcalls.pl | 78 ------------------------------------ usr/klibc/socketcalls/.gitignore | 4 -- usr/klibc/socketcalls/Kbuild | 52 ------------------------ usr/klibc/socketcalls/socketcommon.h | 15 ------- 8 files changed, 18 insertions(+), 178 deletions(-) diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index 8b132190..b2a122aa 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -7,8 +7,6 @@ export klibc-build := y # Generate syscall stubs klib-y += syscalls/ -# Generate socket calls stubs -klib-y += socketcalls/ # zlib, if configured klib-$(CONFIG_KLIBC_ZLIB) += zlib/ # arch specific .o files diff --git a/usr/klibc/SOCKETCALLS.def b/usr/klibc/SOCKETCALLS.def deleted file mode 100644 index 97413dec..00000000 --- a/usr/klibc/SOCKETCALLS.def +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- c -*- - * - * These are calls that are invoked via the socketcall mechanism - * Note that on most architectures this is simply #included into - * SYSCALLS.def. - */ -<?> int socket(int, int, int); -<?> int bind(int, const struct sockaddr *, int); -<?> int connect(int, const struct sockaddr *, socklen_t); -<?> int listen(int, int); -<?> int accept(int, struct sockaddr *, socklen_t *); -<?> int accept4(int, struct sockaddr *, socklen_t *, int); -<?> int getsockname(int, struct sockaddr *, socklen_t *); -<?> int getpeername(int, struct sockaddr *, socklen_t *); -<?> int socketpair(int, int, int, int *); -<?> int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); -<?> int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *); -<?> int shutdown(int, int); -<?> int setsockopt(int, int, int, const void *, socklen_t); -<?> int getsockopt(int, int, int, void *, socklen_t *); -<?> int sendmsg(int, const struct msghdr *, unsigned int); -<?> int recvmsg(int, struct msghdr *, unsigned int); diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def index b3b269ca..d4a593af 100644 --- a/usr/klibc/SYSCALLS.def +++ b/usr/klibc/SYSCALLS.def @@ -259,8 +259,21 @@ long kexec_load(void *, unsigned long, struct kexec_segment *, unsigned long); <i386> int vm86(struct vm86_struct *); /* - * Most architectures have the socket interfaces using regular - * system calls. + * Socket interfaces. */ -<?!i386> long socketcall::__socketcall(int, const unsigned long *); -#include "SOCKETCALLS.def" +int socket(int, int, int); +int bind(int, const struct sockaddr *, int); +int connect(int, const struct sockaddr *, socklen_t); +int listen(int, int); +<?> int accept(int, struct sockaddr *, socklen_t *); +int accept4(int, struct sockaddr *, socklen_t *, int); +int getsockname(int, struct sockaddr *, socklen_t *); +int getpeername(int, struct sockaddr *, socklen_t *); +int socketpair(int, int, int, int *); +int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); +int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *); +int shutdown(int, int); +int setsockopt(int, int, int, const void *, socklen_t); +int getsockopt(int, int, int, void *, socklen_t *); +int sendmsg(int, const struct msghdr *, unsigned int); +int recvmsg(int, struct msghdr *, unsigned int); diff --git a/usr/klibc/accept.c b/usr/klibc/accept.c index 443c2fe9..18c2d6ca 100644 --- a/usr/klibc/accept.c +++ b/usr/klibc/accept.c @@ -6,7 +6,7 @@ #include <sys/socket.h> -#if defined(__NR_accept4) && !defined(__NR_accept) +#ifndef __NR_accept int accept(int socket, struct sockaddr *address, socklen_t *addr_len) { diff --git a/usr/klibc/socketcalls.pl b/usr/klibc/socketcalls.pl deleted file mode 100644 index 8e4fe9fc..00000000 --- a/usr/klibc/socketcalls.pl +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl - -$v = $ENV{'KBUILD_VERBOSE'}; -$quiet = defined($v) ? !$v : 0; - - at args = (); -for $arg ( @ARGV ) { - if ( $arg =~ /^-/ ) { - if ( $arg eq '-q' ) { - $quiet = 1; - } else { - die "$0: Unknown option: $arg\n"; - } - } else { - push(@args, $arg); - } -} -($file, $arch, $outputdir) = @args; - -if (!open(FILE, "< $file")) { - die "$file: $!\n"; -} - -print "socketcall-objs := "; -while ( defined($line = <FILE>) ) { - chomp $line; - $line =~ s/\s*(|\#.*|\/\/.*)$//; # Strip comments and trailing blanks - next unless $line; - - if ( $line =~ /^\s*\<\?\>\s*(.*)\s+([_a-zA-Z][_a-zA-Z0-9]+)\s*\((.*)\)\s*\;$/ ) { - $type = $1; - $name = $2; - $argv = $3; - - @args = split(/\s*\,\s*/, $argv); - @cargs = (); - - $i = 0; - for $arg ( @args ) { - push(@cargs, "$arg a".$i++); - } - $nargs = $i; - print " \\\n\t${name}.o"; - - open(OUT, "> ${outputdir}/${name}.c") - or die "$0: Cannot open ${outputdir}/${name}.c\n"; - - print OUT "#include \"socketcommon.h\"\n"; - print OUT "\n"; - print OUT "#if !defined(__NR_${name})"; - if ($name eq 'accept') { - print OUT " && !defined(__NR_accept4)"; - } - print OUT "\n# define DO_THIS_SOCKETCALL\n"; - print OUT "#endif\n\n"; - - print OUT "#if defined(DO_THIS_SOCKETCALL) && defined(SYS_\U${name}\E)\n\n"; - - print OUT "extern long __socketcall(int, const unsigned long *);\n\n"; - - print OUT "$type ${name}(", join(', ', @cargs), ")\n"; - print OUT "{\n"; - print OUT " unsigned long args[$nargs];\n"; - for ( $i = 0 ; $i < $nargs ; $i++ ) { - print OUT " args[$i] = (unsigned long)a$i;\n"; - } - print OUT " return ($type) __socketcall(SYS_\U${name}\E, args);\n"; - print OUT "}\n\n"; - - print OUT "#endif\n"; - - close(OUT); - } else { - die "$file:$.: Could not parse input\n"; - } -} - -print "\n"; diff --git a/usr/klibc/socketcalls/.gitignore b/usr/klibc/socketcalls/.gitignore deleted file mode 100644 index 67da0d1f..00000000 --- a/usr/klibc/socketcalls/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.S -*.c -SOCKETCALLS.i -socketcalls.mk diff --git a/usr/klibc/socketcalls/Kbuild b/usr/klibc/socketcalls/Kbuild deleted file mode 100644 index a974a889..00000000 --- a/usr/klibc/socketcalls/Kbuild +++ /dev/null @@ -1,52 +0,0 @@ -# -# Generate socket calls based on SOCKETCALLS.def -# - -# Include automatically generated Makefile fragment. -# It contains definition of socketcall-objs specifying name of all .o files -ifeq ($(clean),) --include $(obj)/socketcalls.mk -endif - -# Listing of all .o files -always := klib.list - -##### -# Generate socket calls stubs -# Based on input from SOCKETCALLS.def generate socket call stubs -targets := klib.list -targets += socketcalls.mk -targets += SOCKETCALLS.i -targets += $(socketcall-objs) -clean-files += *.S *.c *.o *.list - -EXTRA_KLIBCCFLAGS := -I$(srctree)/$(src) - -quiet_cmd_makelist = LIST $@ - cmd_makelist = echo '$(filter-out FORCE,$^)' > $@ - -# Create list of all files -$(obj)/klib.list: $(call objectify,$(socketcall-objs)) FORCE - $(call if_changed,makelist) - -# Generate assembler file (.i) -# We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__" -quiet_cmd_socketcall.i = GEN $@ - cmd_socketcall.i = $(KLIBCCC) $(klibccflags) -D__ASSEMBLY__ \ - -ansi -x c -E -o $@ $< -$(obj)/SOCKETCALLS.i: $(KLIBCSRC)/SOCKETCALLS.def FORCE - $(call if_changed_dep,socketcall.i) - -# Generate socketcall stubs -quiet_cmd_socketcalls = GEN $@ - cmd_socketcalls = $(PERL) $(srctree)/$(KLIBCSRC)/socketcalls.pl \ - $(obj)/SOCKETCALLS.i \ - $(KLIBCARCH) $(obj) > $@ \ - || ( rm -f $@ ; exit 1 ) - -$(obj)/socketcalls.mk: $(srctree)/$(KLIBCSRC)/socketcalls.pl \ - $(obj)/SOCKETCALLS.i \ - $(src)/socketcommon.h - $(call cmd,socketcalls) - -PHONY += FORCE diff --git a/usr/klibc/socketcalls/socketcommon.h b/usr/klibc/socketcalls/socketcommon.h deleted file mode 100644 index 7fdd5470..00000000 --- a/usr/klibc/socketcalls/socketcommon.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * socketcommon.h - * - * Common header file for socketcall stubs - */ - -#define __IN_SYS_COMMON -#include <errno.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/syscall.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <linux/net.h>