- Timestamp:
- Feb 26, 2014, 1:19:21 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/include/sys/cdefs.h
r3739 r3819 1 1 /* $Id: $ */ 2 2 /** @file 3 * FreeBSD 9. 03 * FreeBSD 9.1.0 4 4 * 5 5 * @changed bird: Toolkit compatibility (_CDEFS_H_ and __TCPROTO()). … … 8 8 * @changed bird: __offsetof__ was apparently introduced in gcc 3.4.x. 9 9 */ 10 10 11 11 /*- 12 12 * Copyright (c) 1991, 1993 … … 41 41 * 42 42 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 43 * $FreeBSD : src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp$43 * $FreeBSD$ 44 44 */ 45 45 … … 230 230 #endif 231 231 232 #if !__GNUC_PREREQ__(2, 95) 233 #define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) 234 #endif 235 236 /* 237 * Keywords added in C11. 238 */ 239 #if defined(__cplusplus) && __cplusplus >= 201103L 240 #define _Alignas(e) alignas(e) 241 #define _Alignof(e) alignof(e) 242 #define _Noreturn [[noreturn]] 243 #define _Static_assert(e, s) static_assert(e, s) 244 /* FIXME: change this to thread_local when clang in base supports it */ 245 #define _Thread_local __thread 246 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 247 /* Do nothing. They are language keywords. */ 248 #else 249 /* Not supported. Implement them using our versions. */ 250 #define _Alignas(x) __aligned(x) 251 #define _Alignof(x) __alignof(x) 252 #define _Noreturn __dead2 253 #define _Thread_local __thread 254 #ifdef __COUNTER__ 255 #define _Static_assert(x, y) __Static_assert(x, __COUNTER__) 256 #define __Static_assert(x, y) ___Static_assert(x, y) 257 #define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] 258 #else 259 #define _Static_assert(x, y) struct __hack 260 #endif 261 #endif 262 263 /* 264 * Emulation of C11 _Generic(). Unlike the previously defined C11 265 * keywords, it is not possible to implement this using exactly the same 266 * syntax. Therefore implement something similar under the name 267 * __generic(). Unlike _Generic(), this macro can only distinguish 268 * between a single type, so it requires nested invocations to 269 * distinguish multiple cases. 270 */ 271 272 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 273 #define __generic(expr, t, yes, no) \ 274 _Generic(expr, t: yes, default: no) 275 #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) 276 #define __generic(expr, t, yes, no) \ 277 __builtin_choose_expr( \ 278 __builtin_types_compatible_p(__typeof(expr), t), yes, no) 279 #endif 280 232 281 #if __GNUC_PREREQ__(2, 96) 233 282 #define __malloc_like __attribute__((__malloc__)) … … 256 305 #endif 257 306 307 #if __GNUC_PREREQ__(3, 4) 308 #define __fastcall __attribute__((__fastcall__)) 309 #else 310 #define __fastcall 311 #endif 312 313 #if __GNUC_PREREQ__(4, 1) 314 #define __returns_twice __attribute__((__returns_twice__)) 315 #else 316 #define __returns_twice 317 #endif 318 258 319 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */ 259 320 #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) … … 263 324 #if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 264 325 #define __LONG_LONG_SUPPORTED 326 #endif 327 328 /* C++11 exposes a load of C99 stuff */ 329 #if defined(__cplusplus) && __cplusplus >= 201103L 330 #define __LONG_LONG_SUPPORTED 331 #ifndef __STDC_LIMIT_MACROS 332 #define __STDC_LIMIT_MACROS 333 #endif 334 #ifndef __STDC_CONSTANT_MACROS 335 #define __STDC_CONSTANT_MACROS 336 #endif 265 337 #endif 266 338 … … 331 403 #else 332 404 #if !defined(__cplusplus) || !__GNUC_PREREQ__(3,4) /* bird: __offsetof__ was introduced in 3.4.x. */ 333 #define __offsetof(type, field) ((size_t)(&((type *)0)->field)) 405 #define __offsetof(type, field) \ 406 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) 334 407 #else 335 408 #define __offsetof(type, field) \ 336 (__offsetof__ (reinterpret_cast < size_t> \409 (__offsetof__ (reinterpret_cast <__size_t> \ 337 410 (&reinterpret_cast <const volatile char &> \ 338 411 (static_cast<type *> (0)->field)))) … … 352 425 #define __scanflike(fmtarg, firstvararg) 353 426 #define __format_arg(fmtarg) 427 #define __strfmonlike(fmtarg, firstvararg) 428 #define __strftimelike(fmtarg, firstvararg) 354 429 #else 355 430 #define __printflike(fmtarg, firstvararg) \ … … 358 433 __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) 359 434 #define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) 435 #define __strfmonlike(fmtarg, firstvararg) \ 436 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) 437 #define __strftimelike(fmtarg, firstvararg) \ 438 __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) 360 439 #endif 361 440 … … 428 507 * more recent ELF binutils, we use .ident allowing the ID to be stripped. 429 508 * Usage: 430 * __FBSDID("$FreeBSD : src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp$");509 * __FBSDID("$FreeBSD$"); 431 510 */ 432 511 #ifndef __FBSDID … … 471 550 472 551 #ifndef __DECONST 473 #define __DECONST(type, var) ((type)( uintptr_t)(const void *)(var))552 #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) 474 553 #endif 475 554 476 555 #ifndef __DEVOLATILE 477 #define __DEVOLATILE(type, var) ((type)( uintptr_t)(volatile void *)(var))556 #define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) 478 557 #endif 479 558 480 559 #ifndef __DEQUALIFY 481 #define __DEQUALIFY(type, var) ((type)( uintptr_t)(const volatile void *)(var))560 #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) 482 561 #endif 483 562 … … 595 674 #endif 596 675 676 #ifndef __has_feature 677 #define __has_feature(x) 0 678 #endif 679 #ifndef __has_include 680 #define __has_include(x) 0 681 #endif 682 #ifndef __has_builtin 683 #define __has_builtin(x) 0 684 #endif 685 686 #if defined(__mips) || defined(__powerpc64__) || defined(__arm__) 687 #define __NO_TLS 1 688 #endif 689 597 690 /*- 598 691 * There are two strict backwards compatibility modes:
Note:
See TracChangeset
for help on using the changeset viewer.