From nobody Tue Sep 16 17:34:54 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cR8DG6j0sz67hZF; Tue, 16 Sep 2025 17:34:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cR8DG6DFNz4PsX; Tue, 16 Sep 2025 17:34:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758044094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hAB4Z0+SZboqfh4vyxix0RDfFCFsmTDJm/sdS+A46GQ=; b=CUwfyobfJE7wOeolzBtfo8j1sobSBUTJeAbZKhjE6ewpc9q0gdTrP6y+wU0BVTTX0wPFbT Am4XYihw3jgivIFGIA/QrqFq4LaogKusok6Oj2CKXQ806AJQRAxlc1nQsCvXvDgnl3fQ6T FzhMbxRzrO01pPih1tfVRJ9t1Zx2qLoyQJN9Qu9R0oDCyDjCa1I+PhVgNZGsZtYuCEQCtz 8aM30fE/2dR8NewpamBtYXljHQaw2PvTWiwWmgNsWUY0CYgSZjq/yrmZb2WHXF4D8vscE0 rcjws+0hs6sycnZhwiOwiS8mHJ4cmyxK3ikRz2WAjSDCcL07XGFrDPZNIXCpKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758044094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hAB4Z0+SZboqfh4vyxix0RDfFCFsmTDJm/sdS+A46GQ=; b=LnbtkTOivcHyLO7NcbXXwshrxJLxdl2ffENa7sNp8IBTbDKtnjBAi+Qsrd223iTQtBN0Xo a8ZDbsDy25MrSDMFjk8S9OS2JqyBj69y8SlyoqrxnzsIdJOU/XvafjJyfaUl+3m7oNEOFl vx8kp4Y/XqhP+H97MG7sG8XwGJNR/B99vrieuDXgh3QhfCJH7+v6KCKS23uKXTe0TxS22i 2iRy65Xes08RF5lGObquLhtlvDl11BhdUGzh7gwyQZREQgjAHg0LjUL+mnb/CYZovqJHGy rozqWqsl0Yb5eoY48ARyElImgdctF5DwkcE6bx2o9CYdIT5IcQcHuifIQCiOGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758044094; a=rsa-sha256; cv=none; b=OAt5e4LzTwljfsUHXqtOAdf54NhqxznXJrcviAXVm3dzoLq8cqWXSgXv059HCWNuvIhVWx 8LQlIZ7I3ke6YoNIT/qHsSv5mPP6xI0OUuBNOalBHztxVkqeN79DoA31xAkD8aqhsOOP6H QEoNf08kGpDz1m+hRvXUikkYcL7MvNzdekT02Rcp7gE9Fj/t9Ey/kOocTzbDV8xKCIGJKj XeJy6vHEykuz0oN5plaoO9VGzu89hzBVfOekOGNSqh3UDEs8+lSJfXRX2GBVU9Y8H1mTp0 fdwhnsoaIeT1ZT8OL0VQRNrFEO0eRO6efEFP/D6wbZC2Ae7SbQiLdT4VrEcE9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cR8DG5ppCzr5V; Tue, 16 Sep 2025 17:34:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58GHYsVc079497; Tue, 16 Sep 2025 17:34:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58GHYsVZ079494; Tue, 16 Sep 2025 17:34:54 GMT (envelope-from git) Date: Tue, 16 Sep 2025 17:34:54 GMT Message-Id: <202509161734.58GHYsVZ079494@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 79e4dfe2a5f7 - stable/15 - libc: Have memcmp test what the standard requires List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 79e4dfe2a5f7079608b92d2d1fe38838e7601323 Auto-Submitted: auto-generated The branch stable/15 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=79e4dfe2a5f7079608b92d2d1fe38838e7601323 commit 79e4dfe2a5f7079608b92d2d1fe38838e7601323 Author: Ed Maste AuthorDate: 2024-11-20 16:47:35 +0000 Commit: Ed Maste CommitDate: 2025-09-16 17:34:32 +0000 libc: Have memcmp test what the standard requires libc's C memcmp currently returns the difference in byte values rather than just -1/0/1 as the AArch64 assembly implementation, many non- FreeBSD implementations, and compiler built-in optimizations do. It is a bug for a user to expect memcmp to return the difference in the byte values as the compiler is free to inline memcmp() with an implementation that does not do this. Change the test to validate only what the standard requires. PR: 289084 Reviewed by: markj, fuz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52502 (cherry picked from commit e0eaabb80d1724acf88f04acbc2ca13d42270863) --- lib/libc/tests/string/memcmp_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/libc/tests/string/memcmp_test.c b/lib/libc/tests/string/memcmp_test.c index 5286a0b994f3..fa2f498ccfaf 100644 --- a/lib/libc/tests/string/memcmp_test.c +++ b/lib/libc/tests/string/memcmp_test.c @@ -41,14 +41,14 @@ #endif /* - * On FreeBSD we demand that memcmp returns the difference between the - * characters at the first site of mismatch. However, ISO/IEC 9899:1990 - * only specifies that a number greater than, equal to, or less than - * zero shall be returned. If a unit test for this less strict - * behaviour is desired, define RES(x) to be (((x) > 0) - ((x) < 0)). + * On FreeBSD we previously demanded that memcmp returns the difference + * between the characters at the first site of mismatch. However, + * ISO/IEC 9899:1990 only specifies that a number greater than, equal + * to, or less than zero shall be returned. If a unit test for the + * more strict behaviour is desired, define RES(x) to be (x). */ #ifndef RES -#define RES(x) (x) +#define RES(x) (((x) > 0) - ((x) < 0)) #endif static int (*memcmp_fn)(const void *, const void *, size_t);