diff options
author | Zack Weinberg <zackw@panix.com> | 2019-06-01 19:32:01 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-01-08 14:15:41 -0500 |
commit | 0e8caaf081a844893aa5bbf67010c3e34ca47f34 (patch) | |
tree | 0b0c25b99b9531f66d41cdb5821d850c70c14ce6 /resolv | |
parent | b32c5f35b8fb037bd54cde10bb14e6510171534a (diff) | |
download | glibc-0e8caaf081a844893aa5bbf67010c3e34ca47f34.zip glibc-0e8caaf081a844893aa5bbf67010c3e34ca47f34.tar.gz glibc-0e8caaf081a844893aa5bbf67010c3e34ca47f34.tar.bz2 |
Minimize includes of unrelated public headers by networking headers.
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.
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/arpa/nameser.h | 34 | ||||
-rw-r--r-- | resolv/arpa/nameser_compat.h | 1 | ||||
-rw-r--r-- | resolv/ns_print.c | 2 | ||||
-rw-r--r-- | resolv/resolv.h | 13 | ||||
-rw-r--r-- | resolv/tst-ns_name_compress.c | 1 | ||||
-rw-r--r-- | resolv/tst-res_hnok.c | 1 |
6 files changed, 29 insertions, 23 deletions
diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h index a99d5ec..4ce57bd 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 37c178b..8996d37 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 d61f504..1dbcfb8 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 ce3922c..e070755 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> /* @@ -249,10 +250,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 f2602eb..70ec7ed 100644 --- a/resolv/tst-ns_name_compress.c +++ b/resolv/tst-ns_name_compress.c @@ -17,6 +17,7 @@ <https://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 2724d5d..34f6c3c 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> |