Always include <sys/cdefs.h>.

I made a mistake caught by code review earlier, so let's try to be
safer by default.

This patch also moves all our "forwarding" headers to the guardless
just-include-the-other-thing style that we usually use. (Where we
have a comment explaining where the header comes from, I've kept
that.)

Change-Id: I37342cf5e2563c6a269b2ba61a697069b1c7913b
This commit is contained in:
Elliott Hughes 2016-07-22 14:56:18 -07:00
parent 767e8147d7
commit 203e13d97d
44 changed files with 70 additions and 135 deletions

View file

@ -25,9 +25,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ALLOCA_H
#define _ALLOCA_H
#include <sys/cdefs.h>
#define alloca(size) __builtin_alloca(size)
#endif /* _ALLOCA_H */

View file

@ -29,6 +29,8 @@
#ifndef ANDROID_API_LEVEL_H
#define ANDROID_API_LEVEL_H
#include <sys/cdefs.h>
/*
* Magic version number for a current development build, which has
* not yet turned into an official release.

View file

@ -43,6 +43,8 @@
#ifndef _AR_H_
#define _AR_H_
#include <sys/cdefs.h>
/* Pre-4BSD archives had these magic numbers in them. */
#define OARMAG1 0177555
#define OARMAG2 0177545

View file

@ -29,9 +29,10 @@
#ifndef _ARPA_INET_H_
#define _ARPA_INET_H_
#include <stdint.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS

View file

@ -40,9 +40,10 @@
#ifndef _ARPA_NAMESER_COMPAT_
#define _ARPA_NAMESER_COMPAT_
#define __BIND 19950621 /* (DEAD) interface version stamp. */
#include <endian.h>
#include <sys/cdefs.h>
#define __BIND 19950621 /* (DEAD) interface version stamp. */
/*
* Structure for query header. The order of the fields is machine- and

View file

@ -32,6 +32,8 @@
#ifndef _ARPA_TELNET_H
#define _ARPA_TELNET_H 1
#include <sys/cdefs.h>
/*
* Definitions for the TELNET protocol.
*/

View file

@ -29,6 +29,7 @@
#ifndef _BITS_POSIX_LIMITS_H_
#define _BITS_POSIX_LIMITS_H_
#include <sys/cdefs.h>
/* Any constant values here other than -1 or 200809L are explicitly specified by POSIX.1-2008. */
/* Keep it sorted. */

View file

@ -29,6 +29,7 @@
#ifndef _BITS_PTHREAD_TYPES_H_
#define _BITS_PTHREAD_TYPES_H_
#include <sys/cdefs.h>
#include <sys/types.h>
typedef long pthread_t;

View file

@ -29,6 +29,8 @@
#ifndef _BITS_SA_FAMILY_T_H_
#define _BITS_SA_FAMILY_T_H_
#include <sys/cdefs.h>
typedef unsigned short sa_family_t;
#endif

View file

@ -29,6 +29,7 @@
#ifndef _BITS_TIMESPEC_H_
#define _BITS_TIMESPEC_H_
#include <sys/cdefs.h>
#include <sys/types.h>
/*

View file

@ -29,6 +29,8 @@
#ifndef _BITS_WCHAR_LIMITS_H_
#define _BITS_WCHAR_LIMITS_H_
#include <sys/cdefs.h>
/* Both GCC and clang define __WCHAR_MAX__. */
#define WCHAR_MAX __WCHAR_MAX__

View file

@ -25,9 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _BYTESWAP_H_
#define _BYTESWAP_H_
#include <sys/cdefs.h>
#include <sys/endian.h>
#define bswap_16(x) __swap16(x)

View file

@ -25,14 +25,15 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ELF_H
#define _ELF_H
#include <linux/auxvec.h>
#include <linux/elf.h>
#include <linux/elf-em.h>
#include <machine/elf_machdep.h>
#include <sys/cdefs.h>
#define ELF32_R_INFO(sym, type) ((((Elf32_Word)sym) << 8) | ((type) & 0xff))
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)sym) << 32) | ((type) & 0xffffffff))

View file

@ -1,33 +1 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ENDIAN_H_
#define _ENDIAN_H_
#include <sys/endian.h>
#endif /* _ENDIAN_H_ */

View file

@ -35,6 +35,7 @@
#ifndef _FTS_H_
#define _FTS_H_
#include <sys/cdefs.h>
#include <sys/types.h>
typedef struct {

View file

@ -25,8 +25,9 @@
#ifndef _FTW_H
#define _FTW_H
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/stat.h>
#include <sys/types.h>
/*
* Valid flags for the 3rd argument to the function that is passed as the

View file

@ -28,8 +28,9 @@
#ifndef _LINK_H_
#define _LINK_H_
#include <sys/types.h>
#include <elf.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS

View file

@ -29,6 +29,7 @@
#ifndef _NET_ROUTE_H_
#define _NET_ROUTE_H_
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <linux/route.h>
#include <linux/in6.h>

View file

@ -66,6 +66,7 @@
#define _NETINET_ICMP6_H_
#include <netinet/in.h> /* android-added: glibc source compatibility. */
#include <sys/cdefs.h>
#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
- sizeof(struct icmp6_hdr) */

View file

@ -34,6 +34,7 @@
#ifndef _NETINET_IN_SYSTM_H_
#define _NETINET_IN_SYSTM_H_
#include <sys/cdefs.h>
#include <sys/types.h>
/*

View file

@ -64,6 +64,7 @@
#ifndef _NETINET_IP6_H_
#define _NETINET_IP6_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <linux/in6.h>

View file

@ -29,6 +29,7 @@
#ifndef _NETINET_UDP_H
#define _NETINET_UDP_H
#include <sys/cdefs.h>
#include <sys/types.h>
#include <linux/udp.h>

View file

@ -32,6 +32,8 @@
#ifndef _PATHS_H_
#define _PATHS_H_
#include <sys/cdefs.h>
#define _PATH_BSHELL "/system/bin/sh"
#define _PATH_CONSOLE "/dev/console"
#define _PATH_DEFPATH "/sbin:/system/sbin:/system/bin:/system/xbin:/vendor/bin:/vendor/xbin"

View file

@ -31,6 +31,7 @@
#include <bits/wchar_limits.h>
#include <stddef.h>
#include <sys/cdefs.h>
typedef signed char __int8_t;
typedef unsigned char __uint8_t;

View file

@ -29,6 +29,8 @@
#ifndef _INCLUDE_SYS__SYSTEM_PROPERTIES_H
#define _INCLUDE_SYS__SYSTEM_PROPERTIES_H
#include <sys/cdefs.h>
#ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#error you should #include <sys/system_properties.h> instead
#else

View file

@ -25,10 +25,13 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SYS_CACHECTL_H
#define _SYS_CACHECTL_H 1
#include <sys/cdefs.h>
#ifdef __mips__
#include <asm/cachectl.h>
#endif
#endif /* sys/cachectl.h */

View file

@ -29,6 +29,7 @@
#ifndef _SYS_MSG_H_
#define _SYS_MSG_H_
#include <sys/cdefs.h>
#include <linux/msg.h>
#endif /* _SYS_MSG_H_ */

View file

@ -25,11 +25,13 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SYS_PARAM_H_
#define _SYS_PARAM_H_
#include <limits.h>
#include <linux/param.h>
#include <sys/cdefs.h>
#define DEV_BSIZE 512

View file

@ -32,6 +32,8 @@
#ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_
#include <sys/cdefs.h>
/*
* This file defines five types of data structures: singly-linked lists,
* lists, simple queues, tail queues, and circular queues.

View file

@ -29,6 +29,8 @@
#ifndef _SYS_REG_H_
#define _SYS_REG_H_
#include <sys/cdefs.h>
#if defined(__i386__)
#define EBX 0

View file

@ -29,6 +29,7 @@
#ifndef _SYS_SEM_H_
#define _SYS_SEM_H_
#include <sys/cdefs.h>
#include <linux/sem.h>
#endif /* _SYS_SEM_H_ */

View file

@ -31,6 +31,7 @@
#include <asm/unistd.h> /* Linux kernel __NR_* names. */
#include <bits/glibc-syscalls.h> /* glibc-compatible SYS_* aliases. */
#include <sys/cdefs.h>
/* The syscall function itself is declared in <unistd.h>, not here. */

View file

@ -1,33 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* This file used to contain the declarations of sysconf and its associated constants.
* No standard mentions a <sys/sysconf.h>, but there are enough users in vendor (and potential ones
* in the NDK) to warrant not breaking source compatibility.
*/
// This file used to contain the declarations of sysconf and its associated constants.
// No standard mentions a <sys/sysconf.h>, but there are enough users in vendor (and potential ones
// in the NDK) to warrant not breaking source compatibility.
#include <bits/sysconf.h>

View file

@ -29,6 +29,8 @@
#ifndef _SYS_SYSMACROS_H_
#define _SYS_SYSMACROS_H_
#include <sys/cdefs.h>
#define makedev(__major, __minor) \
( \
(((__major) & 0xfffff000ULL) << 32) | (((__major) & 0xfffULL) << 8) | \

View file

@ -31,6 +31,7 @@
#include <fcntl.h> /* For O_CLOEXEC and O_NONBLOCK. */
#include <time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS

View file

@ -42,6 +42,8 @@
#ifndef _SYS_TTYDEFAULTS_H_
#define _SYS_TTYDEFAULTS_H_
#include <sys/cdefs.h>
/*
* Defaults on "first" open.
*/

View file

@ -30,6 +30,7 @@
#define _SYS_UCONTEXT_H_
#include <signal.h>
#include <sys/cdefs.h>
#include <sys/user.h>
__BEGIN_DECLS

View file

@ -31,5 +31,6 @@
#include <bits/sa_family_t.h>
#include <linux/un.h>
#include <sys/cdefs.h>
#endif

View file

@ -30,6 +30,7 @@
#define _SYS_XATTR_H_
#include <linux/xattr.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS

View file

@ -35,6 +35,8 @@
#ifndef _SYSEXITS_H_
#define _SYSEXITS_H_
#include <sys/cdefs.h>
/*
* SYSEXITS.H -- Exit status codes for system programs.
*

View file

@ -1,32 +1 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* All definitions related to termio are in Linux kernel headers
* that are already included by <termios.h>
*/
#include <termios.h>

View file

@ -1,34 +1 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _UCONTEXT_H_
#define _UCONTEXT_H_
#include <sys/ucontext.h>
#endif /* _UCONTEXT_H_ */

View file

@ -29,9 +29,9 @@
#ifndef _WCTYPE_H_
#define _WCTYPE_H_
#include <wchar.h>
#include <bits/wctype.h>
#include <wchar.h>
#include <sys/cdefs.h>
__BEGIN_DECLS

View file

@ -29,6 +29,8 @@
#ifndef _XLOCALE_H_
#define _XLOCALE_H_
#include <sys/cdefs.h>
/* If we just use void* here, GCC exposes that in error messages. */
struct __locale_t;
typedef struct __locale_t* locale_t;