diff options
author | Zack Weinberg <zackw@panix.com> | 2019-05-21 19:05:39 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-01-08 14:15:36 -0500 |
commit | b32c5f35b8fb037bd54cde10bb14e6510171534a (patch) | |
tree | b514a2b1812167dddce8b1219fb018f732fe03d4 /sysdeps/s390/tst-dl-runtime.c | |
parent | 886864a8f2436d8c13f37c425ef28293146691ce (diff) | |
download | glibc-b32c5f35b8fb037bd54cde10bb14e6510171534a.tar.gz |
Don’t include sys/types.h or stdint.h from most public headers.
Many public headers include sys/types.h and/or stdint.h when they only
need and/or are supposed to define a small number of types from that
header. This patch changes as many of them as practical to include
only the single-type headers for the types they are actually specified
to define, and use the impl-namespace aliases for any types they need
but are not specified to define. In most cases, where a header has
historically used uintN_t types, I changed it to use __uintN_t types;
in a few cases I chose to have it continue to define the complete set
of those types (using <bits/stdint-uintn.h>).
After this patch, the public headers that still include sys/types.h are:
stdlib.h and sys/param.h, where removal would risk breaking far too much;
the inclusion of sys/types.h; regex.h, which is taken verbatim from
gnulib and can't include features.h directly (I'm open to better ideas);
sys/bitypes.h, which is an alternative name for sys/types.h; and
the networking headers, which will be dealt with separately. The headers
that still include stdint.h are: inttypes.h, as required by ISO C;
elf.h and thread_db.h, see discussion of debugger interface headers below;
and, again, the networking headers will be dealt with separately.
While I was at it, I moved headers out of sysdeps where possible: If
we have only a sysdeps/generic/something.h or sysdeps/gnu/something.h,
no other sysdeps variants, it is not really system-dependent and can
be moved to the directory that installs it. If we have both
sysdeps/generic/ and gnu/something.h, the generic version is never
used (since we support only GNUish systems these days) and can be
deleted, and the gnu-version can be moved to the directory that
installs it. If the only copy of a bits header is in the
top-level bits directory, it is not system-dependent.
For utmp.h and utmpx.h, I think we might be able to fold their
respective bits headers into the primary headers and make them not
system-dependent at all. The remaining variation is between
s390*-*-linux* and everything else, and it appears to me that the s390
versions of the bits headers are actually the headers that everyone
should be using. The only difference is that the s390 headers
unconditionally use 64-bit quantities for lastlog.ll_time,
utmp{,x}.ut_tv, and utmp{,x}.ut_session, whereas the generic headers
use either 64- or 32-bit quantities depending on
__WORDSIZE_TIME64_COMPAT32. I could be wrong, but I don’t think it
makes sense for programs with 64-bit and 32-bit time_t to have
different ideas of the layout of a structures that are copied directly
to and from a shared file on disk. But fixing that doesn’t belong in
this patch series.
The conform tests expect utmpx.h to define time_t and suseconds_t.
These are the public names for the types of the fields of struct
timeval, and utmpx.h is required to define struct timeval, so this is
a reasonable expectation even though POSIX doesn't _explicitly_ say
it's also required to define time_t and suseconds_t. utmp.h is not a
standard header but it makes sense for it to be as consistent with
utmpx.h as possible, especially in our implementation where
/var/log/utmp and /var/log/utmpx have the same format.
I thought I was going to need to change all of the arch-specific
bits/epoll.h headers as well as sys/epoll.h, but it turned out not to
be necessary. I still took the opportunity to give them all multiple
inclusion guards.
I suspect we do not need as many copies of bits/fcntl.h and bits/sem.h
as we have, but that’s complicated enough that it deserves its own patchset.
The debugger interface headers are a mess and I only have so much
patience for them. This does the bare minimum required for
thread_db.h, sys/procfs.h, and sys/user.h, which are at least
nominally cross-platform interfaces, to avoid including sys/types.h,
sys/time.h, and/or signal.h. Exposure of sys/ucontext.h is reduced
but not eliminated. Cross-architecture consistency should be improved.
It would be desirable to stop including stdint.h from elf.h and
thread_db.h as well, but that would involve touching dozens more
bits headers and I ran out of patience.
Git does not understand “remove file X and then rename file Y over the
top of it” very well, so the diff looks bigger than it should.
This is another partial fix for Hurd-specific bug 23088. The headers
that are still affected by that bug are aio.h, mqueue.h, regex.h,
signal.h, stdlib.h, and sys/types.h.
* io/ftw.h: Don't include sys/types.h.
* misc/sys/uio.h: Don't include sys/types.h.
Include bits/types.h, bits/types/size_t.h, and bits/types/ssize_t.h.
* 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,
bits/types/size_t.h, and bits/types/ssize_t.h.
* sysdeps/pthread/semaphore.h: Don't include sys/types.h.
* sysdeps/unix/sysv/linux/bits/uio-ext.h: Use __pid_t, not pid_t.
* sysdeps/generic/netinet/in_systm.h: Rename to
inet/netinet/in_systm.h. Include bits/stdint-uintn.h,
not sys/types.h or stdint.h.
* sysdeps/generic/netinet/ip.h: Rename to
inet/netinet/ip.h. Include bits/stdint-uintn.h and
bits/endian.h, not sys/types.h.
* sysdeps/gnu/netinet/tcp.h: Rename to
inet/netinet/tcp.h. Include bits/stdint-uintn.h and
bits/endian.h, not sys/types.h or stdint.h.
* sydeps/gnu/net/if.h: Rename to socket/net/if.h.
Don’t include sys/types.h.
* include/net/if.h: Include socket/net/if.h, rather than
whatever the next net/if.h on the include path is.
* include/netinet/in_systm.h, include/netinet/ip.h
* include/netinet/tcp.h: New trivial wrappers.
* sysdeps/generic/net/if.h: Delete, never used.
* sysdeps/generic/netinet/tcp.h: Delete, never used.
* bits/utmp.h: Delete file.
* sysdeps/gnu/bits/utmp.h: Move to bits/utmp.h.
Add multiple include guard.
Don’t include paths.h, sys/time.h, or sys/types.h.
Don’t use struct timeval.
Use __intN_t for consistency with bits/utmpx.h.
* sysdeps/unix/sysv/linux/s390/bits/utmp.h: Add multiple include guard.
Don’t include paths.h, sys/time.h, sys/types.h, or bits/wordsize.h.
Don’t use struct timeval.
Use __intN_t for consistency with bits/utmpx.h.
Use __time64_t unconditionally for lastlog.ll_time.
Use __int64_t unconditionally for utmp.ut_session.
Adjust indentation and blank lines to match bits/utmp.h.
* sysdeps/gnu/bits/utmpx.h: Move to bits/utmpx.h.
Add multiple include guard.
Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
Don’t define _PATH_UTMPX or _PATH_WTMPX.
Don’t use struct timeval.
Use pid_t for consistency with bits/utmp.h.
* sysdeps/unix/sysv/linux/s390/bits/utmpx.h: Add multiple include guard.
Don’t define _PATH_UTMPX or _PATH_WTMPX.
Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
Don’t define _PATH_UTMPX or _PATH_WTMPX.
Don’t use struct timeval.
Use pid_t for consistency with bits/utmp.h.
Use __int64_t unconditionally for utmpx.ut_session.
* login/utmp.h: Don’t include sys/types.h.
Do include paths.h, bits/types.h, bits/types/pid_t.h,
bits/types/suseconds_t, bits/types/time_t.h, and
bits/types/struct_timeval.h.
Move __BEGIN_DECLS to enclose only prototypes.
* sysdeps/gnu/utmpx.h: Move to login/utmpx.h.
Don’t include sys/time.h. Do include bits/types.h,
bits/types/suseconds_t, bits/types/time_t.h, and
bits/types/struct_timeval.h.
When __USE_GNU, include paths.h and define _PATH_UTMPX and _PATH_WTMPX.
* login/Makefile (headers): Add utmpx.h and bits/utmpx.h.
(routines): Add endutxent, getutmp, getutmpx, getutxent,
getutxid, getutxline, pututxline, setutxent, updwtmpx, and
utmpxname. Reorganize.
* sysdeps/gnu/Makefile: Do not add anything to sysdep_routines
or sysdep_headers when subdir == login.
* sysdeps/gnu/sys/mtio.h: Move to misc/sys/mtio.h.
Don't include sys/types.h.
* sysdeps/gnu/Makefile: Don't add anything to sysdep_headers
for the misc directory.
* misc/Makefile (headers): Add sys/mtio.h.
* include/sys/mtio.h: New wrapper.
* elf/link.h, inet/aliases.h, misc/sys/xattr.h:
Don't include sys/types.h. Include bits/types/size_t.h.
* gmon/sys/gmon.h: Don't include sys/types.h.
* gmon/sys/profil.h: Don't include sys/types.h.
Include bits/types/size_t.h and bits/types/struct_timeval.h.
* io/fts.h: Don't include sys/types.h.
Include bits/types/dev_t.h, bits/types/ino_t.h, bits/types/ino64_t.h,
and bits/types/nlink_t.h.
* io/sys/sendfile.h: Don't include sys/types.h.
Include bits/types.h, bits/types/off_t.h, bits/types/size_t.h,
and bits/types/ssize_t.h.
* stdlib/sys/random.h: Don't include sys/types.h.
Include bits/types/size_t.h and bits/types/ssize_t.h.
* gmon/tst-sprofil.h: Include sys/time.h.
* sysdeps/mach/hurd/sendfile.c: Include sys/types.h.
* sysdeps/unix/sysv/linux/sys/epoll.h: Don’t include stdint.h
or sys/types.h. Do include features.h and bits/types.h.
(union epoll_data, struct epoll_event): Use __uint32_t and
__uint64_t for field types.
* sysdeps/unix/sysv/linux/alpha/bits/epoll.h
* sysdeps/unix/sysv/linux/bits/epoll.h
* sysdeps/unix/sysv/linux/hppa/bits/epoll.h
* sysdeps/unix/sysv/linux/mips/bits/epoll.h
* sysdeps/unix/sysv/linux/sparc/bits/epoll.h
* sysdeps/unix/sysv/linux/x86/bits/epoll.h:
Add multiple inclusion guard.
* sysdeps/unix/sysv/linux/alpha/sys/acct.h: Style fix.
* sysdeps/unix/sysv/linux/sys/acct.h: Include features.h
and bits/stdint-uintn.h. Don't include sys/types.h, stdint.h,
or bits/types/time_t.h.
* sysdeps/unix/sysv/linux/sys/fsuid.h
* sysdeps/unix/sysv/linux/sys/quota.h
Include bits/types.h, not sys/types.h.
* sysdeps/nptl/sys/procfs.h: Include features.h and bits/types.h,
not sys/types.h.
* sysdeps/nptl/thread_db.h: Don’t include sys/types.h.
* sysdeps/nptl/proc_service.h: Include bits/types/pid_t.h and
bits/types/size_t.h.
* sysdeps/unix/sysv/linux/sys/procfs.h: Include bits/types.h and
bits/types/struct_timeval.h, not sys/time.h or sys/types.h.
* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Add multiple
inclusion guard. Include bits/types.h. Correct a comment.
* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h:
Add multiple inclusion guard. Include sys/ucontext.h.
* sysdeps/unix/sysv/linux/alpha/bits/procfs.h
* sysdeps/unix/sysv/linux/sparc/bits/procfs.h
Add multiple inclusion guard. Don’t include signal.h or sys/ucontext.h.
* sysdeps/unix/sysv/linux/ia64/bits/procfs.h:
Add multiple inclusion guard. Include sys/ucontext.h, not signal.h.
* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h:
Add multiple inclusion guard. Don’t include signal.h or
sys/ucontext.h. Include bits/wordsize.h and asm/elf.h.
Adjust conditional for whether to provide various fallback
definitions.
* sysdeps/unix/sysv/linux/arm/bits/procfs.h
* sysdeps/unix/sysv/linux/csky/bits/procfs.h
* sysdeps/unix/sysv/linux/hppa/bits/procfs.h
* sysdeps/unix/sysv/linux/m68k/bits/procfs.h
* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
* sysdeps/unix/sysv/linux/mips/bits/procfs.h
* sysdeps/unix/sysv/linux/nios2/bits/procfs.h
* sysdeps/unix/sysv/linux/riscv/bits/procfs.h
* sysdeps/unix/sysv/linux/s390/bits/procfs.h
* sysdeps/unix/sysv/linux/sh/bits/procfs.h
* sysdeps/unix/sysv/linux/x86/bits/procfs.h:
Add multiple inclusion guard. Improve commentary.
* sysdeps/posix/dl-fileid.h (r_file_id): Use __dev_t and __ino64_t
for field types.
* nss/nss.h
* sysdeps/powerpc/sys/platform/ppc.h
* sysdeps/unix/sysv/linux/sys/eventfd.h
* sysdeps/unix/sysv/linux/sys/fanotify.h
* sysdeps/unix/sysv/linux/sys/inotify.h
* sysdeps/unix/sysv/linux/sys/raw.h
* sysdeps/unix/sysv/linux/sys/signalfd.h:
Include bits/types.h, not stdint.h.
Include features.h where not already doing so.
Use __(u)intN_t types instead of (u)intN_t types in all
declarations.
* sysdeps/unix/sysv/linux/powerpc/bits/powerpc.h:
Use __uint64_t instead of uint64_t.
* nss/tst-nss-test4.c: Include stdint.h.
* bits/fcntl.h: Add multiple include guard. Hoist inclusion of
bits/types.h to top of file.
* sysdeps/mach/hurd/bits/fcntl.h: Add multiple include guard.
Include bits/types.h, not sys/types.h; remove redundant inclusion
of bits/types.h in middle of file.
* bits/sem.h: Add multiple include guard. Include bits/types.h,
not sys/types.h.
* sysdeps/gnu/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise.
* sysvipc/sys/sem.h: Include bits/types/pid_t.h and
bits/types/time_t.h.
* resolv/bits/types/res_state.h: Include bits/types.h, not
sys/types.h. Use __uint32_t and __uint16_t, not uint32_t and
uint16_t.
* sysdeps/mach/hurd/bits/socket.h: Include bits/types.h, not
sys/types.h.
* sysdeps/unix/sysv/linux/bits/socket.h: Likewise. Use __pid_t,
__uid_t, and __gid_t, not pid_t, uid_t, and gid_t.
* socket/sys/socket.h: Include bits/types.h, bits/types/ssize_t.h,
and bits/types/socklen_t.h.
* inet/htonl.c, include/htons.c: Include endian.h.
* include/netinet/ether.h: Include bits/types/size_t.h.
* scripts/check-obsolete-constructs.py
(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.
* sysdeps/mach/hurd/i386/Makefile: Update list of xfails for
bug 23088.
Diffstat (limited to 'sysdeps/s390/tst-dl-runtime.c')
0 files changed, 0 insertions, 0 deletions