Author: ed
Date: Wed Dec 14 09:09:37 2011
New Revision: 228495
URL: http://svn.freebsd.org/changeset/base/228495

Log:
  Slightly alter the C1X definitions in in cdefs.h:
  
  - Add _Alignas(). Unfortunately this macro is only partially functional.
    The C1X standard will allow both an integer and a type name to be
    passed to this macro, while this macro only allows an integer. To be
    portable, one must use _Alignas(_Alignof(double)) to use type names.
  
  - Don't do _Static_assert() when __COUNTER__ is not supported. We'd
    better keep this implementation robust and allow it to be used in
    header files, without mysteriously breaking older compilers.

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==============================================================================
--- head/sys/sys/cdefs.h        Wed Dec 14 08:52:27 2011        (r228494)
+++ head/sys/sys/cdefs.h        Wed Dec 14 09:09:37 2011        (r228495)
@@ -222,6 +222,7 @@
  * Keywords added in C1X.
  */
 #if defined(__cplusplus) && __cplusplus >= 201103L
+#define        _Alignas(e)             alignas(e)
 #define        _Alignof(e)             alignof(e)
 #define        _Noreturn               [[noreturn]]
 #define        _Static_assert(e, s)    static_assert(e, s)
@@ -231,21 +232,23 @@
 #else
 /* Not supported.  Implement them manually. */
 #ifdef __GNUC__
+#define        _Alignas(e)             __attribute__((__aligned__(e)))
 #define        _Alignof(e)             __alignof__(e)
 #define        _Noreturn               __attribute__((__noreturn__))
 #define        _Thread_local           __thread
 #else
+#define        _Alignas(e)
 #define        _Alignof(e)             __offsetof(struct { char __a; e __b; }, 
__b)
 #define        _Noreturn
 #define        _Thread_local
 #endif
 #ifdef __COUNTER__
 #define        _Static_assert(e, s)    __Static_assert(e, __COUNTER__)
-#else
-#define        _Static_assert(e, s)    __Static_assert(e, __LINE__)
-#endif
 #define        __Static_assert(e, c)   ___Static_assert(e, c)
 #define        ___Static_assert(e, c)  typedef char __assert ## c[(e) ? 1 : -1]
+#else
+#define        _Static_assert(e, s)
+#endif
 #endif
 
 #if __GNUC_PREREQ__(2, 96)
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to