summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-08-01 17:12:20 +0200
committerKim Gräsman <kim.grasman@gmail.com>2022-09-01 19:44:29 +0200
commit75623bce3bf18664216a56c97f38eb1affeac5f8 (patch)
tree83cffc4f63f010f88fc1ffd6ad978dfd16540b90
parent4ad1d428ffe05e641b276f4dea38b43b1b9537b9 (diff)
Fix mapping for <bits/syscall.h>
SYS_xxx macros, which are implemented in glibc in <bits/syscall.h>, are intended to be included from <sys/syscall.h>. See syscall(2), amd also see the following: $ grepc -k 'SYS_[a-z]\w+' /usr/include | head /usr/include/x86_64-linux-gnu/bits/syscall.h:35:# define SYS_accept __NR_accept /usr/include/x86_64-linux-gnu/bits/syscall.h:39:# define SYS_accept4 __NR_accept4 /usr/include/x86_64-linux-gnu/bits/syscall.h:43:# define SYS_access __NR_access /usr/include/x86_64-linux-gnu/bits/syscall.h:47:# define SYS_acct __NR_acct /usr/include/x86_64-linux-gnu/bits/syscall.h:51:# define SYS_acl_get __NR_acl_get /usr/include/x86_64-linux-gnu/bits/syscall.h:55:# define SYS_acl_set __NR_acl_set /usr/include/x86_64-linux-gnu/bits/syscall.h:59:# define SYS_add_key __NR_add_key /usr/include/x86_64-linux-gnu/bits/syscall.h:63:# define SYS_adjtimex __NR_adjtimex /usr/include/x86_64-linux-gnu/bits/syscall.h:67:# define SYS_afs_syscall __NR_afs_syscall /usr/include/x86_64-linux-gnu/bits/syscall.h:71:# define SYS_alarm __NR_alarm $ grep -rn bits/syscall.h /usr/include /usr/include/x86_64-linux-gnu/bits/syscall.h:5:# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead." /usr/include/x86_64-linux-gnu/sys/syscall.h:27: programs expect the traditional form SYS_*. <bits/syscall.h> /usr/include/x86_64-linux-gnu/sys/syscall.h:29:#include <bits/syscall.h> I removed duplicate mappings, and also removed the mapping for <syscall.h>, which is an undocumented feature of glibc. Portable programs should stick to <sys/syscall.h> (and unportable ones too, since there's no gain apart from those 4 bytes). Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r--gcc.libc.imp6
-rw-r--r--iwyu_include_picker.cc6
2 files changed, 4 insertions, 8 deletions
diff --git a/gcc.libc.imp b/gcc.libc.imp
index a78ce7c..554c63d 100644
--- a/gcc.libc.imp
+++ b/gcc.libc.imp
@@ -91,7 +91,7 @@
{ include: [ "<bits/string3.h>", private, "<string.h>", public ] },
{ include: [ "<bits/stropts.h>", private, "<stropts.h>", public ] },
{ include: [ "<bits/sys_errlist.h>", private, "<stdio.h>", public ] },
- { include: [ "<bits/syscall.h>", private, "<sys/syscall.h>", private ] },
+ { include: [ "<bits/syscall.h>", private, "<sys/syscall.h>", public ] },
{ include: [ "<bits/sysctl.h>", private, "<sys/sysctl.h>", public ] },
{ include: [ "<bits/syslog-ldbl.h>", private, "<sys/syslog.h>", private ] },
{ include: [ "<bits/syslog-path.h>", private, "<sys/syslog.h>", private ] },
@@ -169,7 +169,6 @@
{ include: [ "<bits/string.h>", private, "<string.h>", public ] },
{ include: [ "<bits/string2.h>", private, "<string.h>", public ] },
{ include: [ "<bits/string3.h>", private, "<string.h>", public ] },
- { include: [ "<bits/syscall.h>", private, "<sys/syscall.h>", private ] },
{ include: [ "<bits/timerfd.h>", private, "<sys/timerfd.h>", public ] },
{ include: [ "<bits/typesizes.h>", private, "<sys/types.h>", public ] },
# Top-level #includes that just forward to another file:
@@ -180,7 +179,6 @@
# to decide which of the two files is canonical. If neither is
# on the POSIX.1 1998 list, I just choose the top-level one.
{ include: [ "<sys/poll.h>", private, "<poll.h>", public ] },
- { include: [ "<sys/syscall.h>", private, "<syscall.h>", public ] },
{ include: [ "<sys/syslog.h>", private, "<syslog.h>", public ] },
{ include: [ "<sys/ustat.h>", private, "<ustat.h>", public ] },
{ include: [ "<wait.h>", private, "<sys/wait.h>", public ] },
@@ -202,7 +200,7 @@
{ include: [ "<asm/errno.h>", private, "<errno.h>", public ] },
{ include: [ "<asm/errno-base.h>", private, "<errno.h>", public ] },
{ include: [ "<asm/ptrace-abi.h>", private, "<asm/ptrace.h>", public ] },
- { include: [ "<asm/unistd.h>", private, "<syscall.h>", public ] },
+ { include: [ "<asm/unistd.h>", private, "<sys/syscall.h>", public ] },
{ include: [ "<linux/limits.h>", private, "<limits.h>", public ] }, # PATH_MAX
{ include: [ "<linux/prctl.h>", private, "<sys/prctl.h>", public ] },
{ include: [ "<sys/ucontext.h>", private, "<ucontext.h>", public ] },
diff --git a/iwyu_include_picker.cc b/iwyu_include_picker.cc
index 8b85303..36d7586 100644
--- a/iwyu_include_picker.cc
+++ b/iwyu_include_picker.cc
@@ -460,7 +460,7 @@ const IncludeMapEntry libc_include_map[] = {
{ "<bits/string3.h>", kPrivate, "<string.h>", kPublic },
{ "<bits/stropts.h>", kPrivate, "<stropts.h>", kPublic },
{ "<bits/sys_errlist.h>", kPrivate, "<stdio.h>", kPublic },
- { "<bits/syscall.h>", kPrivate, "<sys/syscall.h>", kPrivate },
+ { "<bits/syscall.h>", kPrivate, "<sys/syscall.h>", kPublic },
{ "<bits/sysctl.h>", kPrivate, "<sys/sysctl.h>", kPublic },
{ "<bits/syslog-ldbl.h>", kPrivate, "<sys/syslog.h>", kPrivate },
{ "<bits/syslog-path.h>", kPrivate, "<sys/syslog.h>", kPrivate },
@@ -538,7 +538,6 @@ const IncludeMapEntry libc_include_map[] = {
{ "<bits/string.h>", kPrivate, "<string.h>", kPublic },
{ "<bits/string2.h>", kPrivate, "<string.h>", kPublic },
{ "<bits/string3.h>", kPrivate, "<string.h>", kPublic },
- { "<bits/syscall.h>", kPrivate, "<sys/syscall.h>", kPrivate },
{ "<bits/timerfd.h>", kPrivate, "<sys/timerfd.h>", kPublic },
{ "<bits/typesizes.h>", kPrivate, "<sys/types.h>", kPublic },
// Top-level #includes that just forward to another file:
@@ -549,7 +548,6 @@ const IncludeMapEntry libc_include_map[] = {
// to decide which of the two files is canonical. If neither is
// on the POSIX.1 1998 list, I just choose the top-level one.
{ "<sys/poll.h>", kPrivate, "<poll.h>", kPublic },
- { "<sys/syscall.h>", kPrivate, "<syscall.h>", kPublic },
{ "<sys/syslog.h>", kPrivate, "<syslog.h>", kPublic },
{ "<sys/ustat.h>", kPrivate, "<ustat.h>", kPublic },
{ "<wait.h>", kPrivate, "<sys/wait.h>", kPublic },
@@ -571,7 +569,7 @@ const IncludeMapEntry libc_include_map[] = {
{ "<asm/errno.h>", kPrivate, "<errno.h>", kPublic },
{ "<asm/errno-base.h>", kPrivate, "<errno.h>", kPublic },
{ "<asm/ptrace-abi.h>", kPrivate, "<asm/ptrace.h>", kPublic },
- { "<asm/unistd.h>", kPrivate, "<syscall.h>", kPublic },
+ { "<asm/unistd.h>", kPrivate, "<sys/syscall.h>", kPublic },
{ "<linux/limits.h>", kPrivate, "<limits.h>", kPublic }, // PATH_MAX
{ "<linux/prctl.h>", kPrivate, "<sys/prctl.h>", kPublic },
{ "<sys/ucontext.h>", kPrivate, "<ucontext.h>", kPublic },