[22/25] Minimize includes of unrelated public headers by networking headers.

Message ID 20190626175029.4699-13-zackw@panix.com
State New
Headers show
Series
  • Public header file hygiene improvements for 2.30
Related show

Commit Message

Zack Weinberg June 26, 2019, 5:50 p.m.
Stop including sys/param.h, sys/types.h, stdint.h, inttypes.h,
stdio.h, and string.h from network-related headers.  This is done
separately from earlier patches because the network headers are extra
messy, and are also more likely to contain quirks inherited verbatim
from 4.xBSD than the bulk of our public headers.

Rose and NetROM are based on AX.25 so it makes practical sense for
netrose/rose.h and netrom/netrom.h to continue including netax25/ax25.h.

The only copies of ip_icmp.h and udp.h in the source tree are moved
from sysdeps/gnu to inet (after which there are no longer any netinet/
headers in sysdeps/gnu).

Much as sys/un.h needs to duplicate the prototype for strlen,
netinet/icmp6.h needs to duplicate the prototype for memset.  I am
open to better ideas on that front.

	* resolv/resolv.h: Include bits/types.h, bits/types/FILE.h,
	and bits/types/size_t.h; don’t include sys/param.h, sys/types.h,
	or stdio.h.  Use __uint16_t and __uint32_t instead of uint16_t and
	uint32_t.
	* resolv/arpa/nameser.h: Include features.h, bits/types.h, and
	bits/types/size_t.h; don’t include sys/param.h, sys/types.h, or
	stdint.h.  Use __uint16_t and __uint32_t instead of uint16_t and
	uint32_t.
	* resolv/arpa/nameser_compat.h: Include features.h.

	* sysdeps/mach/hurd/net/ethernet.h: Include bits/types.h;
	don’t include sys/types.h or stdint.h.  Use __uint8_t and
	__uint16_t instead of uint8_t and uint16_t.
	* sysdeps/unix/sysv/linux/net/ethernet.h: Include features.h and
	bits/types.h; don’t include sys/types.h or stdint.h.
	Use __uint8_t and __uint16_t instead of uint8_t and uint16_t.
	* sysdeps/unix/sysv/linux/netinet/if_ether.h:  Include features.h
	and bits/types.h.  Use __uint8_t instead of uint8_t.

	* sysdeps/mach/hurd/net/if_arp.h: Don’t include sys/types.h or
	stdint.h. Use __uint32_t instead of uint32_t.
	* sysdeps/unix/sysv/linux/net/if_arp.h: Include features.h.
	Don’t include sys/types.h or stdint.h. Use __uint32_t instead of
	uint32_t.

	* sysdeps/mach/hurd/net/route.h: Don’t include sys/types.h.
	* sysdeps/unix/sysv/linux/net/route.h: Don’t include sys/types.h.

	* sysdeps/unix/sysv/linux/net/if_ppp.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h.  Use
	__uint8_t and __uint32_t instead of uint8_t and uint32_t.
	* sysdeps/unix/sysv/linux/net/if_shaper.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h.  Use
	__uint16_t and __uint32_t instead of uint16_t and uint32_t.

	* sysdeps/unix/sysv/linux/netatalk/at.h: Include features.h,
	bits/types.h, and sys/ioctl.h.  Don’t include asm/types.h or
	linux/atalk.h.  Copy over all user-appropriate definitions from
	linux/atalk.h with adjustments for glibc context.

	* grp/initgroups.c, nscd/initgrcache.c, nss/nss_db/db-XXX.c
	* resolv/ns_print.c, resolv/tst-ns_name_compress.c
	* resolv/tst-res_hnok.c, support/resolv_test.c:
	Include stdio.h.

	* nscd/initgrcache.c, nscd/netgroupcache.c
	* nss/nss_compat/compat-grp.c, nss/nss_compat/compat-pwd.c
	* nss/nss_compat/compat-spwd.c, resolv/ns_print.c:
	Include sys/param.h for MIN and/or MAX.

	* resolv/tst-resolv-res_init-skeleton.c: Include signal.h.

	* inet/protocols/rwhod.h: Include features.h and bits/types.h.
	Don’t include sys/types.h.  Use __int32_t instead of int32_t.
	* inet/protocols/talkd.h: Include features.h and bits/types.h.
	Don’t include sys/types.h, sys/socket.h, or stdint.h. Use
	__int32_t and __uint32_t instead of int32_t and uint32_t.
	* inet/protocols/timed.h: Include features.h, bits/types.h,
	and bits/types/struct_timeval.h. Don’t include sys/types.h or
	sys/time.h.
	* sysdeps/unix/sysv/linux/netipx/ipx.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h. Use
	__uint16_t and __uint32_t instead of uint16_t and uint32_t.
	* sysdeps/unix/sysv/linux/netrose/rose.h: Include features.h.
	Don’t include sys/socket.h.

	* inet/netinet/icmp6.h: Include features.h, bits/endian.h,
	bits/types.h, and bits/types/size_t.h.  Don’t include inttypes.h,
	string.h, or sys/types.h.  Duplicate prototype of memset here.
	Use __uintN_t instead of uintN_t types.
	* inet/netinet/igmp.h: Include bits/types.h.  Don’t include sys/types.h.
	Use __uintN_t instead of uintN_t types.
	* inet/netinet/ip.h: Include bits/types.h.  Don’t include
	bits/stdint-uintn.h.  Use __uintN_t instead of uintN_t types.
	* inet/netinet/ip6.h: Include features.h, bits/endian.h, and
	bits/types.h.  Don’t include inttypes.h.  Use __uintN_t instead of
	uintN_t types.

	* inet/netinet/ip_icmp.h: Include features.h and bits/types.h.
	Don’t include sys/types.h or stdint.h.  Use __uintN_t instead of
	uintN_t types.
	* inet/netinet/udp.h: Likewise.
	* sysdeps/generic/netinet/if_ether.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_ether.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_fddi.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_tr.h: Likewise.

	* sysdeps/gnu/netinet/ip_icmp.h: Move to inet/netinet/ip_icmp.h.
	* sysdeps/gnu/netinet/udp.h: Move to inet/netinet/udp.h.
	* include/netinet/ip_icmp.h, include/netinet/udp.h: New wrappers.
	* sysdeps/gnu/Makefile: Remove $(subdir)==inet stanza.
	* inet/Makefile (headers): Add netinet/ip_icmp.h and
	netinet/udp.h. Don’t use $(wildcard *.h) for arpa and protocols
	headers.  Sort list.

	* scripts/check-obsolete-constructs.py
	(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.
---
 grp/initgroups.c                           |   1 +
 include/netinet/ip_icmp.h                  |   1 +
 include/netinet/udp.h                      |   1 +
 inet/Makefile                              |  11 +-
 inet/netinet/icmp6.h                       | 123 +++++++++++----------
 inet/netinet/igmp.h                        |   9 +-
 inet/netinet/ip.h                          |  40 +++----
 inet/netinet/ip6.h                         |  86 +++++++-------
 {sysdeps/gnu => inet}/netinet/ip_icmp.h    |  56 +++++-----
 {sysdeps/gnu => inet}/netinet/udp.h        |  20 ++--
 inet/protocols/rwhod.h                     |   5 +-
 inet/protocols/talkd.h                     |  11 +-
 inet/protocols/timed.h                     |   5 +-
 nscd/initgrcache.c                         |   2 +
 nscd/netgroupcache.c                       |   1 +
 nss/nss_compat/compat-grp.c                |   1 +
 nss/nss_compat/compat-pwd.c                |   1 +
 nss/nss_compat/compat-spwd.c               |   1 +
 nss/nss_db/db-XXX.c                        |   1 +
 resolv/arpa/nameser.h                      |  34 +++---
 resolv/arpa/nameser_compat.h               |   1 +
 resolv/ns_print.c                          |   2 +
 resolv/resolv.h                            |  13 ++-
 resolv/tst-ns_name_compress.c              |   1 +
 resolv/tst-res_hnok.c                      |   1 +
 scripts/check-obsolete-constructs.py       |  53 ++++-----
 support/resolv_test.c                      |   1 +
 sysdeps/generic/netinet/if_ether.h         |   6 +-
 sysdeps/gnu/Makefile                       |   5 -
 sysdeps/mach/hurd/net/ethernet.h           |  12 +-
 sysdeps/mach/hurd/net/if_arp.h             |   5 +-
 sysdeps/mach/hurd/net/route.h              |   3 +-
 sysdeps/unix/sysv/linux/net/ethernet.h     |  12 +-
 sysdeps/unix/sysv/linux/net/if_arp.h       |   5 +-
 sysdeps/unix/sysv/linux/net/if_ppp.h       |  10 +-
 sysdeps/unix/sysv/linux/net/if_shaper.h    |   8 +-
 sysdeps/unix/sysv/linux/net/route.h        |   2 +-
 sysdeps/unix/sysv/linux/netatalk/at.h      |  41 ++++++-
 sysdeps/unix/sysv/linux/netinet/if_ether.h |  21 ++--
 sysdeps/unix/sysv/linux/netinet/if_fddi.h  |  14 ++-
 sysdeps/unix/sysv/linux/netinet/if_tr.h    |  68 ++++++------
 sysdeps/unix/sysv/linux/netipx/ipx.h       |  10 +-
 sysdeps/unix/sysv/linux/netrose/rose.h     |   2 +-
 43 files changed, 370 insertions(+), 336 deletions(-)
 create mode 100644 include/netinet/ip_icmp.h
 create mode 100644 include/netinet/udp.h
 rename {sysdeps/gnu => inet}/netinet/ip_icmp.h (91%)
 rename {sysdeps/gnu => inet}/netinet/udp.h (91%)

-- 
2.20.1

Patch

diff --git a/grp/initgroups.c b/grp/initgroups.c
index a22f33c934..6edfb0a678 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -19,6 +19,7 @@ 
 #include <errno.h>
 #include <grp.h>
 #include <limits.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
diff --git a/include/netinet/ip_icmp.h b/include/netinet/ip_icmp.h
new file mode 100644
index 0000000000..f8d0080f68
--- /dev/null
+++ b/include/netinet/ip_icmp.h
@@ -0,0 +1 @@ 
+#include <inet/netinet/ip_icmp.h>
diff --git a/include/netinet/udp.h b/include/netinet/udp.h
new file mode 100644
index 0000000000..c45cb0bedd
--- /dev/null
+++ b/include/netinet/udp.h
@@ -0,0 +1 @@ 
+#include <inet/netinet/udp.h>
diff --git a/inet/Makefile b/inet/Makefile
index e2371033a7..a58278a1e1 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -22,10 +22,13 @@  subdir	:= inet
 
 include ../Makeconfig
 
-headers	:= netinet/ether.h netinet/in.h netinet/in_systm.h \
-	   netinet/if_ether.h netinet/igmp.h \
-	   netinet/tcp.h netinet/ip.h $(wildcard arpa/*.h protocols/*.h) \
-	   aliases.h ifaddrs.h netinet/ip6.h netinet/icmp6.h bits/in.h
+headers	:= aliases.h ifaddrs.h bits/in.h				     \
+           netinet/ether.h netinet/icmp6.h netinet/if_ether.h netinet/igmp.h \
+           netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h	     \
+	   netinet/ip_icmp.h netinet/tcp.h netinet/udp.h		     \
+	   arpa/ftp.h arpa/inet.h arpa/telnet.h arpa/tftp.h		     \
+           protocols/routed.h protocols/rwhod.h protocols/talkd.h	     \
+	   protocols/timed.h
 
 routines := htonl htons		\
 	    inet_lnaof inet_mkadr	\
diff --git a/inet/netinet/icmp6.h b/inet/netinet/icmp6.h
index 92e84cfd21..5119085391 100644
--- a/inet/netinet/icmp6.h
+++ b/inet/netinet/icmp6.h
@@ -18,9 +18,10 @@ 
 #ifndef _NETINET_ICMP6_H
 #define _NETINET_ICMP6_H 1
 
-#include <inttypes.h>
-#include <string.h>
-#include <sys/types.h>
+#include <features.h>
+#include <bits/endian.h>
+#include <bits/types.h>
+#include <bits/types/size_t.h>
 #include <netinet/in.h>
 
 #define ICMP6_FILTER 1
@@ -32,19 +33,19 @@ 
 
 struct icmp6_filter
   {
-    uint32_t icmp6_filt[8];
+    __uint32_t icmp6_filt[8];
   };
 
 struct icmp6_hdr
   {
-    uint8_t     icmp6_type;   /* type field */
-    uint8_t     icmp6_code;   /* code field */
-    uint16_t    icmp6_cksum;  /* checksum field */
+    __uint8_t     icmp6_type;   /* type field */
+    __uint8_t     icmp6_code;   /* code field */
+    __uint16_t    icmp6_cksum;  /* checksum field */
     union
       {
-	uint32_t  icmp6_un_data32[1]; /* type-specific field */
-	uint16_t  icmp6_un_data16[2]; /* type-specific field */
-	uint8_t   icmp6_un_data8[4];  /* type-specific field */
+	__uint32_t  icmp6_un_data32[1]; /* type-specific field */
+	__uint16_t  icmp6_un_data16[2]; /* type-specific field */
+	__uint8_t   icmp6_un_data8[4];  /* type-specific field */
       } icmp6_dataun;
   };
 
@@ -96,6 +97,8 @@  struct icmp6_hdr
 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
 	((((filterp)->icmp6_filt[(type) >> 5]) |=  (1 << ((type) & 31))))
 
+extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
+
 #define ICMP6_FILTER_SETPASSALL(filterp) \
 	memset (filterp, 0, sizeof (struct icmp6_filter));
 
@@ -122,8 +125,8 @@  struct nd_router_solicit      /* router solicitation */
 struct nd_router_advert       /* router advertisement */
   {
     struct icmp6_hdr  nd_ra_hdr;
-    uint32_t   nd_ra_reachable;   /* reachable time */
-    uint32_t   nd_ra_retransmit;  /* retransmit timer */
+    __uint32_t   nd_ra_reachable;   /* reachable time */
+    __uint32_t   nd_ra_retransmit;  /* retransmit timer */
     /* could be followed by options */
   };
 
@@ -185,8 +188,8 @@  struct nd_redirect            /* redirect */
 
 struct nd_opt_hdr             /* Neighbor discovery option header */
   {
-    uint8_t  nd_opt_type;
-    uint8_t  nd_opt_len;        /* in units of 8 octets */
+    __uint8_t  nd_opt_type;
+    __uint8_t  nd_opt_len;        /* in units of 8 octets */
     /* followed by option specific data */
   };
 
@@ -200,13 +203,13 @@  struct nd_opt_hdr             /* Neighbor discovery option header */
 
 struct nd_opt_prefix_info     /* prefix information */
   {
-    uint8_t   nd_opt_pi_type;
-    uint8_t   nd_opt_pi_len;
-    uint8_t   nd_opt_pi_prefix_len;
-    uint8_t   nd_opt_pi_flags_reserved;
-    uint32_t  nd_opt_pi_valid_time;
-    uint32_t  nd_opt_pi_preferred_time;
-    uint32_t  nd_opt_pi_reserved2;
+    __uint8_t   nd_opt_pi_type;
+    __uint8_t   nd_opt_pi_len;
+    __uint8_t   nd_opt_pi_prefix_len;
+    __uint8_t   nd_opt_pi_flags_reserved;
+    __uint32_t  nd_opt_pi_valid_time;
+    __uint32_t  nd_opt_pi_preferred_time;
+    __uint32_t  nd_opt_pi_reserved2;
     struct in6_addr  nd_opt_pi_prefix;
   };
 
@@ -216,19 +219,19 @@  struct nd_opt_prefix_info     /* prefix information */
 
 struct nd_opt_rd_hdr          /* redirected header */
   {
-    uint8_t   nd_opt_rh_type;
-    uint8_t   nd_opt_rh_len;
-    uint16_t  nd_opt_rh_reserved1;
-    uint32_t  nd_opt_rh_reserved2;
+    __uint8_t   nd_opt_rh_type;
+    __uint8_t   nd_opt_rh_len;
+    __uint16_t  nd_opt_rh_reserved1;
+    __uint32_t  nd_opt_rh_reserved2;
     /* followed by IP header and data */
   };
 
 struct nd_opt_mtu             /* MTU option */
   {
-    uint8_t   nd_opt_mtu_type;
-    uint8_t   nd_opt_mtu_len;
-    uint16_t  nd_opt_mtu_reserved;
-    uint32_t  nd_opt_mtu_mtu;
+    __uint8_t   nd_opt_mtu_type;
+    __uint8_t   nd_opt_mtu_len;
+    __uint16_t  nd_opt_mtu_reserved;
+    __uint32_t  nd_opt_mtu_mtu;
   };
 
 struct mld_hdr
@@ -248,10 +251,10 @@  struct mld_hdr
 struct icmp6_router_renum    /* router renumbering header */
   {
     struct icmp6_hdr    rr_hdr;
-    uint8_t             rr_segnum;
-    uint8_t             rr_flags;
-    uint16_t            rr_maxdelay;
-    uint32_t            rr_reserved;
+    __uint8_t           rr_segnum;
+    __uint8_t           rr_flags;
+    __uint16_t          rr_maxdelay;
+    __uint32_t          rr_reserved;
   };
 
 #define rr_type		rr_hdr.icmp6_type
@@ -268,13 +271,13 @@  struct icmp6_router_renum    /* router renumbering header */
 
 struct rr_pco_match    /* match prefix part */
   {
-    uint8_t             rpm_code;
-    uint8_t             rpm_len;
-    uint8_t             rpm_ordinal;
-    uint8_t             rpm_matchlen;
-    uint8_t             rpm_minlen;
-    uint8_t             rpm_maxlen;
-    uint16_t            rpm_reserved;
+    __uint8_t           rpm_code;
+    __uint8_t           rpm_len;
+    __uint8_t           rpm_ordinal;
+    __uint8_t           rpm_matchlen;
+    __uint8_t           rpm_minlen;
+    __uint8_t           rpm_maxlen;
+    __uint16_t          rpm_reserved;
     struct in6_addr     rpm_prefix;
   };
 
@@ -285,13 +288,13 @@  struct rr_pco_match    /* match prefix part */
 
 struct rr_pco_use      /* use prefix part */
   {
-    uint8_t             rpu_uselen;
-    uint8_t             rpu_keeplen;
-    uint8_t             rpu_ramask;
-    uint8_t             rpu_raflags;
-    uint32_t            rpu_vltime;
-    uint32_t            rpu_pltime;
-    uint32_t            rpu_flags;
+    __uint8_t           rpu_uselen;
+    __uint8_t           rpu_keeplen;
+    __uint8_t           rpu_ramask;
+    __uint8_t           rpu_raflags;
+    __uint32_t          rpu_vltime;
+    __uint32_t          rpu_pltime;
+    __uint32_t          rpu_flags;
     struct in6_addr     rpu_prefix;
   };
 
@@ -308,10 +311,10 @@  struct rr_pco_use      /* use prefix part */
 
 struct rr_result       /* router renumbering result message */
   {
-    uint16_t            rrr_flags;
-    uint8_t             rrr_ordinal;
-    uint8_t             rrr_matchedlen;
-    uint32_t            rrr_ifid;
+    __uint16_t          rrr_flags;
+    __uint8_t           rrr_ordinal;
+    __uint8_t           rrr_matchedlen;
+    __uint32_t          rrr_ifid;
     struct in6_addr     rrr_prefix;
   };
 
@@ -326,20 +329,20 @@  struct rr_result       /* router renumbering result message */
 /* Mobile IPv6 extension: Advertisement Interval.  */
 struct nd_opt_adv_interval
   {
-    uint8_t   nd_opt_adv_interval_type;
-    uint8_t   nd_opt_adv_interval_len;
-    uint16_t  nd_opt_adv_interval_reserved;
-    uint32_t  nd_opt_adv_interval_ival;
+    __uint8_t   nd_opt_adv_interval_type;
+    __uint8_t   nd_opt_adv_interval_len;
+    __uint16_t  nd_opt_adv_interval_reserved;
+    __uint32_t  nd_opt_adv_interval_ival;
   };
 
 /* Mobile IPv6 extension: Home Agent Info.  */
 struct nd_opt_home_agent_info
   {
-    uint8_t   nd_opt_home_agent_info_type;
-    uint8_t   nd_opt_home_agent_info_len;
-    uint16_t  nd_opt_home_agent_info_reserved;
-    uint16_t  nd_opt_home_agent_info_preference;
-    uint16_t  nd_opt_home_agent_info_lifetime;
+    __uint8_t   nd_opt_home_agent_info_type;
+    __uint8_t   nd_opt_home_agent_info_len;
+    __uint16_t  nd_opt_home_agent_info_reserved;
+    __uint16_t  nd_opt_home_agent_info_preference;
+    __uint16_t  nd_opt_home_agent_info_lifetime;
   };
 
 #endif /* netinet/icmpv6.h */
diff --git a/inet/netinet/igmp.h b/inet/netinet/igmp.h
index 2884db59df..6eafc19a73 100644
--- a/inet/netinet/igmp.h
+++ b/inet/netinet/igmp.h
@@ -20,11 +20,10 @@ 
 
 #include <features.h>
 
-#include <sys/types.h>
-
 #ifdef __USE_MISC
 
 #include <netinet/in.h>
+#include <bits/types.h>
 
 __BEGIN_DECLS
 
@@ -65,9 +64,9 @@  __BEGIN_DECLS
  */
 
 struct igmp {
-  uint8_t igmp_type;             /* IGMP type */
-  uint8_t igmp_code;             /* routing code */
-  uint16_t igmp_cksum;           /* checksum */
+  __uint8_t igmp_type;           /* IGMP type */
+  __uint8_t igmp_code;           /* routing code */
+  __uint16_t igmp_cksum;         /* checksum */
   struct in_addr igmp_group;     /* group address */
 };
 
diff --git a/inet/netinet/ip.h b/inet/netinet/ip.h
index 35f61d1694..fa6b588c42 100644
--- a/inet/netinet/ip.h
+++ b/inet/netinet/ip.h
@@ -22,14 +22,14 @@ 
 
 #include <netinet/in.h>
 #include <bits/endian.h>
-#include <bits/stdint-uintn.h>
+#include <bits/types.h>
 
 __BEGIN_DECLS
 
 struct timestamp
   {
-    uint8_t len;
-    uint8_t ptr;
+    __uint8_t len;
+    __uint8_t ptr;
 #if __BYTE_ORDER == __LITTLE_ENDIAN
     unsigned int flags:4;
     unsigned int overflow:4;
@@ -39,7 +39,7 @@  struct timestamp
 #else
 # error	"Please fix <bits/endian.h>"
 #endif
-    uint32_t data[9];
+    __uint32_t data[9];
   };
 
 struct iphdr
@@ -53,15 +53,15 @@  struct iphdr
 #else
 # error	"Please fix <bits/endian.h>"
 #endif
-    uint8_t tos;
-    uint16_t tot_len;
-    uint16_t id;
-    uint16_t frag_off;
-    uint8_t ttl;
-    uint8_t protocol;
-    uint16_t check;
-    uint32_t saddr;
-    uint32_t daddr;
+    __uint8_t tos;
+    __uint16_t tot_len;
+    __uint16_t id;
+    __uint16_t frag_off;
+    __uint8_t ttl;
+    __uint8_t protocol;
+    __uint16_t check;
+    __uint32_t saddr;
+    __uint32_t daddr;
     /*The options start here. */
   };
 
@@ -115,7 +115,7 @@  struct ip
     unsigned int ip_v:4;		/* version */
     unsigned int ip_hl:4;		/* header length */
 #endif
-    uint8_t ip_tos;			/* type of service */
+    __uint8_t ip_tos;			/* type of service */
     unsigned short ip_len;		/* total length */
     unsigned short ip_id;		/* identification */
     unsigned short ip_off;		/* fragment offset field */
@@ -123,8 +123,8 @@  struct ip
 #define	IP_DF 0x4000			/* dont fragment flag */
 #define	IP_MF 0x2000			/* more fragments flag */
 #define	IP_OFFMASK 0x1fff		/* mask for fragmenting bits */
-    uint8_t ip_ttl;			/* time to live */
-    uint8_t ip_p;			/* protocol */
+    __uint8_t ip_ttl;			/* time to live */
+    __uint8_t ip_p;			/* protocol */
     unsigned short ip_sum;		/* checksum */
     struct in_addr ip_src, ip_dst;	/* source and dest address */
   };
@@ -134,9 +134,9 @@  struct ip
  */
 struct ip_timestamp
   {
-    uint8_t ipt_code;			/* IPOPT_TS */
-    uint8_t ipt_len;			/* size of structure (variable) */
-    uint8_t ipt_ptr;			/* index of current entry */
+    __uint8_t ipt_code;			/* IPOPT_TS */
+    __uint8_t ipt_len;			/* size of structure (variable) */
+    __uint8_t ipt_ptr;			/* index of current entry */
 #if __BYTE_ORDER == __LITTLE_ENDIAN
     unsigned int ipt_flg:4;		/* flags, see below */
     unsigned int ipt_oflw:4;		/* overflow counter */
@@ -145,7 +145,7 @@  struct ip_timestamp
     unsigned int ipt_oflw:4;		/* overflow counter */
     unsigned int ipt_flg:4;		/* flags, see below */
 #endif
-    uint32_t data[9];
+    __uint32_t data[9];
   };
 #endif /* __USE_MISC */
 
diff --git a/inet/netinet/ip6.h b/inet/netinet/ip6.h
index 157a27d2df..e2a8d2b356 100644
--- a/inet/netinet/ip6.h
+++ b/inet/netinet/ip6.h
@@ -18,8 +18,10 @@ 
 #ifndef _NETINET_IP6_H
 #define _NETINET_IP6_H 1
 
-#include <inttypes.h>
+#include <features.h>
 #include <netinet/in.h>
+#include <bits/endian.h>
+#include <bits/types.h>
 
 struct ip6_hdr
   {
@@ -27,13 +29,13 @@  struct ip6_hdr
       {
 	struct ip6_hdrctl
 	  {
-	    uint32_t ip6_un1_flow;   /* 4 bits version, 8 bits TC,
-					20 bits flow-ID */
-	    uint16_t ip6_un1_plen;   /* payload length */
-	    uint8_t  ip6_un1_nxt;    /* next header */
-	    uint8_t  ip6_un1_hlim;   /* hop limit */
+	    __uint32_t ip6_un1_flow;   /* 4 bits version, 8 bits TC,
+					  20 bits flow-ID */
+	    __uint16_t ip6_un1_plen;   /* payload length */
+	    __uint8_t  ip6_un1_nxt;    /* next header */
+	    __uint8_t  ip6_un1_hlim;   /* hop limit */
 	  } ip6_un1;
-	uint8_t ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
+	__uint8_t ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
       } ip6_ctlun;
     struct in6_addr ip6_src;      /* source address */
     struct in6_addr ip6_dst;      /* destination address */
@@ -49,45 +51,45 @@  struct ip6_hdr
 /* Generic extension header.  */
 struct ip6_ext
   {
-    uint8_t  ip6e_nxt;		/* next header.  */
-    uint8_t  ip6e_len;		/* length in units of 8 octets.  */
+    __uint8_t  ip6e_nxt;	/* next header.  */
+    __uint8_t  ip6e_len;	/* length in units of 8 octets.  */
   };
 
 /* Hop-by-Hop options header.  */
 struct ip6_hbh
   {
-    uint8_t  ip6h_nxt;		/* next header.  */
-    uint8_t  ip6h_len;		/* length in units of 8 octets.  */
+    __uint8_t  ip6h_nxt;	/* next header.  */
+    __uint8_t  ip6h_len;	/* length in units of 8 octets.  */
     /* followed by options */
   };
 
 /* Destination options header */
 struct ip6_dest
   {
-    uint8_t  ip6d_nxt;		/* next header */
-    uint8_t  ip6d_len;		/* length in units of 8 octets */
+    __uint8_t  ip6d_nxt;	/* next header */
+    __uint8_t  ip6d_len;	/* length in units of 8 octets */
     /* followed by options */
   };
 
 /* Routing header */
 struct ip6_rthdr
   {
-    uint8_t  ip6r_nxt;		/* next header */
-    uint8_t  ip6r_len;		/* length in units of 8 octets */
-    uint8_t  ip6r_type;		/* routing type */
-    uint8_t  ip6r_segleft;	/* segments left */
+    __uint8_t  ip6r_nxt;	/* next header */
+    __uint8_t  ip6r_len;	/* length in units of 8 octets */
+    __uint8_t  ip6r_type;	/* routing type */
+    __uint8_t  ip6r_segleft;	/* segments left */
     /* followed by routing type specific data */
   };
 
 /* Type 0 Routing header */
 struct ip6_rthdr0
   {
-    uint8_t  ip6r0_nxt;		/* next header */
-    uint8_t  ip6r0_len;		/* length in units of 8 octets */
-    uint8_t  ip6r0_type;	/* always zero */
-    uint8_t  ip6r0_segleft;	/* segments left */
-    uint8_t  ip6r0_reserved;	/* reserved field */
-    uint8_t  ip6r0_slmap[3];	/* strict/loose bit map */
+    __uint8_t  ip6r0_nxt;	/* next header */
+    __uint8_t  ip6r0_len;	/* length in units of 8 octets */
+    __uint8_t  ip6r0_type;	/* always zero */
+    __uint8_t  ip6r0_segleft;	/* segments left */
+    __uint8_t  ip6r0_reserved;	/* reserved field */
+    __uint8_t  ip6r0_slmap[3];	/* strict/loose bit map */
     /* followed by up to 127 struct in6_addr */
     struct in6_addr ip6r0_addr[0];
   };
@@ -95,10 +97,10 @@  struct ip6_rthdr0
 /* Fragment header */
 struct ip6_frag
   {
-    uint8_t   ip6f_nxt;		/* next header */
-    uint8_t   ip6f_reserved;	/* reserved field */
-    uint16_t  ip6f_offlg;	/* offset, reserved, and flag */
-    uint32_t  ip6f_ident;	/* identification */
+    __uint8_t   ip6f_nxt;	/* next header */
+    __uint8_t   ip6f_reserved;	/* reserved field */
+    __uint16_t  ip6f_offlg;	/* offset, reserved, and flag */
+    __uint32_t  ip6f_ident;	/* identification */
   };
 
 #if __BYTE_ORDER == __BIG_ENDIAN
@@ -114,8 +116,8 @@  struct ip6_frag
 /* IPv6 options */
 struct ip6_opt
   {
-    uint8_t  ip6o_type;
-    uint8_t  ip6o_len;
+    __uint8_t  ip6o_type;
+    __uint8_t  ip6o_len;
   };
 
 /* The high-order 3 bits of the option type define the behavior
@@ -141,19 +143,19 @@  struct ip6_opt
 /* Jumbo Payload Option */
 struct ip6_opt_jumbo
   {
-    uint8_t  ip6oj_type;
-    uint8_t  ip6oj_len;
-    uint8_t  ip6oj_jumbo_len[4];
+    __uint8_t  ip6oj_type;
+    __uint8_t  ip6oj_len;
+    __uint8_t  ip6oj_jumbo_len[4];
   };
 #define IP6OPT_JUMBO_LEN	6
 
 /* NSAP Address Option */
 struct ip6_opt_nsap
   {
-    uint8_t  ip6on_type;
-    uint8_t  ip6on_len;
-    uint8_t  ip6on_src_nsap_len;
-    uint8_t  ip6on_dst_nsap_len;
+    __uint8_t  ip6on_type;
+    __uint8_t  ip6on_len;
+    __uint8_t  ip6on_src_nsap_len;
+    __uint8_t  ip6on_dst_nsap_len;
       /* followed by source NSAP */
       /* followed by destination NSAP */
   };
@@ -161,17 +163,17 @@  struct ip6_opt_nsap
 /* Tunnel Limit Option */
 struct ip6_opt_tunnel
   {
-    uint8_t  ip6ot_type;
-    uint8_t  ip6ot_len;
-    uint8_t  ip6ot_encap_limit;
+    __uint8_t  ip6ot_type;
+    __uint8_t  ip6ot_len;
+    __uint8_t  ip6ot_encap_limit;
   };
 
 /* Router Alert Option */
 struct ip6_opt_router
   {
-    uint8_t  ip6or_type;
-    uint8_t  ip6or_len;
-    uint8_t  ip6or_value[2];
+    __uint8_t  ip6or_type;
+    __uint8_t  ip6or_len;
+    __uint8_t  ip6or_value[2];
   };
 
 /* Router alert values (in network byte order) */
diff --git a/sysdeps/gnu/netinet/ip_icmp.h b/inet/netinet/ip_icmp.h
similarity index 91%
rename from sysdeps/gnu/netinet/ip_icmp.h
rename to inet/netinet/ip_icmp.h
index 2e2bfe9ff6..da7ff3b81b 100644
--- a/sysdeps/gnu/netinet/ip_icmp.h
+++ b/inet/netinet/ip_icmp.h
@@ -18,28 +18,28 @@ 
 #ifndef __NETINET_IP_ICMP_H
 #define __NETINET_IP_ICMP_H    1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 
 __BEGIN_DECLS
 
 struct icmphdr
 {
-  uint8_t type;		/* message type */
-  uint8_t code;		/* type sub-code */
-  uint16_t checksum;
+  __uint8_t type;		/* message type */
+  __uint8_t code;		/* type sub-code */
+  __uint16_t checksum;
   union
   {
     struct
     {
-      uint16_t	id;
-      uint16_t	sequence;
+      __uint16_t	id;
+      __uint16_t	sequence;
     } echo;			/* echo datagram */
-    uint32_t	gateway;	/* gateway address */
+    __uint32_t	gateway;	/* gateway address */
     struct
     {
-      uint16_t	__glibc_reserved;
-      uint16_t	mtu;
+      __uint16_t	__glibc_reserved;
+      __uint16_t	mtu;
     } frag;			/* path mtu discovery */
   } un;
 };
@@ -130,38 +130,38 @@  struct icmphdr
  */
 struct icmp_ra_addr
 {
-  uint32_t ira_addr;
-  uint32_t ira_preference;
+  __uint32_t ira_addr;
+  __uint32_t ira_preference;
 };
 
 struct icmp
 {
-  uint8_t  icmp_type;	/* type of message, see below */
-  uint8_t  icmp_code;	/* type sub code */
-  uint16_t icmp_cksum;	/* ones complement checksum of struct */
+  __uint8_t  icmp_type;	/* type of message, see below */
+  __uint8_t  icmp_code;	/* type sub code */
+  __uint16_t icmp_cksum;	/* ones complement checksum of struct */
   union
   {
     unsigned char ih_pptr;	/* ICMP_PARAMPROB */
     struct in_addr ih_gwaddr;	/* gateway address */
     struct ih_idseq		/* echo datagram */
     {
-      uint16_t icd_id;
-      uint16_t icd_seq;
+      __uint16_t icd_id;
+      __uint16_t icd_seq;
     } ih_idseq;
-    uint32_t ih_void;
+    __uint32_t ih_void;
 
     /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
     struct ih_pmtu
     {
-      uint16_t ipm_void;
-      uint16_t ipm_nextmtu;
+      __uint16_t ipm_void;
+      __uint16_t ipm_nextmtu;
     } ih_pmtu;
 
     struct ih_rtradv
     {
-      uint8_t irt_num_addrs;
-      uint8_t irt_wpa;
-      uint16_t irt_lifetime;
+      __uint8_t irt_num_addrs;
+      __uint8_t irt_wpa;
+      __uint16_t irt_lifetime;
     } ih_rtradv;
   } icmp_hun;
 #define	icmp_pptr	icmp_hun.ih_pptr
@@ -178,9 +178,9 @@  struct icmp
   {
     struct
     {
-      uint32_t its_otime;
-      uint32_t its_rtime;
-      uint32_t its_ttime;
+      __uint32_t its_otime;
+      __uint32_t its_rtime;
+      __uint32_t its_ttime;
     } id_ts;
     struct
     {
@@ -188,8 +188,8 @@  struct icmp
       /* options and then 64 bits of data */
     } id_ip;
     struct icmp_ra_addr id_radv;
-    uint32_t   id_mask;
-    uint8_t    id_data[1];
+    __uint32_t  id_mask;
+    __uint8_t   id_data[1];
   } icmp_dun;
 #define	icmp_otime	icmp_dun.id_ts.its_otime
 #define	icmp_rtime	icmp_dun.id_ts.its_rtime
diff --git a/sysdeps/gnu/netinet/udp.h b/inet/netinet/udp.h
similarity index 91%
rename from sysdeps/gnu/netinet/udp.h
rename to inet/netinet/udp.h
index b6822cb3e2..481cbeae60 100644
--- a/sysdeps/gnu/netinet/udp.h
+++ b/inet/netinet/udp.h
@@ -47,8 +47,8 @@ 
 #ifndef __NETINET_UDP_H
 #define __NETINET_UDP_H    1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 
 /* UDP header as specified by RFC 768, August 1980. */
 
@@ -58,17 +58,17 @@  struct udphdr
   {
     struct
     {
-      uint16_t uh_sport;	/* source port */
-      uint16_t uh_dport;	/* destination port */
-      uint16_t uh_ulen;		/* udp length */
-      uint16_t uh_sum;		/* udp checksum */
+      __uint16_t uh_sport;	/* source port */
+      __uint16_t uh_dport;	/* destination port */
+      __uint16_t uh_ulen;	/* udp length */
+      __uint16_t uh_sum;	/* udp checksum */
     };
     struct
     {
-      uint16_t source;
-      uint16_t dest;
-      uint16_t len;
-      uint16_t check;
+      __uint16_t source;
+      __uint16_t dest;
+      __uint16_t len;
+      __uint16_t check;
     };
   };
 };
diff --git a/inet/protocols/rwhod.h b/inet/protocols/rwhod.h
index 446d6f97b8..74fe1f926c 100644
--- a/inet/protocols/rwhod.h
+++ b/inet/protocols/rwhod.h
@@ -32,7 +32,8 @@ 
 #ifndef _PROTOCOLS_RWHOD_H
 #define	_PROTOCOLS_RWHOD_H 1
 
-#include <sys/types.h>
+#include <features.h>
+#include <bits/types.h>
 
 /*
  * rwho protocol packet format.
@@ -40,7 +41,7 @@ 
 struct	outmp {
 	char	out_line[8];		/* tty name */
 	char	out_name[8];		/* user id */
-	int32_t	out_time;		/* time on */
+	__int32_t out_time;		/* time on */
 };
 
 struct	whod {
diff --git a/inet/protocols/talkd.h b/inet/protocols/talkd.h
index 09bd8a90ba..5068e981b7 100644
--- a/inet/protocols/talkd.h
+++ b/inet/protocols/talkd.h
@@ -50,9 +50,8 @@ 
  * stream connection through which the conversation takes place.
  */
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 #include <bits/types/struct_osockaddr.h>
 
 /*
@@ -63,10 +62,10 @@  typedef struct {
 	unsigned char	type;	/* request type, see below */
 	unsigned char	answer;	/* not used */
 	unsigned char	pad;
-	uint32_t id_num;	/* message id */
+	__uint32_t	id_num;	/* message id */
 	struct	osockaddr addr;		/* old (4.3) style */
 	struct	osockaddr ctl_addr;	/* old (4.3) style */
-	int32_t	pid;		/* caller's process id */
+	__int32_t	pid;		/* caller's process id */
 #define	NAME_SIZE	12
 	char	l_name[NAME_SIZE];/* caller's name */
 	char	r_name[NAME_SIZE];/* callee's name */
@@ -82,7 +81,7 @@  typedef struct {
 	unsigned char	type;	/* type of request message, see below */
 	unsigned char	answer;	/* response to request message, see below */
 	unsigned char	pad;
-	uint32_t	id_num;	/* message id */
+	__uint32_t	id_num;	/* message id */
 	struct	osockaddr addr;	/* address for establishing conversation */
 } CTL_RESPONSE;
 
diff --git a/inet/protocols/timed.h b/inet/protocols/timed.h
index cabdce44a6..5ec9de87a7 100644
--- a/inet/protocols/timed.h
+++ b/inet/protocols/timed.h
@@ -32,8 +32,9 @@ 
 #ifndef	_PROTOCOLS_TIMED_H
 #define	_PROTOCOLS_TIMED_H 1
 
-#include <sys/types.h>
-#include <sys/time.h>
+#include <features.h>
+#include <bits/types.h>
+#include <bits/types/struct_timeval.h>
 
 /*
  * Time Synchronization Protocol
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index cf38c59b8e..678666563d 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -20,10 +20,12 @@ 
 #include <errno.h>
 #include <grp.h>
 #include <libintl.h>
+#include <stdio.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <sys/param.h>
 #include <scratch_buffer.h>
 #include <config.h>
 
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index cda276eade..8fcb092657 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -24,6 +24,7 @@ 
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <sys/param.h>
 
 #include "../inet/netgroup.h"
 #include "nscd.h"
diff --git a/nss/nss_compat/compat-grp.c b/nss/nss_compat/compat-grp.c
index 8f01e44a72..c46a0dc186 100644
--- a/nss/nss_compat/compat-grp.c
+++ b/nss/nss_compat/compat-grp.c
@@ -24,6 +24,7 @@ 
 #include <nsswitch.h>
 #include <stdio_ext.h>
 #include <string.h>
+#include <sys/param.h>
 #include <libc-lock.h>
 #include <kernel-features.h>
 
diff --git a/nss/nss_compat/compat-pwd.c b/nss/nss_compat/compat-pwd.c
index 37f883f35a..4b6734acae 100644
--- a/nss/nss_compat/compat-pwd.c
+++ b/nss/nss_compat/compat-pwd.c
@@ -25,6 +25,7 @@ 
 #include <pwd.h>
 #include <stdio_ext.h>
 #include <string.h>
+#include <sys/param.h>
 #include <libc-lock.h>
 #include <kernel-features.h>
 
diff --git a/nss/nss_compat/compat-spwd.c b/nss/nss_compat/compat-spwd.c
index bd310ab9aa..3eaa6e866b 100644
--- a/nss/nss_compat/compat-spwd.c
+++ b/nss/nss_compat/compat-spwd.c
@@ -25,6 +25,7 @@ 
 #include <shadow.h>
 #include <stdio_ext.h>
 #include <string.h>
+#include <sys/param.h>
 #include <libc-lock.h>
 #include <kernel-features.h>
 
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c
index e17bbff52b..ac3586ec67 100644
--- a/nss/nss_db/db-XXX.c
+++ b/nss/nss_db/db-XXX.c
@@ -18,6 +18,7 @@ 
 
 #include <dlfcn.h>
 #include <fcntl.h>
+#include <stdio.h>
 #include <stdint.h>
 #include <sys/mman.h>
 #include <libc-lock.h>
diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h
index a99d5ec508..4ce57bd3f9 100644
--- a/resolv/arpa/nameser.h
+++ b/resolv/arpa/nameser.h
@@ -48,9 +48,9 @@ 
 #ifndef _ARPA_NAMESER_H_
 #define _ARPA_NAMESER_H_
 
-#include <sys/param.h>
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
+#include <bits/types/size_t.h>
 
 /*
  * Define constants based on RFC 883, RFC 1034, RFC 1035
@@ -92,7 +92,7 @@  typedef enum __ns_sect {
  */
 typedef struct __ns_msg {
 	const unsigned char	*_msg, *_eom;
-	uint16_t		_id, _flags, _counts[ns_s_max];
+	__uint16_t		_id, _flags, _counts[ns_s_max];
 	const unsigned char	*_sections[ns_s_max];
 	ns_sect			_sect;
 	int			_rrnum;
@@ -116,10 +116,10 @@  extern const struct _ns_flagdata _ns_flagdata[];
  */
 typedef	struct __ns_rr {
 	char			name[NS_MAXDNAME];
-	uint16_t		type;
-	uint16_t		rr_class;
-	uint32_t		ttl;
-	uint16_t		rdlength;
+	__uint16_t		type;
+	__uint16_t		rr_class;
+	__uint32_t		ttl;
+	__uint16_t		rdlength;
 	const unsigned char *	rdata;
 } ns_rr;
 
@@ -355,24 +355,24 @@  typedef enum __ns_cert_types {
  */
 #define NS_GET16(s, cp) do { \
 	const unsigned char *t_cp = (const unsigned char *)(cp); \
-	(s) = ((uint16_t)t_cp[0] << 8) \
-	    | ((uint16_t)t_cp[1]) \
+	(s) = ((__uint16_t)t_cp[0] << 8) \
+	    | ((__uint16_t)t_cp[1]) \
 	    ; \
 	(cp) += NS_INT16SZ; \
 } while (0)
 
 #define NS_GET32(l, cp) do { \
 	const unsigned char *t_cp = (const unsigned char *)(cp); \
-	(l) = ((uint32_t)t_cp[0] << 24) \
-	    | ((uint32_t)t_cp[1] << 16) \
-	    | ((uint32_t)t_cp[2] << 8) \
-	    | ((uint32_t)t_cp[3]) \
+	(l) = ((__uint32_t)t_cp[0] << 24) \
+	    | ((__uint32_t)t_cp[1] << 16) \
+	    | ((__uint32_t)t_cp[2] << 8) \
+	    | ((__uint32_t)t_cp[3]) \
 	    ; \
 	(cp) += NS_INT32SZ; \
 } while (0)
 
 #define NS_PUT16(s, cp) do { \
-	uint16_t t_s = (uint16_t)(s); \
+	__uint16_t t_s = (__uint16_t)(s); \
 	unsigned char *t_cp = (unsigned char *)(cp); \
 	*t_cp++ = t_s >> 8; \
 	*t_cp   = t_s; \
@@ -380,7 +380,7 @@  typedef enum __ns_cert_types {
 } while (0)
 
 #define NS_PUT32(l, cp) do { \
-	uint32_t t_l = (uint32_t)(l); \
+	__uint32_t t_l = (__uint32_t)(l); \
 	unsigned char *t_cp = (unsigned char *)(cp); \
 	*t_cp++ = t_l >> 24; \
 	*t_cp++ = t_l >> 16; \
@@ -408,7 +408,7 @@  int		ns_sprintrrf (const unsigned char *, size_t, const char *,
 			      const char *, char *, size_t) __THROW;
 int		ns_format_ttl (unsigned long, char *, size_t) __THROW;
 int		ns_parse_ttl (const char *, unsigned long *) __THROW;
-uint32_t	ns_datetosecs (const char *, int *) __THROW;
+__uint32_t	ns_datetosecs (const char *, int *) __THROW;
 int		ns_name_ntol (const unsigned char *, unsigned char *, size_t)
      __THROW;
 int		ns_name_ntop (const unsigned char *, char *, size_t) __THROW;
diff --git a/resolv/arpa/nameser_compat.h b/resolv/arpa/nameser_compat.h
index 37c178b524..8996d376da 100644
--- a/resolv/arpa/nameser_compat.h
+++ b/resolv/arpa/nameser_compat.h
@@ -29,6 +29,7 @@ 
 #ifndef _ARPA_NAMESER_COMPAT_
 #define	_ARPA_NAMESER_COMPAT_
 
+#include <features.h>
 #include <bits/endian.h>
 
 /*%
diff --git a/resolv/ns_print.c b/resolv/ns_print.c
index d61f5044b1..1dbcfb8910 100644
--- a/resolv/ns_print.c
+++ b/resolv/ns_print.c
@@ -19,6 +19,7 @@ 
 /* Import. */
 
 #include <sys/types.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 
 #include <netinet/in.h>
@@ -28,6 +29,7 @@ 
 #include <assert.h>
 #include <errno.h>
 #include <resolv.h>
+#include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 
diff --git a/resolv/resolv.h b/resolv/resolv.h
index b4ef66fdfa..5783de697d 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -54,11 +54,12 @@ 
 
 #include <features.h>
 
-#include <sys/param.h>
-#include <sys/types.h>
-#include <stdio.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
+
+#include <bits/types.h>
+#include <bits/types/FILE.h>
+#include <bits/types/size_t.h>
 #include <bits/types/res_state.h>
 
 /*
@@ -248,10 +249,10 @@  int		loc_aton (const char *__ascii, unsigned char *__binary) __THROW;
 const char *	loc_ntoa (const unsigned char *__binary, char *__ascii) __THROW;
 int		dn_skipname (const unsigned char *, const unsigned char *)
      __THROW;
-void		putlong (uint32_t, unsigned char *) __THROW;
-void		putshort (uint16_t, unsigned char *) __THROW;
+void		putlong (__uint32_t, unsigned char *) __THROW;
+void		putshort (__uint16_t, unsigned char *) __THROW;
 const char *	p_class (int) __THROW;
-const char *	p_time (uint32_t) __THROW;
+const char *	p_time (__uint32_t) __THROW;
 const char *	p_type (int) __THROW;
 const char *	p_rcode (int) __THROW;
 const unsigned char * p_cdnname (const unsigned char *,
diff --git a/resolv/tst-ns_name_compress.c b/resolv/tst-ns_name_compress.c
index 00b6e811b8..019edf722d 100644
--- a/resolv/tst-ns_name_compress.c
+++ b/resolv/tst-ns_name_compress.c
@@ -17,6 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <resolv.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <support/check.h>
diff --git a/resolv/tst-res_hnok.c b/resolv/tst-res_hnok.c
index a85449d284..3bc18163c4 100644
--- a/resolv/tst-res_hnok.c
+++ b/resolv/tst-res_hnok.c
@@ -18,6 +18,7 @@ 
 
 #include <array_length.h>
 #include <resolv.h>
+#include <stdio.h>
 #include <string.h>
 #include <support/check.h>
 #include <support/test-driver.h>
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 1ecb7c9823..db367e61ae 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -607,44 +607,30 @@  HEADER_ALLOWED_INCLUDES = {
 
     # Nonstandardized networking headers
     "ifaddrs.h":                   [ "sys/socket.h" ],
-    "resolv.h":                    [ "arpa/nameser.h", "netinet/in.h",
-                                     "stdio.h", "sys/param.h",
-                                     "sys/types.h" ],
 
-    "arpa/nameser.h":              [ "arpa/nameser_compat.h", "stdint.h",
-                                     "sys/param.h", "sys/types.h" ],
-    "net/ethernet.h":              [ "stdint.h", "sys/types.h",
-                                     "net/if_ether.h" ],
-    "net/if_arp.h":                [ "stdint.h", "sys/socket.h",
-                                     "sys/types.h" ],
-    "net/if_ppp.h":                [ "net/if.h", "net/ppp_defs.h", "stdint.h",
-                                     "sys/ioctl.h", "sys/types.h" ],
-    "net/if_shaper.h":             [ "net/if.h", "stdint.h", "sys/ioctl.h",
-                                     "sys/types.h" ],
-    "net/route.h":                 [ "netinet/in.h", "sys/socket.h",
-                                     "sys/types.h" ],
-    "netatalk/at.h":               [ "sys/socket.h" ],
+    "resolv.h":                    [ "arpa/nameser.h", "netinet/in.h" ],
+    "arpa/nameser.h":              [ "arpa/nameser_compat.h" ],
+
+    "net/ethernet.h":              [ "net/if_ether.h" ],
+    "net/if_arp.h":                [ "sys/socket.h" ],
+    "net/if_ppp.h":                [ "net/if.h", "net/ppp_defs.h",
+                                     "sys/ioctl.h" ],
+    "net/if_shaper.h":             [ "net/if.h", "sys/ioctl.h" ],
+    "net/route.h":                 [ "netinet/in.h", "sys/socket.h" ],
+    "netatalk/at.h":               [ "sys/socket.h", "sys/ioctl.h" ],
+
     "netinet/ether.h":             [ "netinet/if_ether.h" ],
-    "netinet/icmp6.h":             [ "inttypes.h", "netinet/in.h", "string.h",
-                                     "sys/types.h" ],
-    "netinet/if_ether.h":          [ "net/ethernet.h", "net/if_arp.h",
-                                     "sys/types.h", "stdint.h" ],
-    "netinet/if_fddi.h":           [ "stdint.h", "sys/types.h" ],
-    "netinet/if_tr.h":             [ "stdint.h", "sys/types.h" ],
-    "netinet/igmp.h":              [ "netinet/in.h", "sys/types.h" ],
+    "netinet/icmp6.h":             [ "netinet/in.h" ],
+    "netinet/if_ether.h":          [ "net/ethernet.h", "net/if_arp.h" ],
+    "netinet/igmp.h":              [ "netinet/in.h" ],
     "netinet/ip.h":                [ "netinet/in.h" ],
-    "netinet/ip6.h":               [ "inttypes.h", "netinet/in.h" ],
-    "netinet/ip_icmp.h":           [ "netinet/in.h", "netinet/ip.h",
-                                     "stdint.h", "sys/types.h" ],
-    "netinet/udp.h":               [ "stdint.h", "sys/types.h" ],
-    "netipx/ipx.h":                [ "stdint.h", "sys/types.h" ],
+    "netinet/ip6.h":               [ "netinet/in.h" ],
+    "netinet/ip_icmp.h":           [ "netinet/in.h", "netinet/ip.h" ],
+
     "netrom/netrom.h":             [ "netax25/ax25.h" ],
-    "netrose/rose.h":              [ "netax25/ax25.h", "sys/socket.h" ],
+    "netrose/rose.h":              [ "netax25/ax25.h" ],
     "protocols/routed.h":          [ "sys/socket.h" ],
-    "protocols/rwhod.h":           [ "paths.h", "sys/types.h" ],
-    "protocols/talkd.h":           [ "stdint.h", "sys/socket.h",
-                                     "sys/types.h" ],
-    "protocols/timed.h":           [ "sys/time.h", "sys/types.h" ],
+    "protocols/rwhod.h":           [ "paths.h" ],
 
     # Internal headers
     "features.h":                  [ "gnu/stubs.h", "stdc-predef.h",
@@ -682,7 +668,6 @@  SYSDEP_ALLOWED_INCLUDES = {
         "net/ethernet.h":          [ "linux/if_ether.h" ],
         "net/if_slip.h":           [ "linux/if_slip.h" ],
         "net/ppp_defs.h":          [ "asm/types.h", "linux/ppp_defs.h" ],
-        "netatalk/at.h":           [ "asm/types.h", "linux/atalk.h" ],
         "netinet/if_ether.h":      [ "linux/if_ether.h" ],
         "netinet/if_fddi.h":       [ "linux/if_fddi.h" ],
 
diff --git a/support/resolv_test.c b/support/resolv_test.c
index 903ab2ac05..45d8ec79ea 100644
--- a/support/resolv_test.c
+++ b/support/resolv_test.c
@@ -24,6 +24,7 @@ 
 #include <nss.h>
 #include <resolv.h>
 #include <search.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <support/check.h>
diff --git a/sysdeps/generic/netinet/if_ether.h b/sysdeps/generic/netinet/if_ether.h
index 985581732e..f4fd66da65 100644
--- a/sysdeps/generic/netinet/if_ether.h
+++ b/sysdeps/generic/netinet/if_ether.h
@@ -18,8 +18,8 @@ 
 #ifndef __NETINET_IF_ETHER_H
 #define __NETINET_IF_ETHER_H	1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 
 #define ETH_ALEN	6	/* Octets in one ethernet address.  */
 
@@ -27,7 +27,7 @@ 
    systems.  */
 struct ether_addr
 {
-  uint8_t ether_addr_octet[ETH_ALEN];
+  __uint8_t ether_addr_octet[ETH_ALEN];
 } __attribute__ ((__packed__));
 
 #endif /* netinet/if_ether.h */
diff --git a/sysdeps/gnu/Makefile b/sysdeps/gnu/Makefile
index fdfbfc45d8..9da12c540d 100644
--- a/sysdeps/gnu/Makefile
+++ b/sysdeps/gnu/Makefile
@@ -59,11 +59,6 @@  $(foreach o,$(object-suffixes) $(object-suffixes:=.d),\
 endif
 
 
-ifeq ($(subdir),inet)
-sysdep_headers += netinet/udp.h netinet/ip_icmp.h
-endif
-
-
 ifeq ($(subdir),csu)
 routines += unwind-resume
 shared-only-routines += unwind-resume
diff --git a/sysdeps/mach/hurd/net/ethernet.h b/sysdeps/mach/hurd/net/ethernet.h
index 8956694b59..3003523869 100644
--- a/sysdeps/mach/hurd/net/ethernet.h
+++ b/sysdeps/mach/hurd/net/ethernet.h
@@ -22,9 +22,7 @@ 
 #define __NET_ETHERNET_H 1
 
 #include <features.h>
-
-#include <sys/types.h>
-#include <stdint.h>
+#include <bits/types.h>
 #include <net/if_ether.h>     /* IEEE 802.3 Ethernet constants */
 
 __BEGIN_DECLS
@@ -33,15 +31,15 @@  __BEGIN_DECLS
    systems.  */
 struct ether_addr
 {
-  uint8_t ether_addr_octet[ETH_ALEN];
+  __uint8_t ether_addr_octet[ETH_ALEN];
 };
 
 /* 10Mb/s ethernet header */
 struct ether_header
 {
-  uint8_t  ether_dhost[ETH_ALEN];	/* destination eth addr	*/
-  uint8_t  ether_shost[ETH_ALEN];	/* source ether addr	*/
-  uint16_t ether_type;		        /* packet type ID field	*/
+  __uint8_t  ether_dhost[ETH_ALEN];	/* destination eth addr	*/
+  __uint8_t  ether_shost[ETH_ALEN];	/* source ether addr	*/
+  __uint16_t ether_type;	        /* packet type ID field	*/
 };
 
 /* Ethernet protocol ID's */
diff --git a/sysdeps/mach/hurd/net/if_arp.h b/sysdeps/mach/hurd/net/if_arp.h
index 9e1b2233ce..38665feab4 100644
--- a/sysdeps/mach/hurd/net/if_arp.h
+++ b/sysdeps/mach/hurd/net/if_arp.h
@@ -23,10 +23,7 @@ 
 #define _NET_IF_ARP_H 1
 
 #include <features.h>
-
-#include <sys/types.h>
 #include <sys/socket.h>
-#include <stdint.h>
 
 __BEGIN_DECLS
 
@@ -133,7 +130,7 @@  struct arpreq
 struct arpd_request
   {
     unsigned short int req;		/* Request type.  */
-    uint32_t ip;			/* IP address of entry.  */
+    __uint32_t ip;			/* IP address of entry.  */
     unsigned long int dev;		/* Device entry is tied to.  */
     unsigned long int stamp;
     unsigned long int updated;
diff --git a/sysdeps/mach/hurd/net/route.h b/sysdeps/mach/hurd/net/route.h
index 4924f099b9..fcb79bb33d 100644
--- a/sysdeps/mach/hurd/net/route.h
+++ b/sysdeps/mach/hurd/net/route.h
@@ -18,12 +18,11 @@ 
 /* Based on the 4.4BSD and Linux version of this file.  */
 
 #ifndef _NET_ROUTE_H
-
 #define _NET_ROUTE_H	1
+
 #include <features.h>
 
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <netinet/in.h>
 
 
diff --git a/sysdeps/unix/sysv/linux/net/ethernet.h b/sysdeps/unix/sysv/linux/net/ethernet.h
index 7e49297de6..1833511c9a 100644
--- a/sysdeps/unix/sysv/linux/net/ethernet.h
+++ b/sysdeps/unix/sysv/linux/net/ethernet.h
@@ -21,8 +21,8 @@ 
 #ifndef __NET_ETHERNET_H
 #define __NET_ETHERNET_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 
 #include <linux/if_ether.h>     /* IEEE 802.3 Ethernet constants */
 
@@ -32,15 +32,15 @@  __BEGIN_DECLS
    systems.  */
 struct ether_addr
 {
-  uint8_t ether_addr_octet[ETH_ALEN];
+  __uint8_t ether_addr_octet[ETH_ALEN];
 } __attribute__ ((__packed__));
 
 /* 10Mb/s ethernet header */
 struct ether_header
 {
-  uint8_t  ether_dhost[ETH_ALEN];	/* destination eth addr	*/
-  uint8_t  ether_shost[ETH_ALEN];	/* source ether addr	*/
-  uint16_t ether_type;		        /* packet type ID field	*/
+  __uint8_t  ether_dhost[ETH_ALEN];	/* destination eth addr	*/
+  __uint8_t  ether_shost[ETH_ALEN];	/* source ether addr	*/
+  __uint16_t ether_type;	        /* packet type ID field	*/
 } __attribute__ ((__packed__));
 
 /* Ethernet protocol ID's */
diff --git a/sysdeps/unix/sysv/linux/net/if_arp.h b/sysdeps/unix/sysv/linux/net/if_arp.h
index f64dcfd9d8..5013d085a2 100644
--- a/sysdeps/unix/sysv/linux/net/if_arp.h
+++ b/sysdeps/unix/sysv/linux/net/if_arp.h
@@ -22,9 +22,8 @@ 
 #ifndef _NET_IF_ARP_H
 #define _NET_IF_ARP_H 1
 
-#include <sys/types.h>
+#include <features.h>
 #include <sys/socket.h>
-#include <stdint.h>
 
 __BEGIN_DECLS
 
@@ -171,7 +170,7 @@  struct arpreq_old
 struct arpd_request
   {
     unsigned short int req;		/* Request type.  */
-    uint32_t ip;			/* IP address of entry.  */
+    __uint32_t ip;			/* IP address of entry.  */
     unsigned long int dev;		/* Device entry is tied to.  */
     unsigned long int stamp;
     unsigned long int updated;
diff --git a/sysdeps/unix/sysv/linux/net/if_ppp.h b/sysdeps/unix/sysv/linux/net/if_ppp.h
index 31a20766f0..1fd813ba8e 100644
--- a/sysdeps/unix/sysv/linux/net/if_ppp.h
+++ b/sysdeps/unix/sysv/linux/net/if_ppp.h
@@ -48,10 +48,10 @@ 
 #ifndef __NET_IF_PPP_H
 #define __NET_IF_PPP_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
-#include <net/if.h>
+#include <features.h>
+#include <bits/types.h>
 #include <sys/ioctl.h>
+#include <net/if.h>
 #include <net/ppp_defs.h>
 
 __BEGIN_DECLS
@@ -113,8 +113,8 @@  struct npioctl {
 
 /* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
 struct ppp_option_data {
-	uint8_t  *ptr;
-	uint32_t length;
+	__uint8_t  *ptr;
+	__uint32_t length;
 	int	 transmit;
 };
 
diff --git a/sysdeps/unix/sysv/linux/net/if_shaper.h b/sysdeps/unix/sysv/linux/net/if_shaper.h
index 77ab6306ac..0ccc2a90cf 100644
--- a/sysdeps/unix/sysv/linux/net/if_shaper.h
+++ b/sysdeps/unix/sysv/linux/net/if_shaper.h
@@ -18,8 +18,8 @@ 
 #ifndef _NET_IF_SHAPER_H
 #define _NET_IF_SHAPER_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
 
@@ -43,11 +43,11 @@  __BEGIN_DECLS
 
 struct shaperconf
 {
-  uint16_t ss_cmd;
+  __uint16_t ss_cmd;
   union
   {
     char ssu_name[14];
-    uint32_t ssu_speed;
+    __uint32_t ssu_speed;
   } ss_u;
 #define ss_speed ss_u.ssu_speed
 #define ss_name ss_u.ssu_name
diff --git a/sysdeps/unix/sysv/linux/net/route.h b/sysdeps/unix/sysv/linux/net/route.h
index a6bda2157f..a0d9a74af4 100644
--- a/sysdeps/unix/sysv/linux/net/route.h
+++ b/sysdeps/unix/sysv/linux/net/route.h
@@ -21,8 +21,8 @@ 
 #define _NET_ROUTE_H	1
 
 #include <features.h>
+
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <netinet/in.h>
 #include <bits/wordsize.h>
 
diff --git a/sysdeps/unix/sysv/linux/netatalk/at.h b/sysdeps/unix/sysv/linux/netatalk/at.h
index 61fb67590c..f78d6b8a07 100644
--- a/sysdeps/unix/sysv/linux/netatalk/at.h
+++ b/sysdeps/unix/sysv/linux/netatalk/at.h
@@ -18,11 +18,46 @@ 
 #ifndef _NETATALK_AT_H
 #define _NETATALK_AT_H 1
 
-#include <asm/types.h>
+#include <features.h>
+#include <bits/types.h>
 #include <bits/sockaddr.h>
-#include <linux/atalk.h>
-#include <sys/socket.h>
 
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+/* Constants from linux/atalk.h as of kernel version 5.0.  */
+
+#define ATPORT_FIRST	1
+#define ATPORT_RESERVED	128
+#define ATPORT_LAST	254	/* 254 is only legal on localtalk */
+#define ATADDR_ANYNET	0
+#define ATADDR_ANYNODE	0
+#define ATADDR_ANYPORT  0
+#define ATADDR_BCAST	255
+#define DDP_MAXSZ	587
+#define DDP_MAXHOPS     15	/* 4 bits of hop counter */
 #define SOL_ATALK       258     /* sockopt level for atalk */
+#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
+
+struct atalk_addr
+{
+  __uint16_t	s_net;  /* network byte order */
+  __uint8_t	s_node;
+};
+
+struct atalk_netrange
+{
+  __uint8_t	nr_phase;
+  __uint16_t	nr_firstnet; /* network byte order */
+  __uint16_t	nr_lastnet;  /* network byte order */
+};
+
+struct sockaddr_at
+{
+  __SOCKADDR_COMMON (sat_);
+  __uint8_t sat_port;
+  struct atalk_addr sat_addr;
+  __uint8_t sat_zero[8];
+};
 
 #endif	/* netatalk/at.h */
diff --git a/sysdeps/unix/sysv/linux/netinet/if_ether.h b/sysdeps/unix/sysv/linux/netinet/if_ether.h
index 2c0750000f..51acbfd5b7 100644
--- a/sysdeps/unix/sysv/linux/netinet/if_ether.h
+++ b/sysdeps/unix/sysv/linux/netinet/if_ether.h
@@ -16,10 +16,10 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef __NETINET_IF_ETHER_H
-
 #define __NETINET_IF_ETHER_H	1
+
 #include <features.h>
-#include <sys/types.h>
+#include <bits/types.h>
 
 /* Get definitions from kernel header file.  */
 #include <linux/if_ether.h>
@@ -56,7 +56,6 @@ 
  *	@(#)if_ether.h	8.3 (Berkeley) 5/2/95
  *	$FreeBSD$
  */
-
 #include <net/ethernet.h>
 #include <net/if_arp.h>
 
@@ -70,10 +69,10 @@  __BEGIN_DECLS
  */
 struct	ether_arp {
 	struct	arphdr ea_hdr;		/* fixed-size header */
-	uint8_t arp_sha[ETH_ALEN];	/* sender hardware address */
-	uint8_t arp_spa[4];		/* sender protocol address */
-	uint8_t arp_tha[ETH_ALEN];	/* target hardware address */
-	uint8_t arp_tpa[4];		/* target protocol address */
+	__uint8_t arp_sha[ETH_ALEN];	/* sender hardware address */
+	__uint8_t arp_spa[4];		/* sender protocol address */
+	__uint8_t arp_tha[ETH_ALEN];	/* target hardware address */
+	__uint8_t arp_tpa[4];		/* target protocol address */
 };
 #define	arp_hrd	ea_hdr.ar_hrd
 #define	arp_pro	ea_hdr.ar_pro
@@ -88,14 +87,14 @@  struct	ether_arp {
  */
 #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
 	/* struct in_addr *ipaddr; */ \
-	/* uint8_t enaddr[ETH_ALEN]; */ \
+	/* __uint8_t enaddr[ETH_ALEN]; */ \
 { \
 	(enaddr)[0] = 0x01; \
 	(enaddr)[1] = 0x00; \
 	(enaddr)[2] = 0x5e; \
-	(enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
-	(enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
-	(enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+	(enaddr)[3] = ((__uint8_t *)ipaddr)[1] & 0x7f; \
+	(enaddr)[4] = ((__uint8_t *)ipaddr)[2]; \
+	(enaddr)[5] = ((__uint8_t *)ipaddr)[3]; \
 }
 
 __END_DECLS
diff --git a/sysdeps/unix/sysv/linux/netinet/if_fddi.h b/sysdeps/unix/sysv/linux/netinet/if_fddi.h
index 2e4bb939f2..6a0e0d82d6 100644
--- a/sysdeps/unix/sysv/linux/netinet/if_fddi.h
+++ b/sysdeps/unix/sysv/linux/netinet/if_fddi.h
@@ -18,16 +18,18 @@ 
 #ifndef _NETINET_IF_FDDI_H
 #define	_NETINET_IF_FDDI_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
+
 #include <linux/if_fddi.h>
 
 #ifdef __USE_MISC
 
-struct fddi_header {
-  uint8_t fddi_fc;                    /* Frame Control (FC) value */
-  uint8_t fddi_dhost[FDDI_K_ALEN];    /* Destination host */
-  uint8_t fddi_shost[FDDI_K_ALEN];    /* Source host */
+struct fddi_header
+{
+  __uint8_t fddi_fc;                    /* Frame Control (FC) value */
+  __uint8_t fddi_dhost[FDDI_K_ALEN];    /* Destination host */
+  __uint8_t fddi_shost[FDDI_K_ALEN];    /* Source host */
 };
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/netinet/if_tr.h b/sysdeps/unix/sysv/linux/netinet/if_tr.h
index 9db6b7a6b5..6d6fd4f7cf 100644
--- a/sysdeps/unix/sysv/linux/netinet/if_tr.h
+++ b/sysdeps/unix/sysv/linux/netinet/if_tr.h
@@ -16,49 +16,49 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _NETINET_IF_TR_H
-#define	_NETINET_IF_TR_H 1
+#define _NETINET_IF_TR_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 
 /* IEEE 802.5 Token-Ring magic constants.  The frame sizes omit the preamble
    and FCS/CRC (frame check sequence). */
 #define TR_ALEN		6		/* Octets in one token-ring addr */
-#define TR_HLEN 	(sizeof (struct trh_hdr) + sizeof (struct trllc))
+#define TR_HLEN		(sizeof (struct trh_hdr) + sizeof (struct trllc))
 #define AC		0x10
-#define LLC_FRAME 	0x40
+#define LLC_FRAME	0x40
 
 /* LLC and SNAP constants */
-#define EXTENDED_SAP 	0xAA
-#define UI_CMD       	0x03
+#define EXTENDED_SAP	0xAA
+#define UI_CMD		0x03
 
 /* This is an Token-Ring frame header. */
 struct trh_hdr
 {
-  uint8_t  ac;			/* access control field */
-  uint8_t  fc;			/* frame control field */
-  uint8_t  daddr[TR_ALEN];	/* destination address */
-  uint8_t  saddr[TR_ALEN];	/* source address */
-  uint16_t rcf;			/* route control field */
-  uint16_t rseg[8];		/* routing registers */
+  __uint8_t  ac;		/* access control field */
+  __uint8_t  fc;		/* frame control field */
+  __uint8_t  daddr[TR_ALEN];	/* destination address */
+  __uint8_t  saddr[TR_ALEN];	/* source address */
+  __uint16_t rcf;		/* route control field */
+  __uint16_t rseg[8];		/* routing registers */
 };
 
 /* This is an Token-Ring LLC structure */
 struct trllc
 {
-  uint8_t  dsap;		/* destination SAP */
-  uint8_t  ssap;		/* source SAP */
-  uint8_t  llc;			/* LLC control field */
-  uint8_t  protid[3];		/* protocol id */
-  uint16_t ethertype;		/* ether type field */
+  __uint8_t  dsap;		/* destination SAP */
+  __uint8_t  ssap;		/* source SAP */
+  __uint8_t  llc;		/* LLC control field */
+  __uint8_t  protid[3];		/* protocol id */
+  __uint16_t ethertype;		/* ether type field */
 };
 
 /* Token-Ring statistics collection data. */
 struct tr_statistics
 {
-  unsigned long rx_packets;     /* total packets received	*/
+  unsigned long rx_packets;	/* total packets received	*/
   unsigned long tx_packets;	/* total packets transmitted	*/
-  unsigned long rx_bytes;	/* total bytes received   	*/
+  unsigned long rx_bytes;	/* total bytes received		*/
   unsigned long tx_bytes;	/* total bytes transmitted	*/
   unsigned long rx_errors;	/* bad packets received		*/
   unsigned long tx_errors;	/* packet transmit problems	*/
@@ -84,27 +84,27 @@  struct tr_statistics
 };
 
 /* source routing stuff */
-#define TR_RII 			0x80
-#define TR_RCF_DIR_BIT 		0x80
-#define TR_RCF_LEN_MASK 	0x1f00
-#define TR_RCF_BROADCAST 	0x8000	/* all-routes broadcast */
+#define TR_RII			 0x80
+#define TR_RCF_DIR_BIT		 0x80
+#define TR_RCF_LEN_MASK		 0x1f00
+#define TR_RCF_BROADCAST	 0x8000	/* all-routes broadcast */
 #define TR_RCF_LIMITED_BROADCAST 0xC000	/* single-route broadcast */
-#define TR_RCF_FRAME2K 		0x20
-#define TR_RCF_BROADCAST_MASK 	0xC000
-#define TR_MAXRIFLEN 		18
+#define TR_RCF_FRAME2K		 0x20
+#define TR_RCF_BROADCAST_MASK	 0xC000
+#define TR_MAXRIFLEN		 18
 
 #ifdef __USE_MISC
 
 struct trn_hdr
 {
-  uint8_t trn_ac;                /* access control field */
-  uint8_t trn_fc;                /* field control field */
-  uint8_t trn_dhost[TR_ALEN];    /* destination host */
-  uint8_t trn_shost[TR_ALEN];    /* source host */
-  uint16_t trn_rcf;              /* route control field */
-  uint16_t trn_rseg[8];          /* routing registers */
+  __uint8_t  trn_ac;		   /* access control field */
+  __uint8_t  trn_fc;		   /* field control field */
+  __uint8_t  trn_dhost[TR_ALEN];   /* destination host */
+  __uint8_t  trn_shost[TR_ALEN];   /* source host */
+  __uint16_t trn_rcf;		   /* route control field */
+  __uint16_t trn_rseg[8];	   /* routing registers */
 };
 
 #endif
 
-#endif	/* netinet/if_tr.h */
+#endif /* netinet/if_tr.h */
diff --git a/sysdeps/unix/sysv/linux/netipx/ipx.h b/sysdeps/unix/sysv/linux/netipx/ipx.h
index 6ccbb8846f..fbd3d9f380 100644
--- a/sysdeps/unix/sysv/linux/netipx/ipx.h
+++ b/sysdeps/unix/sysv/linux/netipx/ipx.h
@@ -18,8 +18,8 @@ 
 #ifndef __NETIPX_IPX_H
 #define __NETIPX_IPX_H 1
 
-#include <sys/types.h>
-#include <stdint.h>
+#include <features.h>
+#include <bits/types.h>
 #include <bits/sockaddr.h>
 
 __BEGIN_DECLS
@@ -33,10 +33,10 @@  __BEGIN_DECLS
 struct sockaddr_ipx
   {
     sa_family_t sipx_family;
-    uint16_t sipx_port;
-    uint32_t sipx_network;
+    __uint16_t sipx_port;
+    __uint32_t sipx_network;
     unsigned char sipx_node[IPX_NODE_LEN];
-    uint8_t sipx_type;
+    __uint8_t sipx_type;
     unsigned char sipx_zero;	/* 16 byte fill */
   };
 
diff --git a/sysdeps/unix/sysv/linux/netrose/rose.h b/sysdeps/unix/sysv/linux/netrose/rose.h
index ab2afb383e..1c4bd26a8f 100644
--- a/sysdeps/unix/sysv/linux/netrose/rose.h
+++ b/sysdeps/unix/sysv/linux/netrose/rose.h
@@ -21,7 +21,7 @@ 
 #ifndef _NETROSE_ROSE_H
 #define _NETROSE_ROSE_H 1
 
-#include <sys/socket.h>
+#include <features.h>
 #include <netax25/ax25.h>
 
 /* Socket level values.  */