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
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 3b1f7d0..60789d4 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -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
diff --git a/libc/include/sys/cachectl.h b/libc/include/sys/cachectl.h
index 0830293..5b20c19 100644
--- a/libc/include/sys/cachectl.h
+++ b/libc/include/sys/cachectl.h
@@ -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 */
diff --git a/libc/include/sys/msg.h b/libc/include/sys/msg.h
index 1a6d30d..73965f2 100644
--- a/libc/include/sys/msg.h
+++ b/libc/include/sys/msg.h
@@ -29,6 +29,7 @@
#ifndef _SYS_MSG_H_
#define _SYS_MSG_H_
+#include <sys/cdefs.h>
#include <linux/msg.h>
#endif /* _SYS_MSG_H_ */
diff --git a/libc/include/sys/param.h b/libc/include/sys/param.h
index 5d2248f..d3686e0 100644
--- a/libc/include/sys/param.h
+++ b/libc/include/sys/param.h
@@ -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
diff --git a/libc/include/sys/queue.h b/libc/include/sys/queue.h
index b0e6b38..0890838 100644
--- a/libc/include/sys/queue.h
+++ b/libc/include/sys/queue.h
@@ -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.
diff --git a/libc/include/sys/reg.h b/libc/include/sys/reg.h
index b3d2aac..1066b6d 100644
--- a/libc/include/sys/reg.h
+++ b/libc/include/sys/reg.h
@@ -29,6 +29,8 @@
#ifndef _SYS_REG_H_
#define _SYS_REG_H_
+#include <sys/cdefs.h>
+
#if defined(__i386__)
#define EBX 0
diff --git a/libc/include/sys/sem.h b/libc/include/sys/sem.h
index a1ecd1f..753fc37 100644
--- a/libc/include/sys/sem.h
+++ b/libc/include/sys/sem.h
@@ -29,6 +29,7 @@
#ifndef _SYS_SEM_H_
#define _SYS_SEM_H_
+#include <sys/cdefs.h>
#include <linux/sem.h>
#endif /* _SYS_SEM_H_ */
diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h
index 87cddc9..a49323d 100644
--- a/libc/include/sys/syscall.h
+++ b/libc/include/sys/syscall.h
@@ -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. */
diff --git a/libc/include/sys/sysconf.h b/libc/include/sys/sysconf.h
index c9895f2..eb30faf 100644
--- a/libc/include/sys/sysconf.h
+++ b/libc/include/sys/sysconf.h
@@ -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>
diff --git a/libc/include/sys/sysmacros.h b/libc/include/sys/sysmacros.h
index 54e43dd..592cc5e 100644
--- a/libc/include/sys/sysmacros.h
+++ b/libc/include/sys/sysmacros.h
@@ -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) | \
diff --git a/libc/include/sys/timerfd.h b/libc/include/sys/timerfd.h
index 8311f08..0090233 100644
--- a/libc/include/sys/timerfd.h
+++ b/libc/include/sys/timerfd.h
@@ -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
diff --git a/libc/include/sys/ttydefaults.h b/libc/include/sys/ttydefaults.h
index b62aab1..62af84b 100644
--- a/libc/include/sys/ttydefaults.h
+++ b/libc/include/sys/ttydefaults.h
@@ -42,6 +42,8 @@
#ifndef _SYS_TTYDEFAULTS_H_
#define _SYS_TTYDEFAULTS_H_
+#include <sys/cdefs.h>
+
/*
* Defaults on "first" open.
*/
diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h
index f252a37..fdb3015 100644
--- a/libc/include/sys/ucontext.h
+++ b/libc/include/sys/ucontext.h
@@ -30,6 +30,7 @@
#define _SYS_UCONTEXT_H_
#include <signal.h>
+#include <sys/cdefs.h>
#include <sys/user.h>
__BEGIN_DECLS
diff --git a/libc/include/sys/un.h b/libc/include/sys/un.h
index 421b900..3e1c429 100644
--- a/libc/include/sys/un.h
+++ b/libc/include/sys/un.h
@@ -31,5 +31,6 @@
#include <bits/sa_family_t.h>
#include <linux/un.h>
+#include <sys/cdefs.h>
#endif
diff --git a/libc/include/sys/xattr.h b/libc/include/sys/xattr.h
index 7e437e9..37e352d 100644
--- a/libc/include/sys/xattr.h
+++ b/libc/include/sys/xattr.h
@@ -30,6 +30,7 @@
#define _SYS_XATTR_H_
#include <linux/xattr.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS