From patchwork Wed Sep 4 17:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 825337 Delivered-To: patch@linaro.org Received: by 2002:adf:e246:0:b0:367:895a:4699 with SMTP id bl6csp287389wrb; Wed, 4 Sep 2024 10:33:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0FYKjXmdeMcCXal08pbE7hy7BF+WSVWhJ8KvdkPrRHjRk0EQK7KWMq7VrHLTxa2iKWCM2ng==@linaro.org X-Google-Smtp-Source: AGHT+IH8pib9VMJJ0E7TgR5kmvq5ALtPtpIxEqQX6SIGhRr4oAT4IFqENAZi3K2PTaXo5yGj2yHr X-Received: by 2002:a05:6214:338a:b0:6c3:33b1:20df with SMTP id 6a1803df08f44-6c3552db17emr165966826d6.14.1725471198117; Wed, 04 Sep 2024 10:33:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725471198; cv=pass; d=google.com; s=arc-20240605; b=P0y5ggC25XJbRTpvaSAzq56QxdIw73S+vgf+OkzEs2usrqHHOEotWxZTcQIF4q2wxk bWTHkZShw76awWrD2O8QEAutPzrfyTXhDqw/T0FOMp59o711pYlxZ1Kwioy7M6DI2cgt PXXimrI6LgDq16ONdxSpvHWyXDMDX4k8BWnwWznNtzR67BG9TFYKzrGHasJK9IEmB78b 57KCCIyasDINmqxI1JoDk+MrmSlanntcy3uMpE7IyZL67zflbsGy3kmoHC7LZNonBw5f hdfyBAB2l7kYUG6qN+ROkQUPTWqV5ZW3J9Jy5mFCTfVSLjS1sCK+RVybBCcUzI0o9F+g sqxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Bx8QVoI+NqHce7RX2xQvkQqNWR/3/nBkJ6O06aNqdl0=; fh=sOUt/o+wj2cuaPYmuAzWR/tPL0iMl3C5hC5LnrFgvSA=; b=X6JS9uZ2P8a1QAenTuh/8tuGHjeFbCxRtWnGK0gFkt92V5K5/o1DsOXV1Sa9lYQq+z qswIopyTlw4zBd70QS7hRfO+N6bUuzT6RqnPKjGpQu6KFxo9EW4exo0jAfnfGOCgmWiU YYBIL/e5bNix7362IHv8cXYWd02AA8jrP8qVLU6XG3aIQSteBR7dvsG4r4vcVFEDLtdH yhEKoqaxSKcFh/eUKw/IL5p5O0sBKGx6ouRJWtwqPR8/1NB8QiElQFnB9lDURpw6QgLK b7RpZkiVRS1+dFHT2ydak52fat+OPNhUHQvDmsSSO9xTlykdYrK2a2D5WM/8qHz5fhpA nPuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aw6Y838S; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6c5201e1b07si536506d6.108.2024.09.04.10.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 10:33:18 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aw6Y838S; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB100385EC35 for ; Wed, 4 Sep 2024 17:33:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id F122B3858406 for ; Wed, 4 Sep 2024 17:33:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F122B3858406 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F122B3858406 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725471187; cv=none; b=CQax6ON3ywFX6Mo4iT5gX7XndunbzlqluJbeEjQ+hvdtetQtdx826DGglXbRk3YG9/WnNWSGy5+hCmNA5E3pkWqgelNgkUceZNi5mDMiwA4J1i1vZ/4/dbJOByv3byJHnqD+N8tclg8wv7sfy5e9SvR+a+GNNN9rG6hOeYP1ijA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725471187; c=relaxed/simple; bh=e28P1xobi0BeQXy0EaoBlctjBxi3epvKmOISLqhveuw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mEuDzGBsVkkyYdN0j8eoM9spoAPeqWZXiE1yVnWaR77E0kcN2+K/W/SD63nfzC9hgGbCvf1hGxTwGfDDAIzXVcluQjTzui3ih57mIMEvT1agYDs6TeCN9AYTL6lVbBuE+ce71RoElpQ+vjwrQFkvojiFUwQAuwBixUjvRVLLvzM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2d8b68bddeaso2920077a91.1 for ; Wed, 04 Sep 2024 10:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725471183; x=1726075983; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Bx8QVoI+NqHce7RX2xQvkQqNWR/3/nBkJ6O06aNqdl0=; b=aw6Y838S7vDQLl7ggxjZ1HSTAFTUJ+UE4QSZqHj4h9J/C7dYnh2Ov8Uc7UW3aWCtV2 wTz3ZeHauD8/xkKf57GTvBQTtzKXbaBsMS+nJ0b9eod90L/gqYXpJ+YCv9OYSwQM+qAJ 49o0dtBfTtK5i3zbqv2tIgvUY8IKzNQMLj1jNK319fEk4r4wqrpb1TOSdCcIOe0IEpVh RPbZUQaR+3p+G7kIowEWKzaGRoIX6g1uhY3ZH+JBNXobsgVhDIMrvuyRLwBDgwBqJRmS 2oHmq/9o7c552DpLNruqQbMzh8EVdAF3QuryjzKLXNl8ssUL/Cpeo78+/+dFQyI+gwcM PYqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725471183; x=1726075983; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bx8QVoI+NqHce7RX2xQvkQqNWR/3/nBkJ6O06aNqdl0=; b=pUukI7yvn/n9wlDi7M6LPnUVD16Atxqf/zjU4gCm3TWAMgLKfR9uQCoLDihX1iVc0C FrqibVr2ZLWQyySCE+3FmNdGquAbXgfh/j5jdJ2cgIo9zxohRqvD5UYgv4B+ihSiyCEx 1N7xI1Z7Xro89MKEVDuTEEChYnwUFBUTIHeEsjHF+Ejdr7NmO+6lxvYop4Xwa0AJOGkd q6hWzRcgjP8t6YG9hYlxidpMaLB8AnKBZ1J4WRtVe7LccsIIeIBwJQ7rD/KIhCNJaM80 JsT5GdruDLzALmwJXgJiCRY34Q4m9uvR4dXyrrtSMxO8ENFIvDoRRZ58GQqJofwwZegl Hslg== X-Gm-Message-State: AOJu0YzcwlbSDll6Mn+ZU/E7h0Z3UZ7HsIzkzOppQBagKj69BcP2rzRX pksLlBkZ758cJKu/np6hY3Z7ryz4FX/QMwd4C8vb4FHfHdqmrEBz5o2pqA9vW5KBbm90qz/H/f4 e8BY= X-Received: by 2002:a17:90a:8d0f:b0:2c9:7611:e15d with SMTP id 98e67ed59e1d1-2d88d6db509mr17463247a91.20.1725471183218; Wed, 04 Sep 2024 10:33:03 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:e912:1301:81fd:2901:4eab]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2da8497d5e6sm2208313a91.52.2024.09.04.10.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 10:33:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , Paul Eggert Subject: [PATCH] timezone: C23 [[reproducible]] and [[unsequenced]] fixups Date: Wed, 4 Sep 2024 14:32:35 -0300 Message-ID: <20240904173259.3073903-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org C23’s [[reproducible]] and [[unsequenced]] are weaker than GCC’s __attribute__((pure)) and __attribute__((const) respectively, so rework the code so that it doesn’t imply they’re equivalent. This is a sync with the fix 'C23 [[reproducible]] and [[unsequenced]] fixups' [1] (not yet in any release). It fixes glibc build with gcc master [2]. Checked on x86_64-linux-gnu. [1] https://github.com/eggert/tz/commit/c0789e468753b3c67805dd5fd08b479e5b101c86 [2] https://sourceware.org/pipermail/libc-alpha/2024-September/159571.html --- timezone/private.h | 41 ++++++++++++++++++++--------------------- timezone/zdump.c | 6 +++--- timezone/zic.c | 18 +++++++++--------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/timezone/private.h b/timezone/private.h index 0dac6af4e3..fd13cc7264 100644 --- a/timezone/private.h +++ b/timezone/private.h @@ -460,14 +460,6 @@ typedef unsigned long uintmax_t; # define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r) #endif -#if 3 <= __GNUC__ -# define ATTRIBUTE_MALLOC __attribute__((malloc)) -# define ATTRIBUTE_FORMAT(spec) __attribute__((format spec)) -#else -# define ATTRIBUTE_MALLOC /* empty */ -# define ATTRIBUTE_FORMAT(spec) /* empty */ -#endif - #if (defined __has_c_attribute \ && (202311 <= __STDC_VERSION__ || !defined __STRICT_ANSI__)) # define HAVE___HAS_C_ATTRIBUTE true @@ -535,11 +527,7 @@ typedef unsigned long uintmax_t; # endif #endif #ifndef ATTRIBUTE_REPRODUCIBLE -# if 3 <= __GNUC__ -# define ATTRIBUTE_REPRODUCIBLE __attribute__((pure)) -# else -# define ATTRIBUTE_REPRODUCIBLE /* empty */ -# endif +# define ATTRIBUTE_REPRODUCIBLE /* empty */ #endif #if HAVE___HAS_C_ATTRIBUTE @@ -548,11 +536,22 @@ typedef unsigned long uintmax_t; # endif #endif #ifndef ATTRIBUTE_UNSEQUENCED -# if 3 <= __GNUC__ -# define ATTRIBUTE_UNSEQUENCED __attribute__((const)) -# else -# define ATTRIBUTE_UNSEQUENCED /* empty */ -# endif +# define ATTRIBUTE_UNSEQUENCED /* empty */ +#endif + +/* __attribute__((const)) is stricter than [[unsequenced]] and + __attribute__((pure)) is stricter than [[reproducible]], + so the latter are adequate substitutes in non-GCC C23 platforms. */ +#if __GNUC__ < 3 +# define ATTRIBUTE_CONST ATTRIBUTE_UNSEQUENCED +# define ATTRIBUTE_FORMAT(spec) /* empty */ +# define ATTRIBUTE_MALLOC /* empty */ +# define ATTRIBUTE_PURE ATTRIBUTE_REPRODUCIBLE +#else +# define ATTRIBUTE_CONST __attribute__((const)) +# define ATTRIBUTE_FORMAT(spec) __attribute__((format spec)) +# define ATTRIBUTE_MALLOC __attribute__((malloc)) +# define ATTRIBUTE_PURE __attribute__((pure)) #endif #if (__STDC_VERSION__ < 199901 && !defined restrict \ @@ -682,7 +681,7 @@ DEPRECATED_IN_C23 char *asctime(struct tm const *); char *asctime_r(struct tm const *restrict, char *restrict); DEPRECATED_IN_C23 char *ctime(time_t const *); char *ctime_r(time_t const *, char *); -ATTRIBUTE_UNSEQUENCED double difftime(time_t, time_t); +ATTRIBUTE_CONST double difftime(time_t, time_t); size_t strftime(char *restrict, size_t, char const *restrict, struct tm const *restrict); # if HAVE_STRFTIME_L @@ -798,10 +797,10 @@ timezone_t tzalloc(char const *); void tzfree(timezone_t); # if STD_INSPIRED # if TZ_TIME_T || !defined posix2time_z -ATTRIBUTE_REPRODUCIBLE time_t posix2time_z(timezone_t, time_t); +ATTRIBUTE_PURE time_t posix2time_z(timezone_t, time_t); # endif # if TZ_TIME_T || !defined time2posix_z -ATTRIBUTE_REPRODUCIBLE time_t time2posix_z(timezone_t, time_t); +ATTRIBUTE_PURE time_t time2posix_z(timezone_t, time_t); # endif # endif #endif diff --git a/timezone/zdump.c b/timezone/zdump.c index 7d99cc74bd..edc4d66627 100644 --- a/timezone/zdump.c +++ b/timezone/zdump.c @@ -89,7 +89,7 @@ static bool warned; static bool errout; static char const *abbr(struct tm const *); -ATTRIBUTE_REPRODUCIBLE static intmax_t delta(struct tm *, struct tm *); +ATTRIBUTE_PURE static intmax_t delta(struct tm *, struct tm *); static void dumptime(struct tm const *); static time_t hunt(timezone_t, time_t, time_t, bool); static void show(timezone_t, char *, time_t, bool); @@ -97,7 +97,7 @@ static void showextrema(timezone_t, char *, time_t, struct tm *, time_t); static void showtrans(char const *, struct tm const *, time_t, char const *, char const *); static const char *tformat(void); -ATTRIBUTE_REPRODUCIBLE static time_t yeartot(intmax_t); +ATTRIBUTE_PURE static time_t yeartot(intmax_t); /* Is C an ASCII digit? */ static bool @@ -134,7 +134,7 @@ size_overflow(void) /* Return A + B, exiting if the result would overflow either ptrdiff_t or size_t. A and B are both nonnegative. */ -ATTRIBUTE_REPRODUCIBLE static ptrdiff_t +ATTRIBUTE_PURE static ptrdiff_t sumsize(ptrdiff_t a, ptrdiff_t b) { #ifdef ckd_add diff --git a/timezone/zic.c b/timezone/zic.c index 00f00e307a..3e7d3552a5 100644 --- a/timezone/zic.c +++ b/timezone/zic.c @@ -470,7 +470,7 @@ size_overflow(void) memory_exhausted(_("size overflow")); } -ATTRIBUTE_REPRODUCIBLE static ptrdiff_t +ATTRIBUTE_PURE static ptrdiff_t size_sum(size_t a, size_t b) { #ifdef ckd_add @@ -484,7 +484,7 @@ size_sum(size_t a, size_t b) size_overflow(); } -ATTRIBUTE_REPRODUCIBLE static ptrdiff_t +ATTRIBUTE_PURE static ptrdiff_t size_product(ptrdiff_t nitems, ptrdiff_t itemsize) { #ifdef ckd_mul @@ -499,7 +499,7 @@ size_product(ptrdiff_t nitems, ptrdiff_t itemsize) size_overflow(); } -ATTRIBUTE_REPRODUCIBLE static ptrdiff_t +ATTRIBUTE_PURE static ptrdiff_t align_to(ptrdiff_t size, ptrdiff_t alignment) { ptrdiff_t lo_bits = alignment - 1, sum = size_sum(size, lo_bits); @@ -1435,7 +1435,7 @@ relname(char const *target, char const *linkname) /* Return true if A and B must have the same parent dir if A and B exist. Return false if this is not necessarily true (though it might be true). Keep it simple, and do not inspect the file system. */ -static bool +ATTRIBUTE_PURE static bool same_parent_dirs(char const *a, char const *b) { for (; *a == *b; a++, b++) @@ -3627,7 +3627,7 @@ lowerit(char a) } /* case-insensitive equality */ -ATTRIBUTE_REPRODUCIBLE static bool +ATTRIBUTE_PURE static bool ciequal(register const char *ap, register const char *bp) { while (lowerit(*ap) == lowerit(*bp++)) @@ -3636,7 +3636,7 @@ ciequal(register const char *ap, register const char *bp) return false; } -ATTRIBUTE_REPRODUCIBLE static bool +ATTRIBUTE_PURE static bool itsabbr(register const char *abbr, register const char *word) { if (lowerit(*abbr) != lowerit(*word)) @@ -3652,7 +3652,7 @@ itsabbr(register const char *abbr, register const char *word) /* Return true if ABBR is an initial prefix of WORD, ignoring ASCII case. */ -ATTRIBUTE_REPRODUCIBLE static bool +ATTRIBUTE_PURE static bool ciprefix(char const *abbr, char const *word) { do @@ -3762,7 +3762,7 @@ time_overflow(void) exit(EXIT_FAILURE); } -ATTRIBUTE_REPRODUCIBLE static zic_t +ATTRIBUTE_PURE static zic_t oadd(zic_t t1, zic_t t2) { #ifdef ckd_add @@ -3776,7 +3776,7 @@ oadd(zic_t t1, zic_t t2) time_overflow(); } -ATTRIBUTE_REPRODUCIBLE static zic_t +ATTRIBUTE_PURE static zic_t tadd(zic_t t1, zic_t t2) { #ifdef ckd_add