cdefs.h revision 24fad01755d33e6772ea3be56b702570bf257d55
11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* $NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $ */ 21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (c) 1991, 1993 51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * The Regents of the University of California. All rights reserved. 61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * This code is derived from software contributed to Berkeley by 81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Berkeley Software Design, Inc. 91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without 111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions 121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met: 131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer. 151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * documentation and/or other materials provided with the distribution. 181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3. Neither the name of the University nor the names of its contributors 191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * may be used to endorse or promote products derived from this software 201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * without specific prior written permission. 211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE. 331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef _SYS_CDEFS_H_ 381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _SYS_CDEFS_H_ 391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Macro to test if we're using a GNU C compiler of a specific vintage 421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * or later, for e.g. features that appeared in a particular version 431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * of GNU C. Usage: 441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * #if __GNUC_PREREQ__(major, minor) 461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ...cool feature... 471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * #else 481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ...delete feature... 491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * #endif 501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifdef __GNUC__ 521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __GNUC_PREREQ__(x, y) \ 531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ 541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project (__GNUC__ > (x))) 551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __GNUC_PREREQ__(x, y) 0 571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <sys/cdefs_elf.h> 601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if defined(__cplusplus) 621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __BEGIN_DECLS extern "C" { 631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __END_DECLS } 641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __static_cast(x,y) static_cast<x>(y) 651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __BEGIN_DECLS 671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __END_DECLS 681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __static_cast(x,y) (x)y 691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * The __CONCAT macro is a bit tricky -- make sure you don't put spaces 751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * in between its arguments. __CONCAT can also concatenate double-quoted 761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * strings produced by the __STRING macro, but this only works with ANSI C. 771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 781dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 791dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define ___STRING(x) __STRING(x) 801dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define ___CONCAT(x,y) __CONCAT(x,y) 811dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 828eda21baa54977e4d164a4174d06b6aa12115fb1David 'Digit' Turner#if defined(__STDC__) || defined(__cplusplus) 831dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __P(protos) protos /* full-blown ANSI C */ 841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __CONCAT(x,y) x ## y 851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __STRING(x) #x 861dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 871dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __const const /* define reserved names to standard */ 881dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __signed signed 891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __volatile volatile 901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if defined(__cplusplus) 911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __inline inline /* convert to C++ keyword */ 921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 931dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !defined(__GNUC__) && !defined(__lint__) 941dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __inline /* delete GCC keyword */ 951dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !__GNUC__ && !__lint__ */ 961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !__cplusplus */ 971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else /* !(__STDC__ || __cplusplus) */ 991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __P(protos) () /* traditional C preprocessor */ 1001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __CONCAT(x,y) x/**/y 1011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __STRING(x) "x" 1021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef __GNUC__ 1041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __const /* delete pseudo-ANSI C keywords */ 1051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __inline 1061dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __signed 1071dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __volatile 1081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !__GNUC__ */ 1091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 1111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * In non-ANSI C environments, new programs will want ANSI-only C keywords 1121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * deleted from the program and old programs will want them left alone. 1131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Programs using the ANSI C keywords const, inline etc. as normal 1141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * identifiers should define -DNO_ANSI_KEYWORDS. 1151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 1161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef NO_ANSI_KEYWORDS 1171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define const __const /* convert ANSI C keywords */ 1181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define inline __inline 1191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define signed __signed 1201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define volatile __volatile 1211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !NO_ANSI_KEYWORDS */ 1221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !(__STDC__ || __cplusplus) */ 1231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 1251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Used for internal auditing of the NetBSD source tree. 1261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 1271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifdef __AUDIT__ 1281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __aconst __const 1291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 1301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __aconst 1311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 1341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * The following macro is used to remove const cast-away warnings 1351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * from gcc -Wcast-qual; it should be used with caution because it 1361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * can hide valid errors; in particular most valid uses are in 1371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * situations where the API requires it, not to cast away string 1381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * constants. We don't use *intptr_t on purpose here and we are 1391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * explicit about unsigned long so that we don't have additional 1401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * dependencies. 1411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 1421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) 1431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 1451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * GCC2 provides __extension__ to suppress warnings for various GNU C 1461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * language extensions under "-ansi -pedantic". 1471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 1481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !__GNUC_PREREQ__(2, 0) 1491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __extension__ /* delete __extension__ if non-gcc or gcc1 */ 1501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 1531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * GCC1 and some versions of GCC2 declare dead (non-returning) and 1541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * pure (no side effects) functions using "volatile" and "const"; 1551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * unfortunately, these then cause warnings under "-ansi -pedantic". 1561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of 1571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * these work for GNU C++ (modulo a slight glitch in the C++ grammar 1581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * in the distribution version of 2.5.5). 1591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 1601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !__GNUC_PREREQ__(2, 5) 1611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ 1621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if defined(__GNUC__) && !defined(__STRICT_ANSI__) 1631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __dead __volatile 1641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __pure __const 1651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* Delete pseudo-keywords wherever they are not available or needed. */ 1691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef __dead 1701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __dead 1711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __pure 1721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 7) 1751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __unused __attribute__((__unused__)) 1761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 1771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __unused /* delete */ 1781dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1791dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 180a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */ 181a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes 1821dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(3, 1) 1831dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __used __attribute__((__used__)) 1841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 1851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __used /* delete */ 1861dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 1871dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1881dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 7) 1891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __packed __attribute__((__packed__)) 1901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __aligned(x) __attribute__((__aligned__(x))) 1911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __section(x) __attribute__((__section__(x))) 1921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#elif defined(__lint__) 1931dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __packed /* delete */ 1941dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __aligned(x) /* delete */ 1951dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __section(x) /* delete */ 1961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 1971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __packed error: no __packed for this compiler 1981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __aligned(x) error: no __aligned for this compiler 1991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __section(x) error: no __section for this compiler 2001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !__GNUC_PREREQ__(2, 8) 2031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __extension__ 2041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2061dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 8) 2071dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __statement(x) __extension__(x) 2081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#elif defined(lint) 2091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __statement(x) (0) 2101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __statement(x) (x) 2121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 2151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * C99 defines the restrict type qualifier keyword, which was made available 2161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * in GCC 2.92. 2171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 2188eda21baa54977e4d164a4174d06b6aa12115fb1David 'Digit' Turner#if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L 2191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __restrict restrict 2201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !__GNUC_PREREQ__(2, 92) 2221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __restrict /* delete __restrict when not supported */ 2231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 2271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * C99 defines __func__ predefined identifier, which was made available 2281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * in GCC 2.95. 2291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 2308eda21baa54977e4d164a4174d06b6aa12115fb1David 'Digit' Turner#if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L) 2311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 6) 2321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __func__ __PRETTY_FUNCTION__ 2331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#elif __GNUC_PREREQ__(2, 4) 2341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __func__ __FUNCTION__ 2351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __func__ "" 2371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !(__STDC_VERSION__ >= 199901L) */ 2391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if defined(_KERNEL) 2411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if defined(NO_KERNEL_RCSIDS) 2421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#undef __KERNEL_RCSID 2431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __KERNEL_RCSID(_n, _s) /* nothing */ 2441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* NO_KERNEL_RCSIDS */ 2451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* _KERNEL */ 2461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if !defined(_STANDALONE) && !defined(_KERNEL) 2481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifdef __GNUC__ 2491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __RENAME(x) ___RENAME(x) 2501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifdef __lint__ 2521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __RENAME(x) __symbolrename(x) 2531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#error "No function renaming possible" 2551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* __lint__ */ 2561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* __GNUC__ */ 2571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else /* _STANDALONE || _KERNEL */ 2581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __RENAME(x) no renaming in kernel or standalone environment 2591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 2621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * A barrier to stop the optimizer from moving code or assume live 2631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * register values. This is gcc specific, the version is more or less 2641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * arbitrary, might work with older compilers. 2651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 2661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 95) 2671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __insn_barrier() __asm __volatile("":::"memory") 2681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 2691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __insn_barrier() /* */ 2701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 2711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 2721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 2731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * GNU C version 2.96 adds explicit branch prediction so that 2741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * the CPU back-end can hint the processor and also so that 2751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * code blocks can be reordered such that the predicted path 2761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * sees a more linear flow, thus improving cache behavior, etc. 2771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2781dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * The following two macros provide us with a way to use this 2791dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * compiler feature. Use __predict_true() if you expect the expression 2801dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * to evaluate to true, and __predict_false() if you expect the 2811dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * expression to evaluate to false. 2821dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2831dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * A few notes about usage: 2841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * * Generally, __predict_false() error condition checks (unless 2861dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * you have some _strong_ reason to do otherwise, in which case 2871dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * document it), and/or __predict_true() `no-error' condition 2881dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * checks, assuming you want to optimize for the no-error case. 2891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * * Other than that, if you don't know the likelihood of a test 2911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * succeeding from empirical or other `hard' evidence, don't 2921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * make predictions. 2931dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2941dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * * These are meant to be used in places that are run `a lot'. 2951dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * It is wasteful to make predictions in code that is run 2961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * seldomly (e.g. at subsystem initialization time) as the 2971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * basic block reordering that this affects can often generate 2981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * larger code. 2991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 3001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 96) 3011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __predict_true(exp) __builtin_expect((exp) != 0, 1) 3021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __predict_false(exp) __builtin_expect((exp) != 0, 0) 3031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 3041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __predict_true(exp) (exp) 3051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __predict_false(exp) (exp) 3061dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 3071dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 3081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#if __GNUC_PREREQ__(2, 96) 3091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __noreturn __attribute__((__noreturn__)) 3101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __mallocfunc __attribute__((malloc)) 311a677907ee8ecca034318fdb97902fa73e7392c4fNick Kralevich#define __purefunc __attribute__((pure)) 3121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#else 3131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __noreturn 3141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __mallocfunc 315a677907ee8ecca034318fdb97902fa73e7392c4fNick Kralevich#define __purefunc 3161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif 3171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 318a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#if __GNUC_PREREQ__(3, 1) 319a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __always_inline __attribute__((__always_inline__)) 320a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#else 321a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __always_inline 322a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#endif 323a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes 32424fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes#if __GNUC_PREREQ__(3, 4) 32524fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes#define __wur __attribute__((__warn_unused_result__)) 32624fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes#else 32724fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes#define __wur 32824fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes#endif 32924fad01755d33e6772ea3be56b702570bf257d55Elliott Hughes 3301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 3311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Macros for manipulating "link sets". Link sets are arrays of pointers 3321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * to objects, which are gathered up by the linker. 3331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Object format-specific code has provided us with the following macros: 3351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_add_text(set, sym) 3371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Add a reference to the .text symbol `sym' to `set'. 3381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_add_rodata(set, sym) 3401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Add a reference to the .rodata symbol `sym' to `set'. 3411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_add_data(set, sym) 3431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Add a reference to the .data symbol `sym' to `set'. 3441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_add_bss(set, sym) 3461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Add a reference to the .bss symbol `sym' to `set'. 3471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_decl(set, ptype) 3491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Provide an extern declaration of the set `set', which 3501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * contains an array of the pointer type `ptype'. This 3511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * macro must be used by any code which wishes to reference 3521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * the elements of a link set. 3531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_start(set) 3551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * This points to the first slot in the link set. 3561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_end(set) 3581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * This points to the (non-existent) slot after the last 3591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * entry in the link set. 3601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_count(set) 3621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Count the number of entries in link set `set'. 3631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * In addition, we provide the following macros for accessing link sets: 3651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_foreach(pvar, set) 3671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Iterate over the link set `set'. Because a link set is 3681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * an array of pointers, pvar must be declared as "type **pvar", 3691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * and the actual entry accessed as "*pvar". 3701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 3711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * __link_set_entry(set, idx) 3721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Access the link set entry at index `idx' from set `set'. 3731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 3741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __link_set_foreach(pvar, set) \ 3751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) 3761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 3771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __link_set_entry(set, idx) (__link_set_begin(set)[idx]) 3781dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 3793527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner/* 3803527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner * Some of the recend FreeBSD sources used in Bionic need this. 3813527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner * Originally, this is used to embed the rcs versions of each source file 3823527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner * in the generated binary. We certainly don't want this in Bionic. 3833527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner */ 3843527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner#define __FBSDID(s) struct __hack 3853527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner 38650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/*- 38750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * The following definitions are an extension of the behavior originally 38850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * implemented in <sys/_posix.h>, but with a different level of granularity. 38950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * POSIX.1 requires that the macros we test be defined before any standard 39050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * header file is included. 39150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * 39250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Here's a quick run-down of the versions: 39350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * defined(_POSIX_SOURCE) 1003.1-1988 39450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 1 1003.1-1990 39550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option 39650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 199309 1003.1b-1993 39750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, 39850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * and the omnibus ISO/IEC 9945-1: 1996 39950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 200112 1003.1-2001 40050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE == 200809 1003.1-2008 40150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * 40250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * In addition, the X/Open Portability Guide, which is now the Single UNIX 40350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Specification, defines a feature-test macro which indicates the version of 40450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * that specification, and which subsumes _POSIX_C_SOURCE. 40550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * 40650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Our macros begin with two underscores to avoid namespace screwage. 40750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner */ 40850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner 40950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ 41050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 41150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ 41250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 199009 41350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 41450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner 41550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ 41650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 41750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#undef _POSIX_C_SOURCE 41850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 199209 41950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 42050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner 42150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ 42250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifdef _XOPEN_SOURCE 42350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if _XOPEN_SOURCE - 0 >= 700 42450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 700 42550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#undef _POSIX_C_SOURCE 42650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 200809 42750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _XOPEN_SOURCE - 0 >= 600 42850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 600 42950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#undef _POSIX_C_SOURCE 43050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 200112 43150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _XOPEN_SOURCE - 0 >= 500 43250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 500 43350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#undef _POSIX_C_SOURCE 43450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 199506 43550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 43650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 43750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner 43850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/* 43950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Deal with all versions of POSIX. The ordering relative to the tests above is 44050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * important. 44150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner */ 44250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) 44350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define _POSIX_C_SOURCE 198808 44450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 44550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifdef _POSIX_C_SOURCE 44650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if _POSIX_C_SOURCE >= 200809 44750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 200809 44850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1999 44950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _POSIX_C_SOURCE >= 200112 45050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 200112 45150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1999 45250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _POSIX_C_SOURCE >= 199506 45350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 199506 45450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1990 45550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _POSIX_C_SOURCE >= 199309 45650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 199309 45750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1990 45850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _POSIX_C_SOURCE >= 199209 45950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 199209 46050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1990 46150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif _POSIX_C_SOURCE >= 199009 46250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 199009 46350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1990 46450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#else 46550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 198808 46650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 0 46750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif /* _POSIX_C_SOURCE */ 46850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#else 46950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/*- 47050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Deal with _ANSI_SOURCE: 47150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * If it is defined, and no other compilation environment is explicitly 47250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * requested, then define our internal feature-test macros to zero. This 47350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * makes no difference to the preprocessor (undefined symbols in preprocessing 47450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * expressions are defined to have value zero), but makes it more convenient for 47550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * a test program to print out the values. 47650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * 47750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * If a program mistakenly defines _ANSI_SOURCE and some other macro such as 47850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * _POSIX_C_SOURCE, we will assume that it wants the broader compilation 47950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * environment (and in fact we will never get here). 48050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner */ 48150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#if defined(_ANSI_SOURCE) /* Hide almost everything. */ 48250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 0 48350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 0 48450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __BSD_VISIBLE 0 48550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1990 48650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ 48750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 0 48850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 0 48950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __BSD_VISIBLE 0 49050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1999 49150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#else /* Default environment: show everything. */ 49250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __POSIX_VISIBLE 200809 49350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __XSI_VISIBLE 700 49450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __BSD_VISIBLE 1 49550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#define __ISO_C_VISIBLE 1999 49650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 49750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 49850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner 49950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner/* 50050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner * Default values. 50150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner */ 50250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifndef __XPG_VISIBLE 50350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner# define __XPG_VISIBLE 700 50450ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 50550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifndef __POSIX_VISIBLE 50650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner# define __POSIX_VISIBLE 200809 50750ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 50850ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifndef __ISO_C_VISIBLE 50950ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner# define __ISO_C_VISIBLE 1999 51050ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 51150ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#ifndef __BSD_VISIBLE 51250ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner# define __BSD_VISIBLE 1 51350ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turner#endif 5143527fd6f0df794207215790321824b7844cc712dDavid 'Digit' Turner 5151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __BIONIC__ 1 51623d24394e72715ddf580726655c8ba3fbcf11bfeDavid 'Digit' Turner#include <android/api-level.h> 5171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 518829c089f83ddee37203b52bcb294867a9ae7bdbcNick Kralevich#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && !defined(__clang__) 51971a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich#define __BIONIC_FORTIFY_INLINE \ 52071a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich extern inline \ 52171a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich __attribute__ ((always_inline)) \ 52271a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich __attribute__ ((gnu_inline)) \ 52371a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich __attribute__ ((artificial)) 5249b6cc223a36835c4367a036d4cfeff14d25bc742Nick Kralevich#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) 52571a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich#endif 52671a18dd435e96564539b5af71b8ea5093a2109a1Nick Kralevich 527a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes/* Android-added: for FreeBSD's libm. */ 528a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __weak_reference(sym,alias) \ 529a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes __asm__(".weak " #alias); \ 530a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes __asm__(".equ " #alias ", " #sym) 531a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes#define __strong_reference(sym,aliassym) \ 532a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) 533a0ee07829a9ba7e99ef68e8c12551301cc797f0fElliott Hughes 5341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* !_SYS_CDEFS_H_ */ 535