From patchwork Fri Apr 22 23:05:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 11867 Received: (qmail 46074 invoked by alias); 23 Apr 2016 21:15:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 46051 invoked by uid 89); 23 Apr 2016 21:15:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_12_24, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mailbackend.panix.com Message-Id: <7d28608ab5396836526b235526e0b757236cfc85.1461444595.git.zackw@panix.com> In-Reply-To: References: From: Zack Weinberg To: libc-alpha@sourceware.org Date: Fri, 22 Apr 2016 19:05:34 -0400 Subject: [PATCH 1/2] Add __clang_has_extension to sys/cdefs.h. clang provides an intrinsic __has_extension() to #if statements, useful for feature detection. Other compilers may throw a syntax error on #if defined __clang__ && __has_extension(...) even though they do not need to evaluate the right-hand side of the logical AND. __clang_has_extension(...) therefore expands to __has_extension(...) when __clang__ is defined, and to 0 otherwise. * misc/sys/cdefs.h: New utility macro __clang_has_extension. --- misc/sys/cdefs.h | 9 +++++++++ 1 file changed, 9 insertions(+) 2.8.1 diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 7fd4154..b31878b 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -77,7 +77,15 @@ #endif /* GCC. */ +/* Compilers that are not clang may object to + #if defined __clang__ && __has_extension (...) + even though they do not need to evaluate the right-hand side of the &&. */ +#ifdef __clang__ +# define __clang_has_extension(ext) __has_extension (ext) +#else +# define __clang_has_extension(ext) 0 +#endif + /* These two macros are not used in glibc anymore. They are kept here only because some other projects expect the macros to be defined. */ #define __P(args) args --