Changeset 3819 for trunk


Ignore:
Timestamp:
Feb 26, 2014, 1:19:21 AM (11 years ago)
Author:
bird
Message:

sys/cdefs.h: Updated to FreeBSD 9.1.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/sys/cdefs.h

    r3739 r3819  
    11/* $Id: $ */
    22/** @file
    3  * FreeBSD 9.0
     3 * FreeBSD 9.1.0
    44 *
    55 * @changed bird: Toolkit compatibility (_CDEFS_H_ and __TCPROTO()).
     
    88 * @changed bird: __offsetof__ was apparently introduced in gcc 3.4.x.
    99 */
    10  
     10
    1111/*-
    1212 * Copyright (c) 1991, 1993
     
    4141 *
    4242 *      @(#)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$
    4444 */
    4545
     
    230230#endif
    231231
     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
    232281#if __GNUC_PREREQ__(2, 96)
    233282#define __malloc_like   __attribute__((__malloc__))
     
    256305#endif
    257306
     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
    258319/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
    259320#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
     
    263324#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
    264325#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
    265337#endif
    266338
     
    331403#else
    332404#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))
    334407#else
    335408#define __offsetof(type, field)                                 \
    336   (__offsetof__ (reinterpret_cast <size_t>                      \
     409  (__offsetof__ (reinterpret_cast <__size_t>                    \
    337410                 (&reinterpret_cast <const volatile char &>     \
    338411                  (static_cast<type *> (0)->field))))
     
    352425#define __scanflike(fmtarg, firstvararg)
    353426#define __format_arg(fmtarg)
     427#define __strfmonlike(fmtarg, firstvararg)
     428#define __strftimelike(fmtarg, firstvararg)
    354429#else
    355430#define __printflike(fmtarg, firstvararg) \
     
    358433            __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
    359434#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)))
    360439#endif
    361440
     
    428507 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
    429508 * Usage:
    430  *      __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $");
     509 *      __FBSDID("$FreeBSD$");
    431510 */
    432511#ifndef __FBSDID
     
    471550
    472551#ifndef __DECONST
    473 #define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
     552#define __DECONST(type, var)    ((type)(__uintptr_t)(const void *)(var))
    474553#endif
    475554
    476555#ifndef __DEVOLATILE
    477 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
     556#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
    478557#endif
    479558
    480559#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))
    482561#endif
    483562
     
    595674#endif
    596675
     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
    597690/*-
    598691 * There are two strict backwards compatibility modes:
Note: See TracChangeset for help on using the changeset viewer.