From patchwork Fri Dec 13 07:13:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 102954 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 E88B73857BBB for ; Fri, 13 Dec 2024 07:14:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by sourceware.org (Postfix) with ESMTPS id F152A385840B for ; Fri, 13 Dec 2024 07:13:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F152A385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F152A385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734074000; cv=none; b=C3SMvCmS0+L45f6pzwo0rFWGi5Kdy0o3Gg0AJ1BG9GEzfjmSRE2sRXj0JwQ4tnbLP+t1M06eXBFDKbKyqjGEsdd6bFFx/nPBuhH8ycsiinYkG8PIzqIXzyBGoovZGqZlpVPzulLztRBmiKBwREJJAc3XMWcAKdj22qDMiq4Qxek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734074000; c=relaxed/simple; bh=HGq1+Hp1TlEvs7+y4s4PU7WrM33BQ7vJEl0nw9avRuQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NAPGN3PTh19AsfCckELQ7Q9pk/tnUcrAZYEGiCSev8oQBXLkUV1613HHHK6TDno9SoA85DPkfLSCQvn5nvW1476bItqEyvEt8eiQW8Z1OSkFkw63mksTfhcM+8C06fz2rSNbmwXwH/132cyMe5LIee89iNOrKfmN34PQ3/RMWWo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F152A385840B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Xb6+YkPi Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5f2d5b3c094so327154eaf.1 for ; Thu, 12 Dec 2024 23:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734073999; x=1734678799; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yQ74vw3J1oXFAj3ejQ6vwx6VspuVdYuM/3U7OP4NVKQ=; b=Xb6+YkPin9l4OnQaco/XDAqHtHKu5p8fZDNxkP2tf1H85DVYaIQGVxhDy65/5jWnQT 9zFPCQ1Q0Hn0268h15zZ/CG+k5Gl/E88Z4RkczApQ2ZvyDc+tuwOsNrmgBSp1VSHEIEu uv3zvoTgCi7LPxPrBVItekrT1X+rIieUP2+LIfbCZT2ZjGS7Uf3pz4mptlX/lLsEJNxA 7TtvvHmQFm8l6Hs8dOLaVbi0AqoFo3mLzkIDVVrx44H8K/bLLj9TUuFo2tTBsFgmWmzM /v3O16MS6egSczXORyEOt7/kbQmQGBnOjp5NwuXRU4nU03CV/LPBbcJIziG0o3AOEna2 hWUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734073999; x=1734678799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yQ74vw3J1oXFAj3ejQ6vwx6VspuVdYuM/3U7OP4NVKQ=; b=hX/XCjEfeQKkGr3QHHh5OFwRMFDtvLJBqN8OtfwF8MN++UCu2eEXOOvNi4xHajudeJ s2/NYSZi0aIwvw5q5674768bzgYQI3E18auleTaiPc7P0icY6b8TH9hZm5k1vPqKlyzn fPn5qKt6n2WikK6+ecp4JEl8eaibDY5aroAVB2hUEdxFng7y+Fw71P/yWNsugLjTuktF JhONKVyQdG+m/Xy3W9UqCf30d3dd52OiX6f5iLmlr+qSh0WcIxxY9iAKK+oHd6SRilmh y4B6CA8qga9lI/UzSaMiZbpyD89CfeTfawE+lqDl1bXsyu/vbhqgz0ZGlL6ki9PvlOLL Tcjg== X-Gm-Message-State: AOJu0YxEDzhbOEaQbxxFKibGmp+GNK8x2ti3P+wODpHwMLanAUUUUxmu 5sRsyxQJua5X4PpzRgXJVSMX0qWMt159Ndd/XvaxemkqbxZ8ytOvzAGbGZraZAuyyCfS X-Gm-Gg: ASbGnctRJffk4tF9k98ILvkgzpyIx1M77kLAe7RhMXiorG5T6puQJ/zPMPn6nVEfSQX mTOtg1qfdMz2eWTg49jtgZlvUYKzMRHgP6UxQiVyiaBI5WmUjTBntlJo5V6bPgIw0DcohIdFtXo Cd/KJzbThTj8WoiahwN1S1it1stb9FZkgZ9WU4DQrGCn3+x2DlNxutFOhiGODwJsxl/Sl5mRUo/ 30gsHFA7y5BgLBZe2iRRVQ/aEns8ZRL/wydJCPwQaQlSYoUfv1yiNQImrlw6o4GW+XJYRVCMP4C mEJHETdoseI2Xpq2 X-Google-Smtp-Source: AGHT+IGbvsJgdIHI1C6NasQpiRGCu0sREG26ry4nngUioXM60C3aMiIW/EYysqASoBd5bxr/Fquhwg== X-Received: by 2002:a05:6870:15ca:b0:29e:43ce:a172 with SMTP id 586e51a60fabf-2a3ac867f5amr764192fac.28.1734073999043; Thu, 12 Dec 2024 23:13:19 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.27.218]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29fb38c2309sm3392153fac.9.2024.12.12.23.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 23:13:18 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 05BADC044D; Fri, 13 Dec 2024 15:13:11 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: sam@gentoo.org Subject: [PATCH 05/10] Return EXIT_UNSUPPORTED if __builtin_add_overflow unavailable Date: Fri, 13 Dec 2024 15:13:05 +0800 Message-ID: <20241213071310.2054769-6-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213071310.2054769-1-hjl.tools@gmail.com> References: <20241213071310.2054769-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3019.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 Since GCC 4.9 doesn't have __builtin_add_overflow: In file included from tst-stringtable.c:180:0: stringtable.c: In function ‘stringtable_finalize’: stringtable.c:185:7: error: implicit declaration of function ‘__builtin_add_overflow’ [-Werror=implicit-function-declaration] else if (__builtin_add_overflow (previous->offset, ^ return EXIT_UNSUPPORTED for GCC 4.9 or older. Signed-off-by: H.J. Lu --- elf/tst-stringtable.c | 10 ++++++++++ io/tst-utimensat-skeleton.c | 5 +++++ sysdeps/unix/sysv/linux/tst-getdents64.c | 7 +++++++ time/tst-ctime.c | 5 +++++ time/tst-difftime.c | 7 ++++++- time/tst-mktime4.c | 8 +++++++- 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/elf/tst-stringtable.c b/elf/tst-stringtable.c index e18496f3f1..a0e358f02a 100644 --- a/elf/tst-stringtable.c +++ b/elf/tst-stringtable.c @@ -17,6 +17,7 @@ #include #include +#if __GNUC_PREREQ (5, 0) #include #include #include @@ -179,3 +180,12 @@ do_test (void) #define _(arg) arg #include "stringtable.c" #include "stringtable_free.c" +#else +#include + +int +main (void) +{ + return EXIT_UNSUPPORTED; +} +#endif diff --git a/io/tst-utimensat-skeleton.c b/io/tst-utimensat-skeleton.c index 290ed81c9b..1386fa3c8f 100644 --- a/io/tst-utimensat-skeleton.c +++ b/io/tst-utimensat-skeleton.c @@ -20,6 +20,7 @@ #include #include #include +#include #include static int temp_fd = -1; @@ -72,6 +73,7 @@ do_test (void) for (int i = 0; i < array_length (tests); i++) { /* Check if we run on port with 32 bit time_t size. */ +#if __GNUC_PREREQ (5, 0) time_t t; if (__builtin_add_overflow (tests[i].v1, 0, &t) || __builtin_add_overflow (tests[i].v2, 0, &t)) @@ -80,6 +82,9 @@ do_test (void) "time_t overflows\n", i, tests[i].v1, tests[i].v2); continue; } +#else + return EXIT_UNSUPPORTED; +#endif if (tests[i].v1 >= 0x100000000LL && !y2106) { diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c index 3dd22a4e03..ba66d49a2e 100644 --- a/sysdeps/unix/sysv/linux/tst-getdents64.c +++ b/sysdeps/unix/sysv/linux/tst-getdents64.c @@ -30,6 +30,7 @@ #include #include +#if __GNUC_PREREQ (5, 0) /* Called by large_buffer_checks below. */ static void large_buffer_check (int fd, char *large_buffer, size_t large_buffer_size) @@ -85,6 +86,12 @@ do_test_large_size (void) xclose (fd); } +#else +static void +do_test_large_size (void) +{ +} +#endif static void do_test_by_size (size_t buffer_size) diff --git a/time/tst-ctime.c b/time/tst-ctime.c index 8debf15004..f997a93801 100644 --- a/time/tst-ctime.c +++ b/time/tst-ctime.c @@ -19,6 +19,7 @@ #include #include #include +#include static int do_test (void) @@ -54,8 +55,12 @@ do_test (void) /* Check if we run on port with 32 bit time_t size */ time_t tov; +#if __GNUC_PREREQ (5, 0) if (__builtin_add_overflow (t, 1, &tov)) return 0; +#else + return EXIT_UNSUPPORTED; +#endif /* Check if the time is converted after 32 bit time_t overflow. */ str = ctime (&tov); diff --git a/time/tst-difftime.c b/time/tst-difftime.c index 5043d55087..94723aa906 100644 --- a/time/tst-difftime.c +++ b/time/tst-difftime.c @@ -18,6 +18,7 @@ #include #include +#include static void test_difftime_helper (time_t t1, time_t t0, double exp_val) @@ -37,10 +38,14 @@ do_test (void) test_difftime_helper (t - 1800, t + 1800, -3600.0); t = 0x7FFFFFFF; - /* Check if we run on port with 32 bit time_t size */ time_t tov; +#if __GNUC_PREREQ (5, 0) + /* Check if we run on port with 32 bit time_t size */ if (__builtin_add_overflow (t, 1, &tov)) return 0; +#else + return EXIT_UNSUPPORTED; +#endif /* Check if the time is converted after 32 bit time_t overflow. */ test_difftime_helper (t + 1800, t - 1800, 3600.0); diff --git a/time/tst-mktime4.c b/time/tst-mktime4.c index 505d9fcc2e..50d3acd375 100644 --- a/time/tst-mktime4.c +++ b/time/tst-mktime4.c @@ -19,6 +19,7 @@ #include #include #include +#include const struct tm tm0 = { @@ -55,11 +56,16 @@ const struct tm tm32bitmax = static int test_mktime_helper (struct tm *tm, long long int exp_val, int line) { - time_t result, t; + time_t result; +#if __GNUC_PREREQ (5, 0) /* Check if we run on port with 32 bit time_t size. */ + time_t t; if (__builtin_add_overflow (exp_val, 0, &t)) return 0; +#else + return EXIT_UNSUPPORTED; +#endif result = mktime (tm); if (result == (time_t) -1)