get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2216451/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2216451,
    "url": "http://patchwork.ozlabs.org/api/patches/2216451/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260326135049.2254482-1-yury.khrustalev@arm.com/",
    "project": {
        "id": 41,
        "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api",
        "name": "GNU C Library",
        "link_name": "glibc",
        "list_id": "libc-alpha.sourceware.org",
        "list_email": "libc-alpha@sourceware.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260326135049.2254482-1-yury.khrustalev@arm.com>",
    "list_archive_url": null,
    "date": "2026-03-26T13:50:49",
    "name": "[v2] support: add support_address_diff function",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "3fac023630cae3f8783cb9a4e58f93833f270672",
    "submitter": {
        "id": 88214,
        "url": "http://patchwork.ozlabs.org/api/people/88214/?format=api",
        "name": "Yury Khrustalev",
        "email": "yury.khrustalev@arm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260326135049.2254482-1-yury.khrustalev@arm.com/mbox/",
    "series": [
        {
            "id": 497590,
            "url": "http://patchwork.ozlabs.org/api/series/497590/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=497590",
            "date": "2026-03-26T13:50:49",
            "name": "[v2] support: add support_address_diff function",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/497590/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2216451/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2216451/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256\n header.s=foss header.b=Gnk+3hna;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)",
            "sourceware.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key,\n unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256\n header.s=foss header.b=Gnk+3hna",
            "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=arm.com",
            "sourceware.org; spf=pass smtp.mailfrom=arm.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=217.140.110.172"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhQDD10GQz1yGD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 00:51:24 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id AB5574BA23E0\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 13:51:21 +0000 (GMT)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by sourceware.org (Postfix) with ESMTP id EA5F04BA23C5\n for <libc-alpha@sourceware.org>; Thu, 26 Mar 2026 13:50:57 +0000 (GMT)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7561E16F3;\n Thu, 26 Mar 2026 06:50:51 -0700 (PDT)",
            "from fdebian.localdomain (unknown [10.1.33.30])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B95953F641;\n Thu, 26 Mar 2026 06:50:56 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org AB5574BA23E0",
            "OpenDKIM Filter v2.11.0 sourceware.org EA5F04BA23C5"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org EA5F04BA23C5",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org EA5F04BA23C5",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774533058; cv=none;\n b=fBYtOetQ9ZPUIowvnHBEQ0Bqv99GHPFvFpSChdg7iNgkLPXz0lfLWCbcbRotkIPrd8KQIdjpkcCAoRdBqu/OnmUsAgBwQmSTSk/gOzcj+QcEstWhRevxUi1gQolSvKtojred6P0819opU7LuK3eqJEgLhZzqT6rFvgVP0UVb8vM=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774533058; c=relaxed/simple;\n bh=ckhRW6nf2n/hkCRSNcxCW03pppDU22x3lWDcIMr3VY8=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=Zi2t6C45tnJV/S6cd5lY7hcP2fEOSi6I0T2Mc0HJONkLhltCh7pLsl58PERn8dy7pdQJ+9Ujx1/Ryo1I8+pR56kUSz1PitAt5tLtZbReWo8mVBzOfGJGMHD9+8LR7oFjV+9jhp69l1J68iTlGwx7Fqej3QJjCFnhG7rpiCRFG5s=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss;\n t=1774533057; bh=ckhRW6nf2n/hkCRSNcxCW03pppDU22x3lWDcIMr3VY8=;\n h=From:To:Cc:Subject:Date:From;\n b=Gnk+3hnaFHCONYcwDn98u8QH0Q+nn22RjlBqm1Qaq3fnCDgeEagc8ruyaRth3CTkc\n ZwocUCOAmsIEasr1S/fJw8ohdz1t0bDs5D/4Rvrpp2vwvPt4qX0cQLr1syxif5I6a1\n ta1o4bTw7AE+Zxk0PVMocOKXm4SoKcoVUuuaqK9o=",
        "From": "Yury Khrustalev <yury.khrustalev@arm.com>",
        "To": "libc-alpha@sourceware.org",
        "Cc": "Adhemerval Zanella <adhemerval.zanella@linaro.org>,\n Florian Weimer <fweimer@redhat.com>,\n Wilco Dijkstra <wilco.dijkstra@arm.com>",
        "Subject": "[PATCH v2] support: add support_address_diff function",
        "Date": "Thu, 26 Mar 2026 13:50:49 +0000",
        "Message-ID": "<20260326135049.2254482-1-yury.khrustalev@arm.com>",
        "X-Mailer": "git-send-email 2.47.3",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libc-alpha@sourceware.org",
        "X-Mailman-Version": "2.1.30",
        "Precedence": "list",
        "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>",
        "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>",
        "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>",
        "List-Post": "<mailto:libc-alpha@sourceware.org>",
        "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>",
        "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>",
        "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"
    },
    "content": "Some malloc tests compare pointers meaning to compare addresses.\nOn AArch64, the 64-bit value of the pointer may contain metadata\nalong with the values of the address.\n\nIn order to correctly compare addresses, we add new function for\nAArch64 target that will use the AArch64 64 SUBP (subtract pointer)\ninstruction when it is available. This instruction uses the 56-bit\naddresses ignoring top-byte metadata.\n\nBest implementation is selected using ifunc resolver.\n\nOn other targets and also on AArch64 when MTE is not available this\nfunction defaults to PTR_DIFF defined in libc-pointer-arith.h.\n\nThree malloc tests are modified accordingly:\n - tst-memalign-2.c\n - tst-memalign-3.c\n - tst-realloc.c\n\n---\nbase-commit: 4a97c12302\npasses regression on aarch64 and x86-64\n\nChanges in v2:\n - Use sysdeps files rather than arch-specific macro for conditional\n   compilation of code.\n - Renamed the support_address_diff and added comment explaining what\n   it does.\n - v1: https://inbox.sourceware.org/libc-alpha/20260325105900.828958-1-yury.khrustalev@arm.com/\n\n---\n malloc/tst-memalign-2.c                | 10 +++---\n malloc/tst-memalign-3.c                | 10 +++---\n malloc/tst-realloc.c                   |  5 +--\n support/Makefile                       |  2 +-\n support/address-diff.h                 | 27 ++++++++++++++\n sysdeps/aarch64/Makefile               |  6 ++++\n sysdeps/aarch64/support-address-diff.c | 50 ++++++++++++++++++++++++++\n sysdeps/generic/Makefile               |  6 ++++\n sysdeps/generic/support-address-diff.c | 26 ++++++++++++++\n 9 files changed, 131 insertions(+), 11 deletions(-)\n create mode 100644 support/address-diff.h\n create mode 100644 sysdeps/aarch64/support-address-diff.c\n create mode 100644 sysdeps/generic/support-address-diff.c",
    "diff": "diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c\nindex b3e393c249..2dd8808236 100644\n--- a/malloc/tst-memalign-2.c\n+++ b/malloc/tst-memalign-2.c\n@@ -23,6 +23,7 @@\n #include <unistd.h>\n #include <array_length.h>\n #include <libc-pointer-arith.h>\n+#include <support/address-diff.h>\n #include <support/check.h>\n #include \"tst-malloc-aux.h\"\n \n@@ -82,9 +83,9 @@ do_test (void)\n       /* This should return the same chunk as was just free'd.  */\n       tcache_allocs[i].ptr2 = memalign (tcache_allocs[i].alignment, sz2);\n       CHECK (tcache_allocs[i].ptr2, tcache_allocs[i].alignment);\n+      TEST_VERIFY (support_address_diff (\n+\ttcache_allocs[i].ptr1, tcache_allocs[i].ptr2) == 0);\n       free (tcache_allocs[i].ptr2);\n-\n-      TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);\n     }\n \n   /* Test for non-head tcache hits.  This exercises the memalign\n@@ -110,7 +111,7 @@ do_test (void)\n \n   count = 0;\n   for (i = 0; i < 10; ++ i)\n-    if (ptr[i] == p)\n+    if (support_address_diff (ptr[i], p) == 0)\n       ++ count;\n   free (p);\n   TEST_VERIFY (count > 0);\n@@ -146,7 +147,8 @@ do_test (void)\n     {\n       int ok = 0;\n       for (j = 0; j < LN; ++ j)\n-\tif (large_allocs[i].ptr1 == large_allocs[j].ptr2)\n+\tif (support_address_diff (large_allocs[i].ptr1, large_allocs[j].ptr2)\n+\t    == 0)\n \t  ok = 1;\n       if (ok == 1)\n \tcount ++;\ndiff --git a/malloc/tst-memalign-3.c b/malloc/tst-memalign-3.c\nindex 435e1c94d5..f1b045b095 100644\n--- a/malloc/tst-memalign-3.c\n+++ b/malloc/tst-memalign-3.c\n@@ -24,6 +24,7 @@\n #include <unistd.h>\n #include <array_length.h>\n #include <libc-pointer-arith.h>\n+#include <support/address-diff.h>\n #include <support/check.h>\n #include <support/xthread.h>\n #include \"tst-malloc-aux.h\"\n@@ -85,9 +86,9 @@ mem_test (void *closure)\n       /* This should return the same chunk as was just free'd.  */\n       tcache_allocs[i].ptr2 = memalign (tcache_allocs[i].alignment, sz2);\n       CHECK (tcache_allocs[i].ptr2, tcache_allocs[i].alignment);\n+      TEST_VERIFY (support_address_diff (\n+\ttcache_allocs[i].ptr1, tcache_allocs[i].ptr2) == 0);\n       free (tcache_allocs[i].ptr2);\n-\n-      TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);\n     }\n \n   /* Test for non-head tcache hits.  */\n@@ -112,7 +113,7 @@ mem_test (void *closure)\n \n   count = 0;\n   for (i = 0; i < 10; ++ i)\n-    if (ptr[i] == p)\n+    if (support_address_diff (ptr[i], p) == 0)\n       ++ count;\n   free (p);\n   TEST_VERIFY (count > 0);\n@@ -146,7 +147,8 @@ mem_test (void *closure)\n     {\n       int ok = 0;\n       for (j = 0; j < LN; ++ j)\n-\tif (large_allocs[i].ptr1 == large_allocs[j].ptr2)\n+\tif (support_address_diff (large_allocs[i].ptr1, large_allocs[j].ptr2)\n+\t    == 0)\n \t  ok = 1;\n       if (ok == 1)\n \tcount ++;\ndiff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c\nindex e02b28d982..0e616d3827 100644\n--- a/malloc/tst-realloc.c\n+++ b/malloc/tst-realloc.c\n@@ -22,6 +22,7 @@\n #include <string.h>\n #include <libc-diag.h>\n #include <support/check.h>\n+#include <support/address-diff.h>\n \n #include \"tst-malloc-aux.h\"\n \n@@ -155,9 +156,9 @@ do_test (void)\n       size_t newsz = malloc_usable_size (p);\n       printf (\"size: %zu, usable size: %zu, extra: %zu\\n\",\n \t      sz, newsz, newsz - sz);\n-      uintptr_t oldp = (uintptr_t) p;\n+      void *oldp = p;\n       void *new_p = realloc (p, newsz);\n-      if ((uintptr_t) new_p != oldp)\n+      if (support_address_diff (new_p, oldp) != 0)\n \tFAIL_EXIT1 (\"Expanding (%zu bytes) to usable size (%zu) moved block\",\n \t\t    sz, newsz);\n       free (new_p);\ndiff --git a/support/Makefile b/support/Makefile\nindex 1dae2802cf..3f19a98bdc 100644\n--- a/support/Makefile\n+++ b/support/Makefile\n@@ -254,7 +254,7 @@ libsupport-routines = \\\n   xwrite \\\n   # libsupport-routines\n \n-libsupport-static-only-routines := $(libsupport-routines)\n+libsupport-static-only-routines = $(libsupport-routines) $(libsupport-sysdep_routines)\n # Only build one variant of the library.\n libsupport-inhibit-o := .os\n ifeq ($(build-shared),yes)\ndiff --git a/support/address-diff.h b/support/address-diff.h\nnew file mode 100644\nindex 0000000000..ef58b9d8a6\n--- /dev/null\n+++ b/support/address-diff.h\n@@ -0,0 +1,27 @@\n+/* Support functions for pointer arithmetic.\n+   Copyright (C) 2026 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#ifndef _POINTER_ARITH_H\n+#define _POINTER_ARITH_H 1\n+\n+#include <stddef.h>\n+\n+/* Returns difference in bytes between addresses of two pointers.  */\n+ptrdiff_t support_address_diff (const void *lhs, const void *rhs);\n+\n+#endif /* _POINTER_ARITH_H */\ndiff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile\nindex d6c5cc96ca..d3146ddced 100644\n--- a/sysdeps/aarch64/Makefile\n+++ b/sysdeps/aarch64/Makefile\n@@ -90,3 +90,9 @@ endif\n ifeq ($(subdir),malloc)\n sysdep_malloc_debug_routines = __mtag_tag_zero_region __mtag_tag_region\n endif # malloc directory\n+\n+ifeq ($(subdir),support)\n+libsupport-sysdep_routines += \\\n+  support-address-diff \\\n+  # libsupport-sysdep_routines\n+endif\ndiff --git a/sysdeps/aarch64/support-address-diff.c b/sysdeps/aarch64/support-address-diff.c\nnew file mode 100644\nindex 0000000000..fd8d3ed920\n--- /dev/null\n+++ b/sysdeps/aarch64/support-address-diff.c\n@@ -0,0 +1,50 @@\n+/* Support functions for pointer arithmetic for AArch64.\n+   Copyright (C) 2026 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#include \"address-diff.h\"\n+\n+#include <sys/ifunc.h>\n+#include <sys/auxv.h>\n+#include <libc-pointer-arith.h>\n+\n+static ptrdiff_t\n+address_diff_mte (const void *lhs, const void *rhs)\n+{\n+  register const void *x0 asm (\"x0\") = lhs;\n+  register const void *x1 asm (\"x1\") = rhs;\n+  asm (\".inst 0x9ac10000 /* subp x0, x0, x1 */\" : \"+r\" (x0) : \"r\" (x1));\n+  return (ptrdiff_t)x0;\n+}\n+\n+static ptrdiff_t\n+address_diff_generic (const void *lhs, const void *rhs)\n+{\n+  return PTR_DIFF (lhs, rhs);\n+}\n+\n+static void * __attribute__ ((unused))\n+address_diff_resolver (unsigned long a0, const unsigned long *a1)\n+{\n+  unsigned long hwcap2 = __ifunc_hwcap (_IFUNC_ARG_AT_HWCAP2, a0, a1);\n+  if (hwcap2 & HWCAP2_MTE)\n+    return (void *)address_diff_mte;\n+  return (void *)address_diff_generic;\n+}\n+\n+ptrdiff_t support_address_diff (const void *lhs, const void *rhs)\n+__attribute__ ((ifunc (\"address_diff_resolver\")));\ndiff --git a/sysdeps/generic/Makefile b/sysdeps/generic/Makefile\nindex 0c25592f35..1f60c29694 100644\n--- a/sysdeps/generic/Makefile\n+++ b/sysdeps/generic/Makefile\n@@ -38,3 +38,9 @@ endif\n ifeq ($(subdir),misc)\n sysdep_routines += malloc-hugepages\n endif\n+\n+ifeq ($(subdir),support)\n+libsupport-sysdep_routines += \\\n+  support-address-diff \\\n+  # libsupport-sysdep_routines\n+endif\ndiff --git a/sysdeps/generic/support-address-diff.c b/sysdeps/generic/support-address-diff.c\nnew file mode 100644\nindex 0000000000..51b5640acd\n--- /dev/null\n+++ b/sysdeps/generic/support-address-diff.c\n@@ -0,0 +1,26 @@\n+/* Support functions for pointer arithmetic.\n+   Copyright (C) 2026 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#include \"address-diff.h\"\n+\n+#include <libc-pointer-arith.h>\n+\n+ptrdiff_t support_address_diff (const void *lhs, const void *rhs)\n+{\n+  return PTR_DIFF (lhs, rhs);\n+}\n",
    "prefixes": [
        "v2"
    ]
}