summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Goldenberg2022-10-12 16:32:43 -0400
committerAmit Goldenberg2022-10-12 16:32:43 -0400
commit56f343b456d943d869ef03339b01d508d12793e8 (patch)
tree8a20d40e4a66deca7d987c91914025e877b5d80c
parentd6b997ac13ac8c2c534c8f1d7c851f88da80da86 (diff)
downloadaur-56f343b456d943d869ef03339b01d508d12793e8.tar.gz
fixed PKGBUILD (hopefully) and made the PKGBUILD follow the upstream/vanilla PKGBUILD more closely + added latest kernel as an dependency, this is my first PKGBUILD so please tell me if you find any mistakes
-rw-r--r--.SRCINFO48
-rw-r--r--PKGBUILD385
-rw-r--r--bz20338.patch110
-rw-r--r--glibc-git.install5
-rw-r--r--lib32-glibc.conf1
-rw-r--r--locale-gen60
-rw-r--r--locale.gen.txt17
-rw-r--r--sdt-config.h6
-rw-r--r--sdt.h430
9 files changed, 808 insertions, 254 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 9d635ffcead4..f60cfb75ab27 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,31 +1,51 @@
pkgbase = glibc-git
- pkgdesc = GNU C Library
- pkgver = 2.33.r62.gebcf45a16c
- pkgrel = 2
+ pkgver = 2.36.r206.gba0ca36132
+ pkgrel = 1
url = https://www.gnu.org/software/libc/
- install = glibc-git.install
- arch = i686
arch = x86_64
- groups = base
+ groups = base-git
license = GPL
license = LGPL
makedepends = git
+ makedepends = gd
+ makedepends = lib32-gcc-libs
makedepends = python
- depends = linux-api-headers
+ options = staticlibs
+ source = git+https://sourceware.org/git/glibc.git
+ source = locale.gen.txt
+ source = locale-gen
+ source = lib32-glibc.conf
+ source = sdt.h
+ source = sdt-config.h
+ b2sums = SKIP
+ b2sums = c859bf2dfd361754c9e3bbd89f10de31f8e81fd95dc67b77d10cb44e23834b096ba3caa65fbc1bd655a8696c6450dfd5a096c476b3abf5c7e125123f97ae1a72
+ b2sums = 04fbb3b0b28705f41ccc6c15ed5532faf0105370f22133a2b49867e790df0491f5a1255220ff6ebab91a462f088d0cf299491b3eb8ea53534cb8638a213e46e3
+ b2sums = 7c265e6d36a5c0dff127093580827d15519b6c7205c2e1300e82f0fb5b9dd00b6accb40c56581f18179c4fbbc95bd2bf1b900ace867a83accde0969f7b609f8a
+ b2sums = a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e
+ b2sums = 214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678
+
+pkgname = glibc-git
+ pkgdesc = GNU C Library - git version
+ install = glibc-git.install
+ depends = linux-api-headers>=5.18.15
depends = tzdata
depends = filesystem
- optdepends = gd: graph image generation with memusage
+ optdepends = gd: for memusagestat
optdepends = perl: for mtrace
- provides = glibc=2.33
+ provides = glibc=2.36
conflicts = glibc
options = staticlibs
+ options = !strip
backup = etc/gai.conf
+ backup = etc/locale.gen
backup = etc/nscd.conf
- source = git+https://sourceware.org/git/glibc.git
- source = locale-gen
- sha256sums = SKIP
- sha256sums = 05fbb88877cdddc99ef25e48304d6e5ac236660c20925d461cb4e90ebcb3b7de
-pkgname = glibc-git
+pkgname = lib32-glibc-git
+ pkgdesc = GNU C Library (32-bit) - git version
+ depends = glibc=2.36
+ optdepends = perl: for mtrace
+ provides = lib32-glibc=2.36
+ conflicts = lib32-glibc
options = staticlibs
+ options = !emptydirs
options = !strip
diff --git a/PKGBUILD b/PKGBUILD
index e80ee0f38fe2..16448ca9f231 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,129 +1,308 @@
-# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
+# Maintainer: Niko Cantero <vextium at gmail dot com>
+# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Earnestly <zibeon@googlemail.com>
+# Contributor: Giancarlo Razzolini <grazzolini@archlinux.org>
+# Contributor: Frederik Schwan <freswa at archlinux dot org>
+# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
+# Contributor: Allan McRae <allan@archlinux.org>
+# Contributor: Dakkshesh <dakkshesh5 at gmail dot com>
+# Contributor: Cyber Knight <cyberknight755 at gmail dot com>
-# All my PKGBUILDs are managed at https://github.com/eli-schwartz/pkgbuilds
+# toolchain build order: linux-api-headers->glibc(-git)->binutils->gcc->glibc(-git)->binutils->gcc
+# NOTE: valgrind requires rebuilt with each major glibc version
-pkgname=glibc-git
-pkgver=2.33.r62.gebcf45a16c
-pkgrel=2
-pkgdesc='GNU C Library'
-arch=('i686' 'x86_64')
+_pkgname='glibc'
+_kernelver='5.18.15'
+pkgbase="${_pkgname}"-git
+pkgname=("${_pkgname}"-git lib32-"${_pkgname}"-git)
+pkgver=2.36.r206.gba0ca36132
+pkgrel=1
+arch=('x86_64')
url='https://www.gnu.org/software/libc/'
license=('GPL' 'LGPL')
-groups=('base')
-depends=('linux-api-headers' 'tzdata' 'filesystem')
-optdepends=('gd: graph image generation with memusage'
- 'perl: for mtrace')
-makedepends=('git' 'python')
-# XXX Arch Linux's valgrind package requires an exact version
-provides=("glibc=${pkgver%%.r*}")
-conflicts=('glibc')
-backup=('etc/gai.conf' 'etc/nscd.conf')
+groups=('base-git')
+makedepends=('git' 'gd' 'lib32-gcc-libs' 'python')
options=('staticlibs')
-install='glibc-git.install'
source=('git+https://sourceware.org/git/glibc.git'
- 'locale-gen')
-sha256sums=('SKIP'
- '05fbb88877cdddc99ef25e48304d6e5ac236660c20925d461cb4e90ebcb3b7de')
+ 'locale.gen.txt'
+ 'locale-gen'
+ 'lib32-glibc.conf'
+ 'sdt.h'
+ 'sdt-config.h')
+b2sums=('SKIP'
+ 'c859bf2dfd361754c9e3bbd89f10de31f8e81fd95dc67b77d10cb44e23834b096ba3caa65fbc1bd655a8696c6450dfd5a096c476b3abf5c7e125123f97ae1a72'
+ '04fbb3b0b28705f41ccc6c15ed5532faf0105370f22133a2b49867e790df0491f5a1255220ff6ebab91a462f088d0cf299491b3eb8ea53534cb8638a213e46e3'
+ '7c265e6d36a5c0dff127093580827d15519b6c7205c2e1300e82f0fb5b9dd00b6accb40c56581f18179c4fbbc95bd2bf1b900ace867a83accde0969f7b609f8a'
+ 'a6a5e2f2a627cc0d13d11a82458cfd0aa75ec1c5a3c7647e5d5a3bb1d4c0770887a3909bfda1236803d5bc9801bfd6251e13483e9adf797e4725332cd0d91a0e'
+ '214e995e84b342fe7b2a7704ce011b7c7fc74c2971f98eeb3b4e677b99c860addc0a7d91b8dc0f0b8be7537782ee331999e02ba48f4ccc1c331b60f27d715678')
-# remove default hardening for building libraries
-CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
+prepare() {
+ mkdir -p glibc-build lib32-glibc-build
+
+ [[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc
+ cd glibc
+}
pkgver() {
cd glibc
- # wtf is tag "glibc-2.26.9000"
+ # Removes .9000 tag from glibc pkgver.
git describe --exclude '*.*.9000' | sed 's/^glibc-//; s/-/.r/; s/-/./'
}
build() {
- mkdir -p build
- cd build
-
- if [[ ${CARCH} = "i686" ]]; then
- # Hack to fix NPTL issues with Xen, only required on 32bit platforms
- export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
- fi
-
- { printf 'slibdir=/usr/lib\n'
- printf 'rtlddir=/usr/lib\n'
- printf 'sbindir=/usr/bin\n'
- printf 'rootsbindir=/usr/bin\n'
- } >> configparms
-
- "$srcdir"/glibc/configure \
- --prefix=/usr \
- --libdir=/usr/lib \
- --libexecdir=/usr/lib \
- --with-headers=/usr/include \
- --with-bugurl=https://bugs.archlinux.org/ \
- --enable-add-ons \
- --enable-bind-now \
- --enable-cet \
- --enable-kernel=4.4 \
- --enable-lock-elision \
- --enable-multi-arch \
- --enable-stack-protector=strong \
- --enable-stackguard-randomization \
- --disable-profile \
+ local _configure_flags=(
+ --prefix=/usr
+ --with-headers=/usr/include
+ --with-bugurl=https://bugs.archlinux.org/
+ --enable-memory-tagging
+ --enable-bind-now
+ --enable-cet
+ --enable-kernel="${_kernelver}"
+ --enable-multi-arch
+ --enable-stack-protector=strong
+ --enable-systemtap
+ --disable-crypt
+ --disable-profile
--disable-werror
+ )
+
+ unset_flags() {
+ unset CFLAGS
+ unset CXXFLAGS
+ }
+
+ configparms_fortify_source() {
+ echo "CFLAGS += -Wp,-D_FORTIFY_SOURCE=2" >> configparms
+ }
+
+ configparms_enable_programs() {
+ sed -i "/build-programs=/s#no#yes#" configparms
+ }
+
+ configparms_disable_programs() {
+ echo "build-programs=no" >> configparms
+ }
+
+ make_build_64 () {
+ make -O CFLAGS="$MAKE_FLAGS_64_FULL" CXXFLAGS="$MAKE_FLAGS_64_FULL" -j$(nproc --all)
+ }
+
+ make_build_32 () {
+ make -O CFLAGS="$MAKE_FLAGS_32_FULL" CXXFLAGS="$MAKE_FLAGS_32_FULL" -j$(nproc --all)
+ }
+
+ MAKE_FLAGS_64="-O2 -pipe"
+ MAKE_FLAGS_32="-mno-tls-direct-seg-refs -O2 -pipe"
+
+ cd "${srcdir}"/glibc-build
- printf 'build-programs=no\n' >> configparms
- make
+ echo "slibdir=/usr/lib" >> configparms
+ echo "rtlddir=/usr/lib" >> configparms
+ echo "sbindir=/usr/bin" >> configparms
+ echo "rootsbindir=/usr/bin" >> configparms
- # Re-enable hardening for programs.
- sed -i '/build-programs=/s/no/yes/' configparms
- { printf 'CC += -D_FORTIFY_SOURCE=2\n'
- printf 'CXX += -D_FORTIFY_SOURCE=2\n'
- } >> configparms
- make
+ # Credits @dakkshesh07 & @cyberknight777
+ # https://github.com/Neutron-Toolchains/glibc-pkgbuild/blob/main/PKGBUILD
+ # remove fortify for building libraries & configure glibc (64-bit) to point at lib directories
+ unset_flags
+ "${srcdir}"/glibc/configure \
+ --host=x86_64-pc-linux-gnu \
+ --libdir=/usr/lib \
+ --libexecdir=/usr/lib \
+ "${_configure_flags[@]}"
+
+ # build libraries with fortify disabled
+ configparms_disable_programs
+ MAKE_FLAGS_64_FULL="$MAKE_FLAGS_64 -U_FORTIFY_SOURCE -ffunction-sections -fdata-sections"
+ make_build_64
+
+ # re-enable fortify for programs
+ configparms_enable_programs
+ unset_flags
+ configparms_fortify_source
+ MAKE_FLAGS_64_FULL="$MAKE_FLAGS_64 -Wp,-D_FORTIFY_SOURCE=2 -ffunction-sections -fdata-sections"
+ make_build_64
+
+ # build info pages manually for reproducibility
+ make info -j$(nproc --all)
+
+ 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
+
+ # remove fortify for building libraries & configure glibc (32-bit) to point at lib directories
+ unset_flags
+ "${srcdir}"/glibc/configure \
+ --host=i686-pc-linux-gnu \
+ --libdir=/usr/lib32 \
+ --libexecdir=/usr/lib32 \
+ "${_configure_flags[@]}"
+
+ # build libraries with fortify disabled
+ configparms_disable_programs
+ MAKE_FLAGS_32_FULL="$MAKE_FLAGS_32 -U_FORTIFY_SOURCE -ffunction-sections -fdata-sections"
+ make_build_32
+
+ # re-enable fortify for programs
+ configparms_enable_programs
+ unset_flags
+ configparms_fortify_source
+ MAKE_FLAGS_32_FULL="$MAKE_FLAGS_32 -Wp,-D_FORTIFY_SOURCE=2 -ffunction-sections -fdata-sections"
+ make_build_32
+
+ # pregenerate C.UTF-8 locale until it is built into glibc
+ # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8, FS#74864)-
+ elf/ld.so --library-path "$PWD" locale/localedef -c -f ../glibc/localedata/charmaps/UTF-8 -i ../glibc/localedata/locales/C ../C.UTF-8/
+}
+# 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 build
+ cd glibc-build
- # Remove harding in preparation to run test-suite.
- sed -i '/FORTIFY/d' configparms
- make check || true
+ # 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-mlock2 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-pkey sysdeps/unix/sysv/linux/Makefile
+ skip_test tst-process_mrelease sysdeps/unix/sysv/linux/Makefile
+ skip_test tst-adjtime time/Makefile
+ skip_test tst-clock2 time/Makefile
+
+ make -O check
}
-package() {
- make -C build install_root="$pkgdir" install
-
- install -dm0755 "$pkgdir"/usr/lib/locale
- install -dm0755 "$pkgdir"/etc/locales
- install -Dm0755 locale-gen "$pkgdir"/usr/bin/locale-gen
- install -Dm0644 glibc/posix/gai.conf "$pkgdir"/etc/gai.conf
- install -Dm0644 glibc/nscd/nscd.conf "$pkgdir"/etc/nscd.conf
- install -Dm0644 glibc/nscd/nscd.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/nscd.conf
- install -Dm0644 glibc/nscd/nscd.service "$pkgdir"/usr/lib/systemd/system/nscd.service
-
- # Only support UTF-8 charmaps.
- find "$pkgdir"/usr/share/i18n/charmaps ! -name UTF-8.gz -type f -delete
-
- # We generate these in the post-install with ldconfig -r .
- rm "$pkgdir"/etc/ld.so.cache
-
- # Shipped in tzdata
- rm -f "$pkgdir"/usr/bin/{tzselect,zdump,zic}
-
- # Provided by libxcrypt; keep the old shared library for backwards compatibility
- rm -f "$pkgdir"/usr/include/crypt.h "$pkgdir"/usr/lib/libcrypt.{a,so}
-
- # handle selectively stripping unless debug packages are requested
- if check_option 'debug' n; then
- options+=('!strip')
- # I use 2> /dev/null for all of these due to many false-positives as it
- # attempts to strip scripts or other unstrippable files.
- 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.
- 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
+package_glibc-git() {
+ pkgdesc='GNU C Library - git version'
+ depends=("linux-api-headers>=${_kernelver}" 'tzdata' 'filesystem')
+ optdepends=('gd: for memusagestat'
+ 'perl: for mtrace')
+ # XXX Arch Linux's valgrind package requires an exact version
+ provides=("${_pkgname}=${pkgver%%.r*}")
+ conflicts=("${_pkgname}")
+ install=glibc-git.install
+ backup=('etc/gai.conf'
+ 'etc/locale.gen'
+ 'etc/nscd.conf')
+
+ # We generate these in the post-install with ldconfig -r
+ 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
+
+ # Add SUPPORTED file to pkg
+ sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' \
+ "${srcdir}"/glibc/localedata/SUPPORTED > "${pkgdir}"/usr/share/i18n/SUPPORTED
+
+ # install C.UTF-8 so that it is always available
+ install -dm755 "${pkgdir}"/usr/lib/locale
+ cp -r "${srcdir}"/C.UTF-8 -t "${pkgdir}"/usr/lib/locale
+ sed -i '/#C\.UTF-8 /d' "${pkgdir}"/etc/locale.gen
+
+ # handle selectively stripping unless debug packages are requested
+ if check_option 'debug' n; then
+ options+=('!strip')
+ # I use 2> /dev/null for all of these due to many false-positives as it
+ # attempts to strip scripts or other unstrippable files.
+ 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.
+ 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-git() {
+ pkgdesc='GNU C Library (32-bit) - git version'
+ depends=("${_pkgname}=${pkgver%%.r*}")
+ optdepends=('perl: for mtrace')
+ # XXX Arch Linux's valgrind package requires an exact version
+ provides=("lib32-${_pkgname}=${pkgver%%.r*}")
+ conflicts=("lib32-${_pkgname}")
+ 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
+
+ # handle selectively stripping unless debug packages are requested
+ if check_option 'debug' n; then
+ options+=('!strip')
+ # I use 2> /dev/null for all of these due to many false-positives as it
+ # attempts to strip scripts or other unstrippable files.
+ find "$pkgdir"/usr/bin -type f -executable -exec strip $STRIP_BINARIES {} + 2> /dev/null || true
+ find "$pkgdir"/usr/lib32 -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true
+
+ # Do not strip these for gdb and valgrind functionality.
+ 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
}
diff --git a/bz20338.patch b/bz20338.patch
deleted file mode 100644
index ac2eedff299b..000000000000
--- a/bz20338.patch
+++ /dev/null
@@ -1,110 +0,0 @@
-From e7d2660cfa942ad08f4398436332f46fd620ddd0 Mon Sep 17 00:00:00 2001
-From: David Michael <david.michael@coreos.com>
-Date: Thu, 15 Dec 2016 15:22:57 -0800
-Subject: [PATCH] gshadow: Sync fgetsgent_r.c with grp/fgetgrent_r.c
-
- [BZ #20338]
- * gshadow/fgetsgent_r.c: Include <libio/iolibio.h>.
- (flockfile): New macro.
- (funlockfile): Likewise.
- (__fgetsgent_r): Sync with __fgetgrent_r.
- * nss/nss_files/files-sgrp.c: Fix "fgetsgent_r.c" typo.
----
- gshadow/fgetsgent_r.c | 33 +++++++++++++++++++++++----------
- nss/nss_files/files-sgrp.c | 2 +-
- 2 files changed, 24 insertions(+), 11 deletions(-)
-
-diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
-index 19a663f048..32eb7a2365 100644
---- a/gshadow/fgetsgent_r.c
-+++ b/gshadow/fgetsgent_r.c
-@@ -20,39 +20,44 @@
- #include <gshadow.h>
- #include <stdio.h>
-
-+#include <libio/iolibio.h>
-+#define flockfile(s) _IO_flockfile (s)
-+#define funlockfile(s) _IO_funlockfile (s)
-+
- /* Define a line parsing function using the common code
- used in the nss_files module. */
-
- #define STRUCTURE sgrp
- #define ENTNAME sgent
--#define EXTERN_PARSER 1
-+#define EXTERN_PARSER 1
- struct sgent_data {};
-
- #include <nss/nss_files/files-parse.c>
-
-
--/* Read one shadow entry from the given stream. */
-+/* Read one entry from the given stream. */
- int
- __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
- struct sgrp **result)
- {
- char *p;
-+ int parse_result;
-
-- _IO_flockfile (stream);
-+ flockfile (stream);
- do
- {
- buffer[buflen - 1] = '\xff';
- p = fgets_unlocked (buffer, buflen, stream);
-- if (p == NULL && feof_unlocked (stream))
-+ if (__builtin_expect (p == NULL, 0) && feof_unlocked (stream))
- {
-- _IO_funlockfile (stream);
-+ funlockfile (stream);
- *result = NULL;
- __set_errno (ENOENT);
- return errno;
- }
-- if (p == NULL || buffer[buflen - 1] != '\xff')
-+ if (__builtin_expect (p == NULL, 0) || buffer[buflen - 1] != '\xff')
- {
-- _IO_funlockfile (stream);
-+ funlockfile (stream);
- *result = NULL;
- __set_errno (ERANGE);
- return errno;
-@@ -64,10 +69,18 @@ __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
- } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
- /* Parse the line. If it is invalid, loop to
- get the next line of the file to parse. */
-- || ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
-- &errno));
-+ || ! (parse_result = parse_line (p, resbuf,
-+ (void *) buffer, buflen,
-+ &errno)));
-+
-+ funlockfile (stream);
-
-- _IO_funlockfile (stream);
-+ if (__builtin_expect (parse_result, 0) == -1)
-+ {
-+ /* The parser ran out of space. */
-+ *result = NULL;
-+ return errno;
-+ }
-
- *result = resbuf;
- return 0;
-diff --git a/nss/nss_files/files-sgrp.c b/nss/nss_files/files-sgrp.c
-index 6fb880a4ba..9f66a4e327 100644
---- a/nss/nss_files/files-sgrp.c
-+++ b/nss/nss_files/files-sgrp.c
-@@ -23,7 +23,7 @@
- #define DATABASE "gshadow"
- struct sgent_data {};
-
--/* Our parser function is already defined in sgetspent_r.c, so use that
-+/* Our parser function is already defined in sgetsgent_r.c, so use that
- to parse lines from the database file. */
- #define EXTERN_PARSER
- #include "files-parse.c"
---
-2.21.0
-
diff --git a/glibc-git.install b/glibc-git.install
index 257530bb546e..351f05b263cb 100644
--- a/glibc-git.install
+++ b/glibc-git.install
@@ -1,4 +1,5 @@
post_upgrade() {
- locale-gen
- ldconfig -r .
+ locale-gen
+
+ ldconfig -r .
}
diff --git a/lib32-glibc.conf b/lib32-glibc.conf
new file mode 100644
index 000000000000..9b08c3f43a78
--- /dev/null
+++ b/lib32-glibc.conf
@@ -0,0 +1 @@
+/usr/lib32
diff --git a/locale-gen b/locale-gen
index de48ddf8d501..ee88880705a5 100644
--- a/locale-gen
+++ b/locale-gen
@@ -1,32 +1,42 @@
-#!/bin/sh --
-# locale-gen: generate system locales
+#!/bin/sh
-if [ ! -d /etc/locales ]; then
- printf '/etc/locales: no such directory\n' >&2
- exit 1
+set -e
+
+LOCALEGEN=/etc/locale.gen
+LOCALES=/usr/share/i18n/locales
+if [ -n "$POSIXLY_CORRECT" ]; then
+ unset POSIXLY_CORRECT
fi
-localegen() {
- printf '%s: generating locale\n' "$1"."$2" >&2
- localedef -i "$1" -f "$2" -c "$1"."$2"
+[ -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/locale-archive || true
+
+umask 022
- case $? in
- 4) printf '%s: invalid locale\n' "$1"."$2" >&2
- esac
+is_entry_ok() {
+ if [ -n "$locale" -a -n "$charset" ] ; then
+ true
+ else
+ echo "error: Bad entry '$locale $charset'"
+ false
+ fi
}
-for locale in /etc/locales/*; do
- if [ -f "$locale" ]; then
- if [ -s "$locale" ]; then
- while read -r charset; do
-
- # This will run for empty lines. Doing this means we can
- # ensure at least a UTF-8 based locale is generated.
- localegen "${locale##*/}" "${charset:-UTF-8}"
- done < "$locale"
- else
- localegen "${locale##*/}" UTF-8
- fi
- fi
-done
+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."
diff --git a/locale.gen.txt b/locale.gen.txt
new file mode 100644
index 000000000000..e32af2962797
--- /dev/null
+++ b/locale.gen.txt
@@ -0,0 +1,17 @@
+# 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
+#
+# The locale-gen command will generate all the locales,
+# placing them in /usr/lib/locale.
+#
+# A list of supported locales is given in /usr/share/i18n/SUPPORTED
+# and is included in this file. Uncomment the needed locales below.
+#
diff --git a/sdt-config.h b/sdt-config.h
new file mode 100644
index 000000000000..733045a52771
--- /dev/null
+++ b/sdt-config.h
@@ -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
diff --git a/sdt.h b/sdt.h
new file mode 100644
index 000000000000..c0c5a492cb9c
--- /dev/null
+++ b/sdt.h
@@ -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@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 */