public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Zack Weinberg <zack@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/zack/no-nested-includes] Don't include sys/types.h from POSIX headers (1/n) Date: Tue, 18 Jun 2019 15:34:00 -0000 [thread overview] Message-ID: <20190618153400.48094.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b54843a67a873ef2a00aec83f2ec4e82d1bc86db commit b54843a67a873ef2a00aec83f2ec4e82d1bc86db Author: Zack Weinberg <zackw@panix.com> Date: Tue May 21 19:05:39 2019 -0400 Don't include sys/types.h from POSIX headers (1/n) Many POSIX headers are including sys/types.h when they are only supposed to expose a small number of types from that header. There will be several patches in this sub-series; this one does the easiest cases. * io/ftw.h: Don't include sys/types.h. * misc/sys/uio.h: Don't include sys/types.h. Include bits/types.h and bits/types/ssize_t.h. Include stddef.h for size_t. * posix/spawn.h: Don't include sys/types.h. Include bits/types.h, bits/types/mode_t.h, and bits/types/pid_t.h. * rt/aio.h: Don't include sys/types.h. Include bits/types.h, bits/pthreadtypes.h, and bits/types/ssize_t.h. Include stddef.h for size_t. * sysdeps/pthread/semaphore.h: Don't include sys/types.h. * sysdeps/unix/sysv/linux/bits/uio-ext.h: Use __pid_t, not pid_t. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update. Diff: --- io/ftw.h | 1 - misc/sys/uio.h | 7 ++++++- posix/spawn.h | 5 ++++- rt/aio.h | 9 ++++++++- rt/mqueue.h | 9 ++++++++- scripts/check-obsolete-constructs.py | 9 +++------ sysdeps/pthread/semaphore.h | 2 +- sysdeps/unix/sysv/linux/bits/uio-ext.h | 4 ++-- 8 files changed, 32 insertions(+), 14 deletions(-) diff --git a/io/ftw.h b/io/ftw.h index 1ef67f7..ea1d1ee 100644 --- a/io/ftw.h +++ b/io/ftw.h @@ -24,7 +24,6 @@ #include <features.h> -#include <sys/types.h> #include <sys/stat.h> diff --git a/misc/sys/uio.h b/misc/sys/uio.h index ec1ca4a..1257858 100644 --- a/misc/sys/uio.h +++ b/misc/sys/uio.h @@ -19,7 +19,12 @@ #define _SYS_UIO_H 1 #include <features.h> -#include <sys/types.h> + +#define __need_size_t +#include <stddef.h> + +#include <bits/types.h> +#include <bits/types/ssize_t.h> #include <bits/types/struct_iovec.h> #include <bits/uio_lim.h> #ifdef __IOV_MAX diff --git a/posix/spawn.h b/posix/spawn.h index 471dbea..2dd7543 100644 --- a/posix/spawn.h +++ b/posix/spawn.h @@ -21,7 +21,10 @@ #include <features.h> #include <sched.h> -#include <sys/types.h> + +#include <bits/types.h> +#include <bits/types/mode_t.h> +#include <bits/types/pid_t.h> #include <bits/types/sigset_t.h> diff --git a/rt/aio.h b/rt/aio.h index d1b97bf..02c164d 100644 --- a/rt/aio.h +++ b/rt/aio.h @@ -23,7 +23,14 @@ #define _AIO_H 1 #include <features.h> -#include <sys/types.h> + +#define __need_size_t +#include <stddef.h> + +#include <bits/types.h> +#include <bits/pthreadtypes.h> +#include <bits/types/off_t.h> +#include <bits/types/ssize_t.h> #include <bits/types/sigevent_t.h> #include <bits/sigevent-consts.h> #include <bits/types/struct_timespec.h> diff --git a/rt/mqueue.h b/rt/mqueue.h index 308a52c..69aa40c 100644 --- a/rt/mqueue.h +++ b/rt/mqueue.h @@ -19,13 +19,20 @@ #define _MQUEUE_H 1 #include <features.h> -#include <sys/types.h> #include <fcntl.h> + +#define __need_size_t +#include <stddef.h> +#include <bits/types.h> +#include <bits/pthreadtypes.h> #include <bits/types/sigevent_t.h> +#include <bits/types/ssize_t.h> #include <bits/types/struct_timespec.h> + /* Get the definition of mqd_t and struct mq_attr. */ #include <bits/mqueue.h> + __BEGIN_DECLS /* Establish connection between a process and a message queue NAME and diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index 36d8746..4eb293e 100755 --- a/scripts/check-obsolete-constructs.py +++ b/scripts/check-obsolete-constructs.py @@ -523,15 +523,13 @@ HEADER_ALLOWED_INCLUDES = { # mqueue.h -> fcntl.h # sched.h -> time.h # spawn.h -> sched.h - "aio.h": [ "sys/types.h" ], - "ftw.h": [ "sys/stat.h", "sys/types.h" ], + "ftw.h": [ "sys/stat.h" ], "langinfo.h": [ "nl_types.h" ], - "mqueue.h": [ "fcntl.h", "sys/types.h" ], + "mqueue.h": [ "fcntl.h" ], "pthread.h": [ "sched.h", "time.h" ], "regex.h": [ "limits.h", "sys/types.h" ], "sched.h": [ "time.h" ], - "semaphore.h": [ "sys/types.h" ], - "spawn.h": [ "sched.h", "sys/types.h" ], + "spawn.h": [ "sched.h" ], "termios.h": [ "sys/ttydefaults.h" ], # POSIX sys/ headers @@ -545,7 +543,6 @@ HEADER_ALLOWED_INCLUDES = { "sys/shm.h": [ "sys/ipc.h" ], "sys/time.h": [ "sys/select.h" ], "sys/types.h": [ "endian.h" ], - "sys/uio.h": [ "sys/types.h" ], "sys/un.h": [ "string.h" ], "sys/wait.h": [ "signal.h" ], diff --git a/sysdeps/pthread/semaphore.h b/sysdeps/pthread/semaphore.h index 87c0543..075b0be 100644 --- a/sysdeps/pthread/semaphore.h +++ b/sysdeps/pthread/semaphore.h @@ -19,7 +19,7 @@ #define _SEMAPHORE_H 1 #include <features.h> -#include <sys/types.h> + #ifdef __USE_XOPEN2K # include <bits/types/struct_timespec.h> #endif diff --git a/sysdeps/unix/sysv/linux/bits/uio-ext.h b/sysdeps/unix/sysv/linux/bits/uio-ext.h index c4ea63d..a390806 100644 --- a/sysdeps/unix/sysv/linux/bits/uio-ext.h +++ b/sysdeps/unix/sysv/linux/bits/uio-ext.h @@ -26,7 +26,7 @@ __BEGIN_DECLS /* Read from another process' address space. */ -extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec, +extern ssize_t process_vm_readv (__pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt, @@ -34,7 +34,7 @@ extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec, __THROW; /* Write to another process' address space. */ -extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec, +extern ssize_t process_vm_writev (__pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt,
next reply other threads:[~2019-06-18 15:34 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-06-18 15:34 Zack Weinberg [this message] -- strict thread matches above, loose matches on Subject: below -- 2019-05-26 16:36 Zack Weinberg
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190618153400.48094.qmail@sourceware.org \ --to=zack@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).