1 # Generate SYS_* macros from a list in a text file.
2 # Copyright (C) 2017-2024 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
19 # Emit a conditional definition for SYS_NAME.
21 print "#ifdef __NR_" name
;
22 print "# define SYS_" name
" __NR_" name
;
27 # Bail out with an error.
28 function fatal
(message
) {
29 print FILENAME ":" FNR ": " message
> "/dev/stderr";
38 # Skip empty lines and comments.
43 # Kernel version. Used for documentation purposes only.
46 fatal
("duplicate kernel directive");
49 print "/* Generated at libc build time from syscall list. */";
50 print "/* The system call list corresponds to kernel " kernel
". */";
52 print "#ifndef _SYSCALL_H"
53 print "# error \"Never use <bits/syscall.h> directly; include <sys/syscall.h> instead.\"";
56 split($
2, kernel_version
, ".");
57 kernel_major = kernel_version
[1];
58 kernel_minor = kernel_version
[2];
59 kernel_version_code = kernel_major
* 65536 + kernel_minor
* 256;
60 print "#define __GLIBC_LINUX_VERSION_CODE " kernel_version_code
;
65 # If there is just one word, it is a system call.
66 /^
[a
-zA
-Z_
][a
-zA
-Z0
-9_
]+$
/ {
68 fatal
("expected kernel directive before this line");
71 fatal
("name " name
" violates ordering");
78 # The rest has to be syntax errors.
80 fatal
("unrecognized syntax");