[arch-commits] Commit in glibc/repos (12 files)

Frederik Schwan freswa at gemini.archlinux.org
Fri May 6 15:53:45 UTC 2022


    Date: Friday, May 6, 2022 @ 15:53:45
  Author: freswa
Revision: 444774

archrelease: copy trunk to staging-x86_64

Added:
  glibc/repos/staging-x86_64/
  glibc/repos/staging-x86_64/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch
    (from rev 444773, glibc/trunk/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch)
  glibc/repos/staging-x86_64/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch
    (from rev 444773, glibc/trunk/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch)
  glibc/repos/staging-x86_64/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch
    (from rev 444773, glibc/trunk/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch)
  glibc/repos/staging-x86_64/PKGBUILD
    (from rev 444773, glibc/trunk/PKGBUILD)
  glibc/repos/staging-x86_64/disable-clone3.diff
    (from rev 444773, glibc/trunk/disable-clone3.diff)
  glibc/repos/staging-x86_64/glibc.install
    (from rev 444773, glibc/trunk/glibc.install)
  glibc/repos/staging-x86_64/lib32-glibc.conf
    (from rev 444773, glibc/trunk/lib32-glibc.conf)
  glibc/repos/staging-x86_64/locale-gen
    (from rev 444773, glibc/trunk/locale-gen)
  glibc/repos/staging-x86_64/locale.gen.txt
    (from rev 444773, glibc/trunk/locale.gen.txt)
  glibc/repos/staging-x86_64/sdt-config.h
    (from rev 444773, glibc/trunk/sdt-config.h)
  glibc/repos/staging-x86_64/sdt.h
    (from rev 444773, glibc/trunk/sdt.h)

-----------------------------------------------------------------+
 0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch |  380 ++++++++
 0001-localedata-Do-not-generate-output-if-warnings-were-p.patch |   69 +
 0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch      |  302 +++++++
 PKGBUILD                                                        |  253 +++++
 disable-clone3.diff                                             |   22 
 glibc.install                                                   |    5 
 lib32-glibc.conf                                                |    1 
 locale-gen                                                      |   42 
 locale.gen.txt                                                  |   23 
 sdt-config.h                                                    |    6 
 sdt.h                                                           |  430 ++++++++++
 11 files changed, 1533 insertions(+)

Copied: glibc/repos/staging-x86_64/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch (from rev 444773, glibc/trunk/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch)
===================================================================
--- staging-x86_64/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch	                        (rev 0)
+++ staging-x86_64/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,380 @@
+From 10fe3cd309b32c003a6b98e08928e7d6007caecf Mon Sep 17 00:00:00 2001
+From: Adhemerval Zanella <adhemerval.zanella at linaro.org>
+Date: Tue, 8 Feb 2022 15:22:49 -0300
+Subject: [PATCH] elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS
+ with missing libraries (BZ #28868)
+
+On _dl_map_object the underlying file is not opened in trace mode
+(in other cases where the underlying file can't be opened,
+_dl_map_object  quits with an error).  If there any missing libraries
+being processed, they will not be considered on final nlist size
+passed on _dl_sort_maps later in the function.  And it is then used by
+_dl_sort_maps_dfs on the stack allocated working maps:
+
+222   /* Array to hold RPO sorting results, before we copy back to  maps[].  */
+223   struct link_map *rpo[nmaps];
+224
+225   /* The 'head' position during each DFS iteration. Note that we start at
+226      one past the last element due to first-decrement-then-store (see the
+227      bottom of above dfs_traversal() routine).  */
+228   struct link_map **rpo_head = &rpo[nmaps];
+
+However while transversing the 'l_initfini' on dfs_traversal it will
+still consider the l_faked maps and thus update rpo more times than the
+allocated working 'rpo', overflowing the stack object.
+
+As suggested in bugzilla, one option would be to avoid sorting the maps
+for trace mode.  However I think ignoring l_faked object does make
+sense (there is one less constraint to call the sorting function), it
+allows a slight less stack usage for trace, and it is slight simpler
+solution.
+
+The tests does trigger the stack overflow, however I tried to make
+it more generic to check different scenarios or missing objects.
+
+Checked on x86_64-linux-gnu.
+
+Reviewed-by: Siddhesh Poyarekar <siddhesh at sourceware.org>
+(cherry picked from commit 3a0588ae48fb35384a6bd33f9b66403badfa1262)
+---
+ elf/Makefile            |  54 ++++++++++++++++++++
+ elf/dl-deps.c           |   2 +
+ elf/dl-sort-maps.c      |   4 +-
+ elf/libtracemod1-1.c    |   1 +
+ elf/libtracemod2-1.c    |   1 +
+ elf/libtracemod3-1.c    |   1 +
+ elf/libtracemod4-1.c    |   1 +
+ elf/libtracemod5-1.c    |   1 +
+ elf/tst-trace1.exp      |   4 ++
+ elf/tst-trace2.exp      |   6 +++
+ elf/tst-trace3.exp      |   6 +++
+ elf/tst-trace4.exp      |   6 +++
+ elf/tst-trace5.exp      |   6 +++
+ scripts/tst-ld-trace.py | 108 ++++++++++++++++++++++++++++++++++++++++
+ 15 files changed, 202 insertions(+), 1 deletion(-)
+ create mode 100644 elf/libtracemod1-1.c
+ create mode 100644 elf/libtracemod2-1.c
+ create mode 100644 elf/libtracemod3-1.c
+ create mode 100644 elf/libtracemod4-1.c
+ create mode 100644 elf/libtracemod5-1.c
+ create mode 100644 elf/tst-trace1.exp
+ create mode 100644 elf/tst-trace2.exp
+ create mode 100644 elf/tst-trace3.exp
+ create mode 100644 elf/tst-trace4.exp
+ create mode 100644 elf/tst-trace5.exp
+ create mode 100755 scripts/tst-ld-trace.py
+
+diff --git a/elf/Makefile b/elf/Makefile
+index 4bca0424a3..fa1ea28b25 100644
+--- a/elf/Makefile
++++ b/elf/Makefile
+@@ -652,6 +652,11 @@ modules-names = \
+   libmarkermod4-2 \
+   libmarkermod4-3 \
+   libmarkermod4-4 \
++  libtracemod1-1 \
++  libtracemod2-1 \
++  libtracemod3-1 \
++  libtracemod4-1 \
++  libtracemod5-1 \
+   ltglobmod1 \
+   ltglobmod2 \
+   neededobj1 \
+@@ -1112,6 +1117,11 @@ tests-special += \
+   $(objpfx)tst-initorder2-cmp.out \
+   $(objpfx)tst-unused-dep-cmp.out \
+   $(objpfx)tst-unused-dep.out \
++  $(objpfx)tst-trace1.out \
++  $(objpfx)tst-trace2.out \
++  $(objpfx)tst-trace3.out \
++  $(objpfx)tst-trace4.out \
++  $(objpfx)tst-trace5.out \
+   # tests-special
+ endif
+ 
+@@ -2787,3 +2797,47 @@ $(objpfx)tst-p_align3: $(objpfx)tst-p_alignmod3.so
+ $(objpfx)tst-p_align3.out: tst-p_align3.sh $(objpfx)tst-p_align3
+ 	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
+ 	$(evaluate-test)
++
++LDFLAGS-libtracemod1-1.so += -Wl,-soname,libtracemod1.so
++LDFLAGS-libtracemod2-1.so += -Wl,-soname,libtracemod2.so
++LDFLAGS-libtracemod3-1.so += -Wl,-soname,libtracemod3.so
++LDFLAGS-libtracemod4-1.so += -Wl,-soname,libtracemod4.so
++LDFLAGS-libtracemod5-1.so += -Wl,-soname,libtracemod5.so
++
++$(objpfx)libtracemod1-1.so: $(objpfx)libtracemod2-1.so \
++			    $(objpfx)libtracemod3-1.so
++$(objpfx)libtracemod2-1.so: $(objpfx)libtracemod4-1.so \
++			    $(objpfx)libtracemod5-1.so
++
++define libtracemod-x
++$(objpfx)libtracemod$(1)/libtracemod$(1).so: $(objpfx)libtracemod$(1)-1.so
++	$$(make-target-directory)
++	cp $$< $$@
++endef
++libtracemod-suffixes = 1 2 3 4 5
++$(foreach i,$(libtracemod-suffixes), $(eval $(call libtracemod-x,$(i))))
++
++define tst-trace-skeleton
++$(objpfx)tst-trace$(1).out: $(objpfx)libtracemod1/libtracemod1.so \
++			    $(objpfx)libtracemod2/libtracemod2.so \
++			    $(objpfx)libtracemod3/libtracemod3.so \
++			    $(objpfx)libtracemod4/libtracemod4.so \
++			    $(objpfx)libtracemod5/libtracemod5.so \
++			    $(..)scripts/tst-ld-trace.py \
++			    tst-trace$(1).exp
++	${ $(PYTHON) $(..)scripts/tst-ld-trace.py \
++	    "$(test-wrapper-env) $(elf-objpfx)$(rtld-installed-name) \
++	    --library-path $(common-objpfx):$(strip $(2)) \
++	    $(objpfx)libtracemod1/libtracemod1.so" tst-trace$(1).exp \
++	} > $$@; $$(evaluate-test)
++endef
++
++$(eval $(call tst-trace-skeleton,1,))
++$(eval $(call tst-trace-skeleton,2,\
++	$(objpfx)libtracemod2))
++$(eval $(call tst-trace-skeleton,3,\
++	$(objpfx)libtracemod2:$(objpfx)libtracemod3))
++$(eval $(call tst-trace-skeleton,4,\
++	$(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4))
++$(eval $(call tst-trace-skeleton,5,\
++	$(objpfx)libtracemod2:$(objpfx)libtracemod3:$(objpfx)libtracemod4:$(objpfx)libtracemod5))
+diff --git a/elf/dl-deps.c b/elf/dl-deps.c
+index c8bab5cad5..cfe7f0743a 100644
+--- a/elf/dl-deps.c
++++ b/elf/dl-deps.c
+@@ -489,6 +489,8 @@ _dl_map_object_deps (struct link_map *map,
+ 
+   for (nlist = 0, runp = known; runp; runp = runp->next)
+     {
++      /* _dl_sort_maps ignores l_faked object, so it is safe to not consider
++	 them for nlist.  */
+       if (__builtin_expect (trace_mode, 0) && runp->map->l_faked)
+ 	/* This can happen when we trace the loading.  */
+ 	--map->l_searchlist.r_nlist;
+diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c
+index 9e9d53ec47..96638d7ed1 100644
+--- a/elf/dl-sort-maps.c
++++ b/elf/dl-sort-maps.c
+@@ -140,7 +140,9 @@ static void
+ dfs_traversal (struct link_map ***rpo, struct link_map *map,
+ 	       bool *do_reldeps)
+ {
+-  if (map->l_visited)
++  /* _dl_map_object_deps ignores l_faked objects when calculating the
++     number of maps before calling _dl_sort_maps, ignore them as well.  */
++  if (map->l_visited || map->l_faked)
+     return;
+ 
+   map->l_visited = 1;
+diff --git a/elf/libtracemod1-1.c b/elf/libtracemod1-1.c
+new file mode 100644
+index 0000000000..7c89c9a5a4
+--- /dev/null
++++ b/elf/libtracemod1-1.c
+@@ -0,0 +1 @@
++/* Empty  */
+diff --git a/elf/libtracemod2-1.c b/elf/libtracemod2-1.c
+new file mode 100644
+index 0000000000..7c89c9a5a4
+--- /dev/null
++++ b/elf/libtracemod2-1.c
+@@ -0,0 +1 @@
++/* Empty  */
+diff --git a/elf/libtracemod3-1.c b/elf/libtracemod3-1.c
+new file mode 100644
+index 0000000000..7c89c9a5a4
+--- /dev/null
++++ b/elf/libtracemod3-1.c
+@@ -0,0 +1 @@
++/* Empty  */
+diff --git a/elf/libtracemod4-1.c b/elf/libtracemod4-1.c
+new file mode 100644
+index 0000000000..7c89c9a5a4
+--- /dev/null
++++ b/elf/libtracemod4-1.c
+@@ -0,0 +1 @@
++/* Empty  */
+diff --git a/elf/libtracemod5-1.c b/elf/libtracemod5-1.c
+new file mode 100644
+index 0000000000..7c89c9a5a4
+--- /dev/null
++++ b/elf/libtracemod5-1.c
+@@ -0,0 +1 @@
++/* Empty  */
+diff --git a/elf/tst-trace1.exp b/elf/tst-trace1.exp
+new file mode 100644
+index 0000000000..4a6f5211a6
+--- /dev/null
++++ b/elf/tst-trace1.exp
+@@ -0,0 +1,4 @@
++ld 1
++libc 1
++libtracemod2.so 0
++libtracemod3.so 0
+diff --git a/elf/tst-trace2.exp b/elf/tst-trace2.exp
+new file mode 100644
+index 0000000000..e13506e2eb
+--- /dev/null
++++ b/elf/tst-trace2.exp
+@@ -0,0 +1,6 @@
++ld 1
++libc 1
++libtracemod2.so 1
++libtracemod3.so 0
++libtracemod4.so 0
++libtracemod5.so 0
+diff --git a/elf/tst-trace3.exp b/elf/tst-trace3.exp
+new file mode 100644
+index 0000000000..e574549d12
+--- /dev/null
++++ b/elf/tst-trace3.exp
+@@ -0,0 +1,6 @@
++ld 1
++libc 1
++libtracemod2.so 1
++libtracemod3.so 1
++libtracemod4.so 0
++libtracemod5.so 0
+diff --git a/elf/tst-trace4.exp b/elf/tst-trace4.exp
+new file mode 100644
+index 0000000000..31ca97b35b
+--- /dev/null
++++ b/elf/tst-trace4.exp
+@@ -0,0 +1,6 @@
++ld 1
++libc 1
++libtracemod2.so 1
++libtracemod3.so 1
++libtracemod4.so 1
++libtracemod5.so 0
+diff --git a/elf/tst-trace5.exp b/elf/tst-trace5.exp
+new file mode 100644
+index 0000000000..5d7d953726
+--- /dev/null
++++ b/elf/tst-trace5.exp
+@@ -0,0 +1,6 @@
++ld 1
++libc 1
++libtracemod2.so 1
++libtracemod3.so 1
++libtracemod4.so 1
++libtracemod5.so 1
+diff --git a/scripts/tst-ld-trace.py b/scripts/tst-ld-trace.py
+new file mode 100755
+index 0000000000..f5a4028003
+--- /dev/null
++++ b/scripts/tst-ld-trace.py
+@@ -0,0 +1,108 @@
++#!/usr/bin/python3
++# Dump the output of LD_TRACE_LOADED_OBJECTS in architecture neutral format.
++# Copyright (C) 2022 Free Software Foundation, Inc.
++# Copyright The GNU Toolchain Authors.
++# This file is part of the GNU C Library.
++#
++# The GNU C Library is free software; you can redistribute it and/or
++# modify it under the terms of the GNU Lesser General Public
++# License as published by the Free Software Foundation; either
++# version 2.1 of the License, or (at your option) any later version.
++#
++# The GNU C Library is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++# Lesser General Public License for more details.
++#
++# You should have received a copy of the GNU Lesser General Public
++# License along with the GNU C Library; if not, see
++# <https://www.gnu.org/licenses/>.
++
++import argparse
++import os
++import subprocess
++import sys
++
++try:
++    subprocess.run
++except:
++    class _CompletedProcess:
++        def __init__(self, args, returncode, stdout=None, stderr=None):
++            self.args = args
++            self.returncode = returncode
++            self.stdout = stdout
++            self.stderr = stderr
++
++    def _run(*popenargs, input=None, timeout=None, check=False, **kwargs):
++        assert(timeout is None)
++        with subprocess.Popen(*popenargs, **kwargs) as process:
++            try:
++                stdout, stderr = process.communicate(input)
++            except:
++                process.kill()
++                process.wait()
++                raise
++            returncode = process.poll()
++            if check and returncode:
++                raise subprocess.CalledProcessError(returncode, popenargs)
++        return _CompletedProcess(popenargs, returncode, stdout, stderr)
++
++    subprocess.run = _run
++
++def is_vdso(lib):
++    return lib.startswith('linux-gate') or lib.startswith('linux-vdso')
++
++
++def parse_trace(cmd, fref):
++    new_env = os.environ.copy()
++    new_env['LD_TRACE_LOADED_OBJECTS'] = '1'
++    trace_out = subprocess.run(cmd, stdout=subprocess.PIPE, check=True,
++                               universal_newlines=True, env=new_env).stdout
++    trace = []
++    for line in trace_out.splitlines():
++        line = line.strip()
++        if is_vdso(line):
++            continue
++        fields = line.split('=>' if '=>' in line else ' ')
++        lib = os.path.basename(fields[0].strip())
++        if lib.startswith('ld'):
++            lib = 'ld'
++        elif lib.startswith('libc'):
++            lib = 'libc'
++        found = 1 if fields[1].strip() != 'not found' else 0
++        trace += ['{} {}'.format(lib, found)]
++    trace = sorted(trace)
++
++    reference = sorted(line.replace('\n','') for line in fref.readlines())
++
++    ret = 0 if trace == reference else 1
++    if ret != 0:
++        for i in reference:
++            if i not in trace:
++                print("Only in {}: {}".format(fref.name, i))
++        for i in trace:
++            if i not in reference:
++                print("Only in trace: {}".format(i))
++
++    sys.exit(ret)
++
++
++def get_parser():
++    parser = argparse.ArgumentParser(description=__doc__)
++    parser.add_argument('command',
++                        help='comand to run')
++    parser.add_argument('reference',
++                        help='reference file to compare')
++    return parser
++
++
++def main(argv):
++    parser = get_parser()
++    opts = parser.parse_args(argv)
++    with open(opts.reference, 'r') as fref:
++        # Remove the initial 'env' command.
++        parse_trace(opts.command.split()[1:], fref)
++
++
++if __name__ == '__main__':
++    main(sys.argv[1:])
+-- 
+2.36.0
+

Copied: glibc/repos/staging-x86_64/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch (from rev 444773, glibc/trunk/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch)
===================================================================
--- staging-x86_64/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch	                        (rev 0)
+++ staging-x86_64/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,69 @@
+From 732dd3a63d39c7ca77e817b462285c14551c8b49 Mon Sep 17 00:00:00 2001
+From: Carlos O'Donell <carlos at redhat.com>
+Date: Thu, 3 Feb 2022 16:01:52 -0500
+Subject: [PATCH] localedata: Do not generate output if warnings were present.
+
+With LC_MONETARY parsing fixed we can now generate locales
+without forcing output with '-c'.
+
+Removing '-c' from localedef invocation is the equivalent of
+using -Werror for localedef.  The glibc locale sources should
+always be clean and free from warnings.
+
+We remove '-c' from both test locale generation and the targets
+used for installing locales e.g. install-locale-archive, and
+install-locale-files.
+
+Tested on x86_64 and i686 without regressions.
+Tested with install-locale-archive target.
+Tested with install-locale-files target.
+
+Reviewed-by: DJ Delorie <dj at redhat.com>
+(cherry picked from commit 1c7a34567d21fbd3b706c77cd794956b43daefe7)
+---
+ localedata/Makefile      |  4 ++--
+ localedata/gen-locale.sh | 10 ++++++++--
+ 2 files changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/localedata/Makefile b/localedata/Makefile
+index 9ae2e5c161..7741ac3b5e 100644
+--- a/localedata/Makefile
++++ b/localedata/Makefile
+@@ -468,11 +468,11 @@ define build-one-locale
+ endef
+ 
+ $(INSTALL-SUPPORTED-LOCALE-ARCHIVE): install-locales-dir
+-	@flags="-c"; \
++	@flags=""; \
+ 	$(build-one-locale)
+ 
+ $(INSTALL-SUPPORTED-LOCALE-FILES): install-locales-dir
+-	@flags="-c --no-archive --no-hard-links"; \
++	@flags="--no-archive --no-hard-links"; \
+ 	$(build-one-locale)
+ 
+ tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP
+diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh
+index 7fce35f212..8053c816a6 100644
+--- a/localedata/gen-locale.sh
++++ b/localedata/gen-locale.sh
+@@ -54,8 +54,14 @@ modifier=`echo $locfile|sed 's|[^.]*[.]\([^@ ]*\)\(@[^ ]*\)\?/LC_CTYPE|\2|'`
+ 
+ echo "Generating locale $locale.$charmap: this might take a while..."
+ 
+-# Run quietly and force output.
+-flags="--quiet -c"
++# Do not force output with '-c', all locales should compile without
++# warning or errors.  There is likewise no need to run quietly with
++# '--quiet' since all locales should compile without additional
++# diagnostics.  If there are messages printed then we want to see
++# them, fix them, and the associated error or warning.  During
++# development it may be beneficialy to put '--quiet -c' here to allow
++# you to develop in-progress locales.
++flags=""
+ 
+ # For SJIS the charmap is SHIFT_JIS. We just want the locale to have
+ # a slightly nicer name instead of using "*.SHIFT_SJIS", but that
+-- 
+2.35.1
+

Copied: glibc/repos/staging-x86_64/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch (from rev 444773, glibc/trunk/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch)
===================================================================
--- staging-x86_64/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch	                        (rev 0)
+++ staging-x86_64/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,302 @@
+From 3feecd80013c822a12d4b01c5c25e155dfbc6e2f Mon Sep 17 00:00:00 2001
+From: Carlos O'Donell <carlos at redhat.com>
+Date: Thu, 3 Feb 2022 16:51:59 -0500
+Subject: [PATCH] localedef: Update LC_MONETARY handling (Bug 28845)
+
+ISO C17, POSIX Issue 7, and ISO 30112 all allow the char*
+types to be empty strings i.e. "", integer or char values to
+be -1 or CHAR_MAX respectively, with the exception of
+decimal_point which must be non-empty in ISO C. Note that
+the defaults for mon_grouping vary, but are functionaly
+equivalent e.g. "\177" (no further grouping reuqired) vs.
+"" (no grouping defined for all groups).
+
+We include a broad comment talking about harmonizing ISO C,
+POSIX, ISO 30112, and the default C/POSIX locale for glibc.
+
+We reorder all setting based on locale/categories.def order.
+
+We soften all missing definitions from errors to warnings when
+defaults exist.
+
+Given that ISO C, POSIX and ISO 30112 allow the empty string
+we change LC_MONETARY handling of mon_decimal_point to allow
+the empty string.  If mon_decimal_point is not defined at all
+then we pick the existing legacy glibc default value of
+<U002E> i.e. ".".
+
+We also set the default for mon_thousands_sep_wc at the
+same time as mon_thousands_sep, but this is not a change in
+behaviour, it is always either a matching value or L'\0',
+but if in the future we change the default to a non-empty
+string we would need to update both at the same time.
+
+Tested on x86_64 and i686 without regressions.
+Tested with install-locale-archive target.
+Tested with install-locale-files target.
+
+Reviewed-by: DJ Delorie <dj at redhat.com>
+(cherry picked from commit 2ab8b74567dc0a9a3c98696e6444881997dd6c49)
+---
+ locale/programs/ld-monetary.c | 182 +++++++++++++++++++++++++++-------
+ 1 file changed, 146 insertions(+), 36 deletions(-)
+
+diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c
+index 3b0412b405..18698bbe94 100644
+--- a/locale/programs/ld-monetary.c
++++ b/locale/programs/ld-monetary.c
+@@ -196,21 +196,105 @@ No definition for %s category found"), "LC_MONETARY");
+ 	}
+     }
+ 
++  /* Generally speaking there are 3 standards the define the default,
++     warning, and error behaviour of LC_MONETARY.  They are ISO/IEC TR 30112,
++     ISO/IEC 9899:2018 (ISO C17), and POSIX.1-2017.  Within 30112 we have the
++     definition of a standard i18n FDCC-set, which for LC_MONETARY has the
++     following default values:
++	int_curr_symbol		""
++	currency_symbol		""
++	mon_decimal_point	"<U002C>" i.e. ","
++	mon_thousand_sep	""
++	mon_grouping		"\177" i.e. CHAR_MAX
++	positive_sign		""
++	negative_sign		"<U002E>" i.e. "."
++	int_frac_digits		-1
++	frac_digits		-1
++	p_cs_precedes		-1
++	p_sep_by_space		-1
++	n_cs_precedes		-1
++	n_sep_by_space		-1
++	p_sign_posn		-1
++	n_sign_posn		-1
++    Under 30112 a keyword that is not provided implies an empty string ""
++    for string values or a -1 for integer values, and indicates the value
++    is unspecified with no default implied.  No errors are considered.
++    The exception is mon_grouping which is a string with a terminating
++    CHAR_MAX.
++    For POSIX Issue 7 we have:
++    https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html
++    and again values not provided default to "" or -1, and indicate the value
++    is not available to the locale.  The exception is mon_grouping which is
++    a string with a terminating CHAR_MAX.  For the POSIX locale the values of
++    LC_MONETARY should be:
++	int_curr_symbol		""
++	currency_symbol		""
++	mon_decimal_point	""
++	mon_thousands_sep	""
++	mon_grouping		"\177" i.e. CHAR_MAX 
++	positive_sign		""
++	negative_sign		""
++	int_frac_digits		-1
++	frac_digits		-1
++	p_cs_precedes		-1
++	p_sep_by_space		-1
++	n_cs_precedes		-1
++	n_sep_by_space		-1
++	p_sign_posn		-1
++	n_sign_posn		-1
++	int_p_cs_precedes	-1
++	int_p_sep_by_space	-1
++	int_n_cs_precedes	-1
++	int_n_sep_by_space	-1
++	int_p_sign_posn		-1
++	int_n_sign_posn		-1
++    Like with 30112, POSIX also considers no error if the keywords are
++    missing, only that if the cateory as a whole is missing the referencing
++    of the category results in unspecified behaviour.
++    For ISO C17 there is no default value provided, but the localeconv
++    specification in 7.11.2.1 admits that members of char * type may point
++    to "" to indicate a value is not available or is of length zero.
++    The exception is decimal_point (not mon_decimal_point) which must be a
++    defined non-empty string.  The values of char, which are generally
++    mapped to integer values in 30112 and POSIX, must be non-negative
++    numbers that map to CHAR_MAX when a value is not available in the
++    locale.
++    In ISO C17 for the "C" locale all values are empty strings "", or
++    CHAR_MAX, with the exception of decimal_point which is "." (defined
++    in LC_NUMERIC).  ISO C17 makes no exception for mon_grouping like
++    30112 and POSIX, but a value of "" is functionally equivalent to
++    "\177" since neither defines a grouping (though the latter terminates
++    the grouping).
++
++    Lastly, we must consider the legacy C/POSIX locale that implemented
++    as a builtin in glibc and wether a default value mapping to the
++    C/POSIX locale may benefit the user from a compatibility perspective.
++
++    Thus given 30112, POSIX, ISO C, and the builtin C/POSIX locale we
++    need to pick appropriate defaults below.   */
++
++  /* The members of LC_MONETARY are handled in the order of their definition
++     in locale/categories.def.  Please keep them in that order.  */
++
++  /* The purpose of TEST_ELEM is to define a default value for the fields
++     in the category if the field was not defined in the cateory.  If the
++     category was present but we didn't see a definition for the field then
++     we also issue a warning, otherwise the only warning you get is the one
++     earlier when a default category is created (completely missing category).
++     This missing field warning is glibc-specific since no standard requires
++     this warning, but we consider it valuable to print a warning for all
++     missing fields in the category.  */
+ #define TEST_ELEM(cat, initval) \
+   if (monetary->cat == NULL)						      \
+     {									      \
+       if (! nothing)							      \
+-	record_error (0, 0, _("%s: field `%s' not defined"),		      \
+-		      "LC_MONETARY", #cat);				      \
++	record_warning (_("%s: field `%s' not defined"),		      \
++			"LC_MONETARY", #cat);				      \
+       monetary->cat = initval;						      \
+     }
+ 
++  /* Keyword: int_curr_symbol.  */
+   TEST_ELEM (int_curr_symbol, "");
+-  TEST_ELEM (currency_symbol, "");
+-  TEST_ELEM (mon_thousands_sep, "");
+-  TEST_ELEM (positive_sign, "");
+-  TEST_ELEM (negative_sign, "");
+-
+   /* The international currency symbol must come from ISO 4217.  */
+   if (monetary->int_curr_symbol != NULL)
+     {
+@@ -247,41 +331,63 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"),
+ 	}
+     }
+ 
+-  /* The decimal point must not be empty.  This is not said explicitly
+-     in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be
+-     != "".  */
++  /* Keyword: currency_symbol */
++  TEST_ELEM (currency_symbol, "");
++
++  /* Keyword: mon_decimal_point */
++  /* ISO C17 7.11.2.1.3 explicitly allows mon_decimal_point to be the
++     empty string e.g. "".  This indicates the value is not available in the
++     current locale or is of zero length.  However, if the value was never
++     defined then we issue a warning and use a glibc-specific default.  ISO
++     30112 in the i18n FDCC-Set uses <U002C> ",", and POSIX Issue 7 in the
++     POSIX locale uses "".  It is specific to glibc that the default is <U002E>
++     "."; we retain this existing behaviour for backwards compatibility.  */
+   if (monetary->mon_decimal_point == NULL)
+     {
+       if (! nothing)
+-	record_error (0, 0, _("%s: field `%s' not defined"),
+-		      "LC_MONETARY", "mon_decimal_point");
++	record_warning (_("%s: field `%s' not defined, using defaults"),
++			"LC_MONETARY", "mon_decimal_point");
+       monetary->mon_decimal_point = ".";
+       monetary->mon_decimal_point_wc = L'.';
+     }
+-  else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing)
++
++  /* Keyword: mon_thousands_sep */
++  if (monetary->mon_thousands_sep == NULL)
+     {
+-      record_error (0, 0, _("\
+-%s: value for field `%s' must not be an empty string"),
+-		    "LC_MONETARY", "mon_decimal_point");
++      if (! nothing)
++	record_warning (_("%s: field `%s' not defined, using defaults"),
++			"LC_MONETARY", "mon_thousands_sep");
++      monetary->mon_thousands_sep = "";
++      monetary->mon_thousands_sep_wc = L'\0';
+     }
+ 
++  /* Keyword: mon_grouping */
+   if (monetary->mon_grouping_len == 0)
+     {
+       if (! nothing)
+-	record_error (0, 0, _("%s: field `%s' not defined"),
+-		      "LC_MONETARY", "mon_grouping");
+-
++	record_warning (_("%s: field `%s' not defined"),
++			"LC_MONETARY", "mon_grouping");
++      /* Missing entries are given 1 element in their bytearray with
++	 a value of CHAR_MAX which indicates that "No further grouping
++	 is to be performed" (functionally equivalent to ISO C's "C"
++	 locale default of ""). */
+       monetary->mon_grouping = (char *) "\177";
+       monetary->mon_grouping_len = 1;
+     }
+ 
++  /* Keyword: positive_sign */
++  TEST_ELEM (positive_sign, "");
++
++  /* Keyword: negative_sign */
++  TEST_ELEM (negative_sign, "");
++
+ #undef TEST_ELEM
+ #define TEST_ELEM(cat, min, max, initval) \
+   if (monetary->cat == -2)						      \
+     {									      \
+        if (! nothing)							      \
+-	 record_error (0, 0, _("%s: field `%s' not defined"),		      \
+-		       "LC_MONETARY", #cat);				      \
++	 record_warning (_("%s: field `%s' not defined"),		      \
++			 "LC_MONETARY", #cat);				      \
+        monetary->cat = initval;						      \
+     }									      \
+   else if ((monetary->cat < min || monetary->cat > max)			      \
+@@ -300,16 +406,11 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"),
+   TEST_ELEM (p_sign_posn, -1, 4, -1);
+   TEST_ELEM (n_sign_posn, -1, 4, -1);
+ 
+-  /* The non-POSIX.2 extensions are optional.  */
+-  if (monetary->duo_int_curr_symbol == NULL)
+-    monetary->duo_int_curr_symbol = monetary->int_curr_symbol;
+-  if (monetary->duo_currency_symbol == NULL)
+-    monetary->duo_currency_symbol = monetary->currency_symbol;
+-
+-  if (monetary->duo_int_frac_digits == -2)
+-    monetary->duo_int_frac_digits = monetary->int_frac_digits;
+-  if (monetary->duo_frac_digits == -2)
+-    monetary->duo_frac_digits = monetary->frac_digits;
++  /* Keyword: crncystr */
++  monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol)
++					 + 2);
++  monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+';
++  strcpy (&monetary->crncystr[1], monetary->currency_symbol);
+ 
+ #undef TEST_ELEM
+ #define TEST_ELEM(cat, alt, min, max) \
+@@ -327,6 +428,17 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"),
+   TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4);
+   TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4);
+ 
++  /* The non-POSIX.2 extensions are optional.  */
++  if (monetary->duo_int_curr_symbol == NULL)
++    monetary->duo_int_curr_symbol = monetary->int_curr_symbol;
++  if (monetary->duo_currency_symbol == NULL)
++    monetary->duo_currency_symbol = monetary->currency_symbol;
++
++  if (monetary->duo_int_frac_digits == -2)
++    monetary->duo_int_frac_digits = monetary->int_frac_digits;
++  if (monetary->duo_frac_digits == -2)
++    monetary->duo_frac_digits = monetary->frac_digits;
++
+   TEST_ELEM (duo_p_cs_precedes, p_cs_precedes, -1, 1);
+   TEST_ELEM (duo_p_sep_by_space, p_sep_by_space, -1, 2);
+   TEST_ELEM (duo_n_cs_precedes, n_cs_precedes, -1, 1);
+@@ -349,17 +461,15 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"),
+   if (monetary->duo_valid_to == 0)
+     monetary->duo_valid_to = 99991231;
+ 
++  /* Keyword: conversion_rate */
+   if (monetary->conversion_rate[0] == 0)
+     {
+       monetary->conversion_rate[0] = 1;
+       monetary->conversion_rate[1] = 1;
+     }
+ 
+-  /* Create the crncystr entry.  */
+-  monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol)
+-					 + 2);
+-  monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+';
+-  strcpy (&monetary->crncystr[1], monetary->currency_symbol);
++  /* A value for monetary-decimal-point-wc was set when
++     monetary_decimal_point was set, likewise for monetary-thousands-sep-wc.  */
+ }
+ 
+ 
+-- 
+2.35.1
+

Copied: glibc/repos/staging-x86_64/PKGBUILD (from rev 444773, glibc/trunk/PKGBUILD)
===================================================================
--- staging-x86_64/PKGBUILD	                        (rev 0)
+++ staging-x86_64/PKGBUILD	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,253 @@
+# Maintainer: Giancarlo Razzolini <grazzolini at archlinux.org>
+# Maintainer: Frederik Schwan <freswa at archlinux dot org>
+# Contributor: Bartłomiej Piotrowski <bpiotrowski at archlinux.org>
+# Contributor: Allan McRae <allan at archlinux.org>
+
+# toolchain build order: linux-api-headers->glibc->binutils->gcc->glibc->binutils->gcc
+# NOTE: valgrind requires rebuilt with each major glibc version
+
+pkgbase=glibc
+pkgname=(glibc lib32-glibc)
+pkgver=2.35
+pkgrel=4
+arch=(x86_64)
+url='https://www.gnu.org/software/libc'
+license=(GPL LGPL)
+makedepends=(git gd lib32-gcc-libs python)
+options=(!strip staticlibs !lto)
+#_commit=3de512be7ea6053255afed6154db9ee31d4e557a
+#source=(git+https://sourceware.org/git/glibc.git#commit=$_commit
+source=(https://ftp.gnu.org/gnu/glibc/glibc-$pkgver.tar.xz{,.sig}
+        locale.gen.txt
+        locale-gen
+        lib32-glibc.conf
+        sdt.h sdt-config.h
+        disable-clone3.diff
+        0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch
+        0001-localedata-Do-not-generate-output-if-warnings-were-p.patch
+        0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch
+)
+validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
+              BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
+b2sums=('623c728884f070cd87ffeb9203f74206197c52405ac9bc44f3dd519a3468b8e8ae2536c883e5d17d94417dbd1e91775de2e674314e4ff7424f9720026d6b7063'
+        'SKIP'
+        '46d533d25c7a2ce4ae75d452eee7ebb8e3ce4d191af9be3daa43718b78cb81d33cfd8046a117a15d87de9f5e940448c66005b0490515bf731c9e4691c53908d6'
+        '1f6d927b4972220b1c00abee5329c5d6bc01ed5bee57b20db0c7d7433292f7d666b02baf9968267f8e378b1f3bb273e8eef0ccbf22d21400ac36949d7615a474'
+        '7c265e6d36a5c0dff127093580827d15519b6c7205c2e1300e82f0fb5b9dd00b6accb40c56581f18179c4fbbc95bd2bf1b900ace867a83accde0969f7b609f8a'
+        'a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e'
+        '214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678'
+        'edef5f724f68ea95c6b0127bd13a10245f548afc381b2d0a6d1d06ee9f87b7dd89c6becd35d5ae722bf838594eb870a747f67f07f46e7d63f8c8d1a43cce4a52'
+        '3c4de02d6308a4d39693e6effa08894ae096397347e439b93b0b5328aba41a373f7f2eeb88c109970f69cca65aaa74ba14e384d6d033f6a913438f4f920854a6'
+        'b6014af23688ea971d7af38d58829c8016a0af63770b7f5e8bc986c13ea2cafefe0935ff483b1b37c87ebe3e652b6e0c48ab43dd8ae752d0ed7fecc3751432f4'
+        'd77c8f9c807f25aeeafa302858116f4adf903f46fe1db2035dbe998105d7206bbc6d3055119831ff7744eb721b05795866c80d99671c3a8f33d5386d80978248')
+
+prepare() {
+  mkdir -p glibc-build lib32-glibc-build
+
+  [[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc 
+  cd glibc
+
+  # Disable clone3 syscall for now
+  # Can be removed when eletron{9,11,12} and discord are removed or patched:
+  # https://github.com/electron/electron/commit/993ecb5bdd5c57024c8718ca6203a8f924d6d574
+  # Patch src: https://patchwork.ozlabs.org/project/glibc/patch/87eebkf8ph.fsf@oldenburg.str.redhat.com/
+  patch -Np1 -i "${srcdir}"/disable-clone3.diff
+
+  # Fix C.UTF-8 generation errors
+  # https://bugs.archlinux.org/task/73797
+  patch -Np1 -i "${srcdir}"/0001-localedef-Update-LC_MONETARY-handling-Bug-28845.patch
+  patch -Np1 -i "${srcdir}"/0001-localedata-Do-not-generate-output-if-warnings-were-p.patch
+
+  # Fix Sefault introduced by new DFS algorithm
+  # https://bugs.archlinux.org/task/73938
+  patch -Np1 -i "${srcdir}"/0001-elf-Fix-DFS-sorting-algorithm-for-LD_TRACE_LOADED_OB.patch
+}
+
+build() {
+  local _configure_flags=(
+      --prefix=/usr
+      --with-headers=/usr/include
+      --with-bugurl=https://bugs.archlinux.org/
+      --enable-bind-now
+      --enable-cet
+      --enable-kernel=4.4
+      --enable-multi-arch
+      --enable-stack-protector=strong
+      --enable-systemtap
+      --disable-profile
+      --disable-crypt
+      --disable-werror
+  )
+
+  cd "$srcdir/glibc-build"
+
+  echo "slibdir=/usr/lib" >> configparms
+  echo "rtlddir=/usr/lib" >> configparms
+  echo "sbindir=/usr/bin" >> configparms
+  echo "rootsbindir=/usr/bin" >> configparms
+
+  # Credits @allanmcrae
+  # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
+  # remove fortify for building libraries
+  CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=2/}
+
+  "$srcdir/glibc/configure" \
+      --libdir=/usr/lib \
+      --libexecdir=/usr/lib \
+      "${_configure_flags[@]}"
+
+  # build libraries with fortify disabled
+  echo "build-programs=no" >> configparms
+  make -O
+
+  # re-enable fortify for programs
+  sed -i "/build-programs=/s#no#yes#" configparms
+  echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
+  make -O
+
+  # build info pages manually for reproducibility
+  make info
+
+  cd "$srcdir/lib32-glibc-build"
+  export CC="gcc -m32 -mstackrealign"
+  export CXX="g++ -m32 -mstackrealign"
+
+  echo "slibdir=/usr/lib32" >> configparms
+  echo "rtlddir=/usr/lib32" >> configparms
+  echo "sbindir=/usr/bin" >> configparms
+  echo "rootsbindir=/usr/bin" >> configparms
+
+  "$srcdir/glibc/configure" \
+      --host=i686-pc-linux-gnu \
+      --libdir=/usr/lib32 \
+      --libexecdir=/usr/lib32 \
+      "${_configure_flags[@]}"
+
+  # build libraries with fortify disabled
+  echo "build-programs=no" >> configparms
+  make -O
+
+  # re-enable fortify for programs
+  sed -i "/build-programs=/s#no#yes#" configparms
+  echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
+  make -O
+
+}
+
+# Credits for skip_test() and check() @allanmcrae
+# https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/glibc/PKGBUILD
+skip_test() {
+  test=$1
+  file=$2
+  sed -i "s/\b$test\b//" $srcdir/glibc/$file
+}
+
+check() {
+  cd glibc-build
+
+  # adjust/remove buildflags that cause false-positive testsuite failures
+  sed -i '/FORTIFY/d' configparms                                     # failure to build testsuite
+  sed -i 's/-Werror=format-security/-Wformat-security/' config.make   # failure to build testsuite
+  sed -i '/CFLAGS/s/-fno-plt//' config.make                           # 16 failures
+  sed -i '/CFLAGS/s/-fexceptions//' config.make                       # 1 failure
+  LDFLAGS=${LDFLAGS/,-z,now/}                                         # 10 failures
+
+  # The following tests fail due to restrictions in the Arch build system
+  # The correct fix is to add the following to the systemd-nspawn call:
+  # --system-call-filter="@clock @memlock @pkey"
+  skip_test test-errno-linux sysdeps/unix/sysv/linux/Makefile
+  skip_test tst-ntp_gettime  sysdeps/unix/sysv/linux/Makefile
+  skip_test tst-ntp_gettimex sysdeps/unix/sysv/linux/Makefile
+  skip_test tst-mlock2       sysdeps/unix/sysv/linux/Makefile
+  skip_test tst-pkey         sysdeps/unix/sysv/linux/Makefile
+  skip_test tst-adjtime      time/Makefile
+  skip_test tst-clock2       time/Makefile
+
+  make -O check
+}
+
+package_glibc() {
+  pkgdesc='GNU C Library'
+  depends=('linux-api-headers>=4.10' tzdata filesystem)
+  optdepends=('gd: for memusagestat'
+              'perl: for mtrace')
+  install=glibc.install
+  backup=(etc/gai.conf
+          etc/locale.gen
+          etc/nscd.conf)
+
+  make -C glibc-build install_root="$pkgdir" install
+  rm -f "$pkgdir"/etc/ld.so.cache
+
+  # Shipped in tzdata
+  rm -f "$pkgdir"/usr/bin/{tzselect,zdump,zic}
+
+  cd glibc
+
+  install -dm755 "$pkgdir"/usr/lib/{locale,systemd/system,tmpfiles.d}
+  install -m644 nscd/nscd.conf "$pkgdir/etc/nscd.conf"
+  install -m644 nscd/nscd.service "$pkgdir/usr/lib/systemd/system"
+  install -m644 nscd/nscd.tmpfiles "$pkgdir/usr/lib/tmpfiles.d/nscd.conf"
+  install -dm755 "$pkgdir/var/db/nscd"
+
+  install -m644 posix/gai.conf "$pkgdir"/etc/gai.conf
+
+  install -m755 "$srcdir/locale-gen" "$pkgdir/usr/bin"
+
+  # Create /etc/locale.gen
+  install -m644 "$srcdir/locale.gen.txt" "$pkgdir/etc/locale.gen"
+  sed -e '1,3d' -e 's|/| |g' -e 's|\\| |g' -e 's|^|#|g' \
+    "$srcdir/glibc/localedata/SUPPORTED" >> "$pkgdir/etc/locale.gen"
+
+  if check_option 'debug' n; then
+    find "$pkgdir"/usr/bin -type f -executable -exec strip $STRIP_BINARIES {} + 2> /dev/null || true
+    find "$pkgdir"/usr/lib -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true
+
+    # Do not strip these for gdb and valgrind functionality, but strip the rest
+    find "$pkgdir"/usr/lib \
+      -not -name 'ld-*.so*' \
+      -not -name 'libc.so*' \
+      -not -name 'libpthread.so*' \
+      -not -name 'libthread_db.so*' \
+      -name '*.so*' -type f -exec strip $STRIP_SHARED {} + 2> /dev/null || true
+  fi
+
+  # Provide tracing probes to libstdc++ for exceptions, possibly for other
+  # libraries too. Useful for gdb's catch command.
+  install -Dm644 "$srcdir/sdt.h" "$pkgdir/usr/include/sys/sdt.h"
+  install -Dm644 "$srcdir/sdt-config.h" "$pkgdir/usr/include/sys/sdt-config.h"
+}
+
+package_lib32-glibc() {
+  pkgdesc='GNU C Library (32-bit)'
+  depends=("glibc=$pkgver")
+  options+=('!emptydirs')
+
+  cd lib32-glibc-build
+
+  make install_root="$pkgdir" install
+  rm -rf "$pkgdir"/{etc,sbin,usr/{bin,sbin,share},var}
+
+  # We need to keep 32 bit specific header files
+  find "$pkgdir/usr/include" -type f -not -name '*-32.h' -delete
+
+  # Dynamic linker
+  install -d "$pkgdir/usr/lib"
+  ln -s ../lib32/ld-linux.so.2 "$pkgdir/usr/lib/"
+
+  # Add lib32 paths to the default library search path
+  install -Dm644 "$srcdir/lib32-glibc.conf" "$pkgdir/etc/ld.so.conf.d/lib32-glibc.conf"
+
+  # Symlink /usr/lib32/locale to /usr/lib/locale
+  ln -s ../lib/locale "$pkgdir/usr/lib32/locale"
+
+  if check_option 'debug' n; then
+    find "$pkgdir"/usr/lib32 -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true
+    find "$pkgdir"/usr/lib32 \
+      -not -name 'ld-*.so*' \
+      -not -name 'libc.so*' \
+      -not -name 'libpthread.so*' \
+      -not -name 'libthread_db.so*' \
+      -name '*.so*' -type f -exec strip $STRIP_SHARED {} + 2> /dev/null || true
+  fi
+}

Copied: glibc/repos/staging-x86_64/disable-clone3.diff (from rev 444773, glibc/trunk/disable-clone3.diff)
===================================================================
--- staging-x86_64/disable-clone3.diff	                        (rev 0)
+++ staging-x86_64/disable-clone3.diff	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,22 @@
+diff --git a/sysdeps/unix/sysv/linux/clone-internal.c b/sysdeps/unix/sysv/linux/clone-internal.c
+index 1e7a8f6b35..4046c81180 100644
+--- a/sysdeps/unix/sysv/linux/clone-internal.c
++++ b/sysdeps/unix/sysv/linux/clone-internal.c
+@@ -48,17 +48,6 @@ __clone_internal (struct clone_args *cl_args,
+ 		  int (*func) (void *arg), void *arg)
+ {
+   int ret;
+-#ifdef HAVE_CLONE3_WRAPPER
+-  /* Try clone3 first.  */
+-  int saved_errno = errno;
+-  ret = __clone3 (cl_args, sizeof (*cl_args), func, arg);
+-  if (ret != -1 || errno != ENOSYS)
+-    return ret;
+-
+-  /* NB: Restore errno since errno may be checked against non-zero
+-     return value.  */
+-  __set_errno (saved_errno);
+-#endif
+ 
+   /* Map clone3 arguments to clone arguments.  NB: No need to check
+      invalid clone3 specific bits in flags nor exit_signal since this

Copied: glibc/repos/staging-x86_64/glibc.install (from rev 444773, glibc/trunk/glibc.install)
===================================================================
--- staging-x86_64/glibc.install	                        (rev 0)
+++ staging-x86_64/glibc.install	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,5 @@
+post_upgrade() {
+  locale-gen
+
+  ldconfig -r .
+}

Copied: glibc/repos/staging-x86_64/lib32-glibc.conf (from rev 444773, glibc/trunk/lib32-glibc.conf)
===================================================================
--- staging-x86_64/lib32-glibc.conf	                        (rev 0)
+++ staging-x86_64/lib32-glibc.conf	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1 @@
+/usr/lib32

Copied: glibc/repos/staging-x86_64/locale-gen (from rev 444773, glibc/trunk/locale-gen)
===================================================================
--- staging-x86_64/locale-gen	                        (rev 0)
+++ staging-x86_64/locale-gen	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+set -e
+
+LOCALEGEN=/etc/locale.gen
+LOCALES=/usr/share/i18n/locales
+if [ -n "$POSIXLY_CORRECT" ]; then
+  unset POSIXLY_CORRECT
+fi
+
+
+[ -f $LOCALEGEN -a -s $LOCALEGEN ] || exit 0;
+
+# Remove all old locale dir and locale-archive before generating new
+# locale data.
+rm -rf /usr/lib/locale/* || true
+
+umask 022
+
+is_entry_ok() {
+  if [ -n "$locale" -a -n "$charset" ] ; then
+    true
+  else
+    echo "error: Bad entry '$locale $charset'"
+    false
+  fi
+}
+
+echo "Generating locales..."
+while read locale charset; do \
+	case $locale in \#*) continue;; "") continue;; esac; \
+	is_entry_ok || continue
+	echo -n "  `echo $locale | sed 's/\([^.\@]*\).*/\1/'`"; \
+	echo -n ".$charset"; \
+	echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
+	echo -n '...'; \
+        if [ -f $LOCALES/$locale ]; then input=$locale; else \
+        input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; fi; \
+	localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale; \
+	echo ' done'; \
+done < $LOCALEGEN
+echo "Generation complete."

Copied: glibc/repos/staging-x86_64/locale.gen.txt (from rev 444773, glibc/trunk/locale.gen.txt)
===================================================================
--- staging-x86_64/locale.gen.txt	                        (rev 0)
+++ staging-x86_64/locale.gen.txt	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,23 @@
+# Configuration file for locale-gen
+#
+# lists of locales that are to be generated by the locale-gen command.
+#
+# Each line is of the form:
+#
+#     <locale> <charset>
+#
+#  where <locale> is one of the locales given in /usr/share/i18n/locales
+#  and <charset> is one of the character sets listed in /usr/share/i18n/charmaps
+#
+#  Examples:
+#  en_US ISO-8859-1
+#  en_US.UTF-8 UTF-8
+#  de_DE ISO-8859-1
+#  de_DE at euro ISO-8859-15
+#
+#  The locale-gen command will generate all the locales,
+#  placing them in /usr/lib/locale.
+#
+#  A list of supported locales is included in this file.
+#  Uncomment the ones you need.
+#

Copied: glibc/repos/staging-x86_64/sdt-config.h (from rev 444773, glibc/trunk/sdt-config.h)
===================================================================
--- staging-x86_64/sdt-config.h	                        (rev 0)
+++ staging-x86_64/sdt-config.h	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,6 @@
+/* includes/sys/sdt-config.h.  Generated from sdt-config.h.in by configure.
+
+   This file just defines _SDT_ASM_SECTION_AUTOGROUP_SUPPORT to 0 or 1 to
+   indicate whether the assembler supports "?" in .pushsection directives.  */
+
+#define _SDT_ASM_SECTION_AUTOGROUP_SUPPORT 1

Copied: glibc/repos/staging-x86_64/sdt.h (from rev 444773, glibc/trunk/sdt.h)
===================================================================
--- staging-x86_64/sdt.h	                        (rev 0)
+++ staging-x86_64/sdt.h	2022-05-06 15:53:45 UTC (rev 444774)
@@ -0,0 +1,430 @@
+/* <sys/sdt.h> - Systemtap static probe definition macros.
+
+   This file is dedicated to the public domain, pursuant to CC0
+   (https://creativecommons.org/publicdomain/zero/1.0/)
+*/
+
+#ifndef _SYS_SDT_H
+#define _SYS_SDT_H    1
+
+/*
+  This file defines a family of macros
+
+       STAP_PROBEn(op1, ..., opn)
+
+  that emit a nop into the instruction stream, and some data into an auxiliary
+  note section.  The data in the note section describes the operands, in terms
+  of size and location.  Each location is encoded as assembler operand string.
+  Consumer tools such as gdb or systemtap insert breakpoints on top of
+  the nop, and decode the location operand-strings, like an assembler,
+  to find the values being passed.
+
+  The operand strings are selected by the compiler for each operand.
+  They are constrained by gcc inline-assembler codes.  The default is:
+
+  #define STAP_SDT_ARG_CONSTRAINT nor
+
+  This is a good default if the operands tend to be integral and
+  moderate in number (smaller than number of registers).  In other
+  cases, the compiler may report "'asm' requires impossible reload" or
+  similar.  In this case, consider simplifying the macro call (fewer
+  and simpler operands), reduce optimization, or override the default
+  constraints string via:
+
+  #define STAP_SDT_ARG_CONSTRAINT g
+  #include <sys/sdt.h>
+
+  See also:
+  https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
+  https://gcc.gnu.org/onlinedocs/gcc/Constraints.html
+ */
+
+
+
+#ifdef __ASSEMBLER__
+# define _SDT_PROBE(provider, name, n, arglist)	\
+  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING_1, (_SDT_DEPAREN_##n arglist)) \
+  _SDT_ASM_BASE
+# define _SDT_ASM_1(x)			x;
+# define _SDT_ASM_2(a, b)		a,b;
+# define _SDT_ASM_3(a, b, c)		a,b,c;
+# define _SDT_ASM_5(a, b, c, d, e)	a,b,c,d,e;
+# define _SDT_ASM_STRING_1(x)		.asciz #x;
+# define _SDT_DEPAREN_0()				/* empty */
+# define _SDT_DEPAREN_1(a)				a
+# define _SDT_DEPAREN_2(a,b)				a b
+# define _SDT_DEPAREN_3(a,b,c)				a b c
+# define _SDT_DEPAREN_4(a,b,c,d)			a b c d
+# define _SDT_DEPAREN_5(a,b,c,d,e)			a b c d e
+# define _SDT_DEPAREN_6(a,b,c,d,e,f)			a b c d e f
+# define _SDT_DEPAREN_7(a,b,c,d,e,f,g)			a b c d e f g
+# define _SDT_DEPAREN_8(a,b,c,d,e,f,g,h)		a b c d e f g h
+# define _SDT_DEPAREN_9(a,b,c,d,e,f,g,h,i)		a b c d e f g h i
+# define _SDT_DEPAREN_10(a,b,c,d,e,f,g,h,i,j)		a b c d e f g h i j
+# define _SDT_DEPAREN_11(a,b,c,d,e,f,g,h,i,j,k)		a b c d e f g h i j k
+# define _SDT_DEPAREN_12(a,b,c,d,e,f,g,h,i,j,k,l)	a b c d e f g h i j k l
+#else
+# define _SDT_PROBE(provider, name, n, arglist) \
+  do {									    \
+    __asm__ __volatile__ (_SDT_ASM_BODY(provider, name, _SDT_ASM_ARGS, (n)) \
+			  :: _SDT_ASM_OPERANDS_##n arglist);		    \
+    __asm__ __volatile__ (_SDT_ASM_BASE);				    \
+  } while (0)
+# define _SDT_S(x)			#x
+# define _SDT_ASM_1(x)			_SDT_S(x) "\n"
+# define _SDT_ASM_2(a, b)		_SDT_S(a) "," _SDT_S(b) "\n"
+# define _SDT_ASM_3(a, b, c)		_SDT_S(a) "," _SDT_S(b) "," \
+					_SDT_S(c) "\n"
+# define _SDT_ASM_5(a, b, c, d, e)	_SDT_S(a) "," _SDT_S(b) "," \
+					_SDT_S(c) "," _SDT_S(d) "," \
+					_SDT_S(e) "\n"
+# define _SDT_ASM_ARGS(n)		_SDT_ASM_STRING(_SDT_ASM_TEMPLATE_##n)
+# define _SDT_ASM_STRING_1(x)		_SDT_ASM_1(.asciz #x)
+
+# define _SDT_ARGFMT(no)		%n[_SDT_S##no]@_SDT_ARGTMPL(_SDT_A##no)
+
+# ifndef STAP_SDT_ARG_CONSTRAINT
+# if defined __powerpc__
+# define STAP_SDT_ARG_CONSTRAINT        nZr
+# else
+# define STAP_SDT_ARG_CONSTRAINT        nor
+# endif
+# endif
+
+# define _SDT_STRINGIFY(x)              #x
+# define _SDT_ARG_CONSTRAINT_STRING(x)  _SDT_STRINGIFY(x)
+# define _SDT_ARG(n, x)			\
+  [_SDT_S##n] "n" ((_SDT_ARGSIGNED (x) ? 1 : -1) * (int) _SDT_ARGSIZE (x)), \
+  [_SDT_A##n] _SDT_ARG_CONSTRAINT_STRING (STAP_SDT_ARG_CONSTRAINT) (_SDT_ARGVAL (x))
+#endif
+#define _SDT_ASM_STRING(x)		_SDT_ASM_STRING_1(x)
+
+#define _SDT_ARGARRAY(x)	(__builtin_classify_type (x) == 14	\
+				 || __builtin_classify_type (x) == 5)
+
+#ifdef __cplusplus
+# define _SDT_ARGSIGNED(x)	(!_SDT_ARGARRAY (x) \
+				 && __sdt_type<__typeof (x)>::__sdt_signed)
+# define _SDT_ARGSIZE(x)	(_SDT_ARGARRAY (x) \
+				 ? sizeof (void *) : sizeof (x))
+# define _SDT_ARGVAL(x)		(x)
+
+# include <cstddef>
+
+template<typename __sdt_T>
+struct __sdt_type
+{
+  static const bool __sdt_signed = false;
+};
+  
+#define __SDT_ALWAYS_SIGNED(T) \
+template<> struct __sdt_type<T> { static const bool __sdt_signed = true; };
+#define __SDT_COND_SIGNED(T,CT)						\
+template<> struct __sdt_type<T> { static const bool __sdt_signed = ((CT)(-1) < 1); };
+__SDT_ALWAYS_SIGNED(signed char)
+__SDT_ALWAYS_SIGNED(short)
+__SDT_ALWAYS_SIGNED(int)
+__SDT_ALWAYS_SIGNED(long)
+__SDT_ALWAYS_SIGNED(long long)
+__SDT_ALWAYS_SIGNED(volatile signed char)
+__SDT_ALWAYS_SIGNED(volatile short)
+__SDT_ALWAYS_SIGNED(volatile int)
+__SDT_ALWAYS_SIGNED(volatile long)
+__SDT_ALWAYS_SIGNED(volatile long long)
+__SDT_ALWAYS_SIGNED(const signed char)
+__SDT_ALWAYS_SIGNED(const short)
+__SDT_ALWAYS_SIGNED(const int)
+__SDT_ALWAYS_SIGNED(const long)
+__SDT_ALWAYS_SIGNED(const long long)
+__SDT_ALWAYS_SIGNED(const volatile signed char)
+__SDT_ALWAYS_SIGNED(const volatile short)
+__SDT_ALWAYS_SIGNED(const volatile int)
+__SDT_ALWAYS_SIGNED(const volatile long)
+__SDT_ALWAYS_SIGNED(const volatile long long)
+__SDT_COND_SIGNED(char, char)
+__SDT_COND_SIGNED(wchar_t, wchar_t)
+__SDT_COND_SIGNED(volatile char, char)
+__SDT_COND_SIGNED(volatile wchar_t, wchar_t)
+__SDT_COND_SIGNED(const char, char)
+__SDT_COND_SIGNED(const wchar_t, wchar_t)
+__SDT_COND_SIGNED(const volatile char, char)
+__SDT_COND_SIGNED(const volatile wchar_t, wchar_t)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+/* __SDT_COND_SIGNED(char16_t) */
+/* __SDT_COND_SIGNED(char32_t) */
+#endif
+
+template<typename __sdt_E>
+struct __sdt_type<__sdt_E[]> : public __sdt_type<__sdt_E *> {};
+
+template<typename __sdt_E, size_t __sdt_N>
+struct __sdt_type<__sdt_E[__sdt_N]> : public __sdt_type<__sdt_E *> {};
+
+#elif !defined(__ASSEMBLER__)
+__extension__ extern unsigned long long __sdt_unsp;
+# define _SDT_ARGINTTYPE(x)						\
+  __typeof (__builtin_choose_expr (((__builtin_classify_type (x)	\
+				     + 3) & -4) == 4, (x), 0U))
+# define _SDT_ARGSIGNED(x)						\
+  (!__extension__							\
+   (__builtin_constant_p ((((unsigned long long)			\
+			    (_SDT_ARGINTTYPE (x)) __sdt_unsp)		\
+			   & ((unsigned long long)1 << (sizeof (unsigned long long)	\
+				       * __CHAR_BIT__ - 1))) == 0)	\
+    || (_SDT_ARGINTTYPE (x)) -1 > (_SDT_ARGINTTYPE (x)) 0))
+# define _SDT_ARGSIZE(x)	\
+  (_SDT_ARGARRAY (x) ? sizeof (void *) : sizeof (x))
+# define _SDT_ARGVAL(x)		(x)
+#endif
+
+#if defined __powerpc__ || defined __powerpc64__
+# define _SDT_ARGTMPL(id)	%I[id]%[id]
+#elif defined __i386__
+# define _SDT_ARGTMPL(id)	%w[id]  /* gcc.gnu.org/PR80115 */
+#else
+# define _SDT_ARGTMPL(id)	%[id]
+#endif
+
+#ifdef __LP64__
+# define _SDT_ASM_ADDR	.8byte
+#else
+# define _SDT_ASM_ADDR	.4byte
+#endif
+
+/* The ia64 and s390 nop instructions take an argument. */
+#if defined(__ia64__) || defined(__s390__) || defined(__s390x__)
+#define _SDT_NOP	nop 0
+#else
+#define _SDT_NOP	nop
+#endif
+
+#define _SDT_NOTE_NAME	"stapsdt"
+#define _SDT_NOTE_TYPE	3
+
+/* If the assembler supports the necessary feature, then we can play
+   nice with code in COMDAT sections, which comes up in C++ code.
+   Without that assembler support, some combinations of probe placements
+   in certain kinds of C++ code may produce link-time errors.  */
+#include "sdt-config.h"
+#if _SDT_ASM_SECTION_AUTOGROUP_SUPPORT
+# define _SDT_ASM_AUTOGROUP "?"
+#else
+# define _SDT_ASM_AUTOGROUP ""
+#endif
+
+#define _SDT_ASM_BODY(provider, name, pack_args, args)			      \
+  _SDT_ASM_1(990:	_SDT_NOP)					      \
+  _SDT_ASM_3(		.pushsection .note.stapsdt,_SDT_ASM_AUTOGROUP,"note") \
+  _SDT_ASM_1(		.balign 4)					      \
+  _SDT_ASM_3(		.4byte 992f-991f, 994f-993f, _SDT_NOTE_TYPE)	      \
+  _SDT_ASM_1(991:	.asciz _SDT_NOTE_NAME)				      \
+  _SDT_ASM_1(992:	.balign 4)					      \
+  _SDT_ASM_1(993:	_SDT_ASM_ADDR 990b)				      \
+  _SDT_ASM_1(		_SDT_ASM_ADDR _.stapsdt.base)			      \
+  _SDT_SEMAPHORE(provider,name)						      \
+  _SDT_ASM_STRING(provider)						      \
+  _SDT_ASM_STRING(name)							      \
+  pack_args args							      \
+  _SDT_ASM_1(994:	.balign 4)					      \
+  _SDT_ASM_1(		.popsection)
+
+#define _SDT_ASM_BASE							      \
+  _SDT_ASM_1(.ifndef _.stapsdt.base)					      \
+  _SDT_ASM_5(		.pushsection .stapsdt.base,"aG","progbits",	      \
+							.stapsdt.base,comdat) \
+  _SDT_ASM_1(		.weak _.stapsdt.base)				      \
+  _SDT_ASM_1(		.hidden _.stapsdt.base)				      \
+  _SDT_ASM_1(	_.stapsdt.base: .space 1)				      \
+  _SDT_ASM_2(		.size _.stapsdt.base, 1)			      \
+  _SDT_ASM_1(		.popsection)					      \
+  _SDT_ASM_1(.endif)
+
+#if defined _SDT_HAS_SEMAPHORES
+#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1(		_SDT_ASM_ADDR p##_##n##_semaphore)
+#else
+#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1(		_SDT_ASM_ADDR 0)
+#endif
+
+#define _SDT_ASM_TEMPLATE_0		/* no arguments */
+#define _SDT_ASM_TEMPLATE_1		_SDT_ARGFMT(1)
+#define _SDT_ASM_TEMPLATE_2		_SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(2)
+#define _SDT_ASM_TEMPLATE_3		_SDT_ASM_TEMPLATE_2 _SDT_ARGFMT(3)
+#define _SDT_ASM_TEMPLATE_4		_SDT_ASM_TEMPLATE_3 _SDT_ARGFMT(4)
+#define _SDT_ASM_TEMPLATE_5		_SDT_ASM_TEMPLATE_4 _SDT_ARGFMT(5)
+#define _SDT_ASM_TEMPLATE_6		_SDT_ASM_TEMPLATE_5 _SDT_ARGFMT(6)
+#define _SDT_ASM_TEMPLATE_7		_SDT_ASM_TEMPLATE_6 _SDT_ARGFMT(7)
+#define _SDT_ASM_TEMPLATE_8		_SDT_ASM_TEMPLATE_7 _SDT_ARGFMT(8)
+#define _SDT_ASM_TEMPLATE_9		_SDT_ASM_TEMPLATE_8 _SDT_ARGFMT(9)
+#define _SDT_ASM_TEMPLATE_10		_SDT_ASM_TEMPLATE_9 _SDT_ARGFMT(10)
+#define _SDT_ASM_TEMPLATE_11		_SDT_ASM_TEMPLATE_10 _SDT_ARGFMT(11)
+#define _SDT_ASM_TEMPLATE_12		_SDT_ASM_TEMPLATE_11 _SDT_ARGFMT(12)
+#define _SDT_ASM_OPERANDS_0()		[__sdt_dummy] "g" (0)
+#define _SDT_ASM_OPERANDS_1(arg1)	_SDT_ARG(1, arg1)
+#define _SDT_ASM_OPERANDS_2(arg1, arg2) \
+  _SDT_ASM_OPERANDS_1(arg1), _SDT_ARG(2, arg2)
+#define _SDT_ASM_OPERANDS_3(arg1, arg2, arg3) \
+  _SDT_ASM_OPERANDS_2(arg1, arg2), _SDT_ARG(3, arg3)
+#define _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4) \
+  _SDT_ASM_OPERANDS_3(arg1, arg2, arg3), _SDT_ARG(4, arg4)
+#define _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5) \
+  _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4), _SDT_ARG(5, arg5)
+#define _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+  _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5), _SDT_ARG(6, arg6)
+#define _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+  _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6), _SDT_ARG(7, arg7)
+#define _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+  _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7), \
+    _SDT_ARG(8, arg8)
+#define _SDT_ASM_OPERANDS_9(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \
+  _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8), \
+    _SDT_ARG(9, arg9)
+#define _SDT_ASM_OPERANDS_10(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
+  _SDT_ASM_OPERANDS_9(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9), \
+    _SDT_ARG(10, arg10)
+#define _SDT_ASM_OPERANDS_11(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11) \
+  _SDT_ASM_OPERANDS_10(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10), \
+    _SDT_ARG(11, arg11)
+#define _SDT_ASM_OPERANDS_12(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12) \
+  _SDT_ASM_OPERANDS_11(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11), \
+    _SDT_ARG(12, arg12)
+
+/* These macros can be used in C, C++, or assembly code.
+   In assembly code the arguments should use normal assembly operand syntax.  */
+
+#define STAP_PROBE(provider, name) \
+  _SDT_PROBE(provider, name, 0, ())
+#define STAP_PROBE1(provider, name, arg1) \
+  _SDT_PROBE(provider, name, 1, (arg1))
+#define STAP_PROBE2(provider, name, arg1, arg2) \
+  _SDT_PROBE(provider, name, 2, (arg1, arg2))
+#define STAP_PROBE3(provider, name, arg1, arg2, arg3) \
+  _SDT_PROBE(provider, name, 3, (arg1, arg2, arg3))
+#define STAP_PROBE4(provider, name, arg1, arg2, arg3, arg4) \
+  _SDT_PROBE(provider, name, 4, (arg1, arg2, arg3, arg4))
+#define STAP_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) \
+  _SDT_PROBE(provider, name, 5, (arg1, arg2, arg3, arg4, arg5))
+#define STAP_PROBE6(provider, name, arg1, arg2, arg3, arg4, arg5, arg6)	\
+  _SDT_PROBE(provider, name, 6, (arg1, arg2, arg3, arg4, arg5, arg6))
+#define STAP_PROBE7(provider, name, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+  _SDT_PROBE(provider, name, 7, (arg1, arg2, arg3, arg4, arg5, arg6, arg7))
+#define STAP_PROBE8(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \
+  _SDT_PROBE(provider, name, 8, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8))
+#define STAP_PROBE9(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+  _SDT_PROBE(provider, name, 9, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9))
+#define STAP_PROBE10(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
+  _SDT_PROBE(provider, name, 10, \
+	     (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10))
+#define STAP_PROBE11(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11) \
+  _SDT_PROBE(provider, name, 11, \
+	     (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11))
+#define STAP_PROBE12(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12) \
+  _SDT_PROBE(provider, name, 12, \
+	     (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12))
+
+/* This STAP_PROBEV macro can be used in variadic scenarios, where the
+   number of probe arguments is not known until compile time.  Since
+   variadic macro support may vary with compiler options, you must
+   pre-#define SDT_USE_VARIADIC to enable this type of probe.
+
+   The trick to count __VA_ARGS__ was inspired by this post by
+   Laurent Deniau <laurent.deniau at cern.ch>:
+       http://groups.google.com/group/comp.std.c/msg/346fc464319b1ee5
+
+   Note that our _SDT_NARG is called with an extra 0 arg that's not
+   counted, so we don't have to worry about the behavior of macros
+   called without any arguments.  */
+
+#ifdef SDT_USE_VARIADIC
+#define _SDT_NARG(...) __SDT_NARG(__VA_ARGS__, 12,11,10,9,8,7,6,5,4,3,2,1,0)
+#define __SDT_NARG(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, N, ...) N
+#define _SDT_PROBE_N(provider, name, N, ...) \
+  _SDT_PROBE(provider, name, N, (__VA_ARGS__))
+#define STAP_PROBEV(provider, name, ...) \
+  _SDT_PROBE_N(provider, name, _SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
+#endif
+
+/* These macros are for use in asm statements.  You must compile
+   with -std=gnu99 or -std=c99 to use the STAP_PROBE_ASM macro.
+
+   The STAP_PROBE_ASM macro generates a quoted string to be used in the
+   template portion of the asm statement, concatenated with strings that
+   contain the actual assembly code around the probe site.
+
+   For example:
+
+	asm ("before\n"
+	     STAP_PROBE_ASM(provider, fooprobe, %eax 4(%esi))
+	     "after");
+
+   emits the assembly code for "before\nafter", with a probe in between.
+   The probe arguments are the %eax register, and the value of the memory
+   word located 4 bytes past the address in the %esi register.  Note that
+   because this is a simple asm, not a GNU C extended asm statement, these
+   % characters do not need to be doubled to generate literal %reg names.
+
+   In a GNU C extended asm statement, the probe arguments can be specified
+   using the macro STAP_PROBE_ASM_TEMPLATE(n) for n arguments.  The paired
+   macro STAP_PROBE_ASM_OPERANDS gives the C values of these probe arguments,
+   and appears in the input operand list of the asm statement.  For example:
+
+	asm ("someinsn %0,%1\n" // %0 is output operand, %1 is input operand
+	     STAP_PROBE_ASM(provider, fooprobe, STAP_PROBE_ASM_TEMPLATE(3))
+	     "otherinsn %[namedarg]"
+	     : "r" (outvar)
+	     : "g" (some_value), [namedarg] "i" (1234),
+	       STAP_PROBE_ASM_OPERANDS(3, some_value, some_ptr->field, 1234));
+
+    This is just like writing:
+
+	STAP_PROBE3(provider, fooprobe, some_value, some_ptr->field, 1234));
+
+    but the probe site is right between "someinsn" and "otherinsn".
+
+    The probe arguments in STAP_PROBE_ASM can be given as assembly
+    operands instead, even inside a GNU C extended asm statement.
+    Note that these can use operand templates like %0 or %[name],
+    and likewise they must write %%reg for a literal operand of %reg.  */
+
+#if __STDC_VERSION__ >= 199901L
+# define STAP_PROBE_ASM(provider, name, ...)		\
+  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (__VA_ARGS__)) \
+  _SDT_ASM_BASE
+# define STAP_PROBE_ASM_OPERANDS(n, ...) _SDT_ASM_OPERANDS_##n(__VA_ARGS__)
+#else
+# define STAP_PROBE_ASM(provider, name, args)	\
+  _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (args)) \
+  _SDT_ASM_BASE
+#endif
+#define STAP_PROBE_ASM_TEMPLATE(n)	_SDT_ASM_TEMPLATE_##n
+
+
+/* DTrace compatible macro names.  */
+#define DTRACE_PROBE(provider,probe)		\
+  STAP_PROBE(provider,probe)
+#define DTRACE_PROBE1(provider,probe,parm1)	\
+  STAP_PROBE1(provider,probe,parm1)
+#define DTRACE_PROBE2(provider,probe,parm1,parm2)	\
+  STAP_PROBE2(provider,probe,parm1,parm2)
+#define DTRACE_PROBE3(provider,probe,parm1,parm2,parm3) \
+  STAP_PROBE3(provider,probe,parm1,parm2,parm3)
+#define DTRACE_PROBE4(provider,probe,parm1,parm2,parm3,parm4)	\
+  STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4)
+#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5)	\
+  STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5)
+#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
+  STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6)
+#define DTRACE_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
+  STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7)
+#define DTRACE_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
+  STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8)
+#define DTRACE_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
+  STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9)
+#define DTRACE_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
+  STAP_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10)
+#define DTRACE_PROBE11(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11) \
+  STAP_PROBE11(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11)
+#define DTRACE_PROBE12(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11,parm12) \
+  STAP_PROBE12(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11,parm12)
+
+
+#endif /* sys/sdt.h */



More information about the arch-commits mailing list