From patchwork Sun Nov 9 21:53:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 123860 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCC773858408 for ; Sun, 9 Nov 2025 22:16:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCC773858408 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SPGm5XWT X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) by sourceware.org (Postfix) with ESMTPS id 66E8C3858412 for ; Sun, 9 Nov 2025 21:53:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66E8C3858412 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 66E8C3858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2600:3c0a:e001:78e:0:1991:8:25 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762725215; cv=none; b=HwJ0fcB2Pp12RRkLG6YbtF0hEdgfAYdpzPwDVgb7as5g6IyQ5Kw0TIvcOHBMt9xyfSmBbPJhOz1Nd4HAHwWTwrREPkFGuxopvEC7EVJMjMgY9tGxvRrAiuw7vhmUSJmoU2oJO9Ws8V8DOLjrz6Gi5rHBQuRKwDQ8OfDqJpUzDPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762725215; c=relaxed/simple; bh=lvV5V1kO/VCSfYtiaHEH+muFcDUkNxgkfwkIYFjY0RU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=nzSC8wOGvAFEdta34hJ+hZGIjVIhvEdW1mREMeQcasjLFsFqiGothnnNbZBYWxqWSdfybZk7hF/JBxeB1U2LFPY7IZMTsBWi7RSlzHgUz3Vlo0VWavX3xJkqNIDEz34Q1UV3CWoRmyxL2xTp1vZE/Yx1Gu3mnhpoPt2GZejqSJA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 66E8C3858412 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id C087B444FC for ; Sun, 9 Nov 2025 21:53:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01B21C116B1; Sun, 9 Nov 2025 21:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762725214; bh=lvV5V1kO/VCSfYtiaHEH+muFcDUkNxgkfwkIYFjY0RU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SPGm5XWTkly+YhLzBkRY/c2deRP4/sMPFwwrK9KdtPH1d0hifXvU3z2zN5SNEir+C 8hb5WcCRPhTVnSq5YgehfpBAkLEcqsKKBllq0726opjIdM27E0Kj54MH9R8CqmKKC8 tGiw1kb+xPs7vI+tKPv5G3RA+4veJvkqAr9UTlz2RY5EAnFZsw3lCBK+AHh1qOIsHt ptTCd/QDAW3QFQhoatiD7PgQnHp+5/OWK+4OdE1rTTRaCQm3rbQhHoZOLUS1sx3PT1 5Hc/aJY4qHkxMNBFpcNiUJDMKvLMEif2uBAAW7e7+xlu1tOn/IPd10xS5xLbFnunGL /MowSTHm09qGw== Date: Sun, 9 Nov 2025 22:53:32 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar Subject: [PATCH v1 18/35] Assume _Generic(3) is supported by the compiler Message-ID: X-Mailer: git-send-email 2.51.0 References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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~patchwork=sourceware.org@sourceware.org We already assume that GCC is at least GCC 5, and we also assume that Clang is at least Clang 4. I don't know when Clang added support for _Generic(3), but I see it being supported in Clang 3.3: llvm.git 587b34850493 (2013-02-12; "Perform placeholder conversions on the controller of a _Generic expression.") $ git describe --contains 587b34850493 llvmorg-3.3.0-rc1~7^2~5659 Signed-off-by: Alejandro Colomar --- timezone/private.h | 22 +--------------------- timezone/zdump.c | 6 ++---- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/timezone/private.h b/timezone/private.h index fcd71a044d..4f430dba2c 100644 --- a/timezone/private.h +++ b/timezone/private.h @@ -72,19 +72,6 @@ ** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'. */ -#if !defined HAVE__GENERIC && defined __has_extension -# if !__has_extension(c_generic_selections) -# define HAVE__GENERIC 0 -# endif -#endif -/* _Generic is buggy in pre-4.9 GCC. */ -#if !defined HAVE__GENERIC && !defined __STRICT_ANSI__ -# define HAVE__GENERIC (4 < __GNUC__ + (9 <= __GNUC_MINOR__)) -#endif -#ifndef HAVE__GENERIC -# define HAVE__GENERIC (201112 <= __STDC_VERSION__) -#endif - #if !defined HAVE_GETTEXT && defined __has_include # if __has_include() # define HAVE_GETTEXT true @@ -844,9 +831,7 @@ ATTRIBUTE_PURE time_t time2posix_z(timezone_t, time_t); any portability problems occur only when compiling .c files that use the macros, which is safer for applications that need only zdump and zic. This implementation assumes no padding if time_t is signed and - either the compiler lacks support for _Generic or time_t is not one - of the standard signed integer types. */ -#if HAVE__GENERIC + time_t is not one of the standard signed integer types. */ # define TIME_T_MIN \ _Generic((time_t) 0, \ signed char: SCHAR_MIN, short: SHRT_MIN, \ @@ -864,11 +849,6 @@ enum { SIGNED_PADDING_CHECK_NEEDED signed char: false, short: false, int: false, long: false, long long: false, default: true) }; -#else -# define TIME_T_MIN TIME_T_MIN_NO_PADDING -# define TIME_T_MAX TIME_T_MAX_NO_PADDING -enum { SIGNED_PADDING_CHECK_NEEDED = true }; -#endif /* Try to check the padding assumptions. Although TIME_T_MAX and the following check can both have undefined behavior on oddball platforms due to shifts exceeding widths of signed integers, these diff --git a/timezone/zdump.c b/timezone/zdump.c index e817873337..3c5f72c665 100644 --- a/timezone/zdump.c +++ b/timezone/zdump.c @@ -1178,14 +1178,12 @@ abbr(struct tm const *tmp) } /* -** The code below can fail on certain theoretical systems; -** it works on all known real-world systems as of 2022-01-25. +** The code below can fail on certain theoretical systems. */ static const char * tformat(void) { -#if HAVE__GENERIC /* C11-style _Generic is more likely to return the correct format when distinct types have the same size. */ char const *fmt = @@ -1201,7 +1199,7 @@ tformat(void) default: NULL); if (fmt) return fmt; -#endif + if (0 > (time_t) -1) { /* signed */ if (sizeof(time_t) == sizeof(intmax_t)) return "%"PRIdMAX;