This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc/zack/no-nested-includes] Don’t include stdint.h 1/n: easy cases
- From: Zack Weinberg <zack at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 31 May 2019 14:42:21 -0000
- Subject: [glibc/zack/no-nested-includes] Don’t include stdint.h 1/n: easy cases
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=012660cbadff12f53e6f5b8fcd40c58b287a0ea8
commit 012660cbadff12f53e6f5b8fcd40c58b287a0ea8
Author: Zack Weinberg <zackw@panix.com>
Date: Thu May 30 12:47:06 2019 -0400
Donâ??t include stdint.h 1/n: easy cases
These headers are all including <stdint.h> for a small number of
specific [u]intN_t types. I chose to change them to use
<bits/types.h> and __[u]intN_t types; this is the option which
minimizes the absolute number of names added to the user namespace by
each header. An alternative would be to have them use
<bits/stdint-[u]intn.h> and continue using user namespace types; this
option would be more conservative (less likely to break existing
application code).
* 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.
* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.
Diff:
---
nss/nss.h | 6 ++--
nss/tst-nss-test4.c | 1 +
scripts/check-obsolete-constructs.py | 8 +----
sysdeps/powerpc/sys/platform/ppc.h | 10 +++----
sysdeps/unix/sysv/linux/powerpc/bits/ppc.h | 2 +-
sysdeps/unix/sysv/linux/sys/eventfd.h | 5 ++--
sysdeps/unix/sysv/linux/sys/fanotify.h | 6 ++--
sysdeps/unix/sysv/linux/sys/inotify.h | 11 +++----
sysdeps/unix/sysv/linux/sys/raw.h | 7 +++--
sysdeps/unix/sysv/linux/sys/signalfd.h | 47 +++++++++++++++---------------
10 files changed, 51 insertions(+), 52 deletions(-)
diff --git a/nss/nss.h b/nss/nss.h
index 9d4f33e..0be3752 100644
--- a/nss/nss.h
+++ b/nss/nss.h
@@ -22,7 +22,7 @@
#define _NSS_H 1
#include <features.h>
-#include <stdint.h>
+#include <bits/types.h>
__BEGIN_DECLS
@@ -44,8 +44,8 @@ struct gaih_addrtuple
struct gaih_addrtuple *next;
char *name;
int family;
- uint32_t addr[4];
- uint32_t scopeid;
+ __uint32_t addr[4];
+ __uint32_t scopeid;
};
diff --git a/nss/tst-nss-test4.c b/nss/tst-nss-test4.c
index cf6ef46..14bea82 100644
--- a/nss/tst-nss-test4.c
+++ b/nss/tst-nss-test4.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <support/support.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 6154e2d..bd4f3c8 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -560,7 +560,6 @@ HEADER_ALLOWED_INCLUDES = {
"libintl.h": [ "locale.h" ],
"link.h": [ "dlfcn.h", "elf.h" ],
"mntent.h": [ "paths.h" ],
- "nss.h": [ "stdint.h" ],
"obstack.h": [ "stddef.h", "string.h" ],
"proc_service.h": [ "sys/procfs.h" ],
"pty.h": [ "sys/ioctl.h", "termios.h" ],
@@ -578,20 +577,15 @@ HEADER_ALLOWED_INCLUDES = {
"sys/auxv.h": [ "elf.h" ],
"sys/dir.h": [ "dirent.h" ],
"sys/elf.h": [ "sys/procfs.h" ],
- "sys/eventfd.h": [ "stdint.h" ],
- "sys/fanotify.h": [ "stdint.h" ],
"sys/file.h": [ "fcntl.h" ],
- "sys/inotify.h": [ "stdint.h" ],
"sys/ioctl.h": [ "sys/ttydefaults.h" ],
"sys/mount.h": [ "sys/ioctl.h" ],
"sys/mtio.h": [ "sys/ioctl.h" ],
"sys/param.h": [ "endian.h", "limits.h", "signal.h",
"sys/types.h" ],
- "sys/platform/ppc.h": [ "stdint.h" ],
"sys/procfs.h": [ "sys/ucontext.h", "sys/user.h" ],
"sys/ptrace.h": [ "sys/ucontext.h" ],
- "sys/raw.h": [ "stdint.h", "sys/ioctl.h" ],
- "sys/signalfd.h": [ "stdint.h" ],
+ "sys/raw.h": [ "sys/ioctl.h" ],
"sys/socketvar.h": [ "sys/socket.h" ],
"sys/termios.h": [ "termios.h" ],
"sys/timerfd.h": [ "time.h" ],
diff --git a/sysdeps/powerpc/sys/platform/ppc.h b/sysdeps/powerpc/sys/platform/ppc.h
index 40ac0a5..fe4d445 100644
--- a/sysdeps/powerpc/sys/platform/ppc.h
+++ b/sysdeps/powerpc/sys/platform/ppc.h
@@ -20,24 +20,24 @@
#define _SYS_PLATFORM_PPC_H 1
#include <features.h>
-#include <stdint.h>
+#include <bits/types.h>
#include <bits/ppc.h>
/* Read the Time Base Register. */
-static __inline__ uint64_t
+static __inline__ __uint64_t
__ppc_get_timebase (void)
{
#if __GNUC_PREREQ (4, 8)
return __builtin_ppc_get_timebase ();
#else
# ifdef __powerpc64__
- uint64_t __tb;
+ __uint64_t __tb;
/* "volatile" is necessary here, because the user expects this assembly
isn't moved after an optimization. */
__asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
return __tb;
# else /* not __powerpc64__ */
- uint32_t __tbu, __tbl, __tmp; \
+ __uint32_t __tbu, __tbl, __tmp;
__asm__ volatile ("0:\n\t"
"mftbu %0\n\t"
"mftbl %1\n\t"
@@ -45,7 +45,7 @@ __ppc_get_timebase (void)
"cmpw %0, %2\n\t"
"bne- 0b"
: "=r" (__tbu), "=r" (__tbl), "=r" (__tmp));
- return (((uint64_t) __tbu << 32) | __tbl);
+ return (((__uint64_t) __tbu << 32) | __tbl);
# endif /* not __powerpc64__ */
#endif
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/ppc.h b/sysdeps/unix/sysv/linux/powerpc/bits/ppc.h
index 4b5667a..77436a9 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/ppc.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/ppc.h
@@ -26,7 +26,7 @@
__BEGIN_DECLS
/* Read the time base frequency. */
-extern uint64_t __ppc_get_timebase_freq (void);
+extern __uint64_t __ppc_get_timebase_freq (void);
__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sys/eventfd.h b/sysdeps/unix/sysv/linux/sys/eventfd.h
index d0a9d4c..b6a6c18 100644
--- a/sysdeps/unix/sysv/linux/sys/eventfd.h
+++ b/sysdeps/unix/sysv/linux/sys/eventfd.h
@@ -18,13 +18,14 @@
#ifndef _SYS_EVENTFD_H
#define _SYS_EVENTFD_H 1
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
/* Get the platform-dependent flags. */
#include <bits/eventfd.h>
/* Type for event counter. */
-typedef uint64_t eventfd_t;
+typedef __uint64_t eventfd_t;
__BEGIN_DECLS
diff --git a/sysdeps/unix/sysv/linux/sys/fanotify.h b/sysdeps/unix/sysv/linux/sys/fanotify.h
index a37b9b6..c024f6a 100644
--- a/sysdeps/unix/sysv/linux/sys/fanotify.h
+++ b/sysdeps/unix/sysv/linux/sys/fanotify.h
@@ -18,10 +18,10 @@
#ifndef _SYS_FANOTIFY_H
#define _SYS_FANOTIFY_H 1
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
#include <linux/fanotify.h>
-
__BEGIN_DECLS
/* Create and initialize fanotify group. */
@@ -30,7 +30,7 @@ extern int fanotify_init (unsigned int __flags, unsigned int __event_f_flags)
/* Add, remove, or modify an fanotify mark on a filesystem object. */
extern int fanotify_mark (int __fanotify_fd, unsigned int __flags,
- uint64_t __mask, int __dfd, const char *__pathname)
+ __uint64_t __mask, int __dfd, const char *__pathname)
__THROW;
__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h
index 4b59b8e..4dc7fc2 100644
--- a/sysdeps/unix/sysv/linux/sys/inotify.h
+++ b/sysdeps/unix/sysv/linux/sys/inotify.h
@@ -18,7 +18,8 @@
#ifndef _SYS_INOTIFY_H
#define _SYS_INOTIFY_H 1
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
/* Get the platform-dependent flags. */
#include <bits/inotify.h>
@@ -28,9 +29,9 @@
struct inotify_event
{
int wd; /* Watch descriptor. */
- uint32_t mask; /* Watch mask. */
- uint32_t cookie; /* Cookie to synchronize two events. */
- uint32_t len; /* Length (including NULs) of name. */
+ __uint32_t mask; /* Watch mask. */
+ __uint32_t cookie; /* Cookie to synchronize two events. */
+ __uint32_t len; /* Length (including NULs) of name. */
char name __flexarr; /* Name. */
};
@@ -89,7 +90,7 @@ extern int inotify_init1 (int __flags) __THROW;
/* Add watch of object NAME to inotify instance FD. Notify about
events specified by MASK. */
-extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask)
+extern int inotify_add_watch (int __fd, const char *__name, __uint32_t __mask)
__THROW;
/* Remove the watch specified by WD from the inotify instance FD. */
diff --git a/sysdeps/unix/sysv/linux/sys/raw.h b/sysdeps/unix/sysv/linux/sys/raw.h
index b4e5a82..fbdefe0 100644
--- a/sysdeps/unix/sysv/linux/sys/raw.h
+++ b/sysdeps/unix/sysv/linux/sys/raw.h
@@ -18,7 +18,8 @@
#ifndef _SYS_RAW_H
#define _SYS_RAW_H 1
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
#include <sys/ioctl.h>
/* The major device number for raw devices. */
@@ -31,8 +32,8 @@
struct raw_config_request
{
int raw_minor;
- uint64_t block_major;
- uint64_t block_minor;
+ __uint64_t block_major;
+ __uint64_t block_minor;
};
#endif /* sys/raw.h */
diff --git a/sysdeps/unix/sysv/linux/sys/signalfd.h b/sysdeps/unix/sysv/linux/sys/signalfd.h
index 13fd8b4..5a8f035 100644
--- a/sysdeps/unix/sysv/linux/sys/signalfd.h
+++ b/sysdeps/unix/sysv/linux/sys/signalfd.h
@@ -18,7 +18,8 @@
#ifndef _SYS_SIGNALFD_H
#define _SYS_SIGNALFD_H 1
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
#include <bits/types/sigset_t.h>
/* Get the platform-dependent flags. */
@@ -26,28 +27,28 @@
struct signalfd_siginfo
{
- uint32_t ssi_signo;
- int32_t ssi_errno;
- int32_t ssi_code;
- uint32_t ssi_pid;
- uint32_t ssi_uid;
- int32_t ssi_fd;
- uint32_t ssi_tid;
- uint32_t ssi_band;
- uint32_t ssi_overrun;
- uint32_t ssi_trapno;
- int32_t ssi_status;
- int32_t ssi_int;
- uint64_t ssi_ptr;
- uint64_t ssi_utime;
- uint64_t ssi_stime;
- uint64_t ssi_addr;
- uint16_t ssi_addr_lsb;
- uint16_t __pad2;
- int32_t ssi_syscall;
- uint64_t ssi_call_addr;
- uint32_t ssi_arch;
- uint8_t __pad[28];
+ __uint32_t ssi_signo;
+ __int32_t ssi_errno;
+ __int32_t ssi_code;
+ __uint32_t ssi_pid;
+ __uint32_t ssi_uid;
+ __int32_t ssi_fd;
+ __uint32_t ssi_tid;
+ __uint32_t ssi_band;
+ __uint32_t ssi_overrun;
+ __uint32_t ssi_trapno;
+ __int32_t ssi_status;
+ __int32_t ssi_int;
+ __uint64_t ssi_ptr;
+ __uint64_t ssi_utime;
+ __uint64_t ssi_stime;
+ __uint64_t ssi_addr;
+ __uint16_t ssi_addr_lsb;
+ __uint16_t __pad2;
+ __int32_t ssi_syscall;
+ __uint64_t ssi_call_addr;
+ __uint32_t ssi_arch;
+ __uint8_t __pad[28];
};
__BEGIN_DECLS