This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch fw/syscall-list created. glibc-2.25-177-g699cbba


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, fw/syscall-list has been created
        at  699cbbad54b922327e99f28b494ea46af601ad1e (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=699cbbad54b922327e99f28b494ea46af601ad1e

commit 699cbbad54b922327e99f28b494ea46af601ad1e
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 5 15:29:29 2017 +0200

    <bits/syscall.h>: Use an arch-independent system call list Linux
    
    This commit changes the way the list of SYS_* system call macros
    is created on Linux.  glibc now contains a list of all known system
    calls, and the generated <bits/syscall.h> file defines the SYS_
    macro only if the correspnding __NR_ macro is defined by the kernel
    headers.
    
    As a result, there glibc does not have to be rebuilt to pick up
    system calls if the glibc sources already know about them.  This
    means that glibc can be built with older kernel headers, and if
    the installed kernel headers are upgraded afterwards, additional
    SYS_ macros become available as long as glibc has a record for
    those system calls.

diff --git a/ChangeLog b/ChangeLog
index 7bc2507..ad23434 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-04-05  Florian Weimer  <fweimer@redhat.com>
+
+	* sysdeps/unix/sysv/linux/Makefile (bits/syscall.h): Generate from
+	list file.
+	[$(subdir) = misc] (tests): Add tst-syscall-list.
+	[$(subdir) = misc] (tests-special): Add tst-syscall-list.out
+	[$(subdir) = misc] (syscall-macros.list, syscall-nr.list)
+	(syscall-sys.list): Helper targets for new tst-syscall-list test.
+	(tst-syscall-list.out): Run test script tst-syscall-list.sh.
+	* sysdeps/unix/sysv/linux/gen-syscall-h.awk: New file.
+	* sysdeps/unix/sysv/linux/syscall-names.list: Likewise.
+	* sysdeps/unix/sysv/linux/tst-syscall-list.sh: Likewise.
+
 2017-04-04  Wainer dos Santos Moschetta  <wainersm@linux.vnet.ibm.com>
 
 	* wcsmbs/tst-btowc.c: Import support/test-driver.c and remove
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 1872cdb..e2a3c97 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -45,75 +45,44 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 tests += tst-clone tst-clone2 tst-fanotify tst-personality tst-quota \
 	 tst-sync_file_range test-errno-linux
 
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-
-# If there is more than one syscall list for different architecture
-# variants, the CPU/Makefile defines abi-variants to be a list of names
-# for those variants (e.g. 32 64), and, for each variant, defines
-# abi-$(variant)-options to be compiler options to cause <asm/unistd.h>
-# to define the desired list of syscalls and abi-$(variant)-condition to
-# be the condition for those options to use in a C #if condition.
-# abi-includes may be defined to a list of headers to include
-# in the generated header, if the default does not suffice.
-#
-# The generated header is compiled with `-ffreestanding' to avoid any
-# circular dependencies against the installed implementation headers.
-# Such a dependency would require the implementation header to be
-# installed before the generated header could be built (See bug 15711).
-# In current practice the generated header dependencies do not include
-# any of the implementation headers removed by the use of `-ffreestanding'.
-
-$(objpfx)bits/syscall%h $(objpfx)bits/syscall%d: ../sysdeps/unix/sysv/linux/sys/syscall.h
+# Generate the list of SYS_* macros for the system calls (__NR_*
+# macros).  The file syscall-names.list contains all possible system
+# call names, and the generated header file produces SYS_* macros for
+# the __NR_* macros which are actually defined.
+
+generated += bits/syscall.h
+$(objpfx)bits/syscall.h: \
+  ../sysdeps/unix/sysv/linux/gen-syscall-h.awk \
+  ../sysdeps/unix/sysv/linux/syscall-names.list
 	$(make-target-directory)
-	{ \
-	 echo '/* Generated at libc build time from kernel syscall list.  */';\
-	 echo ''; \
-	 echo '#ifndef _SYSCALL_H'; \
-	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
-	 echo '#endif'; \
-	 echo ''; \
-	 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
-	 echo ''; \
-	 $(if $(abi-variants), \
-	 $(foreach v,$(abi-variants),\
-	 $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
-	       -x c $(sysincludes) $< $(abi-$(v)-options) \
-	       -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort > $(@:.d=.h).new$(v); \
-	 $(if $(abi-$(v)-condition),\
-	 echo '#if $(abi-$(v)-condition)';) \
-	 cat $(@:.d=.h).new$(v); \
-	 $(if $(abi-$(v)-condition),echo '#endif';) \
-	 rm -f $(@:.d=.h).new$(v); \
-	 ), \
-	 $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
-	       -x c $(sysincludes) $< \
-	       -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
-	 LC_ALL=C sort;) \
-	} > $(@:.d=.h).new
-	mv -f $(@:.d=.h).new $(@:.d=.h)
-ifdef abi-variants
-ifneq (,$(objpfx))
-	sed $(sed-remove-objpfx) \
-	 $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) > $(@:.h=.d)-t3
-else
-	cat $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) \
-	 > $(@:.h=.d)-t3
-endif
-	rm -f $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v))
-	mv -f $(@:.h=.d)-t3 $(@:.h=.d)
-else
-	mv -f $(@:.h=.d)-t $(@:.h=.d)
-endif
-
-ifndef no_deps
-# Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
--include $(objpfx)bits/syscall.d
-endif
-generated += bits/syscall.h bits/syscall.d
-endif
+	$(AWK) -f $^ > $@-tmp
+	$(move-if-change) $@-tmp $@
+
+# All macros defined by <sys/syscall.h>.  Include <bits/syscall.h>
+# explicitly because <sys/sycall.h> skips it if _LIBC is defined.
+$(objpfx)tst-syscall-list-macros.list: \
+  $(objpfx)bits/syscall.h ../sysdeps/unix/sysv/linux/sys/syscall.h
+	printf '#include <sys/syscall.h>\n#include <bits/syscall.h>\n' | \
+	  $(CC) -E -o $@-tmp $(CFLAGS) $(CPPFLAGS) -x c - -dM
+	$(move-if-change) $@-tmp $@
+
+# __NR_* system call names.  Used by the test below.
+$(objpfx)tst-syscall-list-nr.list: $(objpfx)tst-syscall-list-macros.list
+	$(AWK) '/^#define __NR_/ { print substr($$2, 6) }' $< > $@-tmp
+	$(move-if-change) $@-tmp $@
+
+# SYS_* system call names.  Used by the test below.
+$(objpfx)tst-syscall-list-sys.list: $(objpfx)tst-syscall-list-macros.list
+	$(AWK) '/^#define SYS_/ { print substr($$2, 5) }' $< > $@-tmp
+	$(move-if-change) $@-tmp $@
+
+tests-special += $(objpfx)tst-syscall-list.out
+$(objpfx)tst-syscall-list.out: \
+  ../sysdeps/unix/sysv/linux/tst-syscall-list.sh \
+  $(objpfx)tst-syscall-list-nr.list $(objpfx)tst-syscall-list-sys.list
+	$(BASH) $^ > $@; $(evaluate-test)
+
+endif # $(subdir) == misc
 
 ifeq ($(subdir),time)
 sysdep_headers += sys/timex.h bits/timex.h
diff --git a/sysdeps/unix/sysv/linux/gen-syscall-h.awk b/sysdeps/unix/sysv/linux/gen-syscall-h.awk
new file mode 100644
index 0000000..0a27b3c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/gen-syscall-h.awk
@@ -0,0 +1,75 @@
+# Generate SYS_* macros from a list in a text file.
+# Copyright (C) 2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+# Emit a conditional definition for SYS_NAME.
+function emit(name) {
+    print "#ifdef __NR_" name;
+    print "# define SYS_" name " __NR_" name;
+    print "#endif";
+    print "";
+}
+
+# Bail out with an error.
+function fatal(message) {
+    print FILENAME ":" FNR ": " message > "/dev/stderr";
+    exit 1;
+}
+
+BEGIN {
+    name = "";
+    kernel = "";
+}
+
+# Skip empty lines and comments.
+/^\s*(|#.*)$/ {
+    next;
+}
+
+# Kernel version.  Used for documentation purposes only.
+/^kernel [0-9.]+$/ {
+    if (kernel != "") {
+        fatal("duplicate kernel directive");
+    }
+    kernel = $2;
+    print "/* Generated at libc build time from syscall list.  */";
+    print "/* The system call list corresponds to kernel " kernel ".  */";
+    print "";
+    print "#ifndef _SYSCALL_H"
+    print "# error \"Never use <bits/syscall.h> directly; include <sys/syscall.h> instead.\"";
+    print "#endif";
+    print "";
+    next;
+}
+
+# If there is just one word, it is a system call.
+/^[a-zA-Z_][a-zA-Z0-9_]+$/ {
+    if (kernel == "") {
+        fatal("expected kernel directive before this line");
+    }
+    if ($1 <= name) {
+        fatal("name " name " violates ordering");
+    }
+    emit($1);
+    name = $1;
+    next;
+}
+
+# The rest has to be syntax errors.
+// {
+    fatal("unrecognized syntax");
+}
diff --git a/sysdeps/unix/sysv/linux/syscall-names.list b/sysdeps/unix/sysv/linux/syscall-names.list
new file mode 100644
index 0000000..a10b056
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -0,0 +1,359 @@
+# List of all known Linux system calls.
+# Copyright (C) 2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+# This file contains the list of system call names names.  It has to
+# remain in alphabetica order.  Lines which start with # are treated
+# as comments.  This file can list all potential system calls.  The
+# names are only used if the installed kernel headers also provide
+# them.
+
+# The list of system calls is current as of Linux 4.10.
+kernel 4.10
+
+_sysctl
+accept
+accept4
+access
+acct
+add_key
+adjtimex
+afs_syscall
+alarm
+arch_prctl
+bind
+bpf
+brk
+capget
+capset
+chdir
+chmod
+chown
+chroot
+clock_adjtime
+clock_getres
+clock_gettime
+clock_nanosleep
+clock_settime
+clone
+close
+connect
+copy_file_range
+creat
+create_module
+delete_module
+dup
+dup2
+dup3
+epoll_create
+epoll_create1
+epoll_ctl
+epoll_ctl_old
+epoll_pwait
+epoll_wait
+epoll_wait_old
+eventfd
+eventfd2
+execve
+execveat
+exit
+exit_group
+faccessat
+fadvise64
+fallocate
+fanotify_init
+fanotify_mark
+fchdir
+fchmod
+fchmodat
+fchown
+fchownat
+fcntl
+fdatasync
+fgetxattr
+finit_module
+flistxattr
+flock
+fork
+fremovexattr
+fsetxattr
+fstat
+fstatfs
+fsync
+ftruncate
+futex
+futimesat
+get_kernel_syms
+get_mempolicy
+get_robust_list
+get_thread_area
+getcpu
+getcwd
+getdents
+getdents64
+getegid
+geteuid
+getgid
+getgroups
+getitimer
+getpeername
+getpgid
+getpgrp
+getpid
+getpmsg
+getppid
+getpriority
+getrandom
+getresgid
+getresuid
+getrlimit
+getrusage
+getsid
+getsockname
+getsockopt
+gettid
+gettimeofday
+getuid
+getxattr
+init_module
+inotify_add_watch
+inotify_init
+inotify_init1
+inotify_rm_watch
+io_cancel
+io_destroy
+io_getevents
+io_setup
+io_submit
+ioctl
+ioperm
+iopl
+ioprio_get
+ioprio_set
+kcmp
+kexec_file_load
+kexec_load
+keyctl
+kill
+lchown
+lgetxattr
+link
+linkat
+listen
+listxattr
+llistxattr
+lookup_dcookie
+lremovexattr
+lseek
+lsetxattr
+lstat
+madvise
+mbind
+membarrier
+memfd_create
+migrate_pages
+mincore
+mkdir
+mkdirat
+mknod
+mknodat
+mlock
+mlock2
+mlockall
+mmap
+modify_ldt
+mount
+move_pages
+mprotect
+mq_getsetattr
+mq_notify
+mq_open
+mq_timedreceive
+mq_timedsend
+mq_unlink
+mremap
+msgctl
+msgget
+msgrcv
+msgsnd
+msync
+munlock
+munlockall
+munmap
+name_to_handle_at
+nanosleep
+newfstatat
+nfsservctl
+open
+open_by_handle_at
+openat
+pause
+perf_event_open
+personality
+pipe
+pipe2
+pivot_root
+pkey_alloc
+pkey_free
+pkey_mprotect
+poll
+ppoll
+prctl
+pread64
+preadv
+preadv2
+prlimit64
+process_vm_readv
+process_vm_writev
+pselect6
+ptrace
+putpmsg
+pwrite64
+pwritev
+pwritev2
+query_module
+quotactl
+read
+readahead
+readlink
+readlinkat
+readv
+reboot
+recvfrom
+recvmmsg
+recvmsg
+remap_file_pages
+removexattr
+rename
+renameat
+renameat2
+request_key
+restart_syscall
+rmdir
+rt_sigaction
+rt_sigpending
+rt_sigprocmask
+rt_sigqueueinfo
+rt_sigreturn
+rt_sigsuspend
+rt_sigtimedwait
+rt_tgsigqueueinfo
+sched_get_priority_max
+sched_get_priority_min
+sched_getaffinity
+sched_getattr
+sched_getparam
+sched_getscheduler
+sched_rr_get_interval
+sched_setaffinity
+sched_setattr
+sched_setparam
+sched_setscheduler
+sched_yield
+seccomp
+security
+select
+semctl
+semget
+semop
+semtimedop
+sendfile
+sendmmsg
+sendmsg
+sendto
+set_mempolicy
+set_robust_list
+set_thread_area
+set_tid_address
+setdomainname
+setfsgid
+setfsuid
+setgid
+setgroups
+sethostname
+setitimer
+setns
+setpgid
+setpriority
+setregid
+setresgid
+setresuid
+setreuid
+setrlimit
+setsid
+setsockopt
+settimeofday
+setuid
+setxattr
+shmat
+shmctl
+shmdt
+shmget
+shutdown
+sigaltstack
+signalfd
+signalfd4
+socket
+socketpair
+splice
+stat
+statfs
+swapoff
+swapon
+symlink
+symlinkat
+sync
+sync_file_range
+syncfs
+sysfs
+sysinfo
+syslog
+tee
+tgkill
+time
+timer_create
+timer_delete
+timer_getoverrun
+timer_gettime
+timer_settime
+timerfd_create
+timerfd_gettime
+timerfd_settime
+times
+tkill
+truncate
+tuxcall
+umask
+umount2
+uname
+unlink
+unlinkat
+unshare
+uselib
+userfaultfd
+ustat
+utime
+utimensat
+utimes
+vfork
+vhangup
+vmsplice
+vserver
+wait4
+waitid
+write
+writev
diff --git a/sysdeps/unix/sysv/linux/tst-syscall-list.sh b/sysdeps/unix/sysv/linux/tst-syscall-list.sh
new file mode 100644
index 0000000..3693b3b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-syscall-list.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+# Consistency checks for the system call list
+# Copyright (C) 2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+export LC_ALL=C
+set -e
+set -o pipefail
+
+if test $# != 2 ; then
+    echo "error: wrong number of arguments: $#"
+    exit 1
+fi
+
+list_nr="$1"
+list_sys="$2"
+
+errors=0
+
+# Use getpid as a system call which is expected to be always defined.
+if ! grep -q '^getpid$' -- "$list_nr" ; then
+    echo "error: __NR_getpid not defined"
+    errors=1
+fi
+if ! grep -q '^getpid$' -- "$list_sys" ; then
+    echo "error: SYS_getpid not defined"
+    errors=1
+fi
+
+comm_1="$(mktemp)"
+comm_2="$(mktemp)"
+comm_result="$(mktemp)"
+cleanup () {
+    rm -f -- "$comm_1" "$comm_2" "$comm_result"
+}
+trap cleanup 0
+
+sort -o "$comm_1" -- "$list_nr"
+sort -o "$comm_2" -- "$list_sys"
+
+# Check for missing SYS_* macros.
+comm --check-order -2 -3 -- "$comm_1" "$comm_2" > "$comm_result"
+if test -s "$comm_result"; then
+    echo "error: These system calls need to be added to syscall-names.list:"
+    cat -- "$comm_result"
+    errors=1
+fi
+
+# Check for additional SYS_* macros.
+comm --check-order -1 -3 -- "$comm_1" "$comm_2" > "$comm_result"
+if test -s "$comm_result"; then
+    echo "error: The following system calls have unexpected SYS_* macros:"
+    cat -- "$comm_result"
+    errors=1
+fi
+
+exit "$errors"

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]