From owner-svn-src-all@FreeBSD.ORG Fri Dec 16 08:22:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6897A106564A; Fri, 16 Dec 2011 08:22:24 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 574248FC13; Fri, 16 Dec 2011 08:22:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBG8MOWO092849; Fri, 16 Dec 2011 08:22:24 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBG8MODA092847; Fri, 16 Dec 2011 08:22:24 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201112160822.pBG8MODA092847@svn.freebsd.org> From: Ed Schouten Date: Fri, 16 Dec 2011 08:22:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228562 - head/sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 08:22:24 -0000 Author: ed Date: Fri Dec 16 08:22:23 2011 New Revision: 228562 URL: http://svn.freebsd.org/changeset/base/228562 Log: Process a lot of feedback from bde@ on : - Add __alignof() for non-GCC and GCC < 2.95. - Simply implement the C1X keywords on top of the existing __macros. - Add struct __hack to _Static_assert to require consumers to add a semicolon. - Add an extra underscore to __assert_ to allow it to be combined with locally defined versions of CTASSERT in the tree. - Add proper casts to __offsetof() to make it work for cases where sizeof(size_t) != sizeof(uintptr_t). - Globally replace size_t and uintptr_t by __size_t and __uintptr_t. This removes the dependency on / . Practically any header file ends up including somehow. - Change argument names of macros to match with the rest of the file. MFC after: 3 months Modified: head/sys/sys/cdefs.h Modified: head/sys/sys/cdefs.h ============================================================================== --- head/sys/sys/cdefs.h Fri Dec 16 02:09:51 2011 (r228561) +++ head/sys/sys/cdefs.h Fri Dec 16 08:22:23 2011 (r228562) @@ -218,6 +218,10 @@ #endif #endif +#if !__GNUC_PREREQ__(2, 95) +#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) +#endif + /* * Keywords added in C1X. */ @@ -230,24 +234,17 @@ #elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 201000L /* Do nothing. They are language keywords. */ #else -/* Not supported. Implement them manually. */ -#ifdef __GNUC__ -#define _Alignas(e) __attribute__((__aligned__(e))) -#define _Alignof(e) __alignof__(e) -#define _Noreturn __attribute__((__noreturn__)) +/* Not supported. Implement them using our versions. */ +#define _Alignas(x) __aligned(x) +#define _Alignof(x) __alignof(x) +#define _Noreturn __dead2 #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__) -#define __Static_assert(e, c) ___Static_assert(e, c) -#define ___Static_assert(e, c) typedef char __assert ## c[(e) ? 1 : -1] +#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) +#define __Static_assert(x, y) ___Static_assert(x, y) +#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] #else -#define _Static_assert(e, s) +#define _Static_assert(x, y) struct __hack #endif #endif @@ -363,10 +360,11 @@ #define __offsetof(type, field) __builtin_offsetof(type, field) #else #ifndef __cplusplus -#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) +#define __offsetof(type, field) \ + ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->member)) #else #define __offsetof(type, field) \ - (__offsetof__ (reinterpret_cast \ + (__offsetof__ (reinterpret_cast <__size_t> \ (&reinterpret_cast \ (static_cast (0)->field)))) #endif @@ -495,15 +493,15 @@ #endif #ifndef __DECONST -#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) +#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) #endif #ifndef __DEVOLATILE -#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var)) +#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) #endif #ifndef __DEQUALIFY -#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var)) +#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #endif /*-