From nobody Sat Oct 31 10:06:35 2026 X-Original-To: dev-commits-src-branches@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 4jGtsn1vDxz6yLGt for ; Sat, 31 Oct 2026 10:06:37 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jGtsm0PZZz4d0V for ; Sat, 31 Oct 2026 10:06:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793441196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L7C1VOKbPQuVwn/QkcWcyt+H2CkT1xS71OXIKJDLP9w=; b=Y3m3q5nFje8TY3ZJEhY3JSYtjRUnvIjFPx77YyNEeE1MxIgkP0sbP4C4k7aClXPDojxH/V 7idRqua/dCbhIU5PCvxwKzoqlcNGA7j9I6eFmePxC27TyvD16t4Q90uhuguR6AHI5JpIu2 A8XfVxX4/X0613ijaD4r4S3VVGdNvt4KBz+8EC1H74UWt3Z05M1SR5qlJlbemGC9G4KF90 4dcK0BJOBZxIfeekluBkd9ixblROc7efLprpz0YLFGQoBhE4y1Kqy51GJBU8TjTafr4LoM bGFlfsj0iKd3yroguuWrOxp6rAqnB9j1E3WNgX70jDjFxGAv1UkOldOq34vBbw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793441196; b=n3o3PyIIkJBfJg57eES7i5/bZoUVP5ku5/46pGZ+7e9XJkZ+RSEyRSJtrySgdPsrPGqS8G dPllkpcV9U4QUlD7SYfaXSK7kaThcDkRx7CPPsj/gYS4zwIIh7fsIjehgnnVcqFIvIITcj wTW0doCLCtEuJEe2q77/ALhELN7hUK77Huelmx/oPfQqiuZS1ycxDCCF9zzohA8EboDLak Em/jOLbEVCesxQwxhw36XfiZl+4IuS4VOLR375jqcU9KExL8HjEMbVXXHoVab/NAzcDpke 4Rg3OoOZ4BvSmpJ0L1jE0ocXVX0Lob5097/HtdjTVMk0kMQouQYmn4/1Hxal3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793441196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L7C1VOKbPQuVwn/QkcWcyt+H2CkT1xS71OXIKJDLP9w=; b=kUix0owhTYsOPlzotdXzwAiblX+T44lhMhAmwmxwtGYyZmbSf4uOWLT961DTqApD3gQ+AC WObIH2r8XtzCtOsOVDkQAOl/2ZwnPIDIbvF1Resr9oPlAY24bLMZUquBVTZvV30lIr0BNc 5I6OVLHAgVbAwSuw6338TFxMoMhhAzY3VTWr7YNewAzjwVpKn26KKAIajtw2OXTvHaTFPf oItcu0ugC20S1VLoptjW/Q737DlNcIMjSk1irjc/6WG+AX90pYne2ng3LhtOm2x0XlRWu5 1R8LOqLVHryyAWRD7kCqSyxsgfpUtOc9qzJ5ovla31G4ZpiTX+kEp23y9WFofg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jGtsl6xZZz17sK for ; Sat, 31 Oct 2026 10:06:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3b806 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 31 Oct 2026 10:06:35 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Faraz Vahedi From: Faraz Vahedi Subject: git: 123200496e24 - stable/15 - libc: Fix GCC pointer semantics for atomic_fetch_add/sub List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kfv X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 123200496e244a822f0774932336ba0f6ce64a48 Auto-Submitted: auto-generated Date: Sat, 31 Oct 2026 10:06:35 +0000 Message-Id: <6ae5bdab.3b806.1c34f7e8@gitrepo.freebsd.org> The branch stable/15 has been updated by kfv: URL: https://cgit.FreeBSD.org/src/commit/?id=123200496e244a822f0774932336ba0f6ce64a48 commit 123200496e244a822f0774932336ba0f6ce64a48 Author: Faraz Vahedi AuthorDate: 2026-05-08 02:54:23 +0000 Commit: Faraz Vahedi CommitDate: 2026-10-31 10:03:31 +0000 libc: Fix GCC pointer semantics for atomic_fetch_add/sub Correct the GCC implementation of `atomic_fetch_add_explicit()` and `atomic_fetch_sub_explicit()` for atomic pointer types. The previous implementation passed the operand directly to the builtins. For pointer objects, this could result in raw byte-wise address arithmetic rather than the required C atomic pointer semantics, where the operand is interpreted as a `ptrdiff_t` element count. As a result, operations such as `atomic_fetch_sub_explicit(&p, 2, ...)` could produce an incorrect post-operation pointer value. Fix this by applying pointer scaling in the GCC path before invoking the builtin, mirroring the existing legacy fallback implementation. Pointer operands are now scaled by the size of the pointed-to type, while integer atomic behaviour remains unchanged. Signed-off-by: Faraz Vahedi Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/2185 (cherry picked from commit 26bf9fc3a40275a7aca0ce1809751a90c84b643a) --- sys/sys/stdatomic.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index c0cbb7f785b5..a3d1f2cd4aeb 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -270,6 +270,8 @@ typedef _Atomic(__uintmax_t) atomic_uintmax_t; #define atomic_fetch_and_explicit(object, operand, order) \ __c11_atomic_fetch_and(object, operand, order) #elif defined(__GNUC_ATOMICS) +#define __atomic_apply_stride(object, operand) \ + (((__typeof__(*(object)))0) + (operand)) #define atomic_store_explicit(object, desired, order) \ __atomic_store_n(object, desired, order) #define atomic_load_explicit(object, order) \ @@ -285,9 +287,11 @@ typedef _Atomic(__uintmax_t) atomic_uintmax_t; __atomic_compare_exchange_n(object, expected, \ desired, 1, success, failure) #define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(object, operand, order) + __atomic_fetch_add(object, \ + __atomic_apply_stride(object, operand), order) #define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(object, operand, order) + __atomic_fetch_sub(object, \ + __atomic_apply_stride(object, operand), order) #define atomic_fetch_or_explicit(object, operand, order) \ __atomic_fetch_or(object, operand, order) #define atomic_fetch_xor_explicit(object, operand, order) \