Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2202503/?format=api
{ "id": 2202503, "url": "http://patchwork.ozlabs.org/api/patches/2202503/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260227183851.2113417-2-adhemerval.zanella@linaro.org/", "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": "<20260227183851.2113417-2-adhemerval.zanella@linaro.org>", "list_archive_url": null, "date": "2026-02-27T18:37:43", "name": "[v7,1/5] string: Add fallback implementation for ctz/clz", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e3c4f2936163a71f8aeced027de234653da463d2", "submitter": { "id": 66065, "url": "http://patchwork.ozlabs.org/api/people/66065/?format=api", "name": "Adhemerval Zanella", "email": "adhemerval.zanella@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260227183851.2113417-2-adhemerval.zanella@linaro.org/mbox/", "series": [ { "id": 493795, "url": "http://patchwork.ozlabs.org/api/series/493795/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=493795", "date": "2026-02-27T18:37:42", "name": "elf: Allow RPATH/RUNPATH for static-pie (BZ 33326)", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/493795/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2202503/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2202503/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=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=Vm+nUTkk;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::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=pass (2048-bit key,\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=Vm+nUTkk", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=linaro.org", "sourceware.org; spf=pass smtp.mailfrom=linaro.org", "server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::e2c" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::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 4fMxxk4yzBz1xy2\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 28 Feb 2026 05:41:46 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C22594BA23E8\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Feb 2026 18:41:44 +0000 (GMT)", "from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com\n [IPv6:2607:f8b0:4864:20::e2c])\n by sourceware.org (Postfix) with ESMTPS id 89CF74BA23CA\n for <libc-alpha@sourceware.org>; Fri, 27 Feb 2026 18:39:01 +0000 (GMT)", "by mail-vs1-xe2c.google.com with SMTP id\n ada2fe7eead31-5ff0f61abd7so675755137.1\n for <libc-alpha@sourceware.org>; Fri, 27 Feb 2026 10:39:01 -0800 (PST)", "from ubuntu-vm.. ([191.54.27.153]) by smtp.gmail.com with ESMTPSA id\n ada2fe7eead31-5ff1ea6ea19sm6283369137.12.2026.02.27.10.38.58\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 27 Feb 2026 10:39:00 -0800 (PST)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org C22594BA23E8", "OpenDKIM Filter v2.11.0 sourceware.org 89CF74BA23CA" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 89CF74BA23CA", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 89CF74BA23CA", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772217541; cv=none;\n b=Qw30qUudDLHUnh/ox11sjl1URHsNqhHs64aeKwMHYuawNmRgfAzC9/Xw2P4SpBIwjgPhW1E5dcWLwitMqN9PYrJxnadzrXfuRted0rMzL5VCLkkaH3u8bKqzdnePGuetd8ucLrAEVdqsvE+EYC4ZKlfLA7nfaxVWB3PJQ5qJYgI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1772217541; c=relaxed/simple;\n bh=BAu4TFBFoLIUKs46kv7h3yL3bwh4JYf4dxik8WP9hSs=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=so3uvhVf7kFVTIlCbNKdXRhBV3tjLh1xVIzufGOfy3f9+6mri693En6emOwCHrOQ1ycgiER0BlIf6skm7GSZGb+lr4GdWW6ImUz4IxD+SRPt/uRxTdNo3prCRufne6533Ni2C8V4tyhHKs7PP3cYqnMYwiViPiUhYwRN8sKhHqE=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1772217540; x=1772822340; darn=sourceware.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=Qw0l/LTsH5CgFeqg+XarjaTz4uswWL9aK3wa0DrLeS4=;\n b=Vm+nUTkkkrOC66kjHDF/nlbtqZ3U/Mr01kAwomtb9C7uOP5BUOLcrmpYrT/2hJuvKR\n sAEYwkk8sULzDs+zOKOKMyocP18WiePiCzjqG46kgM7YIeazjrNPOW/695cwoujMEpN5\n 3I2jV5L/WYBV02BHMM4w7t0/2fWME/Qi1j9DSBszWvkWf6KI0Z3DrBn78KKG6Srh0Vx1\n l9cRPcawLXTcio7V6nzYIRUP3QqvdPjuHNVfEBIbmIP67S/23xvBV/ImskfG1bRZ8Ihz\n K1x+UTfCSf8+jiFYJBYSw9orJbdmvtkVVBxXlb712FfRytPiBYeFLL/gcSWSc1EkYcyK\n l8CA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1772217540; x=1772822340;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=Qw0l/LTsH5CgFeqg+XarjaTz4uswWL9aK3wa0DrLeS4=;\n b=BE0rS+EH3Ge3TWTTD2Lh2lgMsr/arUCXaAUkjxF9jvErkHgwtOjj/yanagrAXjrGb6\n BlMZnDr26tuXOzWuaRc/K6eg6orfhQYwGgThKtuAKKwL5V2y7Z3DkNpO6XMLO4Ap2mHz\n yER31+YWD616OOJQT5XIaQfyddxr90fqmSVhblDUIMjf2PHWncS9RdAD/mwthrIikglX\n FA/cuwD2bRuMm+mlCaCF8+s38QeNWtIr0ednLdUXuY2a0PgEheq0uRNAy7pfiFqdNSCu\n sB3pha57JoW19U+ndIisPMobpGOHaZLh2NkGT2oSj+ooV0Wp7TdAe5Dch9dNTIs3z7R9\n 4LFw==", "X-Gm-Message-State": "AOJu0Yzm0xLkx8Rf4p5RfXbKg+QsmGmPVqXWmV7Tr27d/f7IR4UWpFMO\n kiq35GmoSl2YT8PRFfP/DUgZ4dJtlC2SnbgY8BmQ3UVAj2hoQfRZVss6MJ9kk44mvcuUKduxhaq\n bZcB9", "X-Gm-Gg": "ATEYQzwUN4X+dITlfoy6JdiiI2JDQQ2gtwjQHaj/swAhxIy89HliXg1tqgRYzwRoGpb\n n4qJMxayFS+AWWtTSLl4wY6pApdwTc2r0yXtwaf7AEwOjefay6ATTQPy8zbOEyZgWgLCzlrUe11\n H3ceq/kqA/y0/W4ZiiqIX08O1OwhTsDJNMz8Z9KiE0Zp5qJx93eEewi3Czw+Eusy/NIqayt1hS8\n aq6DcG1zEB8jU3vEm6k9xNjvSn1CMC9aYkYHKiqr0jjDBn9W3HRPQu6tughpVOXx2jts/U1vSk8\n OXG/c3cVs0Vevrj4gjrWXVuZNsUtcTF1tFO/+RBSFe69Lr2zpQufW8qenUReUv2TU5L2lfAm9ns\n qRzis9hG4nW3uionUbWS8o2sBPrDtOEfMDL/UcC8CDddk0ID5Xu9EorVOYhB9RMylykoMG0LK/0\n /iNBWn0uaUebFEsmjq9jqlZ/eh39j3ybxmoA8=", "X-Received": "by 2002:a05:6102:c01:b0:5f5:33c9:c9b3 with SMTP id\n ada2fe7eead31-5ff32536408mr1879578137.29.1772217540456;\n Fri, 27 Feb 2026 10:39:00 -0800 (PST)", "From": "Adhemerval Zanella <adhemerval.zanella@linaro.org>", "To": "libc-alpha@sourceware.org", "Cc": "Florian Weimer <fweimer@redhat.com>,\n Wilco Dijkstra <Wilco.Dijkstra@arm.com>", "Subject": "[PATCH v7 1/5] string: Add fallback implementation for ctz/clz", "Date": "Fri, 27 Feb 2026 18:37:43 +0000", "Message-ID": "<20260227183851.2113417-2-adhemerval.zanella@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260227183851.2113417-1-adhemerval.zanella@linaro.org>", "References": "<20260227183851.2113417-1-adhemerval.zanella@linaro.org>", "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": "The libgcc implementations of __builtin_clzl/__builtin_ctzl may require\naccess to additional data that is not marked as hidden, which could\nintroduce additional GOT indirection and necessitate RELATIVE relocs.\nAnd the RELATIVE reloc is an issue if the code is used during static-pie\nstartup before self-relocation (for instance, during an assert).\n\nFor this case, the ABI can add a string-bitops.h header that defines\nHAVE_BITOPTS_WORKING to 0. A configure check for this issue is tricky\nbecause it requires linking against the standard libraries, which\ncreate many RELATIVE relocations and complicate filtering those that\nmight be created by the builtins.\n\nThe fallback is disabled by default, so no target is affected.\n\nReviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>\n---\n sysdeps/generic/string-bitops.h | 26 ++++++++++++++++\n sysdeps/generic/string-fzi.h | 54 +++++++++++++++++++++------------\n 2 files changed, 61 insertions(+), 19 deletions(-)\n create mode 100644 sysdeps/generic/string-bitops.h", "diff": "diff --git a/sysdeps/generic/string-bitops.h b/sysdeps/generic/string-bitops.h\nnew file mode 100644\nindex 0000000000..c4c03fbadf\n--- /dev/null\n+++ b/sysdeps/generic/string-bitops.h\n@@ -0,0 +1,26 @@\n+/* Zero byte detection, define whether to use stdbit.h\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+ <http://www.gnu.org/licenses/>. */\n+\n+/* These macros define whether index_first/index_last macro can use the\n+ stdbit.h routines, otherwise fallback that do not call libgcc is used\n+ instead.\n+\n+ An architecture can override it is it uses a generic string routines\n+ on process startup and it can not use the libgcc routines for find\n+ trailing/leading zeros. */\n+#define HAVE_BITOPTS_WORKING 1\ndiff --git a/sysdeps/generic/string-fzi.h b/sysdeps/generic/string-fzi.h\nindex 9f74e42dbf..10be1e2e34 100644\n--- a/sysdeps/generic/string-fzi.h\n+++ b/sysdeps/generic/string-fzi.h\n@@ -22,23 +22,39 @@\n #include <limits.h>\n #include <endian.h>\n #include <string-fza.h>\n+#include <string-bitops.h>\n+#include <stdbit.h>\n \n-static __always_inline int\n-clz (find_t c)\n+static __always_inline unsigned int\n+ctzb (find_t c)\n {\n- if (sizeof (find_t) == sizeof (unsigned long))\n- return __builtin_clzl (c);\n+#if HAVE_BITOPTS_WORKING\n+ return stdc_trailing_zeros (c) / CHAR_BIT;\n+#else\n+ if (sizeof (find_t) <= 4)\n+ return (((c & -c) >> 7) * 0x00010203) >> 24;\n else\n- return __builtin_clzll (c);\n+ return (((c & -c) >> 7) * 0x0001020304050607UL) >> 56;\n+#endif\n }\n \n-static __always_inline int\n-ctz (find_t c)\n+static __always_inline unsigned int\n+clzb (find_t c)\n {\n- if (sizeof (find_t) == sizeof (unsigned long))\n- return __builtin_ctzl (c);\n- else\n- return __builtin_ctzll (c);\n+#if HAVE_BITOPTS_WORKING\n+ return stdc_leading_zeros (c) / CHAR_BIT;\n+#else\n+# if ULONG_MAX == 0xFFFFFFFFUL\n+ c |= c >> 8;\n+ c |= c >> 16;\n+ return ((c >> 7) * 0x30f0f0f0) >> 28;\n+# else\n+ c |= c >> 8;\n+ c |= c >> 16;\n+ c |= c >> 32;\n+ return ((c >> 7) * 0x70f0f0f0f0f0f0f0UL) >> 60;\n+# endif\n+#endif\n }\n \n /* A subroutine for the index_zero functions. Given a test word C, return\n@@ -47,12 +63,12 @@ ctz (find_t c)\n static __always_inline unsigned int\n index_first (find_t c)\n {\n- int r;\n+ unsigned int r;\n if (__BYTE_ORDER == __LITTLE_ENDIAN)\n- r = ctz (c);\n+ r = ctzb (c);\n else\n- r = clz (c);\n- return r / CHAR_BIT;\n+ r = clzb (c);\n+ return r;\n }\n \n /* Similarly, but return the (memory order) index of the last byte that is\n@@ -60,12 +76,12 @@ index_first (find_t c)\n static __always_inline unsigned int\n index_last (find_t c)\n {\n- int r;\n+ unsigned int r;\n if (__BYTE_ORDER == __LITTLE_ENDIAN)\n- r = clz (c);\n+ r = clzb (c);\n else\n- r = ctz (c);\n- return sizeof (find_t) - 1 - (r / CHAR_BIT);\n+ r = ctzb (c);\n+ return sizeof (find_t) - 1 - r;\n }\n \n #endif /* STRING_FZI_H */\n", "prefixes": [ "v7", "1/5" ] }