]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - libc/include/sys/cdefs.h
Remove more BSD cruft from the public headers.
[android-sdk/platform-bionic.git] / libc / include / sys / cdefs.h
index c3338234b625ab0cd02b9e9cdb69e6bd3d50dad1..21d59fa57a87789eab19625a28eac5ab90390b8c 100644 (file)
@@ -53,6 +53,9 @@
 #ifndef __has_builtin
 #define __has_builtin(x)        0
 #endif
+#ifndef __has_attribute
+#define __has_attribute(x)      0
+#endif
 
 
 /*
  * or later, for e.g. features that appeared in a particular version
  * of GNU C.  Usage:
  *
- *     #if __GNUC_PREREQ__(major, minor)
+ *     #if __GNUC_PREREQ(major, minor)
  *     ...cool feature...
  *     #else
  *     ...delete feature...
  *     #endif
  */
 #ifdef __GNUC__
-#define        __GNUC_PREREQ__(x, y)                                           \
+#define        __GNUC_PREREQ(x, y)                                             \
        ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||                  \
         (__GNUC__ > (x)))
 #else
-#define        __GNUC_PREREQ__(x, y)   0
+#define        __GNUC_PREREQ(x, y)     0
 #endif
 
-#include <sys/cdefs_elf.h>
+#define __strong_alias(alias, sym) \
+    __asm__(".global " #alias "\n" \
+            #alias " = " #sym);
 
 #if defined(__cplusplus)
 #define        __BEGIN_DECLS           extern "C" {
  * GCC2 provides __extension__ to suppress warnings for various GNU C
  * language extensions under "-ansi -pedantic".
  */
-#if !__GNUC_PREREQ__(2, 0)
+#if !__GNUC_PREREQ(2, 0)
 #define        __extension__           /* delete __extension__ if non-gcc or gcc1 */
 #endif
 
  * these work for GNU C++ (modulo a slight glitch in the C++ grammar
  * in the distribution version of 2.5.5).
  */
-#if !__GNUC_PREREQ__(2, 5)
+#if !__GNUC_PREREQ(2, 5)
 #define        __attribute__(x)        /* delete __attribute__ if non-gcc or gcc1 */
 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
 #define        __dead          __volatile
 #define        __pure
 #endif
 
-#if __GNUC_PREREQ__(2, 7)
+#if __GNUC_PREREQ(2, 7)
 #define        __unused        __attribute__((__unused__))
 #else
 #define        __unused        /* delete */
 
 #define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */
 
-#if __GNUC_PREREQ__(3, 1)
+#if __GNUC_PREREQ(3, 1)
 #define        __used          __attribute__((__used__))
 #else
 #define        __used          /* delete */
 #endif
 
-#if __GNUC_PREREQ__(2, 7)
+#if __GNUC_PREREQ(2, 7)
 #define        __packed        __attribute__((__packed__))
 #define        __aligned(x)    __attribute__((__aligned__(x)))
 #define        __section(x)    __attribute__((__section__(x)))
 #define        __section(x)    error: no __section for this compiler
 #endif
 
-#if !__GNUC_PREREQ__(2, 8)
+#if !__GNUC_PREREQ(2, 8)
 #define        __extension__
 #endif
 
-#if __GNUC_PREREQ__(2, 8)
+#if __GNUC_PREREQ(2, 8)
 #define __statement(x) __extension__(x)
 #elif defined(lint)
 #define __statement(x) (0)
 #if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L
 #define        __restrict      restrict
 #else
-#if !__GNUC_PREREQ__(2, 92)
+#if !__GNUC_PREREQ(2, 92)
 #define        __restrict      /* delete __restrict when not supported */
 #endif
 #endif
  * in GCC 2.95.
  */
 #if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L)
-#if __GNUC_PREREQ__(2, 6)
+#if __GNUC_PREREQ(2, 6)
 #define        __func__        __PRETTY_FUNCTION__
-#elif __GNUC_PREREQ__(2, 4)
+#elif __GNUC_PREREQ(2, 4)
 #define        __func__        __FUNCTION__
 #else
 #define        __func__        ""
 #endif
 #endif /* !(__STDC_VERSION__ >= 199901L) */
 
-#if defined(_KERNEL)
-#if defined(NO_KERNEL_RCSIDS)
-#undef __KERNEL_RCSID
-#define        __KERNEL_RCSID(_n, _s)          /* nothing */
-#endif /* NO_KERNEL_RCSIDS */
-#endif /* _KERNEL */
-
 /*
  * A barrier to stop the optimizer from moving code or assume live
  * register values. This is gcc specific, the version is more or less
  * arbitrary, might work with older compilers.
  */
-#if __GNUC_PREREQ__(2, 95)
+#if __GNUC_PREREQ(2, 95)
 #define        __insn_barrier()        __asm __volatile("":::"memory")
 #else
 #define        __insn_barrier()        /* */
  *       basic block reordering that this affects can often generate
  *       larger code.
  */
-#if __GNUC_PREREQ__(2, 96)
+#if __GNUC_PREREQ(2, 96)
 #define        __predict_true(exp)     __builtin_expect((exp) != 0, 1)
 #define        __predict_false(exp)    __builtin_expect((exp) != 0, 0)
 #else
 #define        __predict_false(exp)    (exp)
 #endif
 
-#if __GNUC_PREREQ__(2, 96)
+#if __GNUC_PREREQ(2, 96)
 #define __noreturn    __attribute__((__noreturn__))
 #define __mallocfunc  __attribute__((malloc))
 #define __purefunc    __attribute__((pure))
 #define __purefunc
 #endif
 
-#if __GNUC_PREREQ__(3, 1)
+#if __GNUC_PREREQ(3, 1)
 #define __always_inline __attribute__((__always_inline__))
 #else
 #define __always_inline
 #endif
 
-#if __GNUC_PREREQ__(3, 4)
+#if __GNUC_PREREQ(3, 4)
 #define __wur __attribute__((__warn_unused_result__))
 #else
 #define __wur
 #endif
 
-#if __GNUC_PREREQ__(4, 3)
+#if __GNUC_PREREQ(4, 3)
 #define __errordecl(name, msg) extern void name(void) __attribute__((__error__(msg)))
 #define __warnattr(msg) __attribute__((__warning__(msg)))
 #else
 #define __RCSID(_s) /* nothing */
 #define __SCCSID(_s) /* nothing */
 
+/*
+ * _BSD_SOURCE and _GNU_SOURCE are expected to be defined by callers before
+ * any standard header file is included. In those header files we test
+ * against __USE_BSD and __USE_GNU. glibc does this in <features.h> but we
+ * do it in <sys/cdefs.h> instead because that's where our existing
+ * _POSIX_C_SOURCE tests were, and we're already confident that <sys/cdefs.h>
+ * is included everywhere it should be.
+ *
+ * The _GNU_SOURCE test needs to come before any _BSD_SOURCE or _POSIX* tests
+ * because _GNU_SOURCE implies everything else.
+ */
+#if defined(_GNU_SOURCE)
+# define __USE_GNU 1
+# undef _POSIX_SOURCE
+# define _POSIX_SOURCE 1
+# undef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200809L
+# undef _BSD_SOURCE
+# define _BSD_SOURCE 1
+#endif
+
+#if defined(_BSD_SOURCE)
+# define __USE_BSD 1
+#endif
+
 /*-
- * The following definitions are an extension of the behavior originally
- * implemented in <sys/_posix.h>, but with a different level of granularity.
  * POSIX.1 requires that the macros we test be defined before any standard
  * header file is included.
  *
 #endif
 #define __bos0(s) __builtin_object_size((s), 0)
 
+#if __GNUC_PREREQ(4,3) || __has_attribute(__artificial__)
+#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
+#else
 #define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline))
 #endif
+#endif
 #define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
 
 /* Used to tag non-static symbols that are private and never exposed by the shared library. */