| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /*	$NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $	*/ | 
|  | 2 |  | 
|  | 3 | /* | 
|  | 4 | * Copyright (c) 1991, 1993 | 
|  | 5 | *	The Regents of the University of California.  All rights reserved. | 
|  | 6 | * | 
|  | 7 | * This code is derived from software contributed to Berkeley by | 
|  | 8 | * Berkeley Software Design, Inc. | 
|  | 9 | * | 
|  | 10 | * Redistribution and use in source and binary forms, with or without | 
|  | 11 | * modification, are permitted provided that the following conditions | 
|  | 12 | * are met: | 
|  | 13 | * 1. Redistributions of source code must retain the above copyright | 
|  | 14 | *    notice, this list of conditions and the following disclaimer. | 
|  | 15 | * 2. Redistributions in binary form must reproduce the above copyright | 
|  | 16 | *    notice, this list of conditions and the following disclaimer in the | 
|  | 17 | *    documentation and/or other materials provided with the distribution. | 
|  | 18 | * 3. Neither the name of the University nor the names of its contributors | 
|  | 19 | *    may be used to endorse or promote products derived from this software | 
|  | 20 | *    without specific prior written permission. | 
|  | 21 | * | 
|  | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 
|  | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|  | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
|  | 25 | * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
|  | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|  | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|  | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|  | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
|  | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
|  | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
|  | 32 | * SUCH DAMAGE. | 
|  | 33 | * | 
|  | 34 | *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95 | 
|  | 35 | */ | 
|  | 36 |  | 
|  | 37 | #ifndef	_SYS_CDEFS_H_ | 
|  | 38 | #define	_SYS_CDEFS_H_ | 
|  | 39 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 40 | /* | 
|  | 41 | * Macro to test if we're using a GNU C compiler of a specific vintage | 
|  | 42 | * or later, for e.g. features that appeared in a particular version | 
|  | 43 | * of GNU C.  Usage: | 
|  | 44 | * | 
|  | 45 | *	#if __GNUC_PREREQ__(major, minor) | 
|  | 46 | *	...cool feature... | 
|  | 47 | *	#else | 
|  | 48 | *	...delete feature... | 
|  | 49 | *	#endif | 
|  | 50 | */ | 
|  | 51 | #ifdef __GNUC__ | 
|  | 52 | #define	__GNUC_PREREQ__(x, y)						\ | 
|  | 53 | ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\ | 
|  | 54 | (__GNUC__ > (x))) | 
|  | 55 | #else | 
|  | 56 | #define	__GNUC_PREREQ__(x, y)	0 | 
|  | 57 | #endif | 
|  | 58 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 59 | #include <sys/cdefs_elf.h> | 
|  | 60 |  | 
|  | 61 | #if defined(__cplusplus) | 
|  | 62 | #define	__BEGIN_DECLS		extern "C" { | 
|  | 63 | #define	__END_DECLS		} | 
|  | 64 | #define	__static_cast(x,y)	static_cast<x>(y) | 
|  | 65 | #else | 
|  | 66 | #define	__BEGIN_DECLS | 
|  | 67 | #define	__END_DECLS | 
|  | 68 | #define	__static_cast(x,y)	(x)y | 
|  | 69 | #endif | 
|  | 70 |  | 
|  | 71 | /* | 
|  | 72 | * The __CONCAT macro is used to concatenate parts of symbol names, e.g. | 
|  | 73 | * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. | 
|  | 74 | * The __CONCAT macro is a bit tricky -- make sure you don't put spaces | 
|  | 75 | * in between its arguments.  __CONCAT can also concatenate double-quoted | 
|  | 76 | * strings produced by the __STRING macro, but this only works with ANSI C. | 
|  | 77 | */ | 
|  | 78 |  | 
|  | 79 | #define	___STRING(x)	__STRING(x) | 
|  | 80 | #define	___CONCAT(x,y)	__CONCAT(x,y) | 
|  | 81 |  | 
| David 'Digit' Turner | 8eda21b | 2011-03-17 10:56:25 +0100 | [diff] [blame] | 82 | #if defined(__STDC__) || defined(__cplusplus) | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 83 | #define	__P(protos)	protos		/* full-blown ANSI C */ | 
|  | 84 | #define	__CONCAT(x,y)	x ## y | 
|  | 85 | #define	__STRING(x)	#x | 
|  | 86 |  | 
|  | 87 | #define	__const		const		/* define reserved names to standard */ | 
|  | 88 | #define	__signed	signed | 
|  | 89 | #define	__volatile	volatile | 
|  | 90 | #if defined(__cplusplus) | 
|  | 91 | #define	__inline	inline		/* convert to C++ keyword */ | 
|  | 92 | #else | 
|  | 93 | #if !defined(__GNUC__) && !defined(__lint__) | 
|  | 94 | #define	__inline			/* delete GCC keyword */ | 
|  | 95 | #endif /* !__GNUC__  && !__lint__ */ | 
|  | 96 | #endif /* !__cplusplus */ | 
|  | 97 |  | 
|  | 98 | #else	/* !(__STDC__ || __cplusplus) */ | 
|  | 99 | #define	__P(protos)	()		/* traditional C preprocessor */ | 
|  | 100 | #define	__CONCAT(x,y)	x/**/y | 
|  | 101 | #define	__STRING(x)	"x" | 
|  | 102 |  | 
|  | 103 | #ifndef __GNUC__ | 
|  | 104 | #define	__const				/* delete pseudo-ANSI C keywords */ | 
|  | 105 | #define	__inline | 
|  | 106 | #define	__signed | 
|  | 107 | #define	__volatile | 
|  | 108 | #endif	/* !__GNUC__ */ | 
|  | 109 |  | 
|  | 110 | /* | 
|  | 111 | * In non-ANSI C environments, new programs will want ANSI-only C keywords | 
|  | 112 | * deleted from the program and old programs will want them left alone. | 
|  | 113 | * Programs using the ANSI C keywords const, inline etc. as normal | 
|  | 114 | * identifiers should define -DNO_ANSI_KEYWORDS. | 
|  | 115 | */ | 
|  | 116 | #ifndef	NO_ANSI_KEYWORDS | 
|  | 117 | #define	const		__const		/* convert ANSI C keywords */ | 
|  | 118 | #define	inline		__inline | 
|  | 119 | #define	signed		__signed | 
|  | 120 | #define	volatile	__volatile | 
|  | 121 | #endif /* !NO_ANSI_KEYWORDS */ | 
|  | 122 | #endif	/* !(__STDC__ || __cplusplus) */ | 
|  | 123 |  | 
|  | 124 | /* | 
|  | 125 | * Used for internal auditing of the NetBSD source tree. | 
|  | 126 | */ | 
|  | 127 | #ifdef __AUDIT__ | 
|  | 128 | #define	__aconst	__const | 
|  | 129 | #else | 
|  | 130 | #define	__aconst | 
|  | 131 | #endif | 
|  | 132 |  | 
|  | 133 | /* | 
|  | 134 | * The following macro is used to remove const cast-away warnings | 
|  | 135 | * from gcc -Wcast-qual; it should be used with caution because it | 
|  | 136 | * can hide valid errors; in particular most valid uses are in | 
|  | 137 | * situations where the API requires it, not to cast away string | 
|  | 138 | * constants. We don't use *intptr_t on purpose here and we are | 
|  | 139 | * explicit about unsigned long so that we don't have additional | 
|  | 140 | * dependencies. | 
|  | 141 | */ | 
|  | 142 | #define __UNCONST(a)	((void *)(unsigned long)(const void *)(a)) | 
|  | 143 |  | 
|  | 144 | /* | 
|  | 145 | * GCC2 provides __extension__ to suppress warnings for various GNU C | 
|  | 146 | * language extensions under "-ansi -pedantic". | 
|  | 147 | */ | 
|  | 148 | #if !__GNUC_PREREQ__(2, 0) | 
|  | 149 | #define	__extension__		/* delete __extension__ if non-gcc or gcc1 */ | 
|  | 150 | #endif | 
|  | 151 |  | 
|  | 152 | /* | 
|  | 153 | * GCC1 and some versions of GCC2 declare dead (non-returning) and | 
|  | 154 | * pure (no side effects) functions using "volatile" and "const"; | 
|  | 155 | * unfortunately, these then cause warnings under "-ansi -pedantic". | 
|  | 156 | * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of | 
|  | 157 | * these work for GNU C++ (modulo a slight glitch in the C++ grammar | 
|  | 158 | * in the distribution version of 2.5.5). | 
|  | 159 | */ | 
|  | 160 | #if !__GNUC_PREREQ__(2, 5) | 
|  | 161 | #define	__attribute__(x)	/* delete __attribute__ if non-gcc or gcc1 */ | 
|  | 162 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) | 
|  | 163 | #define	__dead		__volatile | 
|  | 164 | #define	__pure		__const | 
|  | 165 | #endif | 
|  | 166 | #endif | 
|  | 167 |  | 
|  | 168 | /* Delete pseudo-keywords wherever they are not available or needed. */ | 
|  | 169 | #ifndef __dead | 
|  | 170 | #define	__dead | 
|  | 171 | #define	__pure | 
|  | 172 | #endif | 
|  | 173 |  | 
|  | 174 | #if __GNUC_PREREQ__(2, 7) | 
|  | 175 | #define	__unused	__attribute__((__unused__)) | 
|  | 176 | #else | 
|  | 177 | #define	__unused	/* delete */ | 
|  | 178 | #endif | 
|  | 179 |  | 
| Elliott Hughes | a0ee078 | 2013-01-30 19:06:37 -0800 | [diff] [blame] | 180 | #define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */ | 
|  | 181 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 182 | #if __GNUC_PREREQ__(3, 1) | 
|  | 183 | #define	__used		__attribute__((__used__)) | 
|  | 184 | #else | 
|  | 185 | #define	__used		/* delete */ | 
|  | 186 | #endif | 
|  | 187 |  | 
|  | 188 | #if __GNUC_PREREQ__(2, 7) | 
|  | 189 | #define	__packed	__attribute__((__packed__)) | 
|  | 190 | #define	__aligned(x)	__attribute__((__aligned__(x))) | 
|  | 191 | #define	__section(x)	__attribute__((__section__(x))) | 
|  | 192 | #elif defined(__lint__) | 
|  | 193 | #define	__packed	/* delete */ | 
|  | 194 | #define	__aligned(x)	/* delete */ | 
|  | 195 | #define	__section(x)	/* delete */ | 
|  | 196 | #else | 
|  | 197 | #define	__packed	error: no __packed for this compiler | 
|  | 198 | #define	__aligned(x)	error: no __aligned for this compiler | 
|  | 199 | #define	__section(x)	error: no __section for this compiler | 
|  | 200 | #endif | 
|  | 201 |  | 
|  | 202 | #if !__GNUC_PREREQ__(2, 8) | 
|  | 203 | #define	__extension__ | 
|  | 204 | #endif | 
|  | 205 |  | 
|  | 206 | #if __GNUC_PREREQ__(2, 8) | 
|  | 207 | #define __statement(x)	__extension__(x) | 
|  | 208 | #elif defined(lint) | 
|  | 209 | #define __statement(x)	(0) | 
|  | 210 | #else | 
|  | 211 | #define __statement(x)	(x) | 
|  | 212 | #endif | 
|  | 213 |  | 
| Elliott Hughes | 06040fd | 2013-07-09 13:25:03 -0700 | [diff] [blame] | 214 | #define __nonnull(args) __attribute__((__nonnull__ args)) | 
|  | 215 |  | 
|  | 216 | #define __printflike(x, y) __attribute__((__format__(printf, x, y))) __nonnull((x)) | 
|  | 217 | #define __scanflike(x, y) __attribute__((__format__(scanf, x, y))) __nonnull((x)) | 
| Elliott Hughes | d04c183 | 2013-05-14 16:08:43 -0700 | [diff] [blame] | 218 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 219 | /* | 
|  | 220 | * C99 defines the restrict type qualifier keyword, which was made available | 
|  | 221 | * in GCC 2.92. | 
|  | 222 | */ | 
| David 'Digit' Turner | 8eda21b | 2011-03-17 10:56:25 +0100 | [diff] [blame] | 223 | #if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 224 | #define	__restrict	restrict | 
|  | 225 | #else | 
|  | 226 | #if !__GNUC_PREREQ__(2, 92) | 
|  | 227 | #define	__restrict	/* delete __restrict when not supported */ | 
|  | 228 | #endif | 
|  | 229 | #endif | 
|  | 230 |  | 
|  | 231 | /* | 
|  | 232 | * C99 defines __func__ predefined identifier, which was made available | 
|  | 233 | * in GCC 2.95. | 
|  | 234 | */ | 
| David 'Digit' Turner | 8eda21b | 2011-03-17 10:56:25 +0100 | [diff] [blame] | 235 | #if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L) | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 236 | #if __GNUC_PREREQ__(2, 6) | 
|  | 237 | #define	__func__	__PRETTY_FUNCTION__ | 
|  | 238 | #elif __GNUC_PREREQ__(2, 4) | 
|  | 239 | #define	__func__	__FUNCTION__ | 
|  | 240 | #else | 
|  | 241 | #define	__func__	"" | 
|  | 242 | #endif | 
|  | 243 | #endif /* !(__STDC_VERSION__ >= 199901L) */ | 
|  | 244 |  | 
|  | 245 | #if defined(_KERNEL) | 
|  | 246 | #if defined(NO_KERNEL_RCSIDS) | 
|  | 247 | #undef __KERNEL_RCSID | 
|  | 248 | #define	__KERNEL_RCSID(_n, _s)		/* nothing */ | 
|  | 249 | #endif /* NO_KERNEL_RCSIDS */ | 
|  | 250 | #endif /* _KERNEL */ | 
|  | 251 |  | 
|  | 252 | #if !defined(_STANDALONE) && !defined(_KERNEL) | 
|  | 253 | #ifdef __GNUC__ | 
|  | 254 | #define	__RENAME(x)	___RENAME(x) | 
|  | 255 | #else | 
|  | 256 | #ifdef __lint__ | 
|  | 257 | #define	__RENAME(x)	__symbolrename(x) | 
|  | 258 | #else | 
|  | 259 | #error "No function renaming possible" | 
|  | 260 | #endif /* __lint__ */ | 
|  | 261 | #endif /* __GNUC__ */ | 
|  | 262 | #else /* _STANDALONE || _KERNEL */ | 
|  | 263 | #define	__RENAME(x)	no renaming in kernel or standalone environment | 
|  | 264 | #endif | 
|  | 265 |  | 
|  | 266 | /* | 
|  | 267 | * A barrier to stop the optimizer from moving code or assume live | 
|  | 268 | * register values. This is gcc specific, the version is more or less | 
|  | 269 | * arbitrary, might work with older compilers. | 
|  | 270 | */ | 
|  | 271 | #if __GNUC_PREREQ__(2, 95) | 
|  | 272 | #define	__insn_barrier()	__asm __volatile("":::"memory") | 
|  | 273 | #else | 
|  | 274 | #define	__insn_barrier()	/* */ | 
|  | 275 | #endif | 
|  | 276 |  | 
|  | 277 | /* | 
|  | 278 | * GNU C version 2.96 adds explicit branch prediction so that | 
|  | 279 | * the CPU back-end can hint the processor and also so that | 
|  | 280 | * code blocks can be reordered such that the predicted path | 
|  | 281 | * sees a more linear flow, thus improving cache behavior, etc. | 
|  | 282 | * | 
|  | 283 | * The following two macros provide us with a way to use this | 
|  | 284 | * compiler feature.  Use __predict_true() if you expect the expression | 
|  | 285 | * to evaluate to true, and __predict_false() if you expect the | 
|  | 286 | * expression to evaluate to false. | 
|  | 287 | * | 
|  | 288 | * A few notes about usage: | 
|  | 289 | * | 
|  | 290 | *	* Generally, __predict_false() error condition checks (unless | 
|  | 291 | *	  you have some _strong_ reason to do otherwise, in which case | 
|  | 292 | *	  document it), and/or __predict_true() `no-error' condition | 
|  | 293 | *	  checks, assuming you want to optimize for the no-error case. | 
|  | 294 | * | 
|  | 295 | *	* Other than that, if you don't know the likelihood of a test | 
|  | 296 | *	  succeeding from empirical or other `hard' evidence, don't | 
|  | 297 | *	  make predictions. | 
|  | 298 | * | 
|  | 299 | *	* These are meant to be used in places that are run `a lot'. | 
|  | 300 | *	  It is wasteful to make predictions in code that is run | 
|  | 301 | *	  seldomly (e.g. at subsystem initialization time) as the | 
|  | 302 | *	  basic block reordering that this affects can often generate | 
|  | 303 | *	  larger code. | 
|  | 304 | */ | 
|  | 305 | #if __GNUC_PREREQ__(2, 96) | 
|  | 306 | #define	__predict_true(exp)	__builtin_expect((exp) != 0, 1) | 
|  | 307 | #define	__predict_false(exp)	__builtin_expect((exp) != 0, 0) | 
|  | 308 | #else | 
|  | 309 | #define	__predict_true(exp)	(exp) | 
|  | 310 | #define	__predict_false(exp)	(exp) | 
|  | 311 | #endif | 
|  | 312 |  | 
|  | 313 | #if __GNUC_PREREQ__(2, 96) | 
|  | 314 | #define __noreturn    __attribute__((__noreturn__)) | 
|  | 315 | #define __mallocfunc  __attribute__((malloc)) | 
| Nick Kralevich | a677907 | 2012-03-21 08:48:18 -0700 | [diff] [blame] | 316 | #define __purefunc    __attribute__((pure)) | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 317 | #else | 
|  | 318 | #define __noreturn | 
|  | 319 | #define __mallocfunc | 
| Nick Kralevich | a677907 | 2012-03-21 08:48:18 -0700 | [diff] [blame] | 320 | #define __purefunc | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 321 | #endif | 
|  | 322 |  | 
| Elliott Hughes | a0ee078 | 2013-01-30 19:06:37 -0800 | [diff] [blame] | 323 | #if __GNUC_PREREQ__(3, 1) | 
|  | 324 | #define __always_inline __attribute__((__always_inline__)) | 
|  | 325 | #else | 
|  | 326 | #define __always_inline | 
|  | 327 | #endif | 
|  | 328 |  | 
| Elliott Hughes | 24fad01 | 2013-02-04 13:44:14 -0800 | [diff] [blame] | 329 | #if __GNUC_PREREQ__(3, 4) | 
|  | 330 | #define __wur __attribute__((__warn_unused_result__)) | 
|  | 331 | #else | 
|  | 332 | #define __wur | 
|  | 333 | #endif | 
|  | 334 |  | 
| Nick Kralevich | b24c063 | 2013-06-18 10:46:02 -0700 | [diff] [blame] | 335 | #if __GNUC_PREREQ__(4, 3) | 
|  | 336 | #define __errordecl(name, msg) extern void name(void) __attribute__((__error__(msg))) | 
| Elliott Hughes | c13fb75 | 2013-12-17 20:43:30 -0800 | [diff] [blame] | 337 | #define __warnattr(msg) __attribute__((__warning__(msg))) | 
| Nick Kralevich | b24c063 | 2013-06-18 10:46:02 -0700 | [diff] [blame] | 338 | #else | 
|  | 339 | #define __errordecl(name, msg) extern void name(void) | 
| Elliott Hughes | c13fb75 | 2013-12-17 20:43:30 -0800 | [diff] [blame] | 340 | #define __warnattr(msg) | 
| Nick Kralevich | b24c063 | 2013-06-18 10:46:02 -0700 | [diff] [blame] | 341 | #endif | 
|  | 342 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 343 | /* | 
|  | 344 | * Macros for manipulating "link sets".  Link sets are arrays of pointers | 
|  | 345 | * to objects, which are gathered up by the linker. | 
|  | 346 | * | 
|  | 347 | * Object format-specific code has provided us with the following macros: | 
|  | 348 | * | 
|  | 349 | *	__link_set_add_text(set, sym) | 
|  | 350 | *		Add a reference to the .text symbol `sym' to `set'. | 
|  | 351 | * | 
|  | 352 | *	__link_set_add_rodata(set, sym) | 
|  | 353 | *		Add a reference to the .rodata symbol `sym' to `set'. | 
|  | 354 | * | 
|  | 355 | *	__link_set_add_data(set, sym) | 
|  | 356 | *		Add a reference to the .data symbol `sym' to `set'. | 
|  | 357 | * | 
|  | 358 | *	__link_set_add_bss(set, sym) | 
|  | 359 | *		Add a reference to the .bss symbol `sym' to `set'. | 
|  | 360 | * | 
|  | 361 | *	__link_set_decl(set, ptype) | 
|  | 362 | *		Provide an extern declaration of the set `set', which | 
|  | 363 | *		contains an array of the pointer type `ptype'.  This | 
|  | 364 | *		macro must be used by any code which wishes to reference | 
|  | 365 | *		the elements of a link set. | 
|  | 366 | * | 
|  | 367 | *	__link_set_start(set) | 
|  | 368 | *		This points to the first slot in the link set. | 
|  | 369 | * | 
|  | 370 | *	__link_set_end(set) | 
|  | 371 | *		This points to the (non-existent) slot after the last | 
|  | 372 | *		entry in the link set. | 
|  | 373 | * | 
|  | 374 | *	__link_set_count(set) | 
|  | 375 | *		Count the number of entries in link set `set'. | 
|  | 376 | * | 
|  | 377 | * In addition, we provide the following macros for accessing link sets: | 
|  | 378 | * | 
|  | 379 | *	__link_set_foreach(pvar, set) | 
|  | 380 | *		Iterate over the link set `set'.  Because a link set is | 
|  | 381 | *		an array of pointers, pvar must be declared as "type **pvar", | 
|  | 382 | *		and the actual entry accessed as "*pvar". | 
|  | 383 | * | 
|  | 384 | *	__link_set_entry(set, idx) | 
|  | 385 | *		Access the link set entry at index `idx' from set `set'. | 
|  | 386 | */ | 
|  | 387 | #define	__link_set_foreach(pvar, set)					\ | 
|  | 388 | for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++) | 
|  | 389 |  | 
|  | 390 | #define	__link_set_entry(set, idx)	(__link_set_begin(set)[idx]) | 
|  | 391 |  | 
| David 'Digit' Turner | 3527fd6 | 2010-06-14 17:18:35 -0700 | [diff] [blame] | 392 | /* | 
| Elliott Hughes | 7582a9c | 2013-02-06 17:08:15 -0800 | [diff] [blame] | 393 | * Some of the FreeBSD sources used in Bionic need this. | 
| David 'Digit' Turner | 3527fd6 | 2010-06-14 17:18:35 -0700 | [diff] [blame] | 394 | * Originally, this is used to embed the rcs versions of each source file | 
|  | 395 | * in the generated binary. We certainly don't want this in Bionic. | 
|  | 396 | */ | 
| Elliott Hughes | 7582a9c | 2013-02-06 17:08:15 -0800 | [diff] [blame] | 397 | #define __FBSDID(s) /* nothing */ | 
| David 'Digit' Turner | 3527fd6 | 2010-06-14 17:18:35 -0700 | [diff] [blame] | 398 |  | 
| David 'Digit' Turner | 50ace4f | 2010-06-16 16:36:41 -0700 | [diff] [blame] | 399 | /*- | 
|  | 400 | * The following definitions are an extension of the behavior originally | 
|  | 401 | * implemented in <sys/_posix.h>, but with a different level of granularity. | 
|  | 402 | * POSIX.1 requires that the macros we test be defined before any standard | 
|  | 403 | * header file is included. | 
|  | 404 | * | 
|  | 405 | * Here's a quick run-down of the versions: | 
|  | 406 | *  defined(_POSIX_SOURCE)		1003.1-1988 | 
|  | 407 | *  _POSIX_C_SOURCE == 1		1003.1-1990 | 
|  | 408 | *  _POSIX_C_SOURCE == 2		1003.2-1992 C Language Binding Option | 
|  | 409 | *  _POSIX_C_SOURCE == 199309		1003.1b-1993 | 
|  | 410 | *  _POSIX_C_SOURCE == 199506		1003.1c-1995, 1003.1i-1995, | 
|  | 411 | *					and the omnibus ISO/IEC 9945-1: 1996 | 
|  | 412 | *  _POSIX_C_SOURCE == 200112		1003.1-2001 | 
|  | 413 | *  _POSIX_C_SOURCE == 200809		1003.1-2008 | 
|  | 414 | * | 
|  | 415 | * In addition, the X/Open Portability Guide, which is now the Single UNIX | 
|  | 416 | * Specification, defines a feature-test macro which indicates the version of | 
|  | 417 | * that specification, and which subsumes _POSIX_C_SOURCE. | 
|  | 418 | * | 
|  | 419 | * Our macros begin with two underscores to avoid namespace screwage. | 
|  | 420 | */ | 
|  | 421 |  | 
|  | 422 | /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ | 
|  | 423 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 | 
|  | 424 | #undef _POSIX_C_SOURCE		/* Probably illegal, but beyond caring now. */ | 
|  | 425 | #define	_POSIX_C_SOURCE		199009 | 
|  | 426 | #endif | 
|  | 427 |  | 
|  | 428 | /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ | 
|  | 429 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 | 
|  | 430 | #undef _POSIX_C_SOURCE | 
|  | 431 | #define	_POSIX_C_SOURCE		199209 | 
|  | 432 | #endif | 
|  | 433 |  | 
|  | 434 | /* Deal with various X/Open Portability Guides and Single UNIX Spec. */ | 
|  | 435 | #ifdef _XOPEN_SOURCE | 
|  | 436 | #if _XOPEN_SOURCE - 0 >= 700 | 
|  | 437 | #define	__XSI_VISIBLE		700 | 
|  | 438 | #undef _POSIX_C_SOURCE | 
|  | 439 | #define	_POSIX_C_SOURCE		200809 | 
|  | 440 | #elif _XOPEN_SOURCE - 0 >= 600 | 
|  | 441 | #define	__XSI_VISIBLE		600 | 
|  | 442 | #undef _POSIX_C_SOURCE | 
|  | 443 | #define	_POSIX_C_SOURCE		200112 | 
|  | 444 | #elif _XOPEN_SOURCE - 0 >= 500 | 
|  | 445 | #define	__XSI_VISIBLE		500 | 
|  | 446 | #undef _POSIX_C_SOURCE | 
|  | 447 | #define	_POSIX_C_SOURCE		199506 | 
|  | 448 | #endif | 
|  | 449 | #endif | 
|  | 450 |  | 
|  | 451 | /* | 
|  | 452 | * Deal with all versions of POSIX.  The ordering relative to the tests above is | 
|  | 453 | * important. | 
|  | 454 | */ | 
|  | 455 | #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) | 
|  | 456 | #define	_POSIX_C_SOURCE		198808 | 
|  | 457 | #endif | 
|  | 458 | #ifdef _POSIX_C_SOURCE | 
|  | 459 | #if _POSIX_C_SOURCE >= 200809 | 
|  | 460 | #define	__POSIX_VISIBLE		200809 | 
|  | 461 | #define	__ISO_C_VISIBLE		1999 | 
|  | 462 | #elif _POSIX_C_SOURCE >= 200112 | 
|  | 463 | #define	__POSIX_VISIBLE		200112 | 
|  | 464 | #define	__ISO_C_VISIBLE		1999 | 
|  | 465 | #elif _POSIX_C_SOURCE >= 199506 | 
|  | 466 | #define	__POSIX_VISIBLE		199506 | 
|  | 467 | #define	__ISO_C_VISIBLE		1990 | 
|  | 468 | #elif _POSIX_C_SOURCE >= 199309 | 
|  | 469 | #define	__POSIX_VISIBLE		199309 | 
|  | 470 | #define	__ISO_C_VISIBLE		1990 | 
|  | 471 | #elif _POSIX_C_SOURCE >= 199209 | 
|  | 472 | #define	__POSIX_VISIBLE		199209 | 
|  | 473 | #define	__ISO_C_VISIBLE		1990 | 
|  | 474 | #elif _POSIX_C_SOURCE >= 199009 | 
|  | 475 | #define	__POSIX_VISIBLE		199009 | 
|  | 476 | #define	__ISO_C_VISIBLE		1990 | 
|  | 477 | #else | 
|  | 478 | #define	__POSIX_VISIBLE		198808 | 
|  | 479 | #define	__ISO_C_VISIBLE		0 | 
|  | 480 | #endif /* _POSIX_C_SOURCE */ | 
|  | 481 | #else | 
|  | 482 | /*- | 
|  | 483 | * Deal with _ANSI_SOURCE: | 
|  | 484 | * If it is defined, and no other compilation environment is explicitly | 
|  | 485 | * requested, then define our internal feature-test macros to zero.  This | 
|  | 486 | * makes no difference to the preprocessor (undefined symbols in preprocessing | 
|  | 487 | * expressions are defined to have value zero), but makes it more convenient for | 
|  | 488 | * a test program to print out the values. | 
|  | 489 | * | 
|  | 490 | * If a program mistakenly defines _ANSI_SOURCE and some other macro such as | 
|  | 491 | * _POSIX_C_SOURCE, we will assume that it wants the broader compilation | 
|  | 492 | * environment (and in fact we will never get here). | 
|  | 493 | */ | 
|  | 494 | #if defined(_ANSI_SOURCE)	/* Hide almost everything. */ | 
|  | 495 | #define	__POSIX_VISIBLE		0 | 
|  | 496 | #define	__XSI_VISIBLE		0 | 
|  | 497 | #define	__BSD_VISIBLE		0 | 
|  | 498 | #define	__ISO_C_VISIBLE		1990 | 
|  | 499 | #elif defined(_C99_SOURCE)	/* Localism to specify strict C99 env. */ | 
|  | 500 | #define	__POSIX_VISIBLE		0 | 
|  | 501 | #define	__XSI_VISIBLE		0 | 
|  | 502 | #define	__BSD_VISIBLE		0 | 
|  | 503 | #define	__ISO_C_VISIBLE		1999 | 
|  | 504 | #else				/* Default environment: show everything. */ | 
|  | 505 | #define	__POSIX_VISIBLE		200809 | 
|  | 506 | #define	__XSI_VISIBLE		700 | 
|  | 507 | #define	__BSD_VISIBLE		1 | 
|  | 508 | #define	__ISO_C_VISIBLE		1999 | 
|  | 509 | #endif | 
|  | 510 | #endif | 
|  | 511 |  | 
|  | 512 | /* | 
|  | 513 | * Default values. | 
|  | 514 | */ | 
|  | 515 | #ifndef __XPG_VISIBLE | 
|  | 516 | # define __XPG_VISIBLE          700 | 
|  | 517 | #endif | 
|  | 518 | #ifndef __POSIX_VISIBLE | 
|  | 519 | # define __POSIX_VISIBLE        200809 | 
|  | 520 | #endif | 
|  | 521 | #ifndef __ISO_C_VISIBLE | 
|  | 522 | # define __ISO_C_VISIBLE        1999 | 
|  | 523 | #endif | 
|  | 524 | #ifndef __BSD_VISIBLE | 
|  | 525 | # define __BSD_VISIBLE          1 | 
|  | 526 | #endif | 
| David 'Digit' Turner | 3527fd6 | 2010-06-14 17:18:35 -0700 | [diff] [blame] | 527 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 528 | #define  __BIONIC__   1 | 
| David 'Digit' Turner | 23d2439 | 2010-12-06 12:05:11 +0100 | [diff] [blame] | 529 | #include <android/api-level.h> | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 530 |  | 
| Nick Kralevich | bd8e674 | 2013-08-28 13:22:52 -0700 | [diff] [blame] | 531 | /* | 
|  | 532 | * When _FORTIFY_SOURCE is defined, automatic bounds checking is | 
|  | 533 | * added to commonly used libc functions. If a buffer overrun is | 
|  | 534 | * detected, the program is safely aborted. | 
|  | 535 | * | 
|  | 536 | * See | 
|  | 537 | * http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html for details. | 
|  | 538 | */ | 
| Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 539 | #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 | 
| Elliott Hughes | 890c8ed | 2013-03-22 10:58:55 -0700 | [diff] [blame] | 540 | #define __BIONIC_FORTIFY 1 | 
| Nick Kralevich | 1aae9bd | 2013-04-29 14:07:06 -0700 | [diff] [blame] | 541 | #if _FORTIFY_SOURCE == 2 | 
| Nick Kralevich | 78d6d98 | 2013-04-29 16:29:37 -0700 | [diff] [blame] | 542 | #define __bos(s) __builtin_object_size((s), 1) | 
| Nick Kralevich | 1aae9bd | 2013-04-29 14:07:06 -0700 | [diff] [blame] | 543 | #else | 
| Nick Kralevich | 78d6d98 | 2013-04-29 16:29:37 -0700 | [diff] [blame] | 544 | #define __bos(s) __builtin_object_size((s), 0) | 
| Nick Kralevich | 1aae9bd | 2013-04-29 14:07:06 -0700 | [diff] [blame] | 545 | #endif | 
| Nick Kralevich | bd8e674 | 2013-08-28 13:22:52 -0700 | [diff] [blame] | 546 | #define __bos0(s) __builtin_object_size((s), 0) | 
| Nick Kralevich | 1aae9bd | 2013-04-29 14:07:06 -0700 | [diff] [blame] | 547 |  | 
| Nick Kralevich | 71a18dd | 2012-06-07 14:01:26 -0700 | [diff] [blame] | 548 | #define __BIONIC_FORTIFY_INLINE \ | 
| Elliott Hughes | 8d60cc6 | 2014-02-03 15:41:57 -0800 | [diff] [blame] | 549 | extern __inline__ \ | 
| Nick Kralevich | 71a18dd | 2012-06-07 14:01:26 -0700 | [diff] [blame] | 550 | __attribute__ ((always_inline)) \ | 
| Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 551 | __attribute__ ((gnu_inline)) | 
| Nick Kralevich | 71a18dd | 2012-06-07 14:01:26 -0700 | [diff] [blame] | 552 | #endif | 
| Elliott Hughes | 890c8ed | 2013-03-22 10:58:55 -0700 | [diff] [blame] | 553 | #define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1) | 
| Nick Kralevich | 71a18dd | 2012-06-07 14:01:26 -0700 | [diff] [blame] | 554 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 555 | #endif /* !_SYS_CDEFS_H_ */ |