From patchwork Sat Feb 10 19:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 1897409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=crapouillou.net header.i=@crapouillou.net header.a=rsa-sha256 header.s=mail header.b=HJyDKl4q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TXYmG2R87z1yP6 for ; Sun, 11 Feb 2024 15:00:59 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 4833C3521117; Sun, 11 Feb 2024 05:00:51 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=crapouillou.net header.i=@crapouillou.net header.a=rsa-sha256 header.s=mail header.b=HJyDKl4q; dkim-atps=neutral Received: from aposti.net (aposti.net [89.234.176.197]) by helium.openadk.org (Postfix) with ESMTPS id A24B23521072 for ; Sat, 10 Feb 2024 20:29:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1707593375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UGrGXlzgEjvPHyAzRZkbcyUOgE8gOza0Kfei5r978h4=; b=HJyDKl4qhzjaa1C6GCt/m8+Hv5zSXExG1Slado3M0NV/XKl2CmJqfy7lvFCS8ptBcRk8Yw XuCZw0nHB93uKD/LlxNtFh5v/ngAF7scJ+BQ0GRs82Rwzzl2F02iOVHcCdEDGGSeuQjMr1 XNJr1196Ug51PO/DQigq3Ju1u3/0rkQ= From: Paul Cercueil To: devel@uclibc-ng.org Date: Sat, 10 Feb 2024 20:29:30 +0100 Message-ID: <20240210192930.296075-1-paul@crapouillou.net> MIME-Version: 1.0 X-MailFrom: paul@crapouillou.net X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: HVGSFWJ3BSCFLBOIVFNTVRN43J2SSC4W X-Message-ID-Hash: HVGSFWJ3BSCFLBOIVFNTVRN43J2SSC4W X-Mailman-Approved-At: Sun, 11 Feb 2024 05:00:41 +0100 CC: Paul Cercueil X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] features.h: Rework _DEFAULT_SOURCE List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The (glibc) documentation for _DEFAULT_SOURCE states: The "default" definitions comprise those required by POSIX.1-2008 and ISO C99, as well as various definitions originally derived from BSD and System V. On glibc 2.19 and earlier, these defaults were approximately equivalent to explicitly defining the following: cc -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809 It also states that _BSD_SOURCE and _SVID_SOURCE are deprecated, and have the same effect as setting _DEFAULT_SOURCE. Therefore, when any of _BSD_SOURCE, _SVID_SOURCE or _DEFAULT_SOURCE is set, the three macros should be set, and POSIX 2008.09 compatibility should be enabled. Signed-off-by: Paul Cercueil --- include/features.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/include/features.h b/include/features.h index d6e45c2ff..11b34205f 100644 --- a/include/features.h +++ b/include/features.h @@ -40,7 +40,8 @@ _SVID_SOURCE ISO C, POSIX, and SVID things. _ATFILE_SOURCE Additional *at interfaces. _GNU_SOURCE All of the above, plus GNU extensions. - _DEFAULT_SOURCE Equivalent to defining _BSD_SOURCE and _SVID_SOURCE. + _DEFAULT_SOURCE Equivalent to defining _BSD_SOURCE and _SVID_SOURCE, + as well as _POSIX_C_SOURCE=200809L. _REENTRANT Select additionally reentrant object. _THREAD_SAFE Same as _REENTRANT, often used by other systems. _FORTIFY_SOURCE If set to numeric value > 0 additional security @@ -142,18 +143,19 @@ /* Whether to use feature set F. */ #define __GLIBC_USE(F) __GLIBC_USE_ ## F -/* _DEFAULT_SOURCE is equivalent to defining _BSD_SOURCE and _SVID_SOURCE - * and vice versa. */ -#ifdef _DEFAULT_SOURCE +/* _DEFAULT_SOURCE is equivalent to defining _BSD_SOURCE, _SVID_SOURCE + * and _POSIX_C_SOURCE=200809L and vice versa. */ +#if defined _DEFAULT_SOURCE || defined _BSD_SOURCE || defined _SVID_SOURCE +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 # undef _BSD_SOURCE # define _BSD_SOURCE 1 # undef _SVID_SOURCE # define _SVID_SOURCE 1 -#endif - -#if defined _BSD_SOURCE || defined _SVID_SOURCE -# undef _DEFAULT_SOURCE -# define _DEFAULT_SOURCE 1 +# if _POSIX_C_SOURCE < 200809L +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200809L +# endif #endif /* If _GNU_SOURCE was defined by the user, turn on all the other features. */