diff -Nru glibc-2.27/debian/changelog glibc-2.27/debian/changelog --- glibc-2.27/debian/changelog 2018-04-02 21:07:23.000000000 +0000 +++ glibc-2.27/debian/changelog 2018-04-16 20:14:20.000000000 +0000 @@ -1,12 +1,86 @@ -glibc (2.27-0ubuntu3) bionic; urgency=medium +glibc (2.27-3ubuntu1) bionic; urgency=medium - * Cherry pick from the Debian packaging: - - debian/sysdeps/*.mk: install gnu/lib-names-*.h for multilib builds. - - debian/patches/any/local-bootstrap-headers.diff: update to install - gnu/lib-names-$abi.h. Closes: #892126. - * d/p/git-updates.diff: update from upstream stable branch (taken from 2.27-3). + * Merge with Debian, with packaging tweaks and master updated to 2018-03-29. + * testsuite-xfail-debian.mk: Allow tst-backtrace{4,5} and tst-cancelx{20,21} + to fail on the 31-bit build of glibc on s390 (see upstream bug in comment) - -- Matthias Klose Mon, 02 Apr 2018 23:07:51 +0200 + -- Adam Conrad Mon, 16 Apr 2018 14:14:20 -0600 + +glibc (2.27-3) unstable; urgency=medium + + [ Samuel Thibault ] + * hurd-i386/tg-NOFOLLOW.diff: Rename to hurd-i386/git-NOFOLLOW.diff. + * hurd-i386/tg-NOFOLLOW-DIRECTORY.diff: Rename to + hurd-i386/git-NOFOLLOW-DIRECTORY.diff. + * hurd-i386/tg-_dl_random.diff: Rename to hurd-i386/git-_dl_random.diff. + * hurd-i386/tg-exec-static.diff: Rename to hurd-i386/git-exec-static.diff. + * hurd-i386/tg-futimens.diff: Rename to hurd-i386/git-futimens.diff. + * hurd-i386/tg-gai_misc.diff: Rename to hurd-i386/git-gai_misc.diff. + * hurd-i386/tg-grantpt.diff: Rename to hurd-i386/git-grantpt.diff. + * hurd-i386/tg-gscope.diff: Rename to hurd-i386/git-gscope.diff. + * hurd-i386/tg-libpthread-gsync-mutex.diff: Rename to + hurd-i386/git-libpthread-gsync-mutex.diff. + * hurd-i386/tg-libpthread-gsync-spin.diff: Rename to + hurd-i386/git-libpthread-gsync-spin.diff. + * hurd-i386/tg-mlockall.diff: Rename to hurd-i386/git-mlockall.diff. + * hurd-i386/tg-pagesize.diff: Rename to hurd-i386/git-pagesize.diff. + * hurd-i386/tg-reboot-startup.diff: Rename to + hurd-i386/git-reboot-startup.diff. + * hurd-i386/tg-thread-linkspace.diff: Rename to + hurd-i386/git-thread-linkspace.diff. + * hurd-i386/tg-timer_routines.diff: Rename to + hurd-i386/git-timer_routines.diff. + * hurd-i386/tg-tls-threadvar.diff: Rename to + hurd-i386/git-tls-threadvar.diff. + * hurd-i386/tg-tls.diff: Rename to hurd-i386/git-tls.diff. + * hurd-i386/tg-tls_thread_leak.diff: Rename to + hurd-i386/git-tls_thread_leak.diff. + * hurd-i386/tg2.25-tls.diff: Rename to hurd-i386/git2.25-tls.diff. + * hurd-i386/submitted-hurd-abilist.diff: Rename to + hurd-i386/git-hurd-abilist.diff. + * hurd-i386/local-libpthread-stacksize.diff: Rename to + hurd-i386/git-libpthread-stacksize.diff. + + [ Aurelien Jarno ] + * debian/patches/localedata/locales-fr.diff: fix conversion from + format to ascii during the latest rebase. Closes: bug#894078. + * debian/patches/git-updates.diff: update from upstream stable branch: + - Fix a missing reorder-end keyword in et_EE locale. Closes: #894395. + + -- Aurelien Jarno Thu, 29 Mar 2018 21:47:29 +0200 + +glibc (2.27-2) unstable; urgency=medium + + [ Samuel Thibault ] + * debian/patches/hurd-i386/git-UTIME.diff: New patch. + * debian/control: Bump hurd build dep accordingly. + * debian/libc0.3.symbols.hurd-i386: Update accordingly. + + [ Aurelien Jarno ] + * debian/control.in/main: drop the branch from Vcs-Git. + * debian/patches/any/local-bootstrap-headers.diff: update to install + gnu/lib-names-$abi.h. Closes: #892126. + * debian/patches/git-updates.diff: update from upstream stable branch: + - Fix FTBFS on powerpcspe. + - debian/patches/sparc/submitted-sparc32-makecontext.diff: upstreamed. + + [ Helmut Grohne ] + * debian/rules: drop DEB_STAGE and DEB_BUILD_PROFILE support. + * debian/rules: disable tests for stage1. + * debian/control.in/*: drop libc*-dev -> libc* dependencies in stage1. + + -- Aurelien Jarno Fri, 09 Mar 2018 21:48:04 +0100 + +glibc (2.27-1) unstable; urgency=medium + + [ Aurelien Jarno ] + * debian/sysdeps/*.mk: install gnu/lib-names-*.h for multilib builds. + * debian/patches/alpha/submitted-makecontext.diff: new patch to fix + infinite backtrace within a context created by makecontext. + * debian/patches/sparc/submitted-sparc32-makecontext.diff: new patch + to fix infinite backtrace within a context created by makecontext. + + -- Aurelien Jarno Sat, 03 Mar 2018 11:47:56 +0100 glibc (2.27-0ubuntu2) bionic; urgency=medium @@ -37,7 +111,7 @@ -- Adam Conrad Thu, 22 Feb 2018 03:58:57 -0700 -glibc (2.27-0experimental1) UNRELEASED; urgency=medium +glibc (2.27-0experimental1) experimental; urgency=medium [ Samuel Thibault ] * debian/patches/hurd-i386/git-test-atexit-race-common.diff: New patch, @@ -64,7 +138,7 @@ from the linux-libc-dev dependency, as the file is not generated anymore from the installed kernel headers. - -- Samuel Thibault Sun, 04 Feb 2018 14:05:22 +0100 + -- Aurelien Jarno Sat, 24 Feb 2018 23:49:00 +0100 glibc (2.27-0experimental0) experimental; urgency=medium @@ -267,6 +341,7 @@ [ Samuel Thibault ] * debian/patches/hurd-i386/tg-grantpt.diff: Update patch. + * debian/patches/hurd-i386/git-libpthread-trylock.diff: New patch. -- Aurelien Jarno Sat, 17 Feb 2018 23:20:49 +0100 diff -Nru glibc-2.27/debian/control glibc-2.27/debian/control --- glibc-2.27/debian/control 2018-02-22 10:14:02.000000000 +0000 +++ glibc-2.27/debian/control 2018-04-16 20:02:50.000000000 +0000 @@ -6,8 +6,8 @@ linux-libc-dev (>= 3.9) [linux-any], systemtap-sdt-dev [linux-any], libaudit-dev [linux-any], libcap-dev [linux-any], libselinux-dev [linux-any], mig (>= 1.5-3) [hurd-i386], gnumach-dev (>= 2:1.8+git20170102-1~) [hurd-i386], - hurd-dev (>= 1:0.9.git20171119-4~) [hurd-i386] | hurd-headers-dev [hurd-i386], - hurd-dev (>= 1:0.9.git20171119-4~) [hurd-i386] | libihash-dev [hurd-i386] , + hurd-dev (>= 1:0.9.git20180305~) [hurd-i386] | hurd-headers-dev [hurd-i386], + hurd-dev (>= 1:0.9.git20180305~) [hurd-i386] | libihash-dev [hurd-i386] , kfreebsd-kernel-headers [kfreebsd-any], binutils (>= 2.25), binutils (>= 2.29) [amd64 i386 x32], g++-7, g++-7 (>= 7.2.0-20) [amd64 i386 x32], g++-7-multilib [amd64 armhf armel i386 kfreebsd-amd64 mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el powerpc ppc64 s390x sparc sparc64 x32] , @@ -19,7 +19,7 @@ Uploaders: Clint Adams , Aurelien Jarno , Adam Conrad , Samuel Thibault Standards-Version: 4.1.3 Vcs-Browser: https://salsa.debian.org/glibc-team/glibc -Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git -b glibc-2.27 +Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git Homepage: https://www.gnu.org/software/libc/libc.html Package: libc-bin @@ -194,7 +194,7 @@ Section: libdevel Priority: optional Multi-Arch: same -Depends: libc6 (= ${binary:Version}), libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] +Depends: libc6 (= ${binary:Version}) , libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] Replaces: hurd-dev (<< 20120408-3) [hurd-i386], kfreebsd-kernel-headers (<< 10.3~4) [kfreebsd-amd64 kfreebsd-i386] Suggests: glibc-doc, manpages-dev Provides: libc-dev, libc6-dev [alpha ia64 hurd-i386 kfreebsd-i386 kfreebsd-amd64], libc6-dev-armel [armel], libc6-dev-armhf [armhf] @@ -283,7 +283,7 @@ Section: libdevel Priority: optional Multi-Arch: same -Depends: libc6.1 (= ${binary:Version}), libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] +Depends: libc6.1 (= ${binary:Version}) , libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] Replaces: hurd-dev (<< 20120408-3) [hurd-i386], kfreebsd-kernel-headers (<< 10.3~4) [kfreebsd-amd64 kfreebsd-i386] Suggests: glibc-doc, manpages-dev Provides: libc-dev, libc6-dev [alpha ia64 hurd-i386 kfreebsd-i386 kfreebsd-amd64], libc6-dev-armel [armel], libc6-dev-armhf [armhf] @@ -372,7 +372,7 @@ Section: libdevel Priority: optional Multi-Arch: same -Depends: libc0.3 (= ${binary:Version}), libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] +Depends: libc0.3 (= ${binary:Version}) , libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] Replaces: hurd-dev (<< 20120408-3) [hurd-i386], kfreebsd-kernel-headers (<< 10.3~4) [kfreebsd-amd64 kfreebsd-i386] Suggests: glibc-doc, manpages-dev Provides: libc-dev, libc6-dev [alpha ia64 hurd-i386 kfreebsd-i386 kfreebsd-amd64], libc6-dev-armel [armel], libc6-dev-armhf [armhf] @@ -461,7 +461,7 @@ Section: libdevel Priority: optional Multi-Arch: same -Depends: libc0.1 (= ${binary:Version}), libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] +Depends: libc0.1 (= ${binary:Version}) , libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] Replaces: hurd-dev (<< 20120408-3) [hurd-i386], kfreebsd-kernel-headers (<< 10.3~4) [kfreebsd-amd64 kfreebsd-i386] Suggests: glibc-doc, manpages-dev Provides: libc-dev, libc6-dev [alpha ia64 hurd-i386 kfreebsd-i386 kfreebsd-amd64], libc6-dev-armel [armel], libc6-dev-armhf [armhf] @@ -531,7 +531,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-i386 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-i386 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32-bit development libraries for AMD64 @@ -556,7 +556,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-sparc (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-sparc (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit Development Libraries for SPARC @@ -581,7 +581,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-sparc64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-sparc64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for UltraSPARC @@ -606,7 +606,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-s390 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-s390 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit Development Libraries for IBM zSeries @@ -630,7 +630,7 @@ Architecture: i386 x32 Section: libdevel Priority: optional -Depends: libc6-amd64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-amd64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Provides: lib64c-dev Build-Profiles: @@ -656,7 +656,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-powerpc (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-powerpc (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit powerpc development libraries for ppc64 @@ -681,7 +681,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-ppc64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-ppc64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for PowerPC64 @@ -706,7 +706,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-dev (= ${binary:Version}), libc6-mips32 (= ${binary:Version}), +Depends: libc6-mips32 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), libc6-dev-mipsn32 (= ${binary:Version}) [mips64 mips64el mips64r6 mips64r6el], libc6-dev-mips64 (= ${binary:Version}) [mipsn32 mipsn32el mipsn32r6 mipsn32r6el], ${misc:Depends} @@ -734,7 +734,7 @@ Section: libdevel Priority: optional Provides: libn32c-dev -Depends: libc6-mipsn32 (= ${binary:Version}), libc6-dev-mips64 (= ${binary:Version}) [mips mipsel mipsr6 mipsr6el], libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-mipsn32 (= ${binary:Version}) , libc6-dev-mips64 (= ${binary:Version}) [mips mipsel mipsr6 mipsr6el], libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: n32 Development Libraries for MIPS64 @@ -759,7 +759,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-mips64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-mips64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for MIPS64 @@ -830,7 +830,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc0.1-i386 (= ${binary:Version}), libc0.1-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc0.1-i386 (= ${binary:Version}) , libc0.1-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit development libraries for AMD64 @@ -854,7 +854,7 @@ Architecture: amd64 i386 Section: libdevel Priority: optional -Depends: libc6-x32 (= ${binary:Version}), libc6-dev-i386 (= ${binary:Version}) [amd64], libc6-dev-amd64 (= ${binary:Version}) [i386], libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-x32 (= ${binary:Version}) , libc6-dev-i386 (= ${binary:Version}) [amd64], libc6-dev-amd64 (= ${binary:Version}) [i386], libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: X32 ABI Development Libraries for AMD64 diff -Nru glibc-2.27/debian/control.in/amd64 glibc-2.27/debian/control.in/amd64 --- glibc-2.27/debian/control.in/amd64 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/amd64 2018-04-16 20:02:33.000000000 +0000 @@ -14,7 +14,7 @@ Architecture: i386 x32 Section: libdevel Priority: optional -Depends: libc6-amd64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-amd64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Provides: lib64c-dev Build-Profiles: diff -Nru glibc-2.27/debian/control.in/armel glibc-2.27/debian/control.in/armel --- glibc-2.27/debian/control.in/armel 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/control.in/armel 2018-04-16 20:02:33.000000000 +0000 @@ -13,7 +13,7 @@ Architecture: armhf Section: libdevel Priority: optional -Depends: libc6-armel (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-armel (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: ARM softfp development libraries for armhf diff -Nru glibc-2.27/debian/control.in/armhf glibc-2.27/debian/control.in/armhf --- glibc-2.27/debian/control.in/armhf 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/control.in/armhf 2018-04-16 20:02:33.000000000 +0000 @@ -13,7 +13,7 @@ Architecture: armel Section: libdevel Priority: optional -Depends: libc6-armhf (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-armhf (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: ARM hard float development libraries for armel diff -Nru glibc-2.27/debian/control.in/i386 glibc-2.27/debian/control.in/i386 --- glibc-2.27/debian/control.in/i386 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/i386 2018-04-16 20:02:33.000000000 +0000 @@ -16,7 +16,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-i386 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-i386 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32-bit development libraries for AMD64 diff -Nru glibc-2.27/debian/control.in/kfreebsd-i386 glibc-2.27/debian/control.in/kfreebsd-i386 --- glibc-2.27/debian/control.in/kfreebsd-i386 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/kfreebsd-i386 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc0.1-i386 (= ${binary:Version}), libc0.1-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc0.1-i386 (= ${binary:Version}) , libc0.1-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit development libraries for AMD64 diff -Nru glibc-2.27/debian/control.in/libc glibc-2.27/debian/control.in/libc --- glibc-2.27/debian/control.in/libc 2018-02-22 10:07:35.000000000 +0000 +++ glibc-2.27/debian/control.in/libc 2018-04-16 20:02:50.000000000 +0000 @@ -35,7 +35,7 @@ Section: libdevel Priority: optional Multi-Arch: same -Depends: @libc@ (= ${binary:Version}), libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] +Depends: @libc@ (= ${binary:Version}) , libc-dev-bin (= ${binary:Version}), ${misc:Depends}, linux-libc-dev [linux-any], kfreebsd-kernel-headers (>= 0.11) [kfreebsd-any], gnumach-dev [hurd-i386], hurd-dev (>= 20080607-3) [hurd-i386] | hurd-headers-dev [hurd-i386] Replaces: hurd-dev (<< 20120408-3) [hurd-i386], kfreebsd-kernel-headers (<< 10.3~4) [kfreebsd-amd64 kfreebsd-i386] Suggests: glibc-doc, manpages-dev Provides: libc-dev, libc6-dev [alpha ia64 hurd-i386 kfreebsd-i386 kfreebsd-amd64], libc6-dev-armel [armel], libc6-dev-armhf [armhf] diff -Nru glibc-2.27/debian/control.in/main glibc-2.27/debian/control.in/main --- glibc-2.27/debian/control.in/main 2018-02-22 10:10:35.000000000 +0000 +++ glibc-2.27/debian/control.in/main 2018-04-16 20:02:50.000000000 +0000 @@ -6,8 +6,8 @@ linux-libc-dev (>= 3.9) [linux-any], systemtap-sdt-dev [linux-any], libaudit-dev [linux-any], libcap-dev [linux-any], libselinux-dev [linux-any], mig (>= 1.5-3) [hurd-i386], gnumach-dev (>= 2:1.8+git20170102-1~) [hurd-i386], - hurd-dev (>= 1:0.9.git20171119-4~) [hurd-i386] | hurd-headers-dev [hurd-i386], - hurd-dev (>= 1:0.9.git20171119-4~) [hurd-i386] | libihash-dev [hurd-i386] , + hurd-dev (>= 1:0.9.git20180305~) [hurd-i386] | hurd-headers-dev [hurd-i386], + hurd-dev (>= 1:0.9.git20180305~) [hurd-i386] | libihash-dev [hurd-i386] , kfreebsd-kernel-headers [kfreebsd-any], binutils (>= 2.25), binutils (>= 2.29) [amd64 i386 x32], g++-7, g++-7 (>= 7.2.0-20) [amd64 i386 x32], g++-7-multilib [amd64 armhf armel i386 kfreebsd-amd64 mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el powerpc ppc64 s390x sparc sparc64 x32] , @@ -19,7 +19,7 @@ Uploaders: Clint Adams , Aurelien Jarno , Adam Conrad , Samuel Thibault Standards-Version: 4.1.3 Vcs-Browser: https://salsa.debian.org/glibc-team/glibc -Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git -b glibc-2.27 +Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git Homepage: https://www.gnu.org/software/libc/libc.html Package: libc-bin diff -Nru glibc-2.27/debian/control.in/mips32 glibc-2.27/debian/control.in/mips32 --- glibc-2.27/debian/control.in/mips32 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/mips32 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-dev (= ${binary:Version}), libc6-mips32 (= ${binary:Version}), +Depends: libc6-mips32 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), libc6-dev-mipsn32 (= ${binary:Version}) [mips64 mips64el mips64r6 mips64r6el], libc6-dev-mips64 (= ${binary:Version}) [mipsn32 mipsn32el mipsn32r6 mipsn32r6el], ${misc:Depends} diff -Nru glibc-2.27/debian/control.in/mips64 glibc-2.27/debian/control.in/mips64 --- glibc-2.27/debian/control.in/mips64 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/mips64 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-mips64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-mips64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for MIPS64 diff -Nru glibc-2.27/debian/control.in/mipsn32 glibc-2.27/debian/control.in/mipsn32 --- glibc-2.27/debian/control.in/mipsn32 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/mipsn32 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: libn32c-dev -Depends: libc6-mipsn32 (= ${binary:Version}), libc6-dev-mips64 (= ${binary:Version}) [mips mipsel mipsr6 mipsr6el], libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-mipsn32 (= ${binary:Version}) , libc6-dev-mips64 (= ${binary:Version}) [mips mipsel mipsr6 mipsr6el], libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: n32 Development Libraries for MIPS64 diff -Nru glibc-2.27/debian/control.in/powerpc glibc-2.27/debian/control.in/powerpc --- glibc-2.27/debian/control.in/powerpc 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/powerpc 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-powerpc (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-powerpc (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit powerpc development libraries for ppc64 diff -Nru glibc-2.27/debian/control.in/ppc64 glibc-2.27/debian/control.in/ppc64 --- glibc-2.27/debian/control.in/ppc64 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/ppc64 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-ppc64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-ppc64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for PowerPC64 diff -Nru glibc-2.27/debian/control.in/s390 glibc-2.27/debian/control.in/s390 --- glibc-2.27/debian/control.in/s390 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/s390 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-s390 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-s390 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit Development Libraries for IBM zSeries diff -Nru glibc-2.27/debian/control.in/sparc glibc-2.27/debian/control.in/sparc --- glibc-2.27/debian/control.in/sparc 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/sparc 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib32c-dev -Depends: libc6-sparc (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-sparc (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 32bit Development Libraries for SPARC diff -Nru glibc-2.27/debian/control.in/sparc64 glibc-2.27/debian/control.in/sparc64 --- glibc-2.27/debian/control.in/sparc64 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/sparc64 2018-04-16 20:02:33.000000000 +0000 @@ -15,7 +15,7 @@ Section: libdevel Priority: optional Provides: lib64c-dev -Depends: libc6-sparc64 (= ${binary:Version}), libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-sparc64 (= ${binary:Version}) , libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: 64bit Development Libraries for UltraSPARC diff -Nru glibc-2.27/debian/control.in/x32 glibc-2.27/debian/control.in/x32 --- glibc-2.27/debian/control.in/x32 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/control.in/x32 2018-04-16 20:02:33.000000000 +0000 @@ -14,7 +14,7 @@ Architecture: amd64 i386 Section: libdevel Priority: optional -Depends: libc6-x32 (= ${binary:Version}), libc6-dev-i386 (= ${binary:Version}) [amd64], libc6-dev-amd64 (= ${binary:Version}) [i386], libc6-dev (= ${binary:Version}), ${misc:Depends} +Depends: libc6-x32 (= ${binary:Version}) , libc6-dev-i386 (= ${binary:Version}) [amd64], libc6-dev-amd64 (= ${binary:Version}) [i386], libc6-dev (= ${binary:Version}), ${misc:Depends} Recommends: gcc-multilib Build-Profiles: Description: GNU C Library: X32 ABI Development Libraries for AMD64 diff -Nru glibc-2.27/debian/libc0.3.symbols.hurd-i386 glibc-2.27/debian/libc0.3.symbols.hurd-i386 --- glibc-2.27/debian/libc0.3.symbols.hurd-i386 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/libc0.3.symbols.hurd-i386 2018-04-16 20:02:33.000000000 +0000 @@ -114,6 +114,7 @@ __file_sync@Base 2.11 __file_syncfs@Base 2.11 __file_utimes@Base 2.11 + __file_utimens@Base 2.27-2~ __fsys_forward@Base 2.11 __fsys_get_children@Base 2.25-3 __fsys_get_options@Base 2.11 @@ -485,6 +486,7 @@ file_sync@Base 2.11 file_syncfs@Base 2.11 file_utimes@Base 2.11 + file_utimens@Base 2.27-2~ fsys_forward@Base 2.11 fsys_get_children@Base 2.25-3 fsys_get_options@Base 2.11 diff -Nru glibc-2.27/debian/patches/alpha/submitted-makecontext.diff glibc-2.27/debian/patches/alpha/submitted-makecontext.diff --- glibc-2.27/debian/patches/alpha/submitted-makecontext.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/alpha/submitted-makecontext.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,30 @@ +2018-03-01 Aurelien Jarno + + [BZ #22910] + * sysdeps/unix/sysv/linux/alpha/setcontext.S (__startcontext): Set + up CFI directive to forbid further backtracing. + + +--- a/sysdeps/unix/sysv/linux/alpha/makecontext.S ++++ b/sysdeps/unix/sysv/linux/alpha/makecontext.S +@@ -138,10 +138,14 @@ weak_alias (__makecontext, makecontext) + + .align 4 + .ent __startcontext ++ cfi_startproc + __startcontext: + .frame $31, 0, $31, 0 + .prologue 0 + ++ /* Mark ra as undefined in order to stop unwinding here. */ ++ cfi_undefined(ra) ++ + jsr $26, ($27), 0 + ldgp $29, 0($26) + mov $9, $16 +@@ -160,4 +164,5 @@ __startcontext: + + halt + ++ cfi_endproc + .end __startcontext diff -Nru glibc-2.27/debian/patches/hurd-i386/git2.25-tls.diff glibc-2.27/debian/patches/hurd-i386/git2.25-tls.diff --- glibc-2.27/debian/patches/hurd-i386/git2.25-tls.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git2.25-tls.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,43 @@ +From: Samuel Thibault +Subject: [PATCH] Fix tls support for glibc 2.25 + +* csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call +__libc_setup_tls. +* sysdeps/mach/hurd/i386/init-first.c (init): Call __libc_setup_tls. + +Signed-off-by: Samuel Thibault + +--- + csu/libc-start.c | 2 ++ + sysdeps/mach/hurd/i386/init-first.c | 3 ++- + 2 files changed, 4 insertions(+), 1 deletion(-) + +Index: glibc-2.26/csu/libc-start.c +=================================================================== +--- glibc-2.26.orig/csu/libc-start.c ++++ glibc-2.26/csu/libc-start.c +@@ -193,8 +193,10 @@ LIBC_START_MAIN (int (*main) (int, char + /* Perform IREL{,A} relocations. */ + ARCH_SETUP_IREL (); + ++#ifndef __GNU__ + /* The stack guard goes into the TCB, so initialize it early. */ + __libc_setup_tls (); ++#endif + + /* In some architectures, IREL{,A} relocations happen after TLS setup in + order to let IFUNC resolvers benefit from TCB information, e.g. powerpc's +Index: glibc-2.26/sysdeps/mach/hurd/i386/init-first.c +=================================================================== +--- glibc-2.26.orig/sysdeps/mach/hurd/i386/init-first.c ++++ glibc-2.26/sysdeps/mach/hurd/i386/init-first.c +@@ -189,7 +189,8 @@ init (int *data) + assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); + } + +- /* We need to setup TLS before starting the signal thread. */ ++ /* We need to setup TLS before starting the signal thread and set stack guard. */ ++ __libc_setup_tls (); + extern void __pthread_initialize_minimal (void); + if (__pthread_initialize_minimal != NULL) + __pthread_initialize_minimal (); diff -Nru glibc-2.27/debian/patches/hurd-i386/git-_dl_random.diff glibc-2.27/debian/patches/hurd-i386/git-_dl_random.diff --- glibc-2.27/debian/patches/hurd-i386/git-_dl_random.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-_dl_random.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,28 @@ +From: Thomas Schwinge +Subject: [PATCH] _dl_random + +_dl_random + +--- + + /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `security_init': + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/rtld.c:844: undefined reference to `_dl_random' + /media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: relocation R_386_GOTOFF against undefined hidden symbol `_dl_random' can not be used when making a shared object + /media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: final link failed: Bad value + collect2: ld returned 1 exit status + make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1 + + sysdeps/mach/hurd/dl-sysdep.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/sysdeps/mach/hurd/dl-sysdep.c ++++ b/sysdeps/mach/hurd/dl-sysdep.c +@@ -61,6 +61,8 @@ + hp_timing_t _dl_cpuclock_offset; + #endif + ++/* TODO: this is never properly initialized in here. */ ++void *_dl_random attribute_relro = NULL; + + struct hurd_startup_data *_dl_hurd_data; + diff -Nru glibc-2.27/debian/patches/hurd-i386/git-exec-static.diff glibc-2.27/debian/patches/hurd-i386/git-exec-static.diff --- glibc-2.27/debian/patches/hurd-i386/git-exec-static.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-exec-static.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,23 @@ +From: Samuel Thibault +Subject: [PATCH] Fix boot with statically-linked exec server. + +* sysdeps/mach/hurd/i386/init-first.c (init): Also find ELF headers by oneself +when the pointer given in D is nul (as set by ext2fs). + +Signed-off-by: Samuel Thibault + +--- + sysdeps/mach/hurd/i386/init-first.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/sysdeps/mach/hurd/i386/init-first.c ++++ b/sysdeps/mach/hurd/i386/init-first.c +@@ -168,7 +168,7 @@ init (int *data) + /* If we are the bootstrap task started by the kernel, + then after the environment pointers there is no Hurd + data block; the argument strings start there. */ +- if ((void *) d == argv[0]) ++ if ((void *) d == argv[0] || !d->phdr) + { + /* With a new enough linker (binutils-2.23 or better), + the magic __ehdr_start symbol will be available and diff -Nru glibc-2.27/debian/patches/hurd-i386/git-futimens.diff glibc-2.27/debian/patches/hurd-i386/git-futimens.diff --- glibc-2.27/debian/patches/hurd-i386/git-futimens.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-futimens.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,69 @@ +From: Samuel Thibault +Subject: [PATCH] Add futimens support + +* sysdeps/mach/hurd/futimens.c: New file. + +Signed-off-by: Samuel Thibault + +--- + sysdeps/mach/hurd/futimens.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 50 insertions(+) + +diff --git a/sysdeps/mach/hurd/futimens.c b/sysdeps/mach/hurd/futimens.c +new file mode 100644 +index 0000000..218779d +--- /dev/null ++++ b/sysdeps/mach/hurd/futimens.c +@@ -0,0 +1,50 @@ ++/* futimes -- change access and modification times of open file. Hurd version. ++ Copyright (C) 2002-2014 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/* Change the access time of FD to TSP[0] and ++ the modification time of FD to TSP[1]. */ ++int ++__futimens (int fd, const struct timespec tsp[2]) ++{ ++ time_value_t atime, mtime; ++ error_t err; ++ ++ if (tsp == NULL) ++ { ++ /* Setting the number of microseconds to `-1' tells the ++ underlying filesystems to use the current time. */ ++ atime.microseconds = mtime.microseconds = -1; ++ } ++ else ++ { ++ atime.seconds = tsp[0].tv_sec; ++ atime.microseconds = tsp[0].tv_nsec / 1000; ++ mtime.seconds = tsp[1].tv_sec; ++ mtime.microseconds = tsp[1].tv_nsec / 1000; ++ } ++ ++ err = HURD_DPORT_USE (fd, __file_utimes (port, atime, mtime)); ++ return err ? __hurd_dfail (fd, err) : 0; ++} ++weak_alias (__futimens, futimens) +-- +tg: (9a079e2..) futimens (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-gai_misc.diff glibc-2.27/debian/patches/hurd-i386/git-gai_misc.diff --- glibc-2.27/debian/patches/hurd-i386/git-gai_misc.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-gai_misc.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,63 @@ +From: Samuel Thibault +Subject: [PATCH] t/gai_misc + +Add a hurd version of threaded gai_misc.h + +Signed-off-by: Samuel Thibault + +--- + sysdeps/mach/hurd/gai_misc.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 44 insertions(+) + +diff --git a/sysdeps/mach/hurd/gai_misc.h b/sysdeps/mach/hurd/gai_misc.h +new file mode 100644 +index 0000000..ee8117f +--- /dev/null ++++ b/sysdeps/mach/hurd/gai_misc.h +@@ -0,0 +1,44 @@ ++#include ++#include ++ ++#define gai_start_notify_thread __gai_start_notify_thread ++#define gai_create_helper_thread __gai_create_helper_thread ++ ++extern inline void ++__gai_start_notify_thread (void) ++{ ++ sigset_t ss; ++ sigemptyset (&ss); ++ sigprocmask(SIG_SETMASK, &ss, NULL); ++} ++ ++extern inline int ++__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), ++ void *arg) ++{ ++ pthread_attr_t attr; ++ ++ /* Make sure the thread is created detached. */ ++ pthread_attr_init (&attr); ++ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); ++ ++ /* The helper thread needs only very little resources. */ ++ (void) pthread_attr_setstacksize (&attr, 0x10000); ++ ++ /* Block all signals in the helper thread. To do this thoroughly we ++ temporarily have to block all signals here. */ ++ sigset_t ss; ++ sigset_t oss; ++ sigfillset (&ss); ++ sigprocmask(SIG_SETMASK, &ss, &oss); ++ ++ int ret = pthread_create (threadp, &attr, tf, arg); ++ ++ /* Restore the signal mask. */ ++ sigprocmask(SIG_SETMASK, &oss, NULL); ++ ++ (void) pthread_attr_destroy (&attr); ++ return ret; ++} ++ ++#include_next +-- +tg: (9a079e2..) t/gai_misc (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-grantpt.diff glibc-2.27/debian/patches/hurd-i386/git-grantpt.diff --- glibc-2.27/debian/patches/hurd-i386/git-grantpt.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-grantpt.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,70 @@ +From: Thomas Schwinge +Subject: [PATCH] t/grantpt + + /media/Stalin/tmp/glibc.hurd.gnu-2/libc_pic.os: In function `pts_name': + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/login/../sysdeps/unix/grantpt.c:52: undefined reference to `__ptsname_internal' + collect2: ld returned 1 exit status + make[1]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/libc.so] Error 1 + +Cf. aa9890239a2aef81e64f3f22a31c7e01b6501f69 + +Need any of the checks (stat, etc.) that Linux' __ptsname_internal does? + +Implement close_all_fds as in 139ee080b6b428240bf49f3e6361f3ac729f891a? + +--- + sysdeps/mach/hurd/ptsname.c | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c +index 2978394eb5..73ec57dd70 100644 +--- a/sysdeps/mach/hurd/ptsname.c ++++ b/sysdeps/mach/hurd/ptsname.c +@@ -18,6 +18,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -38,11 +39,9 @@ ptsname (int fd) + } + + +-/* Store at most BUFLEN characters of the pathname of the slave pseudo +- terminal associated with the master FD is open on in BUF. +- Return 0 on success, otherwise an error number. */ ++/* We don't need STP, but fill it for conformity with the Linux version... */ + int +-__ptsname_r (int fd, char *buf, size_t buflen) ++__ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp) + { + string_t peername; + size_t len; +@@ -58,7 +57,23 @@ __ptsname_r (int fd, char *buf, size_t buflen) + return ERANGE; + } + ++ if (stp) ++ { ++ if (__xstat64 (_STAT_VER, peername, stp) < 0) ++ return errno; ++ } ++ + memcpy (buf, peername, len); + return 0; + } ++ ++ ++/* Store at most BUFLEN characters of the pathname of the slave pseudo ++ terminal associated with the master FD is open on in BUF. ++ Return 0 on success, otherwise an error number. */ ++int ++__ptsname_r (int fd, char *buf, size_t buflen) ++{ ++ return __ptsname_internal (fd, buf, buflen, NULL); ++} + weak_alias (__ptsname_r, ptsname_r) +-- +tg: (7bb5f8a836..) t/grantpt (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-gscope.diff glibc-2.27/debian/patches/hurd-i386/git-gscope.diff --- glibc-2.27/debian/patches/hurd-i386/git-gscope.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-gscope.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,88 @@ +From: Thomas Schwinge +Subject: [PATCH] gscope + +Minimal gscope stuff. + +glibc-2.8/debian/patches/hurd-i386/local-gscope.diff 3085 + +Written by Samuel Thibault. + +--- + +I think that's the corresponding error message: + + /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_dependency': + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:106: undefined reference to `atomic_forced_read' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:109: undefined reference to `atomic_read_barrier' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:113: undefined reference to `atomic_forced_read' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:141: undefined reference to `THREAD_GSCOPE_RESET_FLAG' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:147: undefined reference to `atomic_forced_read' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:284: undefined reference to `THREAD_GSCOPE_SET_FLAG' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:261: undefined reference to `atomic_write_barrier' + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:250: undefined reference to `atomic_write_barrier' + /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_to_global': + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:162: undefined reference to `atomic_write_barrier' + /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `dl_open_worker': + /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:478: undefined reference to `atomic_write_barrier' + collect2: ld returned 1 exit status + make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1 + + elf/dl-support.c | 1 + + sysdeps/generic/ldsodefs.h | 1 + + sysdeps/mach/hurd/sysdep-cancel.h | 9 +++++++++ + sysdeps/mach/hurd/tls.h | 13 +++++++++++++ + 4 files changed, 24 insertions(+) + +--- a/elf/dl-support.c ++++ b/elf/dl-support.c +@@ -196,6 +196,7 @@ int (*_dl_make_stack_executable_hook) (v + /* Function in libpthread to wait for termination of lookups. */ + void (*_dl_wait_lookup_done) (void); + ++int volatile _dl_thread_gscope_count; + struct dl_scope_free_list *_dl_scope_free_list; + + #ifdef NEED_DL_SYSINFO +--- a/sysdeps/generic/ldsodefs.h ++++ b/sysdeps/generic/ldsodefs.h +@@ -409,6 +409,7 @@ struct rtld_global + size_t count; + void *list[50]; + } *_dl_scope_free_list; ++ EXTERN volatile int _dl_thread_gscope_count; + #ifdef SHARED + }; + # define __rtld_global_attribute__ +--- /dev/null ++++ b/sysdeps/mach/hurd/sysdep-cancel.h +@@ -0,0 +1,9 @@ ++#include ++ ++/* Always multi-thread (since there's at least the sig handler), but no ++ handling enabled. */ ++#define SINGLE_THREAD_P (0) ++#define RTLD_SINGLE_THREAD_P (0) ++#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ ++#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ ++#define LIBC_CANCEL_HANDLED() /* Nothing. */ +--- a/sysdeps/mach/hurd/tls.h ++++ b/sysdeps/mach/hurd/tls.h +@@ -75,5 +75,18 @@ typedef struct + + #endif /* !ASSEMBLER */ + ++#ifndef __ASSEMBLER__ ++#include ++#include ++/* Temporary poor-man's global scope switch support: just busy-waits */ ++#define THREAD_GSCOPE_SET_FLAG() \ ++ asm volatile ("lock incl %0":"=m"(GL(dl_thread_gscope_count))) ++#define THREAD_GSCOPE_RESET_FLAG() \ ++ asm volatile ("lock decl %0":"=m"(GL(dl_thread_gscope_count))) ++#define THREAD_GSCOPE_WAIT() \ ++ while (GL(dl_thread_gscope_count)) { \ ++ __swtch_pri (0); \ ++ } ++#endif + + #endif /* tls.h */ diff -Nru glibc-2.27/debian/patches/hurd-i386/git-hurd-abilist.diff glibc-2.27/debian/patches/hurd-i386/git-hurd-abilist.diff --- glibc-2.27/debian/patches/hurd-i386/git-hurd-abilist.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-hurd-abilist.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,23 @@ +2016-02-29 Aurelien Jarno + + * sysdeps/generic/libnsl.abilist: New file. + * sysdeps/generic/libutil.abilist: New file. + * sysdeps/mach/hurd/libhurduser.abilist: New file. + * sysdeps/mach/libmachuser.abilist: New file. + +--- /dev/null ++++ b/sysdeps/generic/libnsl.abilist +@@ -0,0 +1 @@ ++ +--- /dev/null ++++ b/sysdeps/generic/libutil.abilist +@@ -0,0 +1 @@ ++ +--- /dev/null ++++ b/sysdeps/mach/hurd/libhurduser.abilist +@@ -0,0 +1 @@ ++ +--- /dev/null ++++ b/sysdeps/mach/libmachuser.abilist +@@ -0,0 +1 @@ ++ diff -Nru glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-mutex.diff glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-mutex.diff --- glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-mutex.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-mutex.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,1378 @@ +commit f6839074d25aba7e93b8672a9ed9893c0baa5e3d +Author: Agustina Arzille +Date: Mon Oct 17 00:56:58 2016 +0200 + + Make pthread_mutex use gsync + +diff --git a/libpthread/include/pthread/pthread.h b/libpthread/include/pthread/pthread.h +index 350a673..ad34e5d 100644 +--- a/libpthread/include/pthread/pthread.h ++++ b/libpthread/include/pthread/pthread.h +@@ -271,6 +271,11 @@ extern pthread_t pthread_self (void) __THROW; + #define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_TIMED_NP + #endif + ++#ifdef __USE_XOPEN2K ++#define PTHREAD_MUTEX_STALLED __PTHREAD_MUTEX_STALLED ++#define PTHREAD_MUTEX_ROBUST __PTHREAD_MUTEX_ROBUST ++#endif ++ + #include + + /* Initialize the mutex attribute object in *ATTR to the default +@@ -399,6 +404,18 @@ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, + __THROW __nonnull ((1, 3)); + #endif + ++#ifdef __USE_XOPEN2K8 ++ ++/* Declare the state protected by robust mutex MTXP as consistent. */ ++extern int pthread_mutex_consistent (pthread_mutex_t *__mtxp) ++ __THROW __nonnull ((1)); ++ ++# ifdef __USE_GNU ++extern int pthread_mutex_consistent_np (pthread_mutex_t *__mtxp) ++ __THROW __nonnull ((1)); ++# endif ++#endif ++ + + + /* Condition attributes. */ +diff --git a/libpthread/include/pthread/pthreadtypes.h b/libpthread/include/pthread/pthreadtypes.h +index 33bd009..d8aed4d 100644 +--- a/libpthread/include/pthread/pthreadtypes.h ++++ b/libpthread/include/pthread/pthreadtypes.h +@@ -77,6 +77,12 @@ enum __pthread_mutex_type + __PTHREAD_MUTEX_RECURSIVE + }; + ++enum __pthread_mutex_robustness ++ { ++ __PTHREAD_MUTEX_STALLED, ++ __PTHREAD_MUTEX_ROBUST = 0x100 ++ }; ++ + #include + typedef struct __pthread_mutexattr pthread_mutexattr_t; + +diff --git a/libpthread/sysdeps/mach/hurd/bits/mutex.h b/libpthread/sysdeps/mach/hurd/bits/mutex.h +new file mode 100644 +index 0000000..a52a2ad +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/bits/mutex.h +@@ -0,0 +1,64 @@ ++/* Mutex type. Generic version. ++ ++ Copyright (C) 2000-2016 ++ Free Software Foundation, Inc. ++ ++ 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 Library General Public License as ++ published by the Free Software Foundation; either version 2 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 ++ Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with the GNU C Library; see the file COPYING.LIB. If not, ++ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ++ Boston, MA 02111-1307, USA. */ ++ ++#ifndef _BITS_MUTEX_H ++ ++#ifndef __need_pthread_mutex ++# define _BITS_MUTEX_H 1 ++#endif ++ ++#ifndef __pthread_mutex_defined ++# if defined __need_pthread_mutex || defined _BITS_MUTEX_H ++# undef __need_pthread_mutex ++# define __pthread_mutex_defined ++ ++# include ++ ++/* User visible part of a mutex. */ ++struct __pthread_mutex ++{ ++ unsigned int __lock; ++ unsigned int __owner_id; ++ unsigned int __cnt; ++ int __shpid; ++ int __type; ++ int __flags; ++ unsigned int __reserved1; ++ unsigned int __reserved2; ++}; ++ ++/* Static mutex initializers. */ ++#define __PTHREAD_MUTEX_INITIALIZER \ ++ { 0, 0, 0, 0, __PTHREAD_MUTEX_TIMED, 0, 0, 0 } ++ ++/* The +1 is to mantain binary compatibility with the old ++ * libpthread implementation. */ ++#define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \ ++ { 0, 0, 0, 0, __PTHREAD_MUTEX_ERRORCHECK + 1, 0, 0, 0 } ++ ++#define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ ++ { 0, 0, 0, 0, __PTHREAD_MUTEX_RECURSIVE + 1, 0, 0, 0 } ++ ++# endif ++#endif /* Not __pthread_mutex_defined. */ ++ ++#endif /* bits/mutex.h */ +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c b/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c +new file mode 100644 +index 0000000..2c6acd1 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c +@@ -0,0 +1,36 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int _pthread_mutex_destroy (pthread_mutex_t *mtxp) ++{ ++ atomic_read_barrier (); ++ if (*(volatile unsigned int *)&mtxp->__lock != 0) ++ return (EBUSY); ++ ++ mtxp->__type = -1; ++ return (0); ++} ++ ++strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c +new file mode 100644 +index 0000000..8a8a080 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c +@@ -0,0 +1,32 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp) ++{ ++ (void)mtxp; (void)clp; ++ return (ENOSYS); ++} ++ ++stub_warning (pthread_mutex_getprioceiling) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-init.c b/libpthread/sysdeps/mach/hurd/pt-mutex-init.c +new file mode 100644 +index 0000000..af9ed7e +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-init.c +@@ -0,0 +1,55 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++static const pthread_mutexattr_t dfl_attr = ++{ ++ .__prioceiling = 0, ++ .__protocol = PTHREAD_PRIO_NONE, ++ .__pshared = PTHREAD_PROCESS_PRIVATE, ++ .__mutex_type = __PTHREAD_MUTEX_TIMED ++}; ++ ++int _pthread_mutex_init (pthread_mutex_t *mtxp, ++ const pthread_mutexattr_t *attrp) ++{ ++ if (attrp == NULL) ++ attrp = &dfl_attr; ++ ++ mtxp->__flags = (attrp->__pshared == PTHREAD_PROCESS_SHARED ? ++ GSYNC_SHARED : 0) | ((attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? ++ PTHREAD_MUTEX_ROBUST : 0); ++ ++ mtxp->__type = attrp->__mutex_type + ++ (attrp->__mutex_type != __PTHREAD_MUTEX_TIMED); ++ ++ mtxp->__owner_id = 0; ++ mtxp->__shpid = 0; ++ mtxp->__cnt = 0; ++ mtxp->__lock = 0; ++ ++ return (0); ++} ++ ++strong_alias (_pthread_mutex_init, pthread_mutex_init) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c +new file mode 100644 +index 0000000..5d3c958 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c +@@ -0,0 +1,79 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutex_lock (pthread_mutex_t *mtxp) ++{ ++ struct __pthread *self; ++ int flags = mtxp->__flags & GSYNC_SHARED; ++ int ret = 0; ++ ++ switch (MTX_TYPE (mtxp)) ++ { ++ case PT_MTX_NORMAL: ++ lll_lock (&mtxp->__lock, flags); ++ break; ++ ++ case PT_MTX_RECURSIVE: ++ self = _pthread_self (); ++ if (mtx_owned_p (mtxp, self, flags)) ++ { ++ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) ++ return (EAGAIN); ++ ++ ++mtxp->__cnt; ++ return (ret); ++ } ++ ++ lll_lock (&mtxp->__lock, flags); ++ mtx_set_owner (mtxp, self, flags); ++ mtxp->__cnt = 1; ++ break; ++ ++ case PT_MTX_ERRORCHECK: ++ self = _pthread_self (); ++ if (mtx_owned_p (mtxp, self, flags)) ++ return (EDEADLK); ++ ++ lll_lock (&mtxp->__lock, flags); ++ mtx_set_owner (mtxp, self, flags); ++ break; ++ ++ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: ++ self = _pthread_self (); ++ ROBUST_LOCK (self, mtxp, __lll_robust_lock, flags); ++ break; ++ ++ default: ++ ret = EINVAL; ++ break; ++ } ++ ++ return (ret); ++} ++ ++strong_alias (__pthread_mutex_lock, _pthread_mutex_lock) ++strong_alias (__pthread_mutex_lock, pthread_mutex_lock) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c +new file mode 100644 +index 0000000..b88917d +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c +@@ -0,0 +1,32 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp) ++{ ++ (void)mtxp; (void)cl; (void)prp; ++ return (ENOSYS); ++} ++ ++stub_warning (pthread_mutex_setprioceiling) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c +new file mode 100644 +index 0000000..3fdd5da +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c +@@ -0,0 +1,80 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutex_timedlock (pthread_mutex_t *mtxp, ++ const struct timespec *tsp) ++{ ++ struct __pthread *self; ++ int ret, flags = mtxp->__flags & GSYNC_SHARED; ++ ++ switch (MTX_TYPE (mtxp)) ++ { ++ case PT_MTX_NORMAL: ++ ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags); ++ break; ++ ++ case PT_MTX_RECURSIVE: ++ self = _pthread_self (); ++ if (mtx_owned_p (mtxp, self, flags)) ++ { ++ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) ++ return (EAGAIN); ++ ++ ++mtxp->__cnt; ++ ret = 0; ++ } ++ else if ((ret = lll_abstimed_lock (&mtxp->__lock, ++ tsp, flags)) == 0) ++ { ++ mtx_set_owner (mtxp, self, flags); ++ mtxp->__cnt = 1; ++ } ++ ++ break; ++ ++ case PT_MTX_ERRORCHECK: ++ self = _pthread_self (); ++ if (mtx_owned_p (mtxp, self, flags)) ++ ret = EDEADLK; ++ else if ((ret = lll_abstimed_lock (&mtxp->__lock, ++ tsp, flags)) == 0) ++ mtx_set_owner (mtxp, self, flags); ++ ++ break; ++ ++ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: ++ self = _pthread_self (); ++ ROBUST_LOCK (self, mtxp, lll_robust_abstimed_lock, tsp, flags); ++ break; ++ ++ default: ++ ret = EINVAL; ++ break; ++ } ++ ++ return (ret); ++} +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c b/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c +new file mode 100644 +index 0000000..410474f +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c +@@ -0,0 +1,74 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th) ++{ ++ struct __pthread *self = _pthread_self (); ++ struct __pthread *pt = __pthread_getid (th); ++ ++ if (!pt) ++ return (ESRCH); ++ else if (pt == self) ++ return (0); ++ ++ int ret = 0; ++ int flags = mtxp->__flags & GSYNC_SHARED; ++ ++ switch (MTX_TYPE (mtxp)) ++ { ++ case PT_MTX_NORMAL: ++ break; ++ ++ case PT_MTX_RECURSIVE: ++ case PT_MTX_ERRORCHECK: ++ if (!mtx_owned_p (mtxp, self, flags)) ++ ret = EPERM; ++ else ++ mtx_set_owner (mtxp, pt, flags); ++ ++ break; ++ ++ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: ++ /* Note that this can be used to transfer an inconsistent ++ * mutex as well. The new owner will still have the same ++ * flags as the original. */ ++ if (mtxp->__owner_id != self->thread || ++ (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) ++ ret = EPERM; ++ else ++ mtxp->__owner_id = pt->thread; ++ ++ break; ++ ++ default: ++ ret = EINVAL; ++ } ++ ++ return (ret); ++} ++ ++weak_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c +new file mode 100644 +index 0000000..6680094 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c +@@ -0,0 +1,77 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutex_trylock (pthread_mutex_t *mtxp) ++{ ++ struct __pthread *self; ++ int ret; ++ ++ switch (MTX_TYPE (mtxp)) ++ { ++ case PT_MTX_NORMAL: ++ ret = lll_trylock (&mtxp->__lock); ++ break; ++ ++ case PT_MTX_RECURSIVE: ++ self = _pthread_self (); ++ if (mtx_owned_p (mtxp, self, mtxp->__flags)) ++ { ++ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) ++ return (EAGAIN); ++ ++ ++mtxp->__cnt; ++ ret = 0; ++ } ++ else if ((ret = lll_trylock (&mtxp->__lock)) == 0) ++ { ++ mtx_set_owner (mtxp, self, mtxp->__flags); ++ mtxp->__cnt = 1; ++ } ++ ++ break; ++ ++ case PT_MTX_ERRORCHECK: ++ self = _pthread_self (); ++ if ((ret = lll_trylock (&mtxp->__lock)) == 0) ++ mtx_set_owner (mtxp, self, mtxp->__flags); ++ break; ++ ++ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: ++ self = _pthread_self (); ++ ROBUST_LOCK (self, mtxp, __lll_robust_trylock); ++ break; ++ ++ default: ++ ret = EINVAL; ++ break; ++ } ++ ++ return (ret); ++} ++ ++strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock) ++strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c +new file mode 100644 +index 0000000..071f622 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c +@@ -0,0 +1,90 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutex_unlock (pthread_mutex_t *mtxp) ++{ ++ struct __pthread *self; ++ int ret = 0, flags = mtxp->__flags & GSYNC_SHARED; ++ ++ switch (MTX_TYPE (mtxp)) ++ { ++ case PT_MTX_NORMAL: ++ lll_unlock (&mtxp->__lock, flags); ++ break; ++ ++ case PT_MTX_RECURSIVE: ++ self = _pthread_self (); ++ if (!mtx_owned_p (mtxp, self, flags)) ++ ret = EPERM; ++ else if (--mtxp->__cnt == 0) ++ { ++ mtxp->__owner_id = mtxp->__shpid = 0; ++ lll_unlock (&mtxp->__lock, flags); ++ } ++ ++ break; ++ ++ case PT_MTX_ERRORCHECK: ++ self = _pthread_self (); ++ if (!mtx_owned_p (mtxp, self, flags)) ++ ret = EPERM; ++ else ++ { ++ mtxp->__owner_id = mtxp->__shpid = 0; ++ lll_unlock (&mtxp->__lock, flags); ++ } ++ ++ break; ++ ++ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: ++ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: ++ self = _pthread_self (); ++ if (mtxp->__owner_id == NOTRECOVERABLE_ID) ++ ; /* Nothing to do. */ ++ else if (mtxp->__owner_id != self->thread || ++ (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) ++ ret = EPERM; ++ else if (--mtxp->__cnt == 0) ++ { ++ /* Release the lock. If it's in an inconsistent ++ * state, mark it as irrecoverable. */ ++ mtxp->__owner_id = (mtxp->__lock & LLL_DEAD_OWNER) ? ++ NOTRECOVERABLE_ID : 0; ++ __lll_robust_unlock (&mtxp->__lock, flags); ++ } ++ ++ break; ++ ++ default: ++ ret = EINVAL; ++ break; ++ } ++ ++ return (ret); ++} ++ ++strong_alias (__pthread_mutex_unlock, _pthread_mutex_unlock) ++strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c +new file mode 100644 +index 0000000..ad711ac +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c +@@ -0,0 +1,31 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutexattr_destroy (pthread_mutexattr_t *attrp) ++{ ++ (void)attrp; ++ return (0); ++} ++weak_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c +new file mode 100644 +index 0000000..bcfc8c8 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c +@@ -0,0 +1,32 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *ap, int *clp) ++{ ++ (void)ap; (void)clp; ++ return (ENOSYS); ++} ++ ++stub_warning (pthread_mutexattr_getprioceiling) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c +new file mode 100644 +index 0000000..cb94424 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c +@@ -0,0 +1,30 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attrp, int *ptp) ++{ ++ *ptp = attrp->__protocol; ++ return (0); ++} +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c +new file mode 100644 +index 0000000..7639528 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c +@@ -0,0 +1,30 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_getpshared (const pthread_mutexattr_t *attrp, int *outp) ++{ ++ *outp = attrp->__pshared; ++ return (0); ++} +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c +new file mode 100644 +index 0000000..746f628 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c +@@ -0,0 +1,31 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_gettype (const pthread_mutexattr_t *attrp, int *outp) ++{ ++ *outp = attrp->__mutex_type; ++ return (0); ++} ++ +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c +new file mode 100644 +index 0000000..4cac661 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c +@@ -0,0 +1,39 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++static const pthread_mutexattr_t dfl_attr = ++{ ++ .__prioceiling = 0, ++ .__protocol = PTHREAD_PRIO_NONE, ++ .__pshared = PTHREAD_PROCESS_PRIVATE, ++ .__mutex_type = __PTHREAD_MUTEX_TIMED ++}; ++ ++int __pthread_mutexattr_init (pthread_mutexattr_t *attrp) ++{ ++ *attrp = dfl_attr; ++ return (0); ++} ++weak_alias (__pthread_mutexattr_init, pthread_mutexattr_init) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c +new file mode 100644 +index 0000000..d399050 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c +@@ -0,0 +1,32 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attrp, int cl) ++{ ++ (void)attrp; (void)cl; ++ return (ENOSYS); ++} ++ ++stub_warning (pthread_mutexattr_setprioceiling) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c +new file mode 100644 +index 0000000..9f7f152 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c +@@ -0,0 +1,32 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_setprotocol (pthread_mutexattr_t *attrp, int proto) ++{ ++ (void)attrp; ++ return (proto == PTHREAD_PRIO_NONE ? 0 : ++ proto != PTHREAD_PRIO_INHERIT && ++ proto != PTHREAD_PRIO_PROTECT ? EINVAL : ENOTSUP); ++} +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c +new file mode 100644 +index 0000000..c10dfa0 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c +@@ -0,0 +1,34 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_setpshared (pthread_mutexattr_t *attrp, int pshared) ++{ ++ if (pshared != PTHREAD_PROCESS_PRIVATE && ++ pshared != PTHREAD_PROCESS_SHARED) ++ return (EINVAL); ++ ++ attrp->__pshared = pshared; ++ return (0); ++} +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c +new file mode 100644 +index 0000000..67ed4f5 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c +@@ -0,0 +1,34 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int __pthread_mutexattr_settype (pthread_mutexattr_t *attrp, int type) ++{ ++ if (type < 0 || type > __PTHREAD_MUTEX_RECURSIVE) ++ return (EINVAL); ++ ++ attrp->__mutex_type = type; ++ return (0); ++} ++weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr.c +new file mode 100644 +index 0000000..40a8c17 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr.c +@@ -0,0 +1 @@ ++/* empty */ +diff --git a/libpthread/Makefile b/libpthread/Makefile +index 9707f57..776b95d 100644 +--- a/libpthread/Makefile ++++ b/libpthread/Makefile +@@ -87,12 +87,14 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ + pt-mutexattr-getpshared pt-mutexattr-gettype \ + pt-mutexattr-setprioceiling pt-mutexattr-setprotocol \ + pt-mutexattr-setpshared pt-mutexattr-settype \ ++ pt-mutexattr-getrobust pt-mutexattr-setrobust \ + \ + pt-mutex-init pt-mutex-destroy \ + pt-mutex-lock pt-mutex-trylock pt-mutex-timedlock \ + pt-mutex-unlock \ + pt-mutex-transfer-np \ + pt-mutex-getprioceiling pt-mutex-setprioceiling \ ++ pt-mutex-consistent \ + \ + pt-rwlock-attr \ + pt-rwlockattr-init pt-rwlockattr-destroy \ +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c b/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c +new file mode 100644 +index 0000000..28e9e4a +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c +@@ -0,0 +1,45 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutex_consistent (pthread_mutex_t *mtxp) ++{ ++ int ret = EINVAL; ++ unsigned int val = mtxp->__lock; ++ ++ if ((mtxp->__flags & PTHREAD_MUTEX_ROBUST) != 0 && ++ (val & LLL_DEAD_OWNER) != 0 && ++ atomic_compare_and_exchange_bool_acq (&mtxp->__lock, ++ __getpid () | LLL_WAITERS, val) == 0) ++ { ++ /* The mutex is now ours, and it's consistent. */ ++ mtxp->__owner_id = _pthread_self()->thread; ++ mtxp->__cnt = 1; ++ ret = 0; ++ } ++ ++ return (ret); ++} ++ ++weak_alias (pthread_mutex_consistent, pthread_mutex_consistent_np) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex.h b/libpthread/sysdeps/mach/hurd/pt-mutex.h +new file mode 100644 +index 0000000..c67453e +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex.h +@@ -0,0 +1,92 @@ ++/* Internal definitions for pthreads library. ++ Copyright (C) 2016 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ Contributed by Agustina Arzille , 2016. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License as ++ published by the Free Software Foundation; either version 2 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 ++ Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with the GNU C Library; see the file COPYING.LIB. If not, ++ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ++ Boston, MA 02111-1307, USA. */ ++ ++#ifndef _PT_MUTEX_H ++#define _PT_MUTEX_H 1 ++ ++/* Special ID used to signal an unrecoverable robust mutex. */ ++#define NOTRECOVERABLE_ID (1U << 31) ++ ++/* Common path for robust mutexes. Assumes the variable 'ret' ++ * is bound in the function this is called from. */ ++#define ROBUST_LOCK(self, mtxp, cb, ...) \ ++ if (mtxp->__owner_id == NOTRECOVERABLE_ID) \ ++ return (ENOTRECOVERABLE); \ ++ else if (mtxp->__owner_id == self->thread && \ ++ __getpid () == (int)(mtxp->__lock & LLL_OWNER_MASK)) \ ++ { \ ++ if (mtxp->__type == PT_MTX_RECURSIVE) \ ++ { \ ++ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) \ ++ return (EAGAIN); \ ++ \ ++ ++mtxp->__cnt; \ ++ return (0); \ ++ } \ ++ else if (mtxp->__type == PT_MTX_ERRORCHECK) \ ++ return (EDEADLK); \ ++ } \ ++ \ ++ ret = cb (&mtxp->__lock, ##__VA_ARGS__); \ ++ if (ret == 0 || ret == EOWNERDEAD) \ ++ { \ ++ if (mtxp->__owner_id == ENOTRECOVERABLE) \ ++ ret = ENOTRECOVERABLE; \ ++ else \ ++ { \ ++ mtxp->__owner_id = self->thread; \ ++ mtxp->__cnt = 1; \ ++ if (ret == EOWNERDEAD) \ ++ { \ ++ mtxp->__lock = mtxp->__lock | LLL_DEAD_OWNER; \ ++ atomic_write_barrier (); \ ++ } \ ++ } \ ++ } \ ++ (void)0 ++ ++/* Check that a thread owns the mutex. For non-robust, task-shared ++ * objects, we have to check the thread *and* process-id. */ ++#define mtx_owned_p(mtx, pt, flags) \ ++ ((mtx)->__owner_id == (pt)->thread && \ ++ (((flags) & GSYNC_SHARED) == 0 || \ ++ (mtx)->__shpid == __getpid ())) ++ ++/* Record a thread as the owner of the mutex. */ ++#define mtx_set_owner(mtx, pt, flags) \ ++ (void) \ ++ ({ \ ++ (mtx)->__owner_id = (pt)->thread; \ ++ if ((flags) & GSYNC_SHARED) \ ++ (mtx)->__shpid = __getpid (); \ ++ }) ++ ++/* Redefined mutex types. The +1 is for binary compatibility. */ ++#define PT_MTX_NORMAL __PTHREAD_MUTEX_TIMED ++#define PT_MTX_RECURSIVE (__PTHREAD_MUTEX_RECURSIVE + 1) ++#define PT_MTX_ERRORCHECK (__PTHREAD_MUTEX_ERRORCHECK + 1) ++ ++/* Mutex type, including robustness. */ ++#define MTX_TYPE(mtxp) \ ++ ((mtxp)->__type | ((mtxp)->__flags & PTHREAD_MUTEX_ROBUST)) ++ ++extern int __getpid (void) __attribute__ ((const)); ++ ++#endif /* pt-mutex.h */ +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c +new file mode 100644 +index 0000000..86a0909 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c +@@ -0,0 +1,33 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_getrobust (const pthread_mutexattr_t *attrp, int *outp) ++{ ++ *outp = (attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? ++ PTHREAD_MUTEX_ROBUST : PTHREAD_MUTEX_STALLED; ++ return (0); ++} ++ ++weak_alias (pthread_mutexattr_getrobust, pthread_mutexattr_getrobust_np) +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c +new file mode 100644 +index 0000000..a90e747 +--- /dev/null ++++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c +@@ -0,0 +1,36 @@ ++/* Copyright (C) 2016 Free Software Foundation, Inc. ++ Contributed by Agustina Arzille , 2016. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either ++ version 2 of the license, or (at your option) any later version. ++ ++ This program 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 Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, see ++ . ++*/ ++ ++#include ++#include ++#include ++#include ++#include "pt-mutex.h" ++#include ++ ++int pthread_mutexattr_setrobust (pthread_mutexattr_t *attrp, int robust) ++{ ++ if (robust != PTHREAD_MUTEX_ROBUST && ++ robust != PTHREAD_MUTEX_STALLED) ++ return (EINVAL); ++ ++ attrp->__prioceiling |= robust; ++ return (0); ++} ++ ++weak_alias (pthread_mutexattr_setrobust, pthread_mutexattr_setrobust_np) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-spin.diff glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-spin.diff --- glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-spin.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-libpthread-gsync-spin.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,278 @@ +commit cd7e69c545200949cfd1b3c595568556ff9a76e3 +Author: Agustina Arzille +Date: Tue Oct 18 00:20:45 2016 +0200 + + Make pthread_spinlock use gsync + +diff --git a/libpthread/pthread/pt-spin-inlines.c b/libpthread/pthread/pt-spin-inlines.c +index cfb21dd..97afb4d 100644 +--- a/libpthread/pthread/pt-spin-inlines.c ++++ b/libpthread/pthread/pt-spin-inlines.c +@@ -25,10 +25,9 @@ + + #include + +-/* Weak aliases for the spin lock functions. Note that +- pthread_spin_lock is left out deliberately. We already provide an +- implementation for it in pt-spin.c. */ ++/* Weak aliases for the spin lock functions. */ + weak_alias (__pthread_spin_destroy, pthread_spin_destroy); + weak_alias (__pthread_spin_init, pthread_spin_init); + weak_alias (__pthread_spin_trylock, pthread_spin_trylock); ++weak_alias (__pthread_spin_lock, pthread_spin_lock); + weak_alias (__pthread_spin_unlock, pthread_spin_unlock); +diff --git a/libpthread/sysdeps/mach/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/bits/spin-lock-inline.h +index f9f7c29..98e4b3b 100644 +--- a/libpthread/sysdeps/mach/bits/spin-lock-inline.h ++++ b/libpthread/sysdeps/mach/bits/spin-lock-inline.h +@@ -22,7 +22,7 @@ + + #include + #include +-#include /* This does all the work. */ ++#include /* This does all the work. */ + + __BEGIN_DECLS + +@@ -60,17 +60,15 @@ __PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); + __PT_SPIN_INLINE int + __pthread_spin_trylock (__pthread_spinlock_t *__lock) + { +- return __spin_try_lock (__lock) ? 0 : __EBUSY; ++ return __spin_try_lock ((__spin_lock_t *) __lock) ? 0 : __EBUSY; + } + +-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); +-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); ++__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock); + +-__extern_inline int ++__PT_SPIN_INLINE int + __pthread_spin_lock (__pthread_spinlock_t *__lock) + { +- if (__pthread_spin_trylock (__lock)) +- return _pthread_spin_lock (__lock); ++ __spin_lock ((__spin_lock_t *) __lock); + return 0; + } + +@@ -79,7 +77,7 @@ __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); + __PT_SPIN_INLINE int + __pthread_spin_unlock (__pthread_spinlock_t *__lock) + { +- __spin_unlock (__lock); ++ __spin_unlock ((__spin_lock_t *) __lock); + return 0; + } + +diff --git a/libpthread/sysdeps/mach/bits/spin-lock.h b/libpthread/sysdeps/mach/bits/spin-lock.h +index 537dac9..7574b37 100644 +--- a/libpthread/sysdeps/mach/bits/spin-lock.h ++++ b/libpthread/sysdeps/mach/bits/spin-lock.h +@@ -21,17 +21,14 @@ + #define _BITS_SPIN_LOCK_H 1 + + #include +-#include /* This does all the work. */ + + __BEGIN_DECLS + + /* The type of a spin lock object. */ +-typedef __spin_lock_t __pthread_spinlock_t; ++typedef volatile int __pthread_spinlock_t; + + /* Initializer for a spin lock object. */ +-#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER +-#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by . +-#endif ++#define __PTHREAD_SPIN_LOCK_INITIALIZER 0 + + __END_DECLS + +diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h +deleted file mode 100644 +index e5ed3de..0000000 +--- a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h ++++ /dev/null +@@ -1,98 +0,0 @@ +-/* Machine-specific definitions for spin locks. i386 version. +- Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. +- 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 Library General Public License as +- published by the Free Software Foundation; either version 2 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 +- Library General Public License for more details. +- +- You should have received a copy of the GNU Library General Public +- License along with the GNU C Library; see the file COPYING.LIB. If not, +- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- Boston, MA 02111-1307, USA. */ +- +-/* +- * Never include this file directly; use or instead. +- */ +- +-#ifndef _BITS_SPIN_LOCK_INLINE_H +-#define _BITS_SPIN_LOCK_INLINE_H 1 +- +-#include +-#include +- +-__BEGIN_DECLS +- +-#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES +- +-# ifndef __EBUSY +-# include +-# define __EBUSY EBUSY +-# endif +- +-# ifndef __PT_SPIN_INLINE +-# define __PT_SPIN_INLINE __extern_inline +-# endif +- +-__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); +- +-__PT_SPIN_INLINE int +-__pthread_spin_destroy (__pthread_spinlock_t *__lock) +-{ +- return 0; +-} +- +-__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, +- int __pshared); +- +-__PT_SPIN_INLINE int +-__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) +-{ +- *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; +- return 0; +-} +- +-__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); +- +-__PT_SPIN_INLINE int +-__pthread_spin_trylock (__pthread_spinlock_t *__lock) +-{ +- int __locked; +- __asm__ __volatile ("xchgl %0, %1" +- : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); +- return __locked ? __EBUSY : 0; +-} +- +-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); +-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); +- +-__extern_inline int +-__pthread_spin_lock (__pthread_spinlock_t *__lock) +-{ +- if (__pthread_spin_trylock (__lock)) +- return _pthread_spin_lock (__lock); +- return 0; +-} +- +-__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); +- +-__PT_SPIN_INLINE int +-__pthread_spin_unlock (__pthread_spinlock_t *__lock) +-{ +- int __unlocked; +- __asm__ __volatile ("xchgl %0, %1" +- : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); +- return 0; +-} +- +-#endif /* Use extern inlines or force inlines. */ +- +-__END_DECLS +- +-#endif /* bits/spin-lock.h */ +diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock.h b/libpthread/sysdeps/mach/i386/bits/spin-lock.h +deleted file mode 100644 +index 5ae81e1..0000000 +--- a/libpthread/sysdeps/mach/i386/bits/spin-lock.h ++++ /dev/null +@@ -1,39 +0,0 @@ +-/* Machine-specific definitions for spin locks. i386 version. +- Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. +- 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 Library General Public License as +- published by the Free Software Foundation; either version 2 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 +- Library General Public License for more details. +- +- You should have received a copy of the GNU Library General Public +- License along with the GNU C Library; see the file COPYING.LIB. If not, +- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- Boston, MA 02111-1307, USA. */ +- +-/* +- * Never include this file directly; use or instead. +- */ +- +-#ifndef _BITS_SPIN_LOCK_H +-#define _BITS_SPIN_LOCK_H 1 +- +-#include +- +-__BEGIN_DECLS +- +-/* The type of a spin lock object. */ +-typedef __volatile int __pthread_spinlock_t; +- +-/* Initializer for a spin lock object. */ +-# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) +- +-__END_DECLS +- +-#endif /* bits/spin-lock.h */ +diff --git a/libpthread/sysdeps/mach/pt-spin.c b/libpthread/sysdeps/mach/pt-spin.c +index d9a2a32..0cf1c49 100644 +--- a/libpthread/sysdeps/mach/pt-spin.c ++++ b/libpthread/sysdeps/mach/pt-spin.c +@@ -17,20 +17,16 @@ + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +-#include + #include + + /* In glibc. */ +-extern void __spin_lock_solid (__pthread_spinlock_t *lock); ++extern void __spin_lock_solid (__spin_lock_t *lock); + + /* Lock the spin lock object LOCK. If the lock is held by another + thread spin until it becomes available. */ + int +-_pthread_spin_lock (__pthread_spinlock_t *lock) ++_pthread_spin_lock (__spin_lock_t *lock) + { + __spin_lock_solid (lock); + return 0; + } +- +-weak_alias (_pthread_spin_lock, pthread_spin_lock); +-weak_alias (_pthread_spin_lock, __pthread_spin_lock); +diff --git a/libpthread/sysdeps/posix/pt-spin.c b/libpthread/sysdeps/posix/pt-spin.c +index cb809c6..07f8936 100644 +--- a/libpthread/sysdeps/posix/pt-spin.c ++++ b/libpthread/sysdeps/posix/pt-spin.c +@@ -49,6 +49,3 @@ _pthread_spin_lock (__pthread_spinlock_t *lock) + __sched_yield (); + } + } +- +-weak_alias (_pthread_spin_lock, pthread_spin_lock); +-weak_alias (_pthread_spin_lock, __pthread_spin_lock); diff -Nru glibc-2.27/debian/patches/hurd-i386/git-libpthread-stacksize.diff glibc-2.27/debian/patches/hurd-i386/git-libpthread-stacksize.diff --- glibc-2.27/debian/patches/hurd-i386/git-libpthread-stacksize.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-libpthread-stacksize.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,19 @@ +Set the default stack size to 8MiB like on Linux, to avoid surprises +with packages which assume the Linuxish default. + +--- + pt-sysdep.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) +Index: glibc-2.19/libpthread/sysdeps/mach/hurd/pt-sysdep.h +=================================================================== +--- glibc-2.19.orig/libpthread/sysdeps/mach/hurd/pt-sysdep.h ++++ glibc-2.19/libpthread/sysdeps/mach/hurd/pt-sysdep.h +@@ -26,7 +26,7 @@ + #define _POSIX_THREAD_THREADS_MAX 64 + + /* The default stack size. */ +-#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024) ++#define PTHREAD_STACK_DEFAULT (8 * 1024 * 1024) + + #define PTHREAD_SYSDEP_MEMBERS \ + thread_t kernel_thread; \ diff -Nru glibc-2.27/debian/patches/hurd-i386/git-libpthread-trylock.diff glibc-2.27/debian/patches/hurd-i386/git-libpthread-trylock.diff --- glibc-2.27/debian/patches/hurd-i386/git-libpthread-trylock.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-libpthread-trylock.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,40 @@ +commit 55c35d62a3a6ae0d90db40c6e4a2d94d05be71e3 +Author: Samuel Thibault +Date: Sat Feb 24 20:20:33 2018 +0100 + + Fix pthread_mutex_trylock return value + + * sysdeps/mach/hurd/pt-mutex-trylock.c (__pthread_mutex_trylock): Return + EBUSY on failure instead of -1. + +diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c +index 6680094..59244e8 100644 +--- a/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c ++++ b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c +@@ -32,6 +32,8 @@ int __pthread_mutex_trylock (pthread_mutex_t *mtxp) + { + case PT_MTX_NORMAL: + ret = lll_trylock (&mtxp->__lock); ++ if (ret) ++ ret = EBUSY; + break; + + case PT_MTX_RECURSIVE: +@@ -49,6 +51,8 @@ int __pthread_mutex_trylock (pthread_mutex_t *mtxp) + mtx_set_owner (mtxp, self, mtxp->__flags); + mtxp->__cnt = 1; + } ++ else ++ ret = EBUSY; + + break; + +@@ -56,6 +60,8 @@ int __pthread_mutex_trylock (pthread_mutex_t *mtxp) + self = _pthread_self (); + if ((ret = lll_trylock (&mtxp->__lock)) == 0) + mtx_set_owner (mtxp, self, mtxp->__flags); ++ else ++ ret = EBUSY; + break; + + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: diff -Nru glibc-2.27/debian/patches/hurd-i386/git-mlockall.diff glibc-2.27/debian/patches/hurd-i386/git-mlockall.diff --- glibc-2.27/debian/patches/hurd-i386/git-mlockall.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-mlockall.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,106 @@ +Subject: [PATCH] Add mlockall support + +* sysdeps/mach/hurd/mlockall.c: New file +* sysdeps/mach/hurd/munlockall.c: New file + +--- + sysdeps/mach/hurd/mlockall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ + sysdeps/mach/hurd/munlockall.c | 40 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 82 insertions(+) + +diff --git a/sysdeps/mach/hurd/mlockall.c b/sysdeps/mach/hurd/mlockall.c +new file mode 100644 +index 0000000000..11a3deac8a +--- /dev/null ++++ b/sysdeps/mach/hurd/mlockall.c +@@ -0,0 +1,42 @@ ++/* mlockall -- lock in core all the pages in this process. Stub version. ++ Copyright (C) 2001-2016 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/* Cause all currently mapped pages of the process to be memory resident ++ until unlocked by a call to the `munlockall', until the process exits, ++ or until the process calls `execve'. */ ++ ++int ++mlockall (int flags) ++{ ++ mach_port_t host; ++ error_t err; ++ ++ err = __get_privileged_ports (&host, NULL); ++ if (err) ++ return __hurd_fail (err); ++ ++ err = __vm_wire_all (host, __mach_task_self (), flags); ++ __mach_port_deallocate (__mach_task_self (), host); ++ return err ? __hurd_fail (err) : 0; ++} +diff --git a/sysdeps/mach/hurd/munlockall.c b/sysdeps/mach/hurd/munlockall.c +new file mode 100644 +index 0000000000..6fbb69435d +--- /dev/null ++++ b/sysdeps/mach/hurd/munlockall.c +@@ -0,0 +1,40 @@ ++/* munlockall -- undo the effects of all prior mlock calls. Stub version. ++ Copyright (C) 2001-2016 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/* Undo the effects of all prior mlock calls in this process. */ ++ ++int ++munlockall (void) ++{ ++ mach_port_t host; ++ error_t err; ++ ++ err = __get_privileged_ports (&host, NULL); ++ if (err) ++ return __hurd_fail (err); ++ ++ err = __vm_wire_all (host, __mach_task_self (), VM_WIRE_NONE); ++ __mach_port_deallocate (__mach_task_self (), host); ++ return err ? __hurd_fail (err) : 0; ++} +-- +tg: (7bb5f8a836..) t/mlockall (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW.diff glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW.diff --- glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,73 @@ +From: Samuel Thibault +Subject: [PATCH] hurd: Fix O_NOFOLLOW + +The error code documented by POSIX for opening a symlink with O_NOFOLLOW +is ELOOP. + +Also, if the translator does not expose symlink as a symlink translator but +as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too. + +Signed-off-by: Samuel Thibault + +--- + hurd/lookup-retry.c | 36 ++++++++++++++++++++---------------- + 1 file changed, 20 insertions(+), 16 deletions(-) + +diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c +index aee2ba8..b7a6a2b 100644 +--- a/hurd/lookup-retry.c ++++ b/hurd/lookup-retry.c +@@ -127,7 +127,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) + { + /* In Linux, O_NOFOLLOW means to reject symlinks. If we + did an O_NOLINK lookup above and io_stat here to check +- for S_IFLNK, a translator like firmlink could easily ++ for S_IFLNK only, a translator like firmlink could easily + spoof this check by not showing S_IFLNK, but in fact + redirecting the lookup to some other name + (i.e. opening the very same holes a symlink would). +@@ -145,23 +145,27 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) + one exception to our general translator-based rule. */ + struct stat64 st; + err = __io_stat (*result, &st); +- if (!err +- && (st.st_mode & (S_IPTRANS|S_IATRANS))) ++ if (!err) + { +- if (st.st_uid != 0) +- err = ENOENT; +- else if (st.st_mode & S_IPTRANS) ++ if (S_ISLNK(st.st_mode)) ++ err = ELOOP; ++ else if (st.st_mode & (S_IPTRANS|S_IATRANS)) + { +- char buf[1024]; +- char *trans = buf; +- size_t translen = sizeof buf; +- err = __file_get_translator (*result, +- &trans, &translen); +- if (!err +- && translen > sizeof _HURD_SYMLINK +- && !memcmp (trans, +- _HURD_SYMLINK, sizeof _HURD_SYMLINK)) +- err = ENOENT; ++ if (st.st_uid != 0) ++ err = ELOOP; ++ else if (st.st_mode & S_IPTRANS) ++ { ++ char buf[1024]; ++ char *trans = buf; ++ size_t translen = sizeof buf; ++ err = __file_get_translator (*result, ++ &trans, &translen); ++ if (!err ++ && translen > sizeof _HURD_SYMLINK ++ && !memcmp (trans, ++ _HURD_SYMLINK, sizeof _HURD_SYMLINK)) ++ err = ELOOP; ++ } + } + } + } +-- +tg: (7bb5f8a..) t/NOFOLLOW (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW-DIRECTORY.diff glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW-DIRECTORY.diff --- glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW-DIRECTORY.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-NOFOLLOW-DIRECTORY.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,44 @@ +From: Samuel Thibault +Subject: [PATCH] hurd: Fix O_DIRECTORY | O_NOFOLLOW + +Appending / to the path to be looked up would make us always follow a final +symlink, even with O_NOTRANS (since the final resolution is after the +'/'). In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open +the node and stat it, which we already do anyway, and check for +directory type. + +Signed-off-by: Samuel Thibault + +--- + hurd/hurdlookup.c | 2 +- + hurd/lookup-retry.c | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c +index dbff009..bd720c2 100644 +--- a/hurd/hurdlookup.c ++++ b/hurd/hurdlookup.c +@@ -72,7 +72,7 @@ __hurd_file_name_lookup (error_t (*use_init_port) + if (flags & O_NOFOLLOW) /* See lookup-retry.c about O_NOFOLLOW. */ + flags |= O_NOTRANS; + +- if (flags & O_DIRECTORY) ++ if (flags & O_DIRECTORY && (flags & O_NOFOLLOW) == 0) + { + /* The caller wants to require that the file we look up is a directory. + We can do this without an extra RPC by appending a trailing slash +diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c +index b7a6a2b..d372959 100644 +--- a/hurd/lookup-retry.c ++++ b/hurd/lookup-retry.c +@@ -147,6 +147,8 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) + err = __io_stat (*result, &st); + if (!err) + { ++ if (flags & O_DIRECTORY && !S_ISDIR(st.st_mode)) ++ err = ENOTDIR; + if (S_ISLNK(st.st_mode)) + err = ELOOP; + else if (st.st_mode & (S_IPTRANS|S_IATRANS)) +-- +tg: (2bc1a49..) t/NOFOLLOW-DIRECTORY (depends on: t/NOFOLLOW) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-pagesize.diff glibc-2.27/debian/patches/hurd-i386/git-pagesize.diff --- glibc-2.27/debian/patches/hurd-i386/git-pagesize.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-pagesize.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,37 @@ +Subject: [PATCH] t/pagesize + +From: Thomas Schwinge + +Fixed another in glibc 2.28 + +--- + elf/dl-support.c | 2 +- + elf/rtld.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: glibc-2.27/elf/dl-support.c +=================================================================== +--- glibc-2.27.orig/elf/dl-support.c ++++ glibc-2.27/elf/dl-support.c +@@ -136,7 +136,7 @@ hp_timing_t _dl_cpuclock_offset; + + void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls; + +-size_t _dl_pagesize = EXEC_PAGESIZE; ++size_t _dl_pagesize = /* EXEC_PAGESIZE */ 4096; + + int _dl_inhibit_cache; + +Index: glibc-2.27/elf/rtld.c +=================================================================== +--- glibc-2.27.orig/elf/rtld.c ++++ glibc-2.27/elf/rtld.c +@@ -271,7 +271,7 @@ struct rtld_global_ro _rtld_global_ro at + #endif + ._dl_lazy = 1, + ._dl_fpu_control = _FPU_DEFAULT, +- ._dl_pagesize = EXEC_PAGESIZE, ++ ._dl_pagesize = /* EXEC_PAGESIZE */ 4096, + ._dl_inhibit_cache = 0, + + /* Function pointers. */ diff -Nru glibc-2.27/debian/patches/hurd-i386/git-reboot-startup.diff glibc-2.27/debian/patches/hurd-i386/git-reboot-startup.diff --- glibc-2.27/debian/patches/hurd-i386/git-reboot-startup.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-reboot-startup.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,38 @@ +From: David Michael +Subject: [PATCH] Lookup the startup server through /servers/startup + +* sysdeps/mach/hurd/reboot.c: Include +(reboot): Lookup _SERVERS_STARTUP instead of calling proc_getmsgport to get a +port to the startup server. + + + +--- + sysdeps/mach/hurd/reboot.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/mach/hurd/reboot.c b/sysdeps/mach/hurd/reboot.c +index 60d96ea..51c3d73 100644 +--- a/sysdeps/mach/hurd/reboot.c ++++ b/sysdeps/mach/hurd/reboot.c +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -33,8 +34,8 @@ reboot (int howto) + if (err) + return __hurd_fail (EPERM); + +- err = __USEPORT (PROC, __proc_getmsgport (port, 1, &init)); +- if (!err) ++ init = __file_name_lookup (_SERVERS_STARTUP, 0, 0); ++ if (init != MACH_PORT_NULL) + { + err = __startup_reboot (init, hostpriv, howto); + __mach_port_deallocate (__mach_task_self (), init); +-- +tg: (9a079e2..) t/reboot-startup (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/git-thread-linkspace.diff glibc-2.27/debian/patches/hurd-i386/git-thread-linkspace.diff --- glibc-2.27/debian/patches/hurd-i386/git-thread-linkspace.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-thread-linkspace.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,147 @@ +From: Samuel Thibault +Subject: [PATCH] Fix thread linkspace + +Libc uses some thread functions, but should not expose the corresponding +symbols, so call aliases. + +--- + hurd/Versions | 6 +++--- + hurd/hurdsig.c | 20 ++++++++++---------- + sysdeps/mach/hurd/cthreads.c | 10 +++++----- + sysdeps/mach/libc-lock.h | 4 ++-- + 4 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/hurd/Versions b/hurd/Versions +index 414231b5b4..e040b49edc 100644 +--- a/hurd/Versions ++++ b/hurd/Versions +@@ -143,14 +143,14 @@ libc { + + HURD_CTHREADS_0.3 { + # weak refs to libthreads functions that libc calls iff libthreads in use +- cthread_fork; cthread_detach; +- pthread_getattr_np; pthread_attr_getstack; ++ __cthread_fork; __cthread_detach; ++ __pthread_getattr_np; __pthread_attr_getstack; + + # variables used for detecting cthreads + _cthread_exit_routine; _cthread_init_routine; + + # cthreads functions with stubs in libc +- cthread_keycreate; cthread_getspecific; cthread_setspecific; ++ __cthread_keycreate; __cthread_getspecific; __cthread_setspecific; + __libc_getspecific; + } + +diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c +index fd787c6c1b..8584d5c631 100644 +--- a/hurd/hurdsig.c ++++ b/hurd/hurdsig.c +@@ -1466,11 +1466,11 @@ _hurdsig_init (const int *intarray, size_t intarraysize) + + /* Start the signal thread listening on the message port. */ + +-#pragma weak cthread_fork +-#pragma weak cthread_detach +-#pragma weak pthread_getattr_np +-#pragma weak pthread_attr_getstack +- if (!cthread_fork) ++#pragma weak __cthread_fork ++#pragma weak __cthread_detach ++#pragma weak __pthread_getattr_np ++#pragma weak __pthread_attr_getstack ++ if (!__cthread_fork) + { + err = __thread_create (__mach_task_self (), &_hurd_msgport_thread); + assert_perror (err); +@@ -1495,7 +1495,7 @@ _hurdsig_init (const int *intarray, size_t intarraysize) + } + else + { +- cthread_t thread; ++ __cthread_t thread; + /* When cthreads is being used, we need to make the signal thread a + proper cthread. Otherwise it cannot use mutex_lock et al, which + will be the cthreads versions. Various of the message port RPC +@@ -1505,17 +1505,17 @@ _hurdsig_init (const int *intarray, size_t intarraysize) + we'll let the signal thread's per-thread variables be found as for + any normal cthread, and just leave the magic __hurd_sigthread_* + values all zero so they'll be ignored. */ +- cthread_detach (thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); ++ __cthread_detach (thread = __cthread_fork ((__cthread_fn_t) &_hurd_msgport_receive, 0)); + +- if (pthread_getattr_np) ++ if (__pthread_getattr_np) + { + /* Record stack layout for fork() */ + pthread_attr_t attr; + void *addr; + size_t size; + +- pthread_getattr_np ((pthread_t) thread, &attr); +- pthread_attr_getstack (&attr, &addr, &size); ++ __pthread_getattr_np ((pthread_t) thread, &attr); ++ __pthread_attr_getstack (&attr, &addr, &size); + __hurd_sigthread_stack_base = (uintptr_t) addr; + __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size; + } +diff --git a/sysdeps/mach/hurd/cthreads.c b/sysdeps/mach/hurd/cthreads.c +index f223e00b12..0a3780b273 100644 +--- a/sysdeps/mach/hurd/cthreads.c ++++ b/sysdeps/mach/hurd/cthreads.c +@@ -24,7 +24,7 @@ char __libc_lock_self0[0]; + /* Placeholder for key creation routine from Hurd cthreads library. */ + int + weak_function +-cthread_keycreate (cthread_key_t *key) ++__cthread_keycreate (cthread_key_t *key) + { + __set_errno (ENOSYS); + *key = -1; +@@ -34,7 +34,7 @@ cthread_keycreate (cthread_key_t *key) + /* Placeholder for key retrieval routine from Hurd cthreads library. */ + int + weak_function +-cthread_getspecific (cthread_key_t key, void **pval) ++__cthread_getspecific (cthread_key_t key, void **pval) + { + *pval = NULL; + __set_errno (ENOSYS); +@@ -44,19 +44,19 @@ cthread_getspecific (cthread_key_t key, void **pval) + /* Placeholder for key setting routine from Hurd cthreads library. */ + int + weak_function +-cthread_setspecific (cthread_key_t key, void *val) ++__cthread_setspecific (cthread_key_t key, void *val) + { + __set_errno (ENOSYS); + return -1; + } + +-/* Call cthread_getspecific which gets a pointer to the return value instead ++/* Call __cthread_getspecific which gets a pointer to the return value instead + of just returning it. */ + void * + weak_function + __libc_getspecific (cthread_key_t key) + { + void *val; +- cthread_getspecific (key, &val); ++ __cthread_getspecific (key, &val); + return val; + } +diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/libc-lock.h +index f9f57a0a65..35233f797e 100644 +--- a/sysdeps/mach/libc-lock.h ++++ b/sysdeps/mach/libc-lock.h +@@ -223,8 +223,8 @@ struct __libc_once + used as argument to __libc_cleanup_region_start. */ + #define __libc_mutex_unlock __libc_lock_unlock + +-#define __libc_key_create(KEY,DEST) cthread_keycreate (KEY) +-#define __libc_setspecific(KEY,VAL) cthread_setspecific (KEY, VAL) ++#define __libc_key_create(KEY,DEST) __cthread_keycreate (KEY) ++#define __libc_setspecific(KEY,VAL) __cthread_setspecific (KEY, VAL) + void *__libc_getspecific (__libc_key_t key); + + /* Hide the definitions which are only supposed to be used inside libc in diff -Nru glibc-2.27/debian/patches/hurd-i386/git-timer_routines.diff glibc-2.27/debian/patches/hurd-i386/git-timer_routines.diff --- glibc-2.27/debian/patches/hurd-i386/git-timer_routines.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-timer_routines.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,56 @@ +Index: glibc/sysdeps/pthread/timer_routines.c +=================================================================== +--- glibc.orig/sysdeps/pthread/timer_routines.c ++++ glibc/sysdeps/pthread/timer_routines.c +@@ -29,7 +29,7 @@ + #include + + #include "posix-timer.h" +-#include ++//#include + + + /* Number of threads used. */ +@@ -395,6 +395,9 @@ thread_func (void *arg) + { + timespec_add (&timer->expirytime, &timer->expirytime, + &timer->value.it_interval); ++#ifndef DELAYTIMER_MAX ++#define DELAYTIMER_MAX INT_MAX ++#endif + if (timer->overrun_count < DELAYTIMER_MAX) + ++timer->overrun_count; + } +@@ -481,7 +484,7 @@ __timer_thread_wakeup (struct thread_nod + pthread_cond_broadcast (&thread->cond); + } + +- ++#if 0 + /* Compare two pthread_attr_t thread attributes for exact equality. + Returns 1 if they are equal, otherwise zero if they are not equal + or contain illegal values. This version is NPTL-specific for +@@ -506,6 +509,7 @@ thread_attr_compare (const pthread_attr_ + && memcmp (ileft->cpuset, iright->cpuset, + ileft->cpusetsize) == 0))); + } ++#endif + + + /* Search the list of active threads and find one which has matching +@@ -514,6 +518,7 @@ struct thread_node * + __timer_thread_find_matching (const pthread_attr_t *desired_attr, + clockid_t desired_clock_id) + { ++#if 0 + struct list_head *iter = list_first (&thread_active_list); + + while (iter != list_null (&thread_active_list)) +@@ -526,6 +531,7 @@ __timer_thread_find_matching (const pthr + + iter = list_next (iter); + } ++#endif + + return NULL; + } diff -Nru glibc-2.27/debian/patches/hurd-i386/git-tls.diff glibc-2.27/debian/patches/hurd-i386/git-tls.diff --- glibc-2.27/debian/patches/hurd-i386/git-tls.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-tls.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,413 @@ +From: Thomas Schwinge +Subject: [PATCH] tls + +TLS support. + +All by Samuel Thibault. + +glibc-2.8/debian/patches/hurd-i386/local-tls-support.diff 3151 + +2009-07-30 Samuel Thibault + + Align up includes as on Linux, to fix build. + * sysdeps/mach/hurd/tls.h: Include . + +--- + sysdeps/mach/thread_state.h | 3 ++ + csu/libc-start.c | 2 + + include/errno.h | 14 +++++---- + hurd/hurdfault.c | 2 + + hurd/hurdsig.c | 2 + + mach/mach.h | 3 ++ + mach/setup-thread.c | 30 +++++++++++++++++++- + sysdeps/generic/thread_state.h | 1 + sysdeps/mach/hurd/libc-lock.h | 3 ++ + sysdeps/mach/hurd/fork.c | 7 ++++ + sysdeps/mach/hurd/i386/init-first.c | 49 +++++++++++++++++++++------------ + sysdeps/mach/hurd/i386/tls.h | 53 +++++++++++++++++++++++++++++------- + sysdeps/mach/hurd/i386/trampoline.c | 2 - + sysdeps/mach/hurd/profil.c | 2 + + sysdeps/mach/hurd/setitimer.c | 3 +- + sysdeps/mach/hurd/tls.h | 2 + + sysdeps/mach/i386/thread_state.h | 11 ++++++- + 17 files changed, 150 insertions(+), 39 deletions(-) + +--- a/include/errno.h ++++ b/include/errno.h +@@ -21,13 +21,15 @@ extern int rtld_errno attribute_hidden; + + # include + +-# undef errno +-# if IS_IN (libc) +-# define errno __libc_errno +-# else +-# define errno errno /* For #ifndef errno tests. */ +-# endif ++# if !defined(__GNU__) ++# undef errno ++# if IS_IN (libc) ++# define errno __libc_errno ++# else ++# define errno errno /* For #ifndef errno tests. */ ++# endif + extern __thread int errno attribute_tls_model_ie; ++# endif + + # endif /* IS_IN_LIB */ + +--- a/hurd/hurdfault.c ++++ b/hurd/hurdfault.c +@@ -204,6 +204,8 @@ _hurdsig_fault_init (void) + /* This state will be restored when we fault. + It runs the function above. */ + memset (&state, 0, sizeof state); ++ ++ MACHINE_THREAD_STATE_FIX_NEW (&state); + MACHINE_THREAD_STATE_SET_PC (&state, faulted); + MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack); + +--- a/hurd/hurdsig.c ++++ b/hurd/hurdsig.c +@@ -1266,6 +1266,8 @@ _hurdsig_init (const int *intarray, size + (vm_address_t *) &__hurd_sigthread_stack_base, + &stacksize); + assert_perror (err); ++ err = __mach_setup_tls (_hurd_msgport_thread); ++ assert_perror (err); + + __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize; + __hurd_sigthread_variables = +--- a/mach/mach.h ++++ b/mach/mach.h +@@ -100,5 +100,8 @@ kern_return_t mach_setup_thread (task_t + vm_address_t *stack_base, + vm_size_t *stack_size); + ++/* Give THREAD a TLS area. */ ++kern_return_t __mach_setup_tls (thread_t thread); ++kern_return_t mach_setup_tls (thread_t thread); + + #endif /* mach.h */ +--- a/mach/setup-thread.c ++++ b/mach/setup-thread.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include "sysdep.h" /* Defines stack direction. */ + + #define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */ +@@ -72,8 +73,35 @@ __mach_setup_thread (task_t task, thread + if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE)) + return error; + +- return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, ++ return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR, + (natural_t *) &ts, tssize); + } + + weak_alias (__mach_setup_thread, mach_setup_thread) ++ ++/* Give THREAD a TLS area. */ ++kern_return_t ++__mach_setup_tls (thread_t thread) ++{ ++ kern_return_t error; ++ struct machine_thread_state ts; ++ mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; ++ tcbhead_t *tcb; ++ ++ tcb = _dl_allocate_tls(NULL); ++ if (tcb == NULL) ++ return KERN_RESOURCE_SHORTAGE; ++ ++ if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, ++ (natural_t *) &ts, &tssize)) ++ return error; ++ assert (tssize == MACHINE_THREAD_STATE_COUNT); ++ ++ _hurd_tls_new(thread, &ts, tcb); ++ ++ error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, ++ (natural_t *) &ts, tssize); ++ return error; ++} ++ ++weak_alias (__mach_setup_tls, mach_setup_tls) +--- a/sysdeps/generic/thread_state.h ++++ b/sysdeps/generic/thread_state.h +@@ -22,6 +22,7 @@ + + /* Replace with "i386" or "mips" or whatever. */ + ++#define MACHINE_NEW_THREAD_STATE_FLAVOR _NEW_THREAD_STATE + #define MACHINE_THREAD_STATE_FLAVOR _THREAD_STATE + #define MACHINE_THREAD_STATE_COUNT _THREAD_STATE_COUNT + +--- a/sysdeps/mach/hurd/libc-lock.h ++++ b/sysdeps/mach/hurd/libc-lock.h +@@ -20,6 +20,9 @@ + #define _LIBC_LOCK_H 1 + + #if (_LIBC - 0) || (_CTHREADS_ - 0) ++#if (_LIBC - 0) ++#include ++#endif + #include + #include + +--- a/sysdeps/mach/hurd/fork.c ++++ b/sysdeps/mach/hurd/fork.c +@@ -528,6 +528,11 @@ __fork (void) + #endif + MACHINE_THREAD_STATE_SET_PC (&state, + (unsigned long int) _hurd_msgport_receive); ++ ++ /* Do special thread setup for TLS if needed. */ ++ if (err = _hurd_tls_fork (sigthread, _hurd_msgport_thread, &state)) ++ LOSE; ++ + if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR, + (natural_t *) &state, statecount)) + LOSE; +@@ -538,7 +543,7 @@ __fork (void) + _hurd_longjmp_thread_state (&state, env, 1); + + /* Do special thread setup for TLS if needed. */ +- if (err = _hurd_tls_fork (thread, &state)) ++ if (err = _hurd_tls_fork (thread, ss->thread, &state)) + LOSE; + + if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, +--- a/sysdeps/mach/hurd/i386/init-first.c ++++ b/sysdeps/mach/hurd/i386/init-first.c +@@ -113,31 +113,11 @@ init1 (int argc, char *arg0, ...) + data block; the argument strings start there. */ + if ((void *) d == argv[0]) + { +-#ifndef SHARED +- /* With a new enough linker (binutils-2.23 or better), +- the magic __ehdr_start symbol will be available and +- __libc_start_main will have done this that way already. */ +- if (_dl_phdr == NULL) +- { +- /* We may need to see our own phdrs, e.g. for TLS setup. +- Try the usual kludge to find the headers without help from +- the exec server. */ +- extern const void __executable_start; +- const ElfW(Ehdr) *const ehdr = &__executable_start; +- _dl_phdr = (const void *) ehdr + ehdr->e_phoff; +- _dl_phnum = ehdr->e_phnum; +- assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); +- } +-#endif + return; + } + + #ifndef SHARED + __libc_enable_secure = d->flags & EXEC_SECURE; +- +- _dl_phdr = (ElfW(Phdr) *) d->phdr; +- _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr)); +- assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); + #endif + + _hurd_init_dtable = d->dtable; +@@ -193,6 +173,40 @@ init (int *data) + ++envp; + d = (void *) ++envp; + ++#ifndef SHARED ++ /* If we are the bootstrap task started by the kernel, ++ then after the environment pointers there is no Hurd ++ data block; the argument strings start there. */ ++ if ((void *) d == argv[0]) ++ { ++ /* With a new enough linker (binutils-2.23 or better), ++ the magic __ehdr_start symbol will be available and ++ __libc_start_main will have done this that way already. */ ++ if (_dl_phdr == NULL) ++ { ++ /* We may need to see our own phdrs, e.g. for TLS setup. ++ Try the usual kludge to find the headers without help from ++ the exec server. */ ++ extern const void __executable_start; ++ const ElfW(Ehdr) *const ehdr = &__executable_start; ++ _dl_phdr = (const void *) ehdr + ehdr->e_phoff; ++ _dl_phnum = ehdr->e_phnum; ++ assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); ++ } ++ } ++ else ++ { ++ _dl_phdr = (ElfW(Phdr) *) d->phdr; ++ _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr)); ++ assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); ++ } ++ ++ /* We need to setup TLS before starting the signal thread. */ ++ extern void __pthread_initialize_minimal (void); ++ if (__pthread_initialize_minimal != NULL) ++ __pthread_initialize_minimal (); ++#endif ++ + /* The user might have defined a value for this, to get more variables. + Otherwise it will be zero on startup. We must make sure it is set + properly before before cthreads initialization, so cthreads can know +--- a/sysdeps/mach/hurd/i386/tls.h ++++ b/sysdeps/mach/hurd/i386/tls.h +@@ -56,6 +56,15 @@ typedef struct + #define TLS_TCB_AT_TP 1 + #define TLS_DTV_AT_TP 0 + ++/* Alignment requirement for TCB. ++ ++ Some processors such as Intel Atom pay a big penalty on every ++ access using a segment override if that segment's base is not ++ aligned to the size of a cache line. (See Intel 64 and IA-32 ++ Architectures Optimization Reference Manual, section 13.3.3.3, ++ "Segment Base".) On such machines, a cache line is 64 bytes. */ ++#define TCB_ALIGNMENT 64 ++ + #ifndef __ASSEMBLER__ + + /* Use i386-specific RPCs to arrange that %gs segment register prefix +@@ -139,9 +139,40 @@ _hurd_tls_init (tcbhead_t *tcb, int seco + + # include + +-/* Set up TLS in the new thread of a fork child, copying from our own. */ +-static inline error_t __attribute__ ((unused)) +-_hurd_tls_fork (thread_t child, struct i386_thread_state *state) ++/* Set up TLS in the new thread of a fork child, copying from the original. */ ++static inline kern_return_t __attribute__ ((unused)) ++_hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state) ++{ ++ /* Fetch the selector set by _hurd_tls_init. */ ++ int sel; ++ asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); ++ if (sel == state->ds) /* _hurd_tls_init was never called. */ ++ return 0; ++ ++ struct descriptor desc, *_desc = &desc; ++ error_t err; ++ unsigned int count = 1; ++ ++ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ ++ err = __i386_get_ldt (orig, sel, 1, &_desc, &count); ++ else ++ err = __i386_get_gdt (orig, sel, &desc); ++ ++ assert_perror (err); ++ if (err) ++ return err; ++ ++ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ ++ err = __i386_set_ldt (child, sel, &desc, 1); ++ else ++ err = __i386_set_gdt (child, &sel, desc); ++ ++ state->gs = sel; ++ return err; ++} ++ ++static inline kern_return_t __attribute__ ((unused)) ++_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) + { + /* Fetch the selector set by _hurd_tls_init. */ + int sel; +@@ -149,11 +180,13 @@ _hurd_tls_fork (thread_t child, struct i + if (sel == state->ds) /* _hurd_tls_init was never called. */ + return 0; + +- tcbhead_t *const tcb = THREAD_SELF; + HURD_TLS_DESC_DECL (desc, tcb); + error_t err; ++ ++ tcb->tcb = tcb; ++ tcb->self = child; + +- if (__builtin_expect (sel, 0x50) & 4) /* LDT selector */ ++ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ + err = __i386_set_ldt (child, sel, &desc, 1); + else + err = __i386_set_gdt (child, &sel, desc); +--- a/sysdeps/mach/hurd/i386/trampoline.c ++++ b/sysdeps/mach/hurd/i386/trampoline.c +@@ -63,7 +63,7 @@ _hurd_setup_sighandler (struct hurd_sigs + sizeof (state->basic)); + memcpy (&state->fpu, &ss->context->sc_i386_float_state, + sizeof (state->fpu)); +- state->set |= (1 << i386_THREAD_STATE) | (1 << i386_FLOAT_STATE); ++ state->set |= (1 << i386_REGS_SEGS_STATE) | (1 << i386_FLOAT_STATE); + } + } + +--- a/sysdeps/mach/hurd/profil.c ++++ b/sysdeps/mach/hurd/profil.c +@@ -68,6 +68,8 @@ update_waiter (u_short *sample_buffer, s + if (! err) + err = __mach_setup_thread (__mach_task_self (), profile_thread, + &profile_waiter, NULL, NULL); ++ if (! err) ++ err = __mach_setup_tls(profile_thread); + } + else + err = 0; +--- a/sysdeps/mach/hurd/setitimer.c ++++ b/sysdeps/mach/hurd/setitimer.c +@@ -221,11 +221,12 @@ setitimer_locked (const struct itimerval + goto out; + _hurd_itimer_thread_stack_base = 0; /* Anywhere. */ + _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */ +- if (err = __mach_setup_thread (__mach_task_self (), ++ if ((err = __mach_setup_thread (__mach_task_self (), + _hurd_itimer_thread, + &timer_thread, + &_hurd_itimer_thread_stack_base, + &_hurd_itimer_thread_stack_size)) ++ || (err = __mach_setup_tls(_hurd_itimer_thread))) + { + __thread_terminate (_hurd_itimer_thread); + _hurd_itimer_thread = MACH_PORT_NULL; +--- a/sysdeps/mach/i386/thread_state.h ++++ b/sysdeps/mach/i386/thread_state.h +@@ -21,7 +21,8 @@ + + #include + +-#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE ++#define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE ++#define MACHINE_THREAD_STATE_FLAVOR i386_REGS_SEGS_STATE + #define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT + + #define machine_thread_state i386_thread_state +@@ -30,6 +31,14 @@ + #define SP uesp + #define SYSRETURN eax + ++#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \ ++ asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \ ++ asm ("mov %%ds, %w0" : "=q" ((ts)->ds)); \ ++ asm ("mov %%es, %w0" : "=q" ((ts)->es)); \ ++ asm ("mov %%fs, %w0" : "=q" ((ts)->fs)); \ ++ asm ("mov %%gs, %w0" : "=q" ((ts)->gs)); \ ++} while(0) ++ + struct machine_thread_all_state + { + int set; /* Mask of bits (1 << FLAVOR). */ +--- a/sysdeps/mach/thread_state.h ++++ b/sysdeps/mach/thread_state.h +@@ -37,6 +37,9 @@ + ((ts)->SP = (unsigned long int) (stack) + (size)) + #endif + #endif ++#ifndef MACHINE_THREAD_STATE_FIX_NEW ++# define MACHINE_THREAD_STATE_FIX_NEW(ts) ++#endif + + /* These functions are of use in machine-dependent signal trampoline + implementations. */ diff -Nru glibc-2.27/debian/patches/hurd-i386/git-tls_thread_leak.diff glibc-2.27/debian/patches/hurd-i386/git-tls_thread_leak.diff --- glibc-2.27/debian/patches/hurd-i386/git-tls_thread_leak.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-tls_thread_leak.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,71 @@ +From: Richard Braun +Subject: [PATCH] Hurd: fix port leak in TLS + +Depending on whether the thread is the main thread or not, the threading +library can have trouble determining whether the thread reference in the +TCB is valid. The simple solution is to let the threading library +initialize the TCB, and use a temporary reference when initializing TLS. + +* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Use a temporary thread +reference. + +--- + sysdeps/mach/hurd/i386/tls.h | 35 +++++++++++++++++++++++------------ + 1 file changed, 23 insertions(+), 12 deletions(-) + +--- a/sysdeps/mach/hurd/i386/tls.h ++++ b/sysdeps/mach/hurd/i386/tls.h +@@ -69,6 +69,8 @@ static inline const char * __attribute__ + _hurd_tls_init (tcbhead_t *tcb) + { + HURD_TLS_DESC_DECL (desc, tcb); ++ thread_t self = __mach_thread_self (); ++ const char *msg = NULL; + + /* This field is used by TLS accesses to get our "thread pointer" + from the TLS point of view. */ +@@ -76,25 +78,26 @@ _hurd_tls_init (tcbhead_t *tcb, int seco + from the TLS point of view. */ + tcb->tcb = tcb; + +- /* Cache our thread port. */ +- tcb->self = __mach_thread_self (); +- + /* Get the first available selector. */ + int sel = -1; +- error_t err = __i386_set_gdt (tcb->self, &sel, desc); ++ error_t err = __i386_set_gdt (self, &sel, desc); + if (err == MIG_BAD_ID) + { + /* Old kernel, use a per-thread LDT. */ + sel = 0x27; +- err = __i386_set_ldt (tcb->self, sel, &desc, 1); ++ err = __i386_set_ldt (self, sel, &desc, 1); + assert_perror (err); + if (err) +- return "i386_set_ldt failed"; ++ { ++ msg = "i386_set_ldt failed"; ++ goto out; ++ } + } + else if (err) + { + assert_perror (err); /* Separate from above with different line #. */ +- return "i386_set_gdt failed"; ++ msg = "i386_set_gdt failed"; ++ goto out; + } + + /* Now install the new selector. */ +@@ -107,7 +110,9 @@ _hurd_tls_init (tcbhead_t *tcb, int seco + /* Now install the new selector. */ + asm volatile ("mov %w0, %%gs" :: "q" (sel)); + +- return 0; ++out: ++ __mach_port_deallocate (__mach_task_self (), self); ++ return msg; + } + + /* Code to initially initialize the thread pointer. This might need diff -Nru glibc-2.27/debian/patches/hurd-i386/git-tls-threadvar.diff glibc-2.27/debian/patches/hurd-i386/git-tls-threadvar.diff --- glibc-2.27/debian/patches/hurd-i386/git-tls-threadvar.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-tls-threadvar.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,846 @@ +From: Thomas Schwinge +Subject: [PATCH] tls-threadvar + +replace the custom threadvar mechanism with generic TLS. +That will fix sigaltstack. + +Note: the added reply_port and _hurd_sigstate fields should be kept last. + +--- + hurd/Versions | 6 - + hurd/hurd/signal.h | 23 ++++--- + hurd/hurd/threadvar.h | 85 ++-------------------------- + hurd/hurdsig.c | 51 ++++++++++------ + hurd/hurdstartup.c | 1 + hurd/sigunwind.c | 4 - + include/errno.h | 2 + sysdeps/mach/hurd/Versions | 4 - + sysdeps/mach/hurd/cthreads.c | 2 + sysdeps/mach/hurd/dl-sysdep.c | 19 ------ + sysdeps/mach/hurd/errno-loc.c | 22 ++++--- + sysdeps/mach/hurd/errno.c | 1 + sysdeps/mach/hurd/fork.c | 7 -- + sysdeps/mach/hurd/i386/init-first.c | 36 ----------- + sysdeps/mach/hurd/i386/makecontext-helper.c | 2 + sysdeps/mach/hurd/i386/makecontext.S | 2 + sysdeps/mach/hurd/i386/sigreturn.c | 5 - + sysdeps/mach/hurd/i386/tls.h | 29 +++++++++ + sysdeps/mach/hurd/libc-lock.h | 4 - + sysdeps/mach/hurd/libc-tsd.h | 34 ----------- + sysdeps/mach/hurd/mig-reply.c | 39 +++--------- + sysdeps/mach/hurd/profil.c | 6 - + 22 files changed, 126 insertions(+), 258 deletions(-) + +--- a/hurd/Versions ++++ b/hurd/Versions +@@ -4,14 +4,9 @@ + _end; + + # variables used in macros & inline functions +- __hurd_sigthread_stack_base; __hurd_sigthread_stack_end; +- __hurd_sigthread_variables; + __hurd_threadvar_max; + __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; + +- # functions used in macros & inline functions +- __hurd_errno_location; +- + # functions used in libmachuser and libhurduser + _S_catch_exception_raise; + _S_catch_exception_raise_state; +@@ -146,6 +141,7 @@ + HURD_CTHREADS_0.3 { + # weak refs to libthreads functions that libc calls iff libthreads in use + cthread_fork; cthread_detach; ++ pthread_getattr_np; pthread_attr_getstack; + + # variables used for detecting cthreads + _cthread_exit_routine; _cthread_init_routine; +--- a/hurd/hurd/signal.h ++++ b/hurd/hurd/signal.h +@@ -40,7 +40,6 @@ + #include /* For `struct mutex'. */ + #include /* For `jmp_buf'. */ + #include +-#include /* We cache sigstate in a threadvar. */ + struct hurd_signal_preemptor; /* */ + #if defined __USE_EXTERN_INLINES && defined _LIBC + # if IS_IN (libc) || IS_IN (libpthread) +@@ -139,11 +138,9 @@ + _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * + _hurd_self_sigstate (void) + { +- struct hurd_sigstate **location = (struct hurd_sigstate **) +- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); +- if (*location == NULL) +- *location = _hurd_thread_sigstate (__mach_thread_self ()); +- return *location; ++ if (THREAD_SELF->_hurd_sigstate == NULL) ++ THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); ++ return THREAD_SELF->_hurd_sigstate; + } + # endif + #endif +@@ -180,16 +177,22 @@ + _HURD_SIGNAL_H_EXTERN_INLINE void * + _hurd_critical_section_lock (void) + { +- struct hurd_sigstate **location = (struct hurd_sigstate **) +- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); +- struct hurd_sigstate *ss = *location; ++ struct hurd_sigstate *ss; ++ ++#ifdef __LIBC_NO_TLS ++ if (__LIBC_NO_TLS()) ++ /* TLS is currently initializing, no need to enter critical section. */ ++ return NULL; ++#endif ++ ++ ss = THREAD_SELF->_hurd_sigstate; + if (ss == NULL) + { + /* The thread variable is unset; this must be the first time we've + asked for it. In this case, the critical section flag cannot + possible already be set. Look up our sigstate structure the slow + way. */ +- ss = *location = _hurd_thread_sigstate (__mach_thread_self ()); ++ ss = THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); + } + + if (! __spin_try_lock (&ss->critical_section_lock)) +--- a/hurd/hurd/threadvar.h ++++ b/hurd/hurd/threadvar.h +@@ -20,6 +20,7 @@ + #define _HURD_THREADVAR_H + + #include ++#include + + /* The per-thread variables are found by ANDing this mask + with the value of the stack pointer and then adding this offset. +@@ -30,96 +31,24 @@ + __hurd_threadvar_stack_offset to a small offset that skips the data + cthreads itself maintains at the base of each thread's stack. + +- In the single-threaded case, __hurd_threadvar_stack_mask is zero, so the +- stack pointer is ignored; and __hurd_threadvar_stack_offset gives the +- address of a small allocated region which contains the variables for the +- single thread. */ ++ In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is ++ zero, so the stack pointer is ignored. */ + + extern unsigned long int __hurd_threadvar_stack_mask; + extern unsigned long int __hurd_threadvar_stack_offset; + +-/* A special case must always be made for the signal thread. Even when there +- is only one user thread and an allocated region can be used for the user +- thread's variables, the signal thread needs to have its own location for +- per-thread variables. The variables __hurd_sigthread_stack_base and ++/* The variables __hurd_sigthread_stack_base and + __hurd_sigthread_stack_end define the bounds of the stack used by the + signal thread, so that thread can always be specifically identified. */ + + extern unsigned long int __hurd_sigthread_stack_base; + extern unsigned long int __hurd_sigthread_stack_end; +-extern unsigned long int *__hurd_sigthread_variables; + + +-/* At the location described by the two variables above, +- there are __hurd_threadvar_max `unsigned long int's of per-thread data. */ ++/* We do not use threadvars any more, this is kept as zero for compatibility with cthreads */ + extern unsigned int __hurd_threadvar_max; + +-/* These values are the indices for the standard per-thread variables. */ +-enum __hurd_threadvar_index +- { +- _HURD_THREADVAR_MIG_REPLY, /* Reply port for MiG user stub functions. */ +- _HURD_THREADVAR_ERRNO, /* `errno' value for this thread. */ +- _HURD_THREADVAR_SIGSTATE, /* This thread's `struct hurd_sigstate'. */ +- _HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */ +- _HURD_THREADVAR_MALLOC, /* For use of malloc. */ +- _HURD_THREADVAR_DL_ERROR, /* For use of -ldl and dynamic linker. */ +- _HURD_THREADVAR_RPC_VARS, /* For state of RPC functions. */ +- _HURD_THREADVAR_LOCALE, /* For thread-local locale setting. */ +- _HURD_THREADVAR_CTYPE_B, /* Cache of thread-local locale data. */ +- _HURD_THREADVAR_CTYPE_TOLOWER, /* Cache of thread-local locale data. */ +- _HURD_THREADVAR_CTYPE_TOUPPER, /* Cache of thread-local locale data. */ +- _HURD_THREADVAR_MAX /* Default value for __hurd_threadvar_max. */ +- }; +- +- +-#ifndef _HURD_THREADVAR_H_EXTERN_INLINE +-#define _HURD_THREADVAR_H_EXTERN_INLINE __extern_inline +-#endif +- +-/* Return the location of the value for the per-thread variable with index +- INDEX used by the thread whose stack pointer is SP. */ +- +-extern unsigned long int *__hurd_threadvar_location_from_sp +- (enum __hurd_threadvar_index __index, void *__sp); +- +-#if defined __USE_EXTERN_INLINES && defined _LIBC +-# if IS_IN (libc) +-_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int * +-__hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index, +- void *__sp) +-{ +- unsigned long int __stack = (unsigned long int) __sp; +- return &((__stack >= __hurd_sigthread_stack_base && +- __stack < __hurd_sigthread_stack_end) +- ? __hurd_sigthread_variables +- : (unsigned long int *) ((__stack & __hurd_threadvar_stack_mask) + +- __hurd_threadvar_stack_offset))[__index]; +-} +-# endif +-#endif +- +-#include /* Define __thread_stack_pointer. */ +- +-/* Return the location of the current thread's value for the +- per-thread variable with index INDEX. */ +- +-extern unsigned long int * +-__hurd_threadvar_location (enum __hurd_threadvar_index __index) __THROW +- /* This declaration tells the compiler that the value is constant +- given the same argument. We assume this won't be called twice from +- the same stack frame by different threads. */ +- __attribute__ ((__const__)); +- +-#if defined __USE_EXTERN_INLINES && defined _LIBC +-# if IS_IN (libc) +-_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int * +-__hurd_threadvar_location (enum __hurd_threadvar_index __index) +-{ +- return __hurd_threadvar_location_from_sp (__index, +- __thread_stack_pointer ()); +-} +-# endif +-#endif +- ++extern mach_port_t __hurd_reply_port0; ++#define __hurd_local_reply_port (*(__LIBC_NO_TLS() ? &__hurd_reply_port0 : &THREAD_SELF->reply_port)) + + #endif /* hurd/threadvar.h */ +--- a/hurd/hurdsig.c ++++ b/hurd/hurdsig.c +@@ -20,6 +20,7 @@ + #include + + #include /* For `struct mutex'. */ ++#include + #include + #include + +@@ -48,7 +49,6 @@ + /* These are set up by _hurdsig_init. */ + unsigned long int __hurd_sigthread_stack_base; + unsigned long int __hurd_sigthread_stack_end; +-unsigned long int *__hurd_sigthread_variables; + + /* Linked-list of per-thread signal state. */ + struct hurd_sigstate *_hurd_sigstates; +@@ -234,14 +234,14 @@ + that this location can be set without faulting, or else return NULL. */ + + static mach_port_t * +-interrupted_reply_port_location (struct machine_thread_all_state *thread_state, ++interrupted_reply_port_location (thread_t thread, ++ struct machine_thread_all_state *thread_state, + int sigthread) + { +- mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp +- (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP); ++ mach_port_t *portloc = &THREAD_TCB(thread, thread_state)->reply_port; + + if (sigthread && _hurdsig_catch_memory_fault (portloc)) +- /* Faulted trying to read the stack. */ ++ /* Faulted trying to read the TCB. */ + return NULL; + + /* Fault now if this pointer is bogus. */ +@@ -323,7 +323,8 @@ + our nonzero return tells the trampoline code to finish the message + receive operation before running the handler. */ + +- mach_port_t *reply = interrupted_reply_port_location (state, ++ mach_port_t *reply = interrupted_reply_port_location (ss->thread, ++ state, + sigthread); + error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout); + +@@ -835,7 +836,8 @@ + + if (! machine_get_basic_state (ss->thread, &thread_state)) + goto sigbomb; +- loc = interrupted_reply_port_location (&thread_state, 1); ++ loc = interrupted_reply_port_location (ss->thread, ++ &thread_state, 1); + if (loc && *loc != MACH_PORT_NULL) + /* This is the reply port for the context which called + sigreturn. Since we are abandoning that context entirely +@@ -901,7 +903,8 @@ + { + /* Fetch the thread variable for the MiG reply port, + and set it to MACH_PORT_NULL. */ +- mach_port_t *loc = interrupted_reply_port_location (&thread_state, ++ mach_port_t *loc = interrupted_reply_port_location (ss->thread, ++ &thread_state, + 1); + if (loc) + { +@@ -1255,7 +1258,11 @@ + + /* Start the signal thread listening on the message port. */ + +- if (__hurd_threadvar_stack_mask == 0) ++#pragma weak cthread_fork ++#pragma weak cthread_detach ++#pragma weak pthread_getattr_np ++#pragma weak pthread_attr_getstack ++ if (!cthread_fork) + { + err = __thread_create (__mach_task_self (), &_hurd_msgport_thread); + assert_perror (err); +@@ -1270,14 +1277,6 @@ + assert_perror (err); + + __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize; +- __hurd_sigthread_variables = +- malloc (__hurd_threadvar_max * sizeof (unsigned long int)); +- if (__hurd_sigthread_variables == NULL) +- __libc_fatal ("hurd: Can't allocate threadvars for signal thread\n"); +- memset (__hurd_sigthread_variables, 0, +- __hurd_threadvar_max * sizeof (unsigned long int)); +- __hurd_sigthread_variables[_HURD_THREADVAR_LOCALE] +- = (unsigned long int) &_nl_global_locale; + + /* Reinitialize the MiG support routines so they will use a per-thread + variable for the cached reply port. */ +@@ -1288,6 +1287,7 @@ + } + else + { ++ cthread_t thread; + /* When cthreads is being used, we need to make the signal thread a + proper cthread. Otherwise it cannot use mutex_lock et al, which + will be the cthreads versions. Various of the message port RPC +@@ -1297,9 +1297,20 @@ + we'll let the signal thread's per-thread variables be found as for + any normal cthread, and just leave the magic __hurd_sigthread_* + values all zero so they'll be ignored. */ +-#pragma weak cthread_fork +-#pragma weak cthread_detach +- cthread_detach (cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); ++ cthread_detach (thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); ++ ++ if (pthread_getattr_np) ++ { ++ /* Record stack layout for fork() */ ++ pthread_attr_t attr; ++ void *addr; ++ size_t size; ++ ++ pthread_getattr_np ((pthread_t) thread, &attr); ++ pthread_attr_getstack (&attr, &addr, &size); ++ __hurd_sigthread_stack_base = (uintptr_t) addr; ++ __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size; ++ } + + /* XXX We need the thread port for the signal thread further on + in this thread (see hurdfault.c:_hurdsigfault_init). +--- a/hurd/hurdstartup.c ++++ b/hurd/hurdstartup.c +@@ -23,7 +23,6 @@ + #include + #include + #include +-#include + #include + #include + #include +--- a/hurd/sigunwind.c ++++ b/hurd/sigunwind.c +@@ -18,6 +18,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -38,8 +39,7 @@ + { + /* Destroy the MiG reply port used by the signal handler, and restore + the reply port in use by the thread when interrupted. */ +- mach_port_t *reply_port = +- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY); ++ mach_port_t *reply_port = &__hurd_local_reply_port; + if (*reply_port) + { + mach_port_t port = *reply_port; +--- a/include/errno.h ++++ b/include/errno.h +@@ -24,7 +24,7 @@ + + # include + +-# if !defined(__GNU__) ++# if !(defined(__GNU__) && IS_IN (rtld)) + # undef errno + # if IS_IN (libc) + # define errno __libc_errno +--- a/sysdeps/mach/hurd/Versions ++++ b/sysdeps/mach/hurd/Versions +@@ -6,6 +6,7 @@ + GLIBC_PRIVATE { + # Functions shared with the dynamic linker + __libc_read; __libc_write; __libc_lseek64; ++ __libc_lock_self0; + + _dl_init_first; + } +@@ -14,8 +15,6 @@ + ld { + GLIBC_2.0 { + # variables that must be shared with libc +- __hurd_sigthread_stack_base; __hurd_sigthread_stack_end; +- __hurd_sigthread_variables; + __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; + + # functions that must be shared with libc +@@ -33,5 +32,6 @@ + + # functions that must be shared with libc + __libc_read; __libc_write; __libc_lseek64; ++ __libc_lock_self0; + } + } +--- a/sysdeps/mach/hurd/libc-lock.h ++++ b/sysdeps/mach/hurd/libc-lock.h +@@ -24,7 +24,6 @@ + #include + #endif + #include +-#include + + /* The locking here is very inexpensive, even for inlining. */ + #define _IO_lock_inexpensive 1 +@@ -38,7 +37,8 @@ + } __libc_lock_recursive_t; + typedef __libc_lock_recursive_t __rtld_lock_recursive_t; + +-#define __libc_lock_owner_self() ((void *) __hurd_threadvar_location (0)) ++extern char __libc_lock_self0[0]; ++#define __libc_lock_owner_self() (__LIBC_NO_TLS() ? &__libc_lock_self0 : THREAD_SELF) + + #else + typedef struct __libc_lock_opaque__ __libc_lock_t; +--- a/sysdeps/mach/hurd/libc-tsd.h ++++ /dev/null +@@ -1,34 +0,0 @@ +-/* libc-internal interface for thread-specific data. Hurd version. +- Copyright (C) 1998-2018 Free Software Foundation, Inc. +- 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 +- . */ +- +-#ifndef _LIBC_TSD_H +-#define _LIBC_TSD_H 1 +- +-#include +- +-#define __libc_tsd_define(CLASS, TYPE, KEY) /* nothing, always have threadvars */ +- +-#define __libc_tsd_address(TYPE, KEY) \ +- ((TYPE *) __hurd_threadvar_location (_HURD_THREADVAR_##KEY)) +- +-#define __libc_tsd_get(TYPE, KEY) \ +- (*__libc_tsd_address (TYPE, KEY)) +-#define __libc_tsd_set(TYPE, KEY, VALUE) \ +- (*__libc_tsd_address (TYPE, KEY) = (VALUE)) +- +-#endif /* libc-tsd.h */ +--- a/sysdeps/mach/hurd/cthreads.c ++++ b/sysdeps/mach/hurd/cthreads.c +@@ -19,6 +19,8 @@ + #include + #include + ++char __libc_lock_self0[0]; ++ + /* Placeholder for key creation routine from Hurd cthreads library. */ + int + weak_function +--- a/sysdeps/mach/hurd/dl-sysdep.c ++++ b/sysdeps/mach/hurd/dl-sysdep.c +@@ -67,25 +67,6 @@ + + struct hurd_startup_data *_dl_hurd_data; + +-/* This is used only within ld.so, via dl-minimal.c's __errno_location. */ +-#undef errno +-int errno attribute_hidden; +- +-/* Defining these variables here avoids the inclusion of hurdsig.c. */ +-unsigned long int __hurd_sigthread_stack_base; +-unsigned long int __hurd_sigthread_stack_end; +-unsigned long int *__hurd_sigthread_variables; +- +-/* Defining these variables here avoids the inclusion of init-first.c. +- We need to provide temporary storage for the per-thread variables +- of the main user thread here, since it is used for storing the +- `errno' variable. Note that this information is lost once we +- relocate the dynamic linker. */ +-static unsigned long int threadvars[_HURD_THREADVAR_MAX]; +-unsigned long int __hurd_threadvar_stack_offset +- = (unsigned long int) &threadvars; +-unsigned long int __hurd_threadvar_stack_mask; +- + #define FMH defined(__i386__) + #if ! FMH + # define fmh() ((void)0) +--- a/sysdeps/mach/hurd/errno-loc.c ++++ b/sysdeps/mach/hurd/errno-loc.c +@@ -16,13 +16,21 @@ + License along with the GNU C Library; if not, see + . */ + +-#include +-#include +- +-int * ++#if IS_IN (rtld) ++/* ++ * rtld can not access TLS too early, thus rtld_errno. ++ * ++ * Instead of making __open/__close pass errno from TLS to rtld_errno, simply ++ * use a weak __errno_location using rtld_errno, which will be overriden by the ++ * libc definition. ++ */ ++static int rtld_errno; ++int * weak_function + __errno_location (void) + { +- return (int *) __hurd_threadvar_location (_HURD_THREADVAR_ERRNO); ++ return &rtld_errno; + } +-strong_alias (__errno_location, __hurd_errno_location) +-libc_hidden_def (__errno_location) ++libc_hidden_weak (__errno_location) ++#else ++#include <../../../csu/errno-loc.c> ++#endif +--- a/sysdeps/mach/hurd/errno.c ++++ /dev/null +@@ -1 +0,0 @@ +-/* No definition of `errno' variable on the Hurd. */ +--- a/sysdeps/mach/hurd/fork.c ++++ b/sysdeps/mach/hurd/fork.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include /* For stack growth direction. */ +@@ -483,19 +484,17 @@ + (natural_t *) &state, &statecount)) + LOSE; + #ifdef STACK_GROWTH_UP +-#define THREADVAR_SPACE (__hurd_threadvar_max \ +- * sizeof *__hurd_sightread_variables) + if (__hurd_sigthread_stack_base == 0) + { + state.SP &= __hurd_threadvar_stack_mask; +- state.SP += __hurd_threadvar_stack_offset + THREADVAR_SPACE; ++ state.SP += __hurd_threadvar_stack_offset; + } + else + state.SP = __hurd_sigthread_stack_base; + #else + if (__hurd_sigthread_stack_end == 0) + { +- /* The signal thread has a normal stack assigned by cthreads. ++ /* The signal thread has a stack assigned by cthreads. + The threadvar_stack variables conveniently tell us how + to get to the highest address in the stack, just below + the per-thread variables. */ +--- a/sysdeps/mach/hurd/i386/init-first.c ++++ b/sysdeps/mach/hurd/i386/init-first.c +@@ -149,15 +149,6 @@ + char **argv = (void *) (data + 1); + char **envp = &argv[argc + 1]; + struct hurd_startup_data *d; +- unsigned long int threadvars[_HURD_THREADVAR_MAX]; +- +- /* Provide temporary storage for thread-specific variables on the +- startup stack so the cthreads initialization code can use them +- for malloc et al, or so we can use malloc below for the real +- threadvars array. */ +- memset (threadvars, 0, sizeof threadvars); +- threadvars[_HURD_THREADVAR_LOCALE] = (unsigned long int) &_nl_global_locale; +- __hurd_threadvar_stack_offset = (unsigned long int) threadvars; + + /* Since the cthreads initialization code uses malloc, and the + malloc initialization code needs to get at the environment, make +@@ -204,13 +195,6 @@ + __pthread_initialize_minimal (); + #endif + +- /* The user might have defined a value for this, to get more variables. +- Otherwise it will be zero on startup. We must make sure it is set +- properly before before cthreads initialization, so cthreads can know +- how much space to leave for thread variables. */ +- if (__hurd_threadvar_max < _HURD_THREADVAR_MAX) +- __hurd_threadvar_max = _HURD_THREADVAR_MAX; +- + + /* After possibly switching stacks, call `init1' (above) with the user + code as the return address, and the argument data immediately above +@@ -226,11 +210,6 @@ + + __libc_stack_end = newsp; + +- /* Copy per-thread variables from that temporary +- area onto the new cthread stack. */ +- memcpy (__hurd_threadvar_location_from_sp (0, newsp), +- threadvars, sizeof threadvars); +- + /* Copy the argdata from the old stack to the new one. */ + newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data, + (char *) d - (char *) data); +@@ -271,25 +250,10 @@ + } + else + { +- /* We are not using cthreads, so we will have just a single allocated +- area for the per-thread variables of the main user thread. */ +- unsigned long int *array; +- unsigned int i; + int usercode; + + void call_init1 (void); + +- array = malloc (__hurd_threadvar_max * sizeof (unsigned long int)); +- if (array == NULL) +- __libc_fatal ("Can't allocate single-threaded thread variables."); +- +- /* Copy per-thread variables from the temporary array into the +- newly malloc'd space. */ +- memcpy (array, threadvars, sizeof threadvars); +- __hurd_threadvar_stack_offset = (unsigned long int) array; +- for (i = _HURD_THREADVAR_MAX; i < __hurd_threadvar_max; ++i) +- array[i] = 0; +- + /* The argument data is just above the stack frame we will unwind by + returning. Mutate our own return address to run the code below. */ + /* The following expression would typically be written as +--- a/sysdeps/mach/hurd/i386/makecontext-helper.c ++++ b/sysdeps/mach/hurd/i386/makecontext-helper.c +@@ -22,6 +22,7 @@ + #include + #include + ++#if 0 + + void + __makecontext_helper (ucontext_t *ucp) +@@ -67,3 +68,4 @@ + ucp->uc_stack.ss_size -= t_size; + } + } ++#endif +--- a/sysdeps/mach/hurd/i386/makecontext.S ++++ b/sysdeps/mach/hurd/i386/makecontext.S +@@ -27,7 +27,7 @@ + subl $4, %esp + cfi_adjust_cfa_offset (4) + movl %eax, (%esp) +- call HIDDEN_JUMPTARGET (__makecontext_helper) ++ /* call HIDDEN_JUMPTARGET (__makecontext_helper) */ + addl $4, %esp + cfi_adjust_cfa_offset (-4) + +--- a/sysdeps/mach/hurd/i386/sigreturn.c ++++ b/sysdeps/mach/hurd/i386/sigreturn.c +@@ -68,7 +68,7 @@ + + if (scp->sc_onstack) + { +- ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */ ++ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; + /* XXX cannot unlock until off sigstack */ + abort (); + } +@@ -77,8 +77,7 @@ + + /* Destroy the MiG reply port used by the signal handler, and restore the + reply port in use by the thread when interrupted. */ +- reply_port = +- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY); ++ reply_port = &__hurd_local_reply_port; + if (*reply_port) + { + mach_port_t port = *reply_port; +--- a/sysdeps/mach/hurd/i386/tls.h ++++ b/sysdeps/mach/hurd/i386/tls.h +@@ -43,6 +43,10 @@ + void *__private_tm[4]; + /* GCC split stack support. */ + void *__private_ss; ++ ++ /* Keep this field last */ ++ mach_port_t reply_port; /* This thread's reply port. */ ++ struct hurd_sigstate *_hurd_sigstate; + } tcbhead_t; + #endif + +@@ -87,6 +91,17 @@ + | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ + } + ++# define HURD_DESC_TLS(desc) \ ++ ({ \ ++ (tcbhead_t *) ( (desc->low_word >> 16) \ ++ | ((desc->high_word & 0xff) << 16) \ ++ | (desc->high_word & 0xff000000) \ ++ );}) ++ ++#define __LIBC_NO_TLS() \ ++ ({ unsigned short ds, gs; \ ++ asm ("movw %%ds,%w0; movw %%gs,%w1" : "=q" (ds), "=q" (gs)); \ ++ ds == gs; }) + + static inline const char * __attribute__ ((unused)) + _hurd_tls_init (tcbhead_t *tcb) +@@ -137,6 +152,20 @@ + : "i" (offsetof (tcbhead_t, tcb))); \ + __tcb;}) + ++/* Return the TCB address of a thread given its state. */ ++# define THREAD_TCB(thread, thread_state) \ ++ ({ int __sel = (thread_state)->basic.gs; \ ++ struct descriptor __desc, *___desc = &__desc; \ ++ unsigned int __count = 1; \ ++ kern_return_t __err; \ ++ if (__builtin_expect (__sel, 0x48) & 4) /* LDT selector */ \ ++ __err = __i386_get_ldt ((thread), __sel, 1, &___desc, &__count); \ ++ else \ ++ __err = __i386_get_gdt ((thread), __sel, &__desc); \ ++ assert_perror (__err); \ ++ assert (__count == 1); \ ++ HURD_DESC_TLS(___desc);}) ++ + /* Install new dtv for current thread. */ + # define INSTALL_NEW_DTV(dtvp) \ + ({ asm volatile ("movl %0,%%gs:%P1" \ +--- a/sysdeps/mach/hurd/mig-reply.c ++++ b/sysdeps/mach/hurd/mig-reply.c +@@ -18,26 +18,20 @@ + #include + #include + +-#define GETPORT \ +- mach_port_t *portloc = \ +- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY) +-#define reply_port (*(use_threadvar ? portloc : &global_reply_port)) +- +-static int use_threadvar; +-static mach_port_t global_reply_port; +- + /* These functions are called by MiG-generated code. */ + ++mach_port_t __hurd_reply_port0; ++ + /* Called by MiG to get a reply port. */ + mach_port_t + __mig_get_reply_port (void) + { +- GETPORT; +- +- if (reply_port == MACH_PORT_NULL) +- reply_port = __mach_reply_port (); ++ if (__hurd_local_reply_port == MACH_PORT_NULL || ++ (&__hurd_local_reply_port != &__hurd_reply_port0 ++ && __hurd_local_reply_port == __hurd_reply_port0)) ++ __hurd_local_reply_port = __mach_reply_port (); + +- return reply_port; ++ return __hurd_local_reply_port; + } + weak_alias (__mig_get_reply_port, mig_get_reply_port) + +@@ -45,12 +39,8 @@ + void + __mig_dealloc_reply_port (mach_port_t arg) + { +- mach_port_t port; +- +- GETPORT; +- +- port = reply_port; +- reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ ++ mach_port_t port = __hurd_local_reply_port; ++ __hurd_local_reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ + + if (MACH_PORT_VALID (port)) + __mach_port_mod_refs (__mach_task_self (), port, +@@ -73,15 +63,6 @@ + void + __mig_init (void *stack) + { +- use_threadvar = stack != 0; +- +- if (use_threadvar) +- { +- /* Recycle the reply port used before multithreading was enabled. */ +- mach_port_t *portloc = (mach_port_t *) +- __hurd_threadvar_location_from_sp (_HURD_THREADVAR_MIG_REPLY, stack); +- *portloc = global_reply_port; +- global_reply_port = MACH_PORT_NULL; +- } ++ /* Do nothing. */ + } + weak_alias (__mig_init, mig_init) +--- a/sysdeps/mach/hurd/profil.c ++++ b/sysdeps/mach/hurd/profil.c +@@ -143,7 +143,7 @@ + static volatile error_t special_profil_failure; + + /* Fetch PC samples. This function must be very careful not to depend +- on Hurd threadvar variables. We arrange that by using a special ++ on Hurd TLS variables. We arrange that by using a special + stub arranged for at the end of this file. */ + static void + fetch_samples (void) +@@ -178,7 +178,7 @@ + } + + +-/* This function must be very careful not to depend on Hurd threadvar ++/* This function must be very careful not to depend on Hurd TLS + variables. We arrange that by using special stubs arranged for at the + end of this file. */ + static void +@@ -269,7 +269,7 @@ + are fatal in profile_waiter anyhow. */ + #define __mig_put_reply_port(foo) + +-/* Use our static variable instead of the usual threadvar mechanism for ++/* Use our static variable instead of the usual TLS mechanism for + this. */ + #define __mig_get_reply_port() profil_reply_port + diff -Nru glibc-2.27/debian/patches/hurd-i386/git-UTIME.diff glibc-2.27/debian/patches/hurd-i386/git-UTIME.diff --- glibc-2.27/debian/patches/hurd-i386/git-UTIME.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/git-UTIME.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,493 @@ +commit bbe762d1e596d7f5a1cd560a229387cb856916e0 +Author: Flávio Cruz +Date: Mon Mar 5 23:25:00 2018 +0100 + + hurd: Define and pass UTIME_NOW and UTIME_OMIT to new file_utimens RPC + + * sysdeps/mach/hurd/bits/stat.h [__USE_ATFILE] (UTIME_NOW, + UTIME_OMIT): New macros. + * sysdeps/mach/hurd/futimens.c (__futimens): Try to use __file_utimens + before reverting to converting time spec to time value and calling + __file_utimes. + * sysdeps/mach/hurd/utime-helper.c: New file. + * sysdeps/mach/hurd/futimes.c: Include "utime-helper.c". + (__futimes): Try to use utime_ts_from_tval and __file_utimens before + reverting to utime_tvalue_from_tval and __file_utimes. + * sysdeps/mach/hurd/lutimes.c: Include "utime-helper.c". + (__lutimes): Just call hurd_futimens after lookup. + * sysdeps/mach/hurd/utimes.c: Likewise. + +commit ec1300cfc83c716f33ee3231bba0a6e270abfc73 +Author: Samuel Thibault +Date: Tue Mar 6 00:13:54 2018 +0100 + + hurd: Add futimesat and utimensat support + + * sysdeps/mach/hurd/utime-helper.c (hurd_futimens): Rename function to + hurd_futimes. + * sysdeps/mach/hurd/utimes.c (__utimes): Update call accordingly. + * sysdeps/mach/hurd/lutimes.c (__lutimes): Likewise. + * sysdeps/mach/hurd/futimens.c: Include "utime-helper.c". + (__futimens): Move implementation to... + * sysdeps/mach/hurd/utime-helper.c (utime_ts_from_tspec, + utime_tvalue_from_tspec): ... new helper functions. + (hurd_futimens): New function. + * sysdeps/mach/hurd/futimesat.c: New file. + * sysdeps/mach/hurd/utimensat.c: New file. + +Index: glibc-2.27/sysdeps/mach/hurd/bits/stat.h +=================================================================== +--- glibc-2.27.orig/sysdeps/mach/hurd/bits/stat.h ++++ glibc-2.27/sysdeps/mach/hurd/bits/stat.h +@@ -244,6 +244,11 @@ struct stat64 + # define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */ + # define SF_SNAPSHOT 0x00200000 /* snapshot inode */ + ++#ifdef __USE_ATFILE ++# define UTIME_NOW -1 /* corresponds to the current time */ ++# define UTIME_OMIT -2 /* target time is omitted */ ++#endif ++ + __BEGIN_DECLS + + /* Set file flags for FILE to FLAGS. */ +Index: glibc-2.27/sysdeps/mach/hurd/futimens.c +=================================================================== +--- glibc-2.27.orig/sysdeps/mach/hurd/futimens.c ++++ glibc-2.27/sysdeps/mach/hurd/futimens.c +@@ -22,29 +22,29 @@ + #include + #include + ++#include "utime-helper.c" ++ + /* Change the access time of FD to TSP[0] and + the modification time of FD to TSP[1]. */ + int + __futimens (int fd, const struct timespec tsp[2]) + { +- time_value_t atime, mtime; ++ struct timespec atime, mtime; + error_t err; + +- if (tsp == NULL) +- { +- /* Setting the number of microseconds to `-1' tells the +- underlying filesystems to use the current time. */ +- atime.microseconds = mtime.microseconds = -1; +- } +- else ++ utime_ts_from_tspec (tsp, &atime, &mtime); ++ ++ err = HURD_DPORT_USE (fd, __file_utimens (port, atime, mtime)); ++ ++ if (err == MIG_BAD_ID || err == EOPNOTSUPP) + { +- atime.seconds = tsp[0].tv_sec; +- atime.microseconds = tsp[0].tv_nsec / 1000; +- mtime.seconds = tsp[1].tv_sec; +- mtime.microseconds = tsp[1].tv_nsec / 1000; +- } ++ time_value_t atim, mtim; ++ ++ utime_tvalue_from_tspec (tsp, &atim, &mtim); ++ ++ err = HURD_DPORT_USE (fd, __file_utimes (port, atim, mtim)); ++ } + +- err = HURD_DPORT_USE (fd, __file_utimes (port, atime, mtime)); + return err ? __hurd_dfail (fd, err) : 0; + } + weak_alias (__futimens, futimens) +Index: glibc-2.27/sysdeps/mach/hurd/futimes.c +=================================================================== +--- glibc-2.27.orig/sysdeps/mach/hurd/futimes.c ++++ glibc-2.27/sysdeps/mach/hurd/futimes.c +@@ -22,29 +22,29 @@ + #include + #include + ++#include "utime-helper.c" ++ + /* Change the access time of FD to TVP[0] and + the modification time of FD to TVP[1]. */ + int + __futimes (int fd, const struct timeval tvp[2]) + { +- union tv +- { +- struct timeval tv; +- time_value_t tvt; +- }; +- const union tv *u = (const union tv *) tvp; +- union tv nulltv[2]; ++ struct timespec atime, mtime; + error_t err; + +- if (tvp == NULL) ++ utime_ts_from_tval (tvp, &atime, &mtime); ++ ++ err = HURD_DPORT_USE (fd, __file_utimens (port, atime, mtime)); ++ ++ if (err == EMIG_BAD_ID || err == EOPNOTSUPP) + { +- /* Setting the number of microseconds to `-1' tells the +- underlying filesystems to use the current time. */ +- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; +- u = nulltv; ++ time_value_t atim, mtim; ++ ++ utime_tvalue_from_tval (tvp, &atim, &mtim); ++ ++ err = HURD_DPORT_USE (fd, __file_utimes (port, atim, mtim)); + } + +- err = HURD_DPORT_USE (fd, __file_utimes (port, u[0].tvt, u[1].tvt)); + return err ? __hurd_dfail (fd, err) : 0; + } + weak_alias (__futimes, futimes) +Index: glibc-2.27/sysdeps/mach/hurd/lutimes.c +=================================================================== +--- glibc-2.27.orig/sysdeps/mach/hurd/lutimes.c ++++ glibc-2.27/sysdeps/mach/hurd/lutimes.c +@@ -22,33 +22,22 @@ + #include + #include + ++#include "utime-helper.c" ++ + /* Change the access time of FILE to TVP[0] and + the modification time of FILE to TVP[1]. */ + int + __lutimes (const char *file, const struct timeval tvp[2]) + { +- union tv +- { +- struct timeval tv; +- time_value_t tvt; +- }; +- const union tv *u = (const union tv *) tvp; +- union tv nulltv[2]; + error_t err; + file_t port; + +- if (tvp == NULL) +- { +- /* Setting the number of microseconds to `-1' tells the +- underlying filesystems to use the current time. */ +- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; +- u = nulltv; +- } +- + port = __file_name_lookup (file, O_NOLINK, 0); + if (port == MACH_PORT_NULL) + return -1; +- err = __file_utimes (port, u[0].tvt, u[1].tvt); ++ ++ err = hurd_futimes (port, tvp); ++ + __mach_port_deallocate (__mach_task_self (), port); + if (err) + return __hurd_fail (err); +Index: glibc-2.27/sysdeps/mach/hurd/utime-helper.c +=================================================================== +--- /dev/null ++++ glibc-2.27/sysdeps/mach/hurd/utime-helper.c +@@ -0,0 +1,154 @@ ++/* Helpers for utimes/utimens conversions. ++ Copyright (C) 2015-2018 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++ ++/* Initializes atime/mtime timespec structures from an array of timeval. */ ++static inline void ++utime_ts_from_tval (const struct timeval tvp[2], ++ struct timespec *atime, struct timespec *mtime) ++{ ++ if (tvp == NULL) ++ { ++ /* Setting the number of nanoseconds to UTIME_NOW tells the ++ underlying filesystems to use the current time. */ ++ atime->tv_sec = 0; ++ atime->tv_nsec = UTIME_NOW; ++ mtime->tv_sec = 0; ++ mtime->tv_nsec = UTIME_NOW; ++ } ++ else ++ { ++ TIMEVAL_TO_TIMESPEC (&tvp[0], atime); ++ TIMEVAL_TO_TIMESPEC (&tvp[1], mtime); ++ } ++} ++ ++/* Initializes atime/mtime time_value_t structures from an array of timeval. */ ++static inline void ++utime_tvalue_from_tval (const struct timeval tvp[2], ++ time_value_t *atime, time_value_t *mtime) ++{ ++ if (tvp == NULL) ++ /* Setting the number of microseconds to `-1' tells the ++ underlying filesystems to use the current time. */ ++ atime->microseconds = mtime->microseconds = -1; ++ else ++ { ++ atime->seconds = tvp[0].tv_sec; ++ atime->microseconds = tvp[0].tv_usec; ++ mtime->seconds = tvp[1].tv_sec; ++ mtime->microseconds = tvp[1].tv_usec; ++ } ++} ++ ++/* Changes the access time of the file behind PORT using a timeval array. */ ++static inline error_t ++hurd_futimes (const file_t port, const struct timeval tvp[2]) ++{ ++ error_t err; ++ struct timespec atime, mtime; ++ ++ utime_ts_from_tval (tvp, &atime, &mtime); ++ ++ err = __file_utimens (port, atime, mtime); ++ ++ if (err == MIG_BAD_ID || err == EOPNOTSUPP) ++ { ++ time_value_t atim, mtim; ++ ++ utime_tvalue_from_tval (tvp, &atim, &mtim); ++ ++ err = __file_utimes (port, atim, mtim); ++ } ++ ++ return err; ++} ++ ++/* Initializes atime/mtime timespec structures from an array of timespec. */ ++static inline void ++utime_ts_from_tspec (const struct timespec tsp[2], ++ struct timespec *atime, struct timespec *mtime) ++{ ++ if (tsp == NULL) ++ { ++ /* Setting the number of nanoseconds to UTIME_NOW tells the ++ underlying filesystems to use the current time. */ ++ atime->tv_sec = 0; ++ atime->tv_nsec = UTIME_NOW; ++ mtime->tv_sec = 0; ++ mtime->tv_nsec = UTIME_NOW; ++ } ++ else ++ { ++ *atime = tsp[0]; ++ *mtime = tsp[1]; ++ } ++} ++ ++/* Initializes atime/mtime time_value_t structures from an array of timespec. */ ++static inline void ++utime_tvalue_from_tspec (const struct timespec tsp[2], ++ time_value_t *atime, time_value_t *mtime) ++{ ++ if (tsp == NULL) ++ /* Setting the number of microseconds to `-1' tells the ++ underlying filesystems to use the current time. */ ++ atime->microseconds = mtime->microseconds = -1; ++ else ++ { ++ if (tsp[0].tv_nsec == UTIME_NOW) ++ atime->microseconds = -1; ++ else if (tsp[0].tv_nsec == UTIME_OMIT) ++ atime->microseconds = -2; ++ else ++ TIMESPEC_TO_TIME_VALUE (atime, &(tsp[0])); ++ if (tsp[1].tv_nsec == UTIME_NOW) ++ mtime->microseconds = -1; ++ else if (tsp[1].tv_nsec == UTIME_OMIT) ++ mtime->microseconds = -2; ++ else ++ TIMESPEC_TO_TIME_VALUE (mtime, &(tsp[1])); ++ } ++} ++ ++/* Changes the access time of the file behind PORT using a timespec array. */ ++static inline error_t ++hurd_futimens (const file_t port, const struct timespec tsp[2]) ++{ ++ error_t err; ++ struct timespec atime, mtime; ++ ++ utime_ts_from_tspec (tsp, &atime, &mtime); ++ ++ err = __file_utimens (port, atime, mtime); ++ ++ if (err == MIG_BAD_ID || err == EOPNOTSUPP) ++ { ++ time_value_t atim, mtim; ++ ++ utime_tvalue_from_tspec (tsp, &atim, &mtim); ++ ++ err = __file_utimes (port, atim, mtim); ++ } ++ ++ return err; ++} +Index: glibc-2.27/sysdeps/mach/hurd/utimes.c +=================================================================== +--- glibc-2.27.orig/sysdeps/mach/hurd/utimes.c ++++ glibc-2.27/sysdeps/mach/hurd/utimes.c +@@ -20,33 +20,22 @@ + #include + #include + ++#include "utime-helper.c" ++ + /* Change the access time of FILE to TVP[0] and + the modification time of FILE to TVP[1]. */ + int + __utimes (const char *file, const struct timeval tvp[2]) + { +- union tv +- { +- struct timeval tv; +- time_value_t tvt; +- }; +- const union tv *u = (const union tv *) tvp; +- union tv nulltv[2]; + error_t err; + file_t port; + +- if (tvp == NULL) +- { +- /* Setting the number of microseconds to `-1' tells the +- underlying filesystems to use the current time. */ +- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; +- u = nulltv; +- } +- + port = __file_name_lookup (file, 0, 0); + if (port == MACH_PORT_NULL) + return -1; +- err = __file_utimes (port, u[0].tvt, u[1].tvt); ++ ++ err = hurd_futimes (port, tvp); ++ + __mach_port_deallocate (__mach_task_self (), port); + if (err) + return __hurd_fail (err); +Index: glibc-2.27/sysdeps/mach/hurd/futimesat.c +=================================================================== +--- /dev/null ++++ glibc-2.27/sysdeps/mach/hurd/futimesat.c +@@ -0,0 +1,44 @@ ++/* Copyright (C) 1991-2018 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "utime-helper.c" ++ ++/* Change the access time of FILE relative to FD to TVP[0] and ++ the modification time of FILE to TVP[1]. */ ++int ++futimesat (int fd, const char *file, const struct timeval tvp[2]) ++{ ++ error_t err; ++ file_t port; ++ ++ port = __file_name_lookup_at (fd, 0, file, 0, 0); ++ if (port == MACH_PORT_NULL) ++ return -1; ++ ++ err = hurd_futimes (port, tvp); ++ ++ __mach_port_deallocate (__mach_task_self (), port); ++ if (err) ++ return __hurd_fail (err); ++ return 0; ++} +Index: glibc-2.27/sysdeps/mach/hurd/utimensat.c +=================================================================== +--- /dev/null ++++ glibc-2.27/sysdeps/mach/hurd/utimensat.c +@@ -0,0 +1,46 @@ ++/* Change access and modification times of open file. Hurd version. ++ Copyright (C) 1991-2018 Free Software Foundation, Inc. ++ 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "utime-helper.c" ++ ++/* Change the access time of FILE to TSP[0] and ++ the modification time of FILE to TSP[1]. */ ++int ++utimensat (int fd, const char *file, const struct timespec tsp[2], ++ int flags) ++{ ++ error_t err; ++ file_t port; ++ ++ port = __file_name_lookup_at (fd, flags, file, 0, 0); ++ if (port == MACH_PORT_NULL) ++ return -1; ++ ++ err = hurd_futimens (port, tsp); ++ ++ __mach_port_deallocate (__mach_task_self (), port); ++ if (err) ++ return __hurd_fail (err); ++ return 0; ++} diff -Nru glibc-2.27/debian/patches/hurd-i386/libpthread_sigs.diff glibc-2.27/debian/patches/hurd-i386/libpthread_sigs.diff --- glibc-2.27/debian/patches/hurd-i386/libpthread_sigs.diff 1970-01-01 00:00:00.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/libpthread_sigs.diff 2018-04-16 20:02:33.000000000 +0000 @@ -0,0 +1,82 @@ +To be activated with glibc 2.28 to re-install thread signal dispatch + +Revert of +commit 5049fabcfad4d5197669e5aa13d4d5f87f39d0bb +Author: Samuel Thibault +Date: Thu Jan 25 01:47:51 2018 +0100 + + Until posix thread signal distribution is commited + +diff --git b/htl/sysdeps/mach/hurd/pt-sigstate-destroy.c a/htl/sysdeps/mach/hurd/pt-sigstate-destroy.c +index fce56c5d0d..d5e28d22d8 100644 +--- b/htl/sysdeps/mach/hurd/pt-sigstate-destroy.c ++++ a/htl/sysdeps/mach/hurd/pt-sigstate-destroy.c +@@ -24,4 +24,5 @@ + void + __pthread_sigstate_destroy (struct __pthread *thread) + { ++ _hurd_sigstate_delete (thread->kernel_thread); + } +diff --git b/htl/sysdeps/mach/hurd/pt-sigstate-init.c a/htl/sysdeps/mach/hurd/pt-sigstate-init.c +index 660d5a02a6..4848f2ea91 100644 +--- b/htl/sysdeps/mach/hurd/pt-sigstate-init.c ++++ a/htl/sysdeps/mach/hurd/pt-sigstate-init.c +@@ -36,7 +36,7 @@ __pthread_sigstate_init (struct __pthread *thread) + if (do_init_global) + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (thread->kernel_thread); +- (void) ss; ++ _hurd_sigstate_set_global_rcv (ss); + } + else if (__pthread_num_threads >= 2) + do_init_global = 1; + + +Revert of +commit 797492f8769ced63b209246858c0550e23009e40 +Author: Samuel Thibault +Date: Thu Jan 25 01:49:49 2018 +0100 + + Revert signal disposition, not in glibc's cvs yet + +diff --git b/htl/sysdeps/mach/hurd/pt-sigstate.c a/htl/sysdeps/mach/hurd/pt-sigstate.c +index bae6ae7c45..74fd72a2c0 100644 +--- b/htl/sysdeps/mach/hurd/pt-sigstate.c ++++ a/htl/sysdeps/mach/hurd/pt-sigstate.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include + +@@ -31,11 +32,12 @@ __pthread_sigstate (struct __pthread *thread, int how, + { + error_t err = 0; + struct hurd_sigstate *ss; ++ sigset_t pending; + + ss = _hurd_thread_sigstate (thread->kernel_thread); + assert (ss); + +- __spin_lock (&ss->lock); ++ _hurd_sigstate_lock (ss); + + if (oset) + *oset = ss->blocked; +@@ -66,7 +68,13 @@ __pthread_sigstate (struct __pthread *thread, int how, + if (! err && clear_pending) + __sigemptyset (&ss->pending); + +- __spin_unlock (&ss->lock); ++ pending = _hurd_sigstate_pending (ss) & ~ss->blocked; ++ _hurd_sigstate_unlock (ss); ++ ++ if (! err && pending) ++ /* Send a message to the signal thread so it ++ will wake up and check for pending signals. */ ++ __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); + + return err; + } diff -Nru glibc-2.27/debian/patches/hurd-i386/local-libpthread-stacksize.diff glibc-2.27/debian/patches/hurd-i386/local-libpthread-stacksize.diff --- glibc-2.27/debian/patches/hurd-i386/local-libpthread-stacksize.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/local-libpthread-stacksize.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Set the default stack size to 8MiB like on Linux, to avoid surprises -with packages which assume the Linuxish default. - ---- - pt-sysdep.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) -Index: glibc-2.19/libpthread/sysdeps/mach/hurd/pt-sysdep.h -=================================================================== ---- glibc-2.19.orig/libpthread/sysdeps/mach/hurd/pt-sysdep.h -+++ glibc-2.19/libpthread/sysdeps/mach/hurd/pt-sysdep.h -@@ -26,7 +26,7 @@ - #define _POSIX_THREAD_THREADS_MAX 64 - - /* The default stack size. */ --#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024) -+#define PTHREAD_STACK_DEFAULT (8 * 1024 * 1024) - - #define PTHREAD_SYSDEP_MEMBERS \ - thread_t kernel_thread; \ diff -Nru glibc-2.27/debian/patches/hurd-i386/local-nocheck-installed-headers.diff glibc-2.27/debian/patches/hurd-i386/local-nocheck-installed-headers.diff --- glibc-2.27/debian/patches/hurd-i386/local-nocheck-installed-headers.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/local-nocheck-installed-headers.diff 2018-04-16 20:02:33.000000000 +0000 @@ -1,3 +1,5 @@ +TODO: Will be fixed in glibc 2.28 + --- a/scripts/check-installed-headers.sh +++ b/scripts/check-installed-headers.sh @@ -83,6 +83,10 @@ diff -Nru glibc-2.27/debian/patches/hurd-i386/submitted-hurd-abilist.diff glibc-2.27/debian/patches/hurd-i386/submitted-hurd-abilist.diff --- glibc-2.27/debian/patches/hurd-i386/submitted-hurd-abilist.diff 2016-03-10 10:14:20.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/submitted-hurd-abilist.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -2016-02-29 Aurelien Jarno - - * sysdeps/generic/libnsl.abilist: New file. - * sysdeps/generic/libutil.abilist: New file. - * sysdeps/mach/hurd/libhurduser.abilist: New file. - * sysdeps/mach/libmachuser.abilist: New file. - ---- /dev/null -+++ b/sysdeps/generic/libnsl.abilist -@@ -0,0 +1 @@ -+ ---- /dev/null -+++ b/sysdeps/generic/libutil.abilist -@@ -0,0 +1 @@ -+ ---- /dev/null -+++ b/sysdeps/mach/hurd/libhurduser.abilist -@@ -0,0 +1 @@ -+ ---- /dev/null -+++ b/sysdeps/mach/libmachuser.abilist -@@ -0,0 +1 @@ -+ diff -Nru glibc-2.27/debian/patches/hurd-i386/submitted-malloc-setstate.diff glibc-2.27/debian/patches/hurd-i386/submitted-malloc-setstate.diff --- glibc-2.27/debian/patches/hurd-i386/submitted-malloc-setstate.diff 2017-09-03 20:41:15.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/submitted-malloc-setstate.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -https://sourceware.org/ml/libc-alpha/2016-07/msg00175.html - -diff --git a/malloc/malloc.c b/malloc/malloc.c -index 1f5f166..beb97e9 100644 ---- a/malloc/malloc.c -+++ b/malloc/malloc.c -@@ -2600,13 +2600,12 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) - { - /* - Skip over some bytes to arrive at an aligned position. -- We don't need to specially mark these wasted front bytes. -- They will never be accessed anyway because -- prev_inuse of av->top (and any chunk created from its start) -- is always true after initialization. -+ We zero them for malloc_set_state to properly find the -+ first chunk. - */ - - correction = MALLOC_ALIGNMENT - front_misalign; -+ memset (brk, 0, correction); - aligned_brk += correction; - } - -@@ -2661,13 +2660,13 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) - { - /* - Skip over some bytes to arrive at an aligned position. -- We don't need to specially mark these wasted front bytes. -- They will never be accessed anyway because -- prev_inuse of av->top (and any chunk created from its start) -- is always true after initialization. -+ We zero them for malloc_set_state to properly find -+ the first chunk. - */ - -- aligned_brk += MALLOC_ALIGNMENT - front_misalign; -+ correction = MALLOC_ALIGNMENT - front_misalign; -+ memset (brk, 0, correction); -+ aligned_brk += correction; - } - } - -@@ -2682,6 +2681,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) - if (snd_brk != (char *) (MORECORE_FAILURE)) - { - av->top = (mchunkptr) aligned_brk; -+ prev_size(av->top) = 0; - set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); - av->system_mem += correction; - diff -Nru glibc-2.27/debian/patches/hurd-i386/tg2.25-tls.diff glibc-2.27/debian/patches/hurd-i386/tg2.25-tls.diff --- glibc-2.27/debian/patches/hurd-i386/tg2.25-tls.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg2.25-tls.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] Fix tls support for glibc 2.25 - -* csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call -__libc_setup_tls. -* sysdeps/mach/hurd/i386/init-first.c (init): Call __libc_setup_tls. - -Signed-off-by: Samuel Thibault - ---- - csu/libc-start.c | 2 ++ - sysdeps/mach/hurd/i386/init-first.c | 3 ++- - 2 files changed, 4 insertions(+), 1 deletion(-) - -Index: glibc-2.26/csu/libc-start.c -=================================================================== ---- glibc-2.26.orig/csu/libc-start.c -+++ glibc-2.26/csu/libc-start.c -@@ -193,8 +193,10 @@ LIBC_START_MAIN (int (*main) (int, char - /* Perform IREL{,A} relocations. */ - ARCH_SETUP_IREL (); - -+#ifndef __GNU__ - /* The stack guard goes into the TCB, so initialize it early. */ - __libc_setup_tls (); -+#endif - - /* In some architectures, IREL{,A} relocations happen after TLS setup in - order to let IFUNC resolvers benefit from TCB information, e.g. powerpc's -Index: glibc-2.26/sysdeps/mach/hurd/i386/init-first.c -=================================================================== ---- glibc-2.26.orig/sysdeps/mach/hurd/i386/init-first.c -+++ glibc-2.26/sysdeps/mach/hurd/i386/init-first.c -@@ -189,7 +189,8 @@ init (int *data) - assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); - } - -- /* We need to setup TLS before starting sigthread */ -+ /* We need to setup TLS before starting sigthread and set stack guard. */ -+ __libc_setup_tls (); - extern void __pthread_initialize_minimal(void); - if (__pthread_initialize_minimal != NULL) - __pthread_initialize_minimal(); diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-_dl_random.diff glibc-2.27/debian/patches/hurd-i386/tg-_dl_random.diff --- glibc-2.27/debian/patches/hurd-i386/tg-_dl_random.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-_dl_random.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -From: Thomas Schwinge -Subject: [PATCH] _dl_random - -_dl_random - ---- - - /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `security_init': - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/rtld.c:844: undefined reference to `_dl_random' - /media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: relocation R_386_GOTOFF against undefined hidden symbol `_dl_random' can not be used when making a shared object - /media/data/home/thomas/tmp/gnu-2/bin/../lib/gcc/i586-pc-gnu/4.3.3/../../../../i586-pc-gnu/bin/ld: final link failed: Bad value - collect2: ld returned 1 exit status - make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1 - - sysdeps/mach/hurd/dl-sysdep.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/sysdeps/mach/hurd/dl-sysdep.c -+++ b/sysdeps/mach/hurd/dl-sysdep.c -@@ -61,6 +61,8 @@ - hp_timing_t _dl_cpuclock_offset; - #endif - -+/* TODO: this is never properly initialized in here. */ -+void *_dl_random attribute_relro = NULL; - - struct hurd_startup_data *_dl_hurd_data; - diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-exec-static.diff glibc-2.27/debian/patches/hurd-i386/tg-exec-static.diff --- glibc-2.27/debian/patches/hurd-i386/tg-exec-static.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-exec-static.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] Fix boot with statically-linked exec server. - -* sysdeps/mach/hurd/i386/init-first.c (init): Also find ELF headers by oneself -when the pointer given in D is nul (as set by ext2fs). - -Signed-off-by: Samuel Thibault - ---- - sysdeps/mach/hurd/i386/init-first.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/sysdeps/mach/hurd/i386/init-first.c -+++ b/sysdeps/mach/hurd/i386/init-first.c -@@ -168,7 +168,7 @@ init (int *data) - /* If we are the bootstrap task started by the kernel, - then after the environment pointers there is no Hurd - data block; the argument strings start there. */ -- if ((void *) d == argv[0]) -+ if ((void *) d == argv[0] || !d->phdr) - { - /* With a new enough linker (binutils-2.23 or better), - the magic __ehdr_start symbol will be available and diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-futimens.diff glibc-2.27/debian/patches/hurd-i386/tg-futimens.diff --- glibc-2.27/debian/patches/hurd-i386/tg-futimens.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-futimens.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] Add futimens support - -* sysdeps/mach/hurd/futimens.c: New file. - -Signed-off-by: Samuel Thibault - ---- - sysdeps/mach/hurd/futimens.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 50 insertions(+) - -diff --git a/sysdeps/mach/hurd/futimens.c b/sysdeps/mach/hurd/futimens.c -new file mode 100644 -index 0000000..218779d ---- /dev/null -+++ b/sysdeps/mach/hurd/futimens.c -@@ -0,0 +1,50 @@ -+/* futimes -- change access and modification times of open file. Hurd version. -+ Copyright (C) 2002-2014 Free Software Foundation, Inc. -+ 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 -+ . */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+/* Change the access time of FD to TSP[0] and -+ the modification time of FD to TSP[1]. */ -+int -+__futimens (int fd, const struct timespec tsp[2]) -+{ -+ time_value_t atime, mtime; -+ error_t err; -+ -+ if (tsp == NULL) -+ { -+ /* Setting the number of microseconds to `-1' tells the -+ underlying filesystems to use the current time. */ -+ atime.microseconds = mtime.microseconds = -1; -+ } -+ else -+ { -+ atime.seconds = tsp[0].tv_sec; -+ atime.microseconds = tsp[0].tv_nsec / 1000; -+ mtime.seconds = tsp[1].tv_sec; -+ mtime.microseconds = tsp[1].tv_nsec / 1000; -+ } -+ -+ err = HURD_DPORT_USE (fd, __file_utimes (port, atime, mtime)); -+ return err ? __hurd_dfail (fd, err) : 0; -+} -+weak_alias (__futimens, futimens) --- -tg: (9a079e2..) futimens (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-gai_misc.diff glibc-2.27/debian/patches/hurd-i386/tg-gai_misc.diff --- glibc-2.27/debian/patches/hurd-i386/tg-gai_misc.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-gai_misc.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] t/gai_misc - -Add a hurd version of threaded gai_misc.h - -Signed-off-by: Samuel Thibault - ---- - sysdeps/mach/hurd/gai_misc.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 44 insertions(+) - -diff --git a/sysdeps/mach/hurd/gai_misc.h b/sysdeps/mach/hurd/gai_misc.h -new file mode 100644 -index 0000000..ee8117f ---- /dev/null -+++ b/sysdeps/mach/hurd/gai_misc.h -@@ -0,0 +1,44 @@ -+#include -+#include -+ -+#define gai_start_notify_thread __gai_start_notify_thread -+#define gai_create_helper_thread __gai_create_helper_thread -+ -+extern inline void -+__gai_start_notify_thread (void) -+{ -+ sigset_t ss; -+ sigemptyset (&ss); -+ sigprocmask(SIG_SETMASK, &ss, NULL); -+} -+ -+extern inline int -+__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), -+ void *arg) -+{ -+ pthread_attr_t attr; -+ -+ /* Make sure the thread is created detached. */ -+ pthread_attr_init (&attr); -+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); -+ -+ /* The helper thread needs only very little resources. */ -+ (void) pthread_attr_setstacksize (&attr, 0x10000); -+ -+ /* Block all signals in the helper thread. To do this thoroughly we -+ temporarily have to block all signals here. */ -+ sigset_t ss; -+ sigset_t oss; -+ sigfillset (&ss); -+ sigprocmask(SIG_SETMASK, &ss, &oss); -+ -+ int ret = pthread_create (threadp, &attr, tf, arg); -+ -+ /* Restore the signal mask. */ -+ sigprocmask(SIG_SETMASK, &oss, NULL); -+ -+ (void) pthread_attr_destroy (&attr); -+ return ret; -+} -+ -+#include_next --- -tg: (9a079e2..) t/gai_misc (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-grantpt.diff glibc-2.27/debian/patches/hurd-i386/tg-grantpt.diff --- glibc-2.27/debian/patches/hurd-i386/tg-grantpt.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-grantpt.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -From: Thomas Schwinge -Subject: [PATCH] t/grantpt - - /media/Stalin/tmp/glibc.hurd.gnu-2/libc_pic.os: In function `pts_name': - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/login/../sysdeps/unix/grantpt.c:52: undefined reference to `__ptsname_internal' - collect2: ld returned 1 exit status - make[1]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/libc.so] Error 1 - -Cf. aa9890239a2aef81e64f3f22a31c7e01b6501f69 - -Need any of the checks (stat, etc.) that Linux' __ptsname_internal does? - -Implement close_all_fds as in 139ee080b6b428240bf49f3e6361f3ac729f891a? - ---- - sysdeps/mach/hurd/ptsname.c | 23 +++++++++++++++++++---- - 1 file changed, 19 insertions(+), 4 deletions(-) - -diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c -index 2978394eb5..73ec57dd70 100644 ---- a/sysdeps/mach/hurd/ptsname.c -+++ b/sysdeps/mach/hurd/ptsname.c -@@ -18,6 +18,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -38,11 +39,9 @@ ptsname (int fd) - } - - --/* Store at most BUFLEN characters of the pathname of the slave pseudo -- terminal associated with the master FD is open on in BUF. -- Return 0 on success, otherwise an error number. */ -+/* We don't need STP, but fill it for conformity with the Linux version... */ - int --__ptsname_r (int fd, char *buf, size_t buflen) -+__ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp) - { - string_t peername; - size_t len; -@@ -58,7 +57,23 @@ __ptsname_r (int fd, char *buf, size_t buflen) - return ERANGE; - } - -+ if (stp) -+ { -+ if (__xstat64 (_STAT_VER, peername, stp) < 0) -+ return errno; -+ } -+ - memcpy (buf, peername, len); - return 0; - } -+ -+ -+/* Store at most BUFLEN characters of the pathname of the slave pseudo -+ terminal associated with the master FD is open on in BUF. -+ Return 0 on success, otherwise an error number. */ -+int -+__ptsname_r (int fd, char *buf, size_t buflen) -+{ -+ return __ptsname_internal (fd, buf, buflen, NULL); -+} - weak_alias (__ptsname_r, ptsname_r) --- -tg: (7bb5f8a836..) t/grantpt (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-gscope.diff glibc-2.27/debian/patches/hurd-i386/tg-gscope.diff --- glibc-2.27/debian/patches/hurd-i386/tg-gscope.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-gscope.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -From: Thomas Schwinge -Subject: [PATCH] gscope - -Minimal gscope stuff. - -glibc-2.8/debian/patches/hurd-i386/local-gscope.diff 3085 - -Written by Samuel Thibault. - ---- - -I think that's the corresponding error message: - - /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_dependency': - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:106: undefined reference to `atomic_forced_read' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:109: undefined reference to `atomic_read_barrier' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:113: undefined reference to `atomic_forced_read' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:141: undefined reference to `THREAD_GSCOPE_RESET_FLAG' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:147: undefined reference to `atomic_forced_read' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:284: undefined reference to `THREAD_GSCOPE_SET_FLAG' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:261: undefined reference to `atomic_write_barrier' - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-lookup.c:250: undefined reference to `atomic_write_barrier' - /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `add_to_global': - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:162: undefined reference to `atomic_write_barrier' - /media/Stalin/tmp/glibc.hurd.gnu-2/elf/librtld.os: In function `dl_open_worker': - /media/data/home/thomas/tmp/source/glibc/git/glibc.hurd/elf/dl-open.c:478: undefined reference to `atomic_write_barrier' - collect2: ld returned 1 exit status - make[2]: *** [/media/Stalin/tmp/glibc.hurd.gnu-2/elf/ld.so] Error 1 - - elf/dl-support.c | 1 + - sysdeps/generic/ldsodefs.h | 1 + - sysdeps/mach/hurd/sysdep-cancel.h | 9 +++++++++ - sysdeps/mach/hurd/tls.h | 13 +++++++++++++ - 4 files changed, 24 insertions(+) - ---- a/elf/dl-support.c -+++ b/elf/dl-support.c -@@ -196,6 +196,7 @@ int (*_dl_make_stack_executable_hook) (v - /* Function in libpthread to wait for termination of lookups. */ - void (*_dl_wait_lookup_done) (void); - -+int volatile _dl_thread_gscope_count; - struct dl_scope_free_list *_dl_scope_free_list; - - #ifdef NEED_DL_SYSINFO ---- a/sysdeps/generic/ldsodefs.h -+++ b/sysdeps/generic/ldsodefs.h -@@ -409,6 +409,7 @@ struct rtld_global - size_t count; - void *list[50]; - } *_dl_scope_free_list; -+ EXTERN volatile int _dl_thread_gscope_count; - #ifdef SHARED - }; - # define __rtld_global_attribute__ ---- /dev/null -+++ b/sysdeps/mach/hurd/sysdep-cancel.h -@@ -0,0 +1,9 @@ -+#include -+ -+/* Always multi-thread (since there's at least the sig handler), but no -+ handling enabled. */ -+#define SINGLE_THREAD_P (0) -+#define RTLD_SINGLE_THREAD_P (0) -+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ -+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -+#define LIBC_CANCEL_HANDLED() /* Nothing. */ ---- a/sysdeps/mach/hurd/tls.h -+++ b/sysdeps/mach/hurd/tls.h -@@ -75,5 +75,18 @@ typedef struct - - #endif /* !ASSEMBLER */ - -+#ifndef __ASSEMBLER__ -+#include -+#include -+/* Temporary poor-man's global scope switch support: just busy-waits */ -+#define THREAD_GSCOPE_SET_FLAG() \ -+ asm volatile ("lock incl %0":"=m"(GL(dl_thread_gscope_count))) -+#define THREAD_GSCOPE_RESET_FLAG() \ -+ asm volatile ("lock decl %0":"=m"(GL(dl_thread_gscope_count))) -+#define THREAD_GSCOPE_WAIT() \ -+ while (GL(dl_thread_gscope_count)) { \ -+ __swtch_pri (0); \ -+ } -+#endif - - #endif /* tls.h */ diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff --- glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,1378 +0,0 @@ -commit f6839074d25aba7e93b8672a9ed9893c0baa5e3d -Author: Agustina Arzille -Date: Mon Oct 17 00:56:58 2016 +0200 - - Make pthread_mutex use gsync - -diff --git a/libpthread/include/pthread/pthread.h b/libpthread/include/pthread/pthread.h -index 350a673..ad34e5d 100644 ---- a/libpthread/include/pthread/pthread.h -+++ b/libpthread/include/pthread/pthread.h -@@ -271,6 +271,11 @@ extern pthread_t pthread_self (void) __THROW; - #define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_TIMED_NP - #endif - -+#ifdef __USE_XOPEN2K -+#define PTHREAD_MUTEX_STALLED __PTHREAD_MUTEX_STALLED -+#define PTHREAD_MUTEX_ROBUST __PTHREAD_MUTEX_ROBUST -+#endif -+ - #include - - /* Initialize the mutex attribute object in *ATTR to the default -@@ -399,6 +404,18 @@ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, - __THROW __nonnull ((1, 3)); - #endif - -+#ifdef __USE_XOPEN2K8 -+ -+/* Declare the state protected by robust mutex MTXP as consistent. */ -+extern int pthread_mutex_consistent (pthread_mutex_t *__mtxp) -+ __THROW __nonnull ((1)); -+ -+# ifdef __USE_GNU -+extern int pthread_mutex_consistent_np (pthread_mutex_t *__mtxp) -+ __THROW __nonnull ((1)); -+# endif -+#endif -+ - - - /* Condition attributes. */ -diff --git a/libpthread/include/pthread/pthreadtypes.h b/libpthread/include/pthread/pthreadtypes.h -index 33bd009..d8aed4d 100644 ---- a/libpthread/include/pthread/pthreadtypes.h -+++ b/libpthread/include/pthread/pthreadtypes.h -@@ -77,6 +77,12 @@ enum __pthread_mutex_type - __PTHREAD_MUTEX_RECURSIVE - }; - -+enum __pthread_mutex_robustness -+ { -+ __PTHREAD_MUTEX_STALLED, -+ __PTHREAD_MUTEX_ROBUST = 0x100 -+ }; -+ - #include - typedef struct __pthread_mutexattr pthread_mutexattr_t; - -diff --git a/libpthread/sysdeps/mach/hurd/bits/mutex.h b/libpthread/sysdeps/mach/hurd/bits/mutex.h -new file mode 100644 -index 0000000..a52a2ad ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/bits/mutex.h -@@ -0,0 +1,64 @@ -+/* Mutex type. Generic version. -+ -+ Copyright (C) 2000-2016 -+ Free Software Foundation, Inc. -+ -+ 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 Library General Public License as -+ published by the Free Software Foundation; either version 2 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 -+ Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with the GNU C Library; see the file COPYING.LIB. If not, -+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -+ Boston, MA 02111-1307, USA. */ -+ -+#ifndef _BITS_MUTEX_H -+ -+#ifndef __need_pthread_mutex -+# define _BITS_MUTEX_H 1 -+#endif -+ -+#ifndef __pthread_mutex_defined -+# if defined __need_pthread_mutex || defined _BITS_MUTEX_H -+# undef __need_pthread_mutex -+# define __pthread_mutex_defined -+ -+# include -+ -+/* User visible part of a mutex. */ -+struct __pthread_mutex -+{ -+ unsigned int __lock; -+ unsigned int __owner_id; -+ unsigned int __cnt; -+ int __shpid; -+ int __type; -+ int __flags; -+ unsigned int __reserved1; -+ unsigned int __reserved2; -+}; -+ -+/* Static mutex initializers. */ -+#define __PTHREAD_MUTEX_INITIALIZER \ -+ { 0, 0, 0, 0, __PTHREAD_MUTEX_TIMED, 0, 0, 0 } -+ -+/* The +1 is to mantain binary compatibility with the old -+ * libpthread implementation. */ -+#define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \ -+ { 0, 0, 0, 0, __PTHREAD_MUTEX_ERRORCHECK + 1, 0, 0, 0 } -+ -+#define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ -+ { 0, 0, 0, 0, __PTHREAD_MUTEX_RECURSIVE + 1, 0, 0, 0 } -+ -+# endif -+#endif /* Not __pthread_mutex_defined. */ -+ -+#endif /* bits/mutex.h */ -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c b/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c -new file mode 100644 -index 0000000..2c6acd1 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c -@@ -0,0 +1,36 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int _pthread_mutex_destroy (pthread_mutex_t *mtxp) -+{ -+ atomic_read_barrier (); -+ if (*(volatile unsigned int *)&mtxp->__lock != 0) -+ return (EBUSY); -+ -+ mtxp->__type = -1; -+ return (0); -+} -+ -+strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c -new file mode 100644 -index 0000000..8a8a080 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp) -+{ -+ (void)mtxp; (void)clp; -+ return (ENOSYS); -+} -+ -+stub_warning (pthread_mutex_getprioceiling) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-init.c b/libpthread/sysdeps/mach/hurd/pt-mutex-init.c -new file mode 100644 -index 0000000..af9ed7e ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-init.c -@@ -0,0 +1,55 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+static const pthread_mutexattr_t dfl_attr = -+{ -+ .__prioceiling = 0, -+ .__protocol = PTHREAD_PRIO_NONE, -+ .__pshared = PTHREAD_PROCESS_PRIVATE, -+ .__mutex_type = __PTHREAD_MUTEX_TIMED -+}; -+ -+int _pthread_mutex_init (pthread_mutex_t *mtxp, -+ const pthread_mutexattr_t *attrp) -+{ -+ if (attrp == NULL) -+ attrp = &dfl_attr; -+ -+ mtxp->__flags = (attrp->__pshared == PTHREAD_PROCESS_SHARED ? -+ GSYNC_SHARED : 0) | ((attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? -+ PTHREAD_MUTEX_ROBUST : 0); -+ -+ mtxp->__type = attrp->__mutex_type + -+ (attrp->__mutex_type != __PTHREAD_MUTEX_TIMED); -+ -+ mtxp->__owner_id = 0; -+ mtxp->__shpid = 0; -+ mtxp->__cnt = 0; -+ mtxp->__lock = 0; -+ -+ return (0); -+} -+ -+strong_alias (_pthread_mutex_init, pthread_mutex_init) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c -new file mode 100644 -index 0000000..5d3c958 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c -@@ -0,0 +1,79 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutex_lock (pthread_mutex_t *mtxp) -+{ -+ struct __pthread *self; -+ int flags = mtxp->__flags & GSYNC_SHARED; -+ int ret = 0; -+ -+ switch (MTX_TYPE (mtxp)) -+ { -+ case PT_MTX_NORMAL: -+ lll_lock (&mtxp->__lock, flags); -+ break; -+ -+ case PT_MTX_RECURSIVE: -+ self = _pthread_self (); -+ if (mtx_owned_p (mtxp, self, flags)) -+ { -+ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) -+ return (EAGAIN); -+ -+ ++mtxp->__cnt; -+ return (ret); -+ } -+ -+ lll_lock (&mtxp->__lock, flags); -+ mtx_set_owner (mtxp, self, flags); -+ mtxp->__cnt = 1; -+ break; -+ -+ case PT_MTX_ERRORCHECK: -+ self = _pthread_self (); -+ if (mtx_owned_p (mtxp, self, flags)) -+ return (EDEADLK); -+ -+ lll_lock (&mtxp->__lock, flags); -+ mtx_set_owner (mtxp, self, flags); -+ break; -+ -+ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: -+ self = _pthread_self (); -+ ROBUST_LOCK (self, mtxp, __lll_robust_lock, flags); -+ break; -+ -+ default: -+ ret = EINVAL; -+ break; -+ } -+ -+ return (ret); -+} -+ -+strong_alias (__pthread_mutex_lock, _pthread_mutex_lock) -+strong_alias (__pthread_mutex_lock, pthread_mutex_lock) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c -new file mode 100644 -index 0000000..b88917d ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp) -+{ -+ (void)mtxp; (void)cl; (void)prp; -+ return (ENOSYS); -+} -+ -+stub_warning (pthread_mutex_setprioceiling) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c -new file mode 100644 -index 0000000..3fdd5da ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c -@@ -0,0 +1,80 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutex_timedlock (pthread_mutex_t *mtxp, -+ const struct timespec *tsp) -+{ -+ struct __pthread *self; -+ int ret, flags = mtxp->__flags & GSYNC_SHARED; -+ -+ switch (MTX_TYPE (mtxp)) -+ { -+ case PT_MTX_NORMAL: -+ ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags); -+ break; -+ -+ case PT_MTX_RECURSIVE: -+ self = _pthread_self (); -+ if (mtx_owned_p (mtxp, self, flags)) -+ { -+ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) -+ return (EAGAIN); -+ -+ ++mtxp->__cnt; -+ ret = 0; -+ } -+ else if ((ret = lll_abstimed_lock (&mtxp->__lock, -+ tsp, flags)) == 0) -+ { -+ mtx_set_owner (mtxp, self, flags); -+ mtxp->__cnt = 1; -+ } -+ -+ break; -+ -+ case PT_MTX_ERRORCHECK: -+ self = _pthread_self (); -+ if (mtx_owned_p (mtxp, self, flags)) -+ ret = EDEADLK; -+ else if ((ret = lll_abstimed_lock (&mtxp->__lock, -+ tsp, flags)) == 0) -+ mtx_set_owner (mtxp, self, flags); -+ -+ break; -+ -+ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: -+ self = _pthread_self (); -+ ROBUST_LOCK (self, mtxp, lll_robust_abstimed_lock, tsp, flags); -+ break; -+ -+ default: -+ ret = EINVAL; -+ break; -+ } -+ -+ return (ret); -+} -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c b/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c -new file mode 100644 -index 0000000..410474f ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c -@@ -0,0 +1,74 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th) -+{ -+ struct __pthread *self = _pthread_self (); -+ struct __pthread *pt = __pthread_getid (th); -+ -+ if (!pt) -+ return (ESRCH); -+ else if (pt == self) -+ return (0); -+ -+ int ret = 0; -+ int flags = mtxp->__flags & GSYNC_SHARED; -+ -+ switch (MTX_TYPE (mtxp)) -+ { -+ case PT_MTX_NORMAL: -+ break; -+ -+ case PT_MTX_RECURSIVE: -+ case PT_MTX_ERRORCHECK: -+ if (!mtx_owned_p (mtxp, self, flags)) -+ ret = EPERM; -+ else -+ mtx_set_owner (mtxp, pt, flags); -+ -+ break; -+ -+ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: -+ /* Note that this can be used to transfer an inconsistent -+ * mutex as well. The new owner will still have the same -+ * flags as the original. */ -+ if (mtxp->__owner_id != self->thread || -+ (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) -+ ret = EPERM; -+ else -+ mtxp->__owner_id = pt->thread; -+ -+ break; -+ -+ default: -+ ret = EINVAL; -+ } -+ -+ return (ret); -+} -+ -+weak_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c -new file mode 100644 -index 0000000..6680094 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c -@@ -0,0 +1,77 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutex_trylock (pthread_mutex_t *mtxp) -+{ -+ struct __pthread *self; -+ int ret; -+ -+ switch (MTX_TYPE (mtxp)) -+ { -+ case PT_MTX_NORMAL: -+ ret = lll_trylock (&mtxp->__lock); -+ break; -+ -+ case PT_MTX_RECURSIVE: -+ self = _pthread_self (); -+ if (mtx_owned_p (mtxp, self, mtxp->__flags)) -+ { -+ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) -+ return (EAGAIN); -+ -+ ++mtxp->__cnt; -+ ret = 0; -+ } -+ else if ((ret = lll_trylock (&mtxp->__lock)) == 0) -+ { -+ mtx_set_owner (mtxp, self, mtxp->__flags); -+ mtxp->__cnt = 1; -+ } -+ -+ break; -+ -+ case PT_MTX_ERRORCHECK: -+ self = _pthread_self (); -+ if ((ret = lll_trylock (&mtxp->__lock)) == 0) -+ mtx_set_owner (mtxp, self, mtxp->__flags); -+ break; -+ -+ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: -+ self = _pthread_self (); -+ ROBUST_LOCK (self, mtxp, __lll_robust_trylock); -+ break; -+ -+ default: -+ ret = EINVAL; -+ break; -+ } -+ -+ return (ret); -+} -+ -+strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock) -+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c b/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c -new file mode 100644 -index 0000000..071f622 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c -@@ -0,0 +1,90 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutex_unlock (pthread_mutex_t *mtxp) -+{ -+ struct __pthread *self; -+ int ret = 0, flags = mtxp->__flags & GSYNC_SHARED; -+ -+ switch (MTX_TYPE (mtxp)) -+ { -+ case PT_MTX_NORMAL: -+ lll_unlock (&mtxp->__lock, flags); -+ break; -+ -+ case PT_MTX_RECURSIVE: -+ self = _pthread_self (); -+ if (!mtx_owned_p (mtxp, self, flags)) -+ ret = EPERM; -+ else if (--mtxp->__cnt == 0) -+ { -+ mtxp->__owner_id = mtxp->__shpid = 0; -+ lll_unlock (&mtxp->__lock, flags); -+ } -+ -+ break; -+ -+ case PT_MTX_ERRORCHECK: -+ self = _pthread_self (); -+ if (!mtx_owned_p (mtxp, self, flags)) -+ ret = EPERM; -+ else -+ { -+ mtxp->__owner_id = mtxp->__shpid = 0; -+ lll_unlock (&mtxp->__lock, flags); -+ } -+ -+ break; -+ -+ case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: -+ case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: -+ self = _pthread_self (); -+ if (mtxp->__owner_id == NOTRECOVERABLE_ID) -+ ; /* Nothing to do. */ -+ else if (mtxp->__owner_id != self->thread || -+ (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) -+ ret = EPERM; -+ else if (--mtxp->__cnt == 0) -+ { -+ /* Release the lock. If it's in an inconsistent -+ * state, mark it as irrecoverable. */ -+ mtxp->__owner_id = (mtxp->__lock & LLL_DEAD_OWNER) ? -+ NOTRECOVERABLE_ID : 0; -+ __lll_robust_unlock (&mtxp->__lock, flags); -+ } -+ -+ break; -+ -+ default: -+ ret = EINVAL; -+ break; -+ } -+ -+ return (ret); -+} -+ -+strong_alias (__pthread_mutex_unlock, _pthread_mutex_unlock) -+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c -new file mode 100644 -index 0000000..ad711ac ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutexattr_destroy (pthread_mutexattr_t *attrp) -+{ -+ (void)attrp; -+ return (0); -+} -+weak_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c -new file mode 100644 -index 0000000..bcfc8c8 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *ap, int *clp) -+{ -+ (void)ap; (void)clp; -+ return (ENOSYS); -+} -+ -+stub_warning (pthread_mutexattr_getprioceiling) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c -new file mode 100644 -index 0000000..cb94424 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c -@@ -0,0 +1,30 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attrp, int *ptp) -+{ -+ *ptp = attrp->__protocol; -+ return (0); -+} -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c -new file mode 100644 -index 0000000..7639528 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c -@@ -0,0 +1,30 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_getpshared (const pthread_mutexattr_t *attrp, int *outp) -+{ -+ *outp = attrp->__pshared; -+ return (0); -+} -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c -new file mode 100644 -index 0000000..746f628 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c -@@ -0,0 +1,31 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_gettype (const pthread_mutexattr_t *attrp, int *outp) -+{ -+ *outp = attrp->__mutex_type; -+ return (0); -+} -+ -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c -new file mode 100644 -index 0000000..4cac661 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c -@@ -0,0 +1,39 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+static const pthread_mutexattr_t dfl_attr = -+{ -+ .__prioceiling = 0, -+ .__protocol = PTHREAD_PRIO_NONE, -+ .__pshared = PTHREAD_PROCESS_PRIVATE, -+ .__mutex_type = __PTHREAD_MUTEX_TIMED -+}; -+ -+int __pthread_mutexattr_init (pthread_mutexattr_t *attrp) -+{ -+ *attrp = dfl_attr; -+ return (0); -+} -+weak_alias (__pthread_mutexattr_init, pthread_mutexattr_init) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c -new file mode 100644 -index 0000000..d399050 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attrp, int cl) -+{ -+ (void)attrp; (void)cl; -+ return (ENOSYS); -+} -+ -+stub_warning (pthread_mutexattr_setprioceiling) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c -new file mode 100644 -index 0000000..9f7f152 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c -@@ -0,0 +1,32 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_setprotocol (pthread_mutexattr_t *attrp, int proto) -+{ -+ (void)attrp; -+ return (proto == PTHREAD_PRIO_NONE ? 0 : -+ proto != PTHREAD_PRIO_INHERIT && -+ proto != PTHREAD_PRIO_PROTECT ? EINVAL : ENOTSUP); -+} -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c -new file mode 100644 -index 0000000..c10dfa0 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c -@@ -0,0 +1,34 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_setpshared (pthread_mutexattr_t *attrp, int pshared) -+{ -+ if (pshared != PTHREAD_PROCESS_PRIVATE && -+ pshared != PTHREAD_PROCESS_SHARED) -+ return (EINVAL); -+ -+ attrp->__pshared = pshared; -+ return (0); -+} -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c -new file mode 100644 -index 0000000..67ed4f5 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c -@@ -0,0 +1,34 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int __pthread_mutexattr_settype (pthread_mutexattr_t *attrp, int type) -+{ -+ if (type < 0 || type > __PTHREAD_MUTEX_RECURSIVE) -+ return (EINVAL); -+ -+ attrp->__mutex_type = type; -+ return (0); -+} -+weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr.c -new file mode 100644 -index 0000000..40a8c17 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr.c -@@ -0,0 +1 @@ -+/* empty */ -diff --git a/libpthread/Makefile b/libpthread/Makefile -index 9707f57..776b95d 100644 ---- a/libpthread/Makefile -+++ b/libpthread/Makefile -@@ -87,12 +87,14 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ - pt-mutexattr-getpshared pt-mutexattr-gettype \ - pt-mutexattr-setprioceiling pt-mutexattr-setprotocol \ - pt-mutexattr-setpshared pt-mutexattr-settype \ -+ pt-mutexattr-getrobust pt-mutexattr-setrobust \ - \ - pt-mutex-init pt-mutex-destroy \ - pt-mutex-lock pt-mutex-trylock pt-mutex-timedlock \ - pt-mutex-unlock \ - pt-mutex-transfer-np \ - pt-mutex-getprioceiling pt-mutex-setprioceiling \ -+ pt-mutex-consistent \ - \ - pt-rwlock-attr \ - pt-rwlockattr-init pt-rwlockattr-destroy \ -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c b/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c -new file mode 100644 -index 0000000..28e9e4a ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-consistent.c -@@ -0,0 +1,45 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutex_consistent (pthread_mutex_t *mtxp) -+{ -+ int ret = EINVAL; -+ unsigned int val = mtxp->__lock; -+ -+ if ((mtxp->__flags & PTHREAD_MUTEX_ROBUST) != 0 && -+ (val & LLL_DEAD_OWNER) != 0 && -+ atomic_compare_and_exchange_bool_acq (&mtxp->__lock, -+ __getpid () | LLL_WAITERS, val) == 0) -+ { -+ /* The mutex is now ours, and it's consistent. */ -+ mtxp->__owner_id = _pthread_self()->thread; -+ mtxp->__cnt = 1; -+ ret = 0; -+ } -+ -+ return (ret); -+} -+ -+weak_alias (pthread_mutex_consistent, pthread_mutex_consistent_np) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex.h b/libpthread/sysdeps/mach/hurd/pt-mutex.h -new file mode 100644 -index 0000000..c67453e ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutex.h -@@ -0,0 +1,92 @@ -+/* Internal definitions for pthreads library. -+ Copyright (C) 2016 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ Contributed by Agustina Arzille , 2016. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License as -+ published by the Free Software Foundation; either version 2 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 -+ Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with the GNU C Library; see the file COPYING.LIB. If not, -+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -+ Boston, MA 02111-1307, USA. */ -+ -+#ifndef _PT_MUTEX_H -+#define _PT_MUTEX_H 1 -+ -+/* Special ID used to signal an unrecoverable robust mutex. */ -+#define NOTRECOVERABLE_ID (1U << 31) -+ -+/* Common path for robust mutexes. Assumes the variable 'ret' -+ * is bound in the function this is called from. */ -+#define ROBUST_LOCK(self, mtxp, cb, ...) \ -+ if (mtxp->__owner_id == NOTRECOVERABLE_ID) \ -+ return (ENOTRECOVERABLE); \ -+ else if (mtxp->__owner_id == self->thread && \ -+ __getpid () == (int)(mtxp->__lock & LLL_OWNER_MASK)) \ -+ { \ -+ if (mtxp->__type == PT_MTX_RECURSIVE) \ -+ { \ -+ if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) \ -+ return (EAGAIN); \ -+ \ -+ ++mtxp->__cnt; \ -+ return (0); \ -+ } \ -+ else if (mtxp->__type == PT_MTX_ERRORCHECK) \ -+ return (EDEADLK); \ -+ } \ -+ \ -+ ret = cb (&mtxp->__lock, ##__VA_ARGS__); \ -+ if (ret == 0 || ret == EOWNERDEAD) \ -+ { \ -+ if (mtxp->__owner_id == ENOTRECOVERABLE) \ -+ ret = ENOTRECOVERABLE; \ -+ else \ -+ { \ -+ mtxp->__owner_id = self->thread; \ -+ mtxp->__cnt = 1; \ -+ if (ret == EOWNERDEAD) \ -+ { \ -+ mtxp->__lock = mtxp->__lock | LLL_DEAD_OWNER; \ -+ atomic_write_barrier (); \ -+ } \ -+ } \ -+ } \ -+ (void)0 -+ -+/* Check that a thread owns the mutex. For non-robust, task-shared -+ * objects, we have to check the thread *and* process-id. */ -+#define mtx_owned_p(mtx, pt, flags) \ -+ ((mtx)->__owner_id == (pt)->thread && \ -+ (((flags) & GSYNC_SHARED) == 0 || \ -+ (mtx)->__shpid == __getpid ())) -+ -+/* Record a thread as the owner of the mutex. */ -+#define mtx_set_owner(mtx, pt, flags) \ -+ (void) \ -+ ({ \ -+ (mtx)->__owner_id = (pt)->thread; \ -+ if ((flags) & GSYNC_SHARED) \ -+ (mtx)->__shpid = __getpid (); \ -+ }) -+ -+/* Redefined mutex types. The +1 is for binary compatibility. */ -+#define PT_MTX_NORMAL __PTHREAD_MUTEX_TIMED -+#define PT_MTX_RECURSIVE (__PTHREAD_MUTEX_RECURSIVE + 1) -+#define PT_MTX_ERRORCHECK (__PTHREAD_MUTEX_ERRORCHECK + 1) -+ -+/* Mutex type, including robustness. */ -+#define MTX_TYPE(mtxp) \ -+ ((mtxp)->__type | ((mtxp)->__flags & PTHREAD_MUTEX_ROBUST)) -+ -+extern int __getpid (void) __attribute__ ((const)); -+ -+#endif /* pt-mutex.h */ -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c -new file mode 100644 -index 0000000..86a0909 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getrobust.c -@@ -0,0 +1,33 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_getrobust (const pthread_mutexattr_t *attrp, int *outp) -+{ -+ *outp = (attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? -+ PTHREAD_MUTEX_ROBUST : PTHREAD_MUTEX_STALLED; -+ return (0); -+} -+ -+weak_alias (pthread_mutexattr_getrobust, pthread_mutexattr_getrobust_np) -diff --git a/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c -new file mode 100644 -index 0000000..a90e747 ---- /dev/null -+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setrobust.c -@@ -0,0 +1,36 @@ -+/* Copyright (C) 2016 Free Software Foundation, Inc. -+ Contributed by Agustina Arzille , 2016. -+ -+ This program is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Library General Public License -+ as published by the Free Software Foundation; either -+ version 2 of the license, or (at your option) any later version. -+ -+ This program 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 Library General Public License for more details. -+ -+ You should have received a copy of the GNU Library General Public -+ License along with this program; if not, see -+ . -+*/ -+ -+#include -+#include -+#include -+#include -+#include "pt-mutex.h" -+#include -+ -+int pthread_mutexattr_setrobust (pthread_mutexattr_t *attrp, int robust) -+{ -+ if (robust != PTHREAD_MUTEX_ROBUST && -+ robust != PTHREAD_MUTEX_STALLED) -+ return (EINVAL); -+ -+ attrp->__prioceiling |= robust; -+ return (0); -+} -+ -+weak_alias (pthread_mutexattr_setrobust, pthread_mutexattr_setrobust_np) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-spin.diff glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-spin.diff --- glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-spin.diff 2016-11-30 16:53:58.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-libpthread-gsync-spin.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -commit cd7e69c545200949cfd1b3c595568556ff9a76e3 -Author: Agustina Arzille -Date: Tue Oct 18 00:20:45 2016 +0200 - - Make pthread_spinlock use gsync - -diff --git a/libpthread/pthread/pt-spin-inlines.c b/libpthread/pthread/pt-spin-inlines.c -index cfb21dd..97afb4d 100644 ---- a/libpthread/pthread/pt-spin-inlines.c -+++ b/libpthread/pthread/pt-spin-inlines.c -@@ -25,10 +25,9 @@ - - #include - --/* Weak aliases for the spin lock functions. Note that -- pthread_spin_lock is left out deliberately. We already provide an -- implementation for it in pt-spin.c. */ -+/* Weak aliases for the spin lock functions. */ - weak_alias (__pthread_spin_destroy, pthread_spin_destroy); - weak_alias (__pthread_spin_init, pthread_spin_init); - weak_alias (__pthread_spin_trylock, pthread_spin_trylock); -+weak_alias (__pthread_spin_lock, pthread_spin_lock); - weak_alias (__pthread_spin_unlock, pthread_spin_unlock); -diff --git a/libpthread/sysdeps/mach/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/bits/spin-lock-inline.h -index f9f7c29..98e4b3b 100644 ---- a/libpthread/sysdeps/mach/bits/spin-lock-inline.h -+++ b/libpthread/sysdeps/mach/bits/spin-lock-inline.h -@@ -22,7 +22,7 @@ - - #include - #include --#include /* This does all the work. */ -+#include /* This does all the work. */ - - __BEGIN_DECLS - -@@ -60,17 +60,15 @@ __PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); - __PT_SPIN_INLINE int - __pthread_spin_trylock (__pthread_spinlock_t *__lock) - { -- return __spin_try_lock (__lock) ? 0 : __EBUSY; -+ return __spin_try_lock ((__spin_lock_t *) __lock) ? 0 : __EBUSY; - } - --__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); --extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); -+__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock); - --__extern_inline int -+__PT_SPIN_INLINE int - __pthread_spin_lock (__pthread_spinlock_t *__lock) - { -- if (__pthread_spin_trylock (__lock)) -- return _pthread_spin_lock (__lock); -+ __spin_lock ((__spin_lock_t *) __lock); - return 0; - } - -@@ -79,7 +77,7 @@ __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); - __PT_SPIN_INLINE int - __pthread_spin_unlock (__pthread_spinlock_t *__lock) - { -- __spin_unlock (__lock); -+ __spin_unlock ((__spin_lock_t *) __lock); - return 0; - } - -diff --git a/libpthread/sysdeps/mach/bits/spin-lock.h b/libpthread/sysdeps/mach/bits/spin-lock.h -index 537dac9..7574b37 100644 ---- a/libpthread/sysdeps/mach/bits/spin-lock.h -+++ b/libpthread/sysdeps/mach/bits/spin-lock.h -@@ -21,17 +21,14 @@ - #define _BITS_SPIN_LOCK_H 1 - - #include --#include /* This does all the work. */ - - __BEGIN_DECLS - - /* The type of a spin lock object. */ --typedef __spin_lock_t __pthread_spinlock_t; -+typedef volatile int __pthread_spinlock_t; - - /* Initializer for a spin lock object. */ --#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER --#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by . --#endif -+#define __PTHREAD_SPIN_LOCK_INITIALIZER 0 - - __END_DECLS - -diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h b/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h -deleted file mode 100644 -index e5ed3de..0000000 ---- a/libpthread/sysdeps/mach/i386/bits/spin-lock-inline.h -+++ /dev/null -@@ -1,98 +0,0 @@ --/* Machine-specific definitions for spin locks. i386 version. -- Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. -- 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 Library General Public License as -- published by the Free Software Foundation; either version 2 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 -- Library General Public License for more details. -- -- You should have received a copy of the GNU Library General Public -- License along with the GNU C Library; see the file COPYING.LIB. If not, -- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- Boston, MA 02111-1307, USA. */ -- --/* -- * Never include this file directly; use or instead. -- */ -- --#ifndef _BITS_SPIN_LOCK_INLINE_H --#define _BITS_SPIN_LOCK_INLINE_H 1 -- --#include --#include -- --__BEGIN_DECLS -- --#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES -- --# ifndef __EBUSY --# include --# define __EBUSY EBUSY --# endif -- --# ifndef __PT_SPIN_INLINE --# define __PT_SPIN_INLINE __extern_inline --# endif -- --__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); -- --__PT_SPIN_INLINE int --__pthread_spin_destroy (__pthread_spinlock_t *__lock) --{ -- return 0; --} -- --__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, -- int __pshared); -- --__PT_SPIN_INLINE int --__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) --{ -- *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; -- return 0; --} -- --__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); -- --__PT_SPIN_INLINE int --__pthread_spin_trylock (__pthread_spinlock_t *__lock) --{ -- int __locked; -- __asm__ __volatile ("xchgl %0, %1" -- : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory"); -- return __locked ? __EBUSY : 0; --} -- --__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock); --extern int _pthread_spin_lock (__pthread_spinlock_t *__lock); -- --__extern_inline int --__pthread_spin_lock (__pthread_spinlock_t *__lock) --{ -- if (__pthread_spin_trylock (__lock)) -- return _pthread_spin_lock (__lock); -- return 0; --} -- --__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); -- --__PT_SPIN_INLINE int --__pthread_spin_unlock (__pthread_spinlock_t *__lock) --{ -- int __unlocked; -- __asm__ __volatile ("xchgl %0, %1" -- : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory"); -- return 0; --} -- --#endif /* Use extern inlines or force inlines. */ -- --__END_DECLS -- --#endif /* bits/spin-lock.h */ -diff --git a/libpthread/sysdeps/mach/i386/bits/spin-lock.h b/libpthread/sysdeps/mach/i386/bits/spin-lock.h -deleted file mode 100644 -index 5ae81e1..0000000 ---- a/libpthread/sysdeps/mach/i386/bits/spin-lock.h -+++ /dev/null -@@ -1,39 +0,0 @@ --/* Machine-specific definitions for spin locks. i386 version. -- Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc. -- 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 Library General Public License as -- published by the Free Software Foundation; either version 2 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 -- Library General Public License for more details. -- -- You should have received a copy of the GNU Library General Public -- License along with the GNU C Library; see the file COPYING.LIB. If not, -- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- Boston, MA 02111-1307, USA. */ -- --/* -- * Never include this file directly; use or instead. -- */ -- --#ifndef _BITS_SPIN_LOCK_H --#define _BITS_SPIN_LOCK_H 1 -- --#include -- --__BEGIN_DECLS -- --/* The type of a spin lock object. */ --typedef __volatile int __pthread_spinlock_t; -- --/* Initializer for a spin lock object. */ --# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) -- --__END_DECLS -- --#endif /* bits/spin-lock.h */ -diff --git a/libpthread/sysdeps/mach/pt-spin.c b/libpthread/sysdeps/mach/pt-spin.c -index d9a2a32..0cf1c49 100644 ---- a/libpthread/sysdeps/mach/pt-spin.c -+++ b/libpthread/sysdeps/mach/pt-spin.c -@@ -17,20 +17,16 @@ - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - --#include - #include - - /* In glibc. */ --extern void __spin_lock_solid (__pthread_spinlock_t *lock); -+extern void __spin_lock_solid (__spin_lock_t *lock); - - /* Lock the spin lock object LOCK. If the lock is held by another - thread spin until it becomes available. */ - int --_pthread_spin_lock (__pthread_spinlock_t *lock) -+_pthread_spin_lock (__spin_lock_t *lock) - { - __spin_lock_solid (lock); - return 0; - } -- --weak_alias (_pthread_spin_lock, pthread_spin_lock); --weak_alias (_pthread_spin_lock, __pthread_spin_lock); -diff --git a/libpthread/sysdeps/posix/pt-spin.c b/libpthread/sysdeps/posix/pt-spin.c -index cb809c6..07f8936 100644 ---- a/libpthread/sysdeps/posix/pt-spin.c -+++ b/libpthread/sysdeps/posix/pt-spin.c -@@ -49,6 +49,3 @@ _pthread_spin_lock (__pthread_spinlock_t *lock) - __sched_yield (); - } - } -- --weak_alias (_pthread_spin_lock, pthread_spin_lock); --weak_alias (_pthread_spin_lock, __pthread_spin_lock); diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-mlockall.diff glibc-2.27/debian/patches/hurd-i386/tg-mlockall.diff --- glibc-2.27/debian/patches/hurd-i386/tg-mlockall.diff 2017-03-20 17:03:33.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-mlockall.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -Subject: [PATCH] Add mlockall support - -* sysdeps/mach/hurd/mlockall.c: New file -* sysdeps/mach/hurd/munlockall.c: New file - ---- - sysdeps/mach/hurd/mlockall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ - sysdeps/mach/hurd/munlockall.c | 40 ++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 82 insertions(+) - -diff --git a/sysdeps/mach/hurd/mlockall.c b/sysdeps/mach/hurd/mlockall.c -new file mode 100644 -index 0000000000..11a3deac8a ---- /dev/null -+++ b/sysdeps/mach/hurd/mlockall.c -@@ -0,0 +1,42 @@ -+/* mlockall -- lock in core all the pages in this process. Stub version. -+ Copyright (C) 2001-2016 Free Software Foundation, Inc. -+ 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 -+ . */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+/* Cause all currently mapped pages of the process to be memory resident -+ until unlocked by a call to the `munlockall', until the process exits, -+ or until the process calls `execve'. */ -+ -+int -+mlockall (int flags) -+{ -+ mach_port_t host; -+ error_t err; -+ -+ err = __get_privileged_ports (&host, NULL); -+ if (err) -+ return __hurd_fail (err); -+ -+ err = __vm_wire_all (host, __mach_task_self (), flags); -+ __mach_port_deallocate (__mach_task_self (), host); -+ return err ? __hurd_fail (err) : 0; -+} -diff --git a/sysdeps/mach/hurd/munlockall.c b/sysdeps/mach/hurd/munlockall.c -new file mode 100644 -index 0000000000..6fbb69435d ---- /dev/null -+++ b/sysdeps/mach/hurd/munlockall.c -@@ -0,0 +1,40 @@ -+/* munlockall -- undo the effects of all prior mlock calls. Stub version. -+ Copyright (C) 2001-2016 Free Software Foundation, Inc. -+ 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 -+ . */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+/* Undo the effects of all prior mlock calls in this process. */ -+ -+int -+munlockall (void) -+{ -+ mach_port_t host; -+ error_t err; -+ -+ err = __get_privileged_ports (&host, NULL); -+ if (err) -+ return __hurd_fail (err); -+ -+ err = __vm_wire_all (host, __mach_task_self (), VM_WIRE_NONE); -+ __mach_port_deallocate (__mach_task_self (), host); -+ return err ? __hurd_fail (err) : 0; -+} --- -tg: (7bb5f8a836..) t/mlockall (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW.diff glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW.diff --- glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW.diff 2016-11-30 16:53:58.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] hurd: Fix O_NOFOLLOW - -The error code documented by POSIX for opening a symlink with O_NOFOLLOW -is ELOOP. - -Also, if the translator does not expose symlink as a symlink translator but -as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too. - -Signed-off-by: Samuel Thibault - ---- - hurd/lookup-retry.c | 36 ++++++++++++++++++++---------------- - 1 file changed, 20 insertions(+), 16 deletions(-) - -diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c -index aee2ba8..b7a6a2b 100644 ---- a/hurd/lookup-retry.c -+++ b/hurd/lookup-retry.c -@@ -127,7 +127,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) - { - /* In Linux, O_NOFOLLOW means to reject symlinks. If we - did an O_NOLINK lookup above and io_stat here to check -- for S_IFLNK, a translator like firmlink could easily -+ for S_IFLNK only, a translator like firmlink could easily - spoof this check by not showing S_IFLNK, but in fact - redirecting the lookup to some other name - (i.e. opening the very same holes a symlink would). -@@ -145,23 +145,27 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) - one exception to our general translator-based rule. */ - struct stat64 st; - err = __io_stat (*result, &st); -- if (!err -- && (st.st_mode & (S_IPTRANS|S_IATRANS))) -+ if (!err) - { -- if (st.st_uid != 0) -- err = ENOENT; -- else if (st.st_mode & S_IPTRANS) -+ if (S_ISLNK(st.st_mode)) -+ err = ELOOP; -+ else if (st.st_mode & (S_IPTRANS|S_IATRANS)) - { -- char buf[1024]; -- char *trans = buf; -- size_t translen = sizeof buf; -- err = __file_get_translator (*result, -- &trans, &translen); -- if (!err -- && translen > sizeof _HURD_SYMLINK -- && !memcmp (trans, -- _HURD_SYMLINK, sizeof _HURD_SYMLINK)) -- err = ENOENT; -+ if (st.st_uid != 0) -+ err = ELOOP; -+ else if (st.st_mode & S_IPTRANS) -+ { -+ char buf[1024]; -+ char *trans = buf; -+ size_t translen = sizeof buf; -+ err = __file_get_translator (*result, -+ &trans, &translen); -+ if (!err -+ && translen > sizeof _HURD_SYMLINK -+ && !memcmp (trans, -+ _HURD_SYMLINK, sizeof _HURD_SYMLINK)) -+ err = ELOOP; -+ } - } - } - } --- -tg: (7bb5f8a..) t/NOFOLLOW (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW-DIRECTORY.diff glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW-DIRECTORY.diff --- glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW-DIRECTORY.diff 2016-11-30 16:53:58.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-NOFOLLOW-DIRECTORY.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] hurd: Fix O_DIRECTORY | O_NOFOLLOW - -Appending / to the path to be looked up makes us always follow a final -symlink, even with O_NOTRANS (since the final resolution is after the -'/'). In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open -the node and stat it, which we already do anyway, and check for -directory type. - -Signed-off-by: Samuel Thibault - ---- - hurd/hurdlookup.c | 2 +- - hurd/lookup-retry.c | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c -index dbff009..bd720c2 100644 ---- a/hurd/hurdlookup.c -+++ b/hurd/hurdlookup.c -@@ -72,7 +72,7 @@ __hurd_file_name_lookup (error_t (*use_init_port) - if (flags & O_NOFOLLOW) /* See lookup-retry.c about O_NOFOLLOW. */ - flags |= O_NOTRANS; - -- if (flags & O_DIRECTORY) -+ if (flags & O_DIRECTORY && !(flags & O_NOFOLLOW)) - { - /* The caller wants to require that the file we look up is a directory. - We can do this without an extra RPC by appending a trailing slash -diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c -index b7a6a2b..d372959 100644 ---- a/hurd/lookup-retry.c -+++ b/hurd/lookup-retry.c -@@ -147,6 +147,8 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) - err = __io_stat (*result, &st); - if (!err) - { -+ if (flags & O_DIRECTORY && !S_ISDIR(st.st_mode)) -+ err = ENOTDIR; - if (S_ISLNK(st.st_mode)) - err = ELOOP; - else if (st.st_mode & (S_IPTRANS|S_IATRANS)) --- -tg: (2bc1a49..) t/NOFOLLOW-DIRECTORY (depends on: t/NOFOLLOW) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-pagesize.diff glibc-2.27/debian/patches/hurd-i386/tg-pagesize.diff --- glibc-2.27/debian/patches/hurd-i386/tg-pagesize.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-pagesize.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -Subject: [PATCH] t/pagesize - -From: Thomas Schwinge - -WIP. id:"87mxd9hl2n.fsf@kepler.schwinge.homeip.net" - ---- - elf/dl-support.c | 2 +- - elf/rtld.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -Index: glibc-2.27/elf/dl-support.c -=================================================================== ---- glibc-2.27.orig/elf/dl-support.c -+++ glibc-2.27/elf/dl-support.c -@@ -136,7 +136,7 @@ hp_timing_t _dl_cpuclock_offset; - - void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls; - --size_t _dl_pagesize = EXEC_PAGESIZE; -+size_t _dl_pagesize = /* EXEC_PAGESIZE */ 4096; - - int _dl_inhibit_cache; - -Index: glibc-2.27/elf/rtld.c -=================================================================== ---- glibc-2.27.orig/elf/rtld.c -+++ glibc-2.27/elf/rtld.c -@@ -271,7 +271,7 @@ struct rtld_global_ro _rtld_global_ro at - #endif - ._dl_lazy = 1, - ._dl_fpu_control = _FPU_DEFAULT, -- ._dl_pagesize = EXEC_PAGESIZE, -+ ._dl_pagesize = /* EXEC_PAGESIZE */ 4096, - ._dl_inhibit_cache = 0, - - /* Function pointers. */ diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-reboot-startup.diff glibc-2.27/debian/patches/hurd-i386/tg-reboot-startup.diff --- glibc-2.27/debian/patches/hurd-i386/tg-reboot-startup.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-reboot-startup.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -From: David Michael -Subject: [PATCH] Lookup the startup server through /servers/startup - -* sysdeps/mach/hurd/reboot.c: Include -(reboot): Lookup _SERVERS_STARTUP instead of calling proc_getmsgport to get a -port to the startup server. - - - ---- - sysdeps/mach/hurd/reboot.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/sysdeps/mach/hurd/reboot.c b/sysdeps/mach/hurd/reboot.c -index 60d96ea..51c3d73 100644 ---- a/sysdeps/mach/hurd/reboot.c -+++ b/sysdeps/mach/hurd/reboot.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -33,8 +34,8 @@ reboot (int howto) - if (err) - return __hurd_fail (EPERM); - -- err = __USEPORT (PROC, __proc_getmsgport (port, 1, &init)); -- if (!err) -+ init = __file_name_lookup (_SERVERS_STARTUP, 0, 0); -+ if (init != MACH_PORT_NULL) - { - err = __startup_reboot (init, hostpriv, howto); - __mach_port_deallocate (__mach_task_self (), init); --- -tg: (9a079e2..) t/reboot-startup (depends on: baseline) diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-thread-linkspace.diff glibc-2.27/debian/patches/hurd-i386/tg-thread-linkspace.diff --- glibc-2.27/debian/patches/hurd-i386/tg-thread-linkspace.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-thread-linkspace.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -From: Samuel Thibault -Subject: [PATCH] Fix thread linkspace - -Libc uses some thread functions, but should not expose the corresponding -symbols, so call aliases. - ---- - hurd/Versions | 6 +++--- - hurd/hurdsig.c | 20 ++++++++++---------- - sysdeps/mach/hurd/cthreads.c | 10 +++++----- - sysdeps/mach/libc-lock.h | 4 ++-- - 4 files changed, 20 insertions(+), 20 deletions(-) - -diff --git a/hurd/Versions b/hurd/Versions -index 414231b5b4..e040b49edc 100644 ---- a/hurd/Versions -+++ b/hurd/Versions -@@ -143,14 +143,14 @@ libc { - - HURD_CTHREADS_0.3 { - # weak refs to libthreads functions that libc calls iff libthreads in use -- cthread_fork; cthread_detach; -- pthread_getattr_np; pthread_attr_getstack; -+ __cthread_fork; __cthread_detach; -+ __pthread_getattr_np; __pthread_attr_getstack; - - # variables used for detecting cthreads - _cthread_exit_routine; _cthread_init_routine; - - # cthreads functions with stubs in libc -- cthread_keycreate; cthread_getspecific; cthread_setspecific; -+ __cthread_keycreate; __cthread_getspecific; __cthread_setspecific; - __libc_getspecific; - } - -diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c -index fd787c6c1b..8584d5c631 100644 ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -1466,11 +1466,11 @@ _hurdsig_init (const int *intarray, size_t intarraysize) - - /* Start the signal thread listening on the message port. */ - --#pragma weak cthread_fork --#pragma weak cthread_detach --#pragma weak pthread_getattr_np --#pragma weak pthread_attr_getstack -- if (!cthread_fork) -+#pragma weak __cthread_fork -+#pragma weak __cthread_detach -+#pragma weak __pthread_getattr_np -+#pragma weak __pthread_attr_getstack -+ if (!__cthread_fork) - { - err = __thread_create (__mach_task_self (), &_hurd_msgport_thread); - assert_perror (err); -@@ -1495,7 +1495,7 @@ _hurdsig_init (const int *intarray, size_t intarraysize) - } - else - { -- cthread_t thread; -+ __cthread_t thread; - /* When cthreads is being used, we need to make the signal thread a - proper cthread. Otherwise it cannot use mutex_lock et al, which - will be the cthreads versions. Various of the message port RPC -@@ -1505,17 +1505,17 @@ _hurdsig_init (const int *intarray, size_t intarraysize) - we'll let the signal thread's per-thread variables be found as for - any normal cthread, and just leave the magic __hurd_sigthread_* - values all zero so they'll be ignored. */ -- cthread_detach (thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); -+ __cthread_detach (thread = __cthread_fork ((__cthread_fn_t) &_hurd_msgport_receive, 0)); - -- if (pthread_getattr_np) -+ if (__pthread_getattr_np) - { - /* Record stack layout for fork() */ - pthread_attr_t attr; - void *addr; - size_t size; - -- pthread_getattr_np ((pthread_t) thread, &attr); -- pthread_attr_getstack (&attr, &addr, &size); -+ __pthread_getattr_np ((pthread_t) thread, &attr); -+ __pthread_attr_getstack (&attr, &addr, &size); - __hurd_sigthread_stack_base = (uintptr_t) addr; - __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size; - } -diff --git a/sysdeps/mach/hurd/cthreads.c b/sysdeps/mach/hurd/cthreads.c -index f223e00b12..0a3780b273 100644 ---- a/sysdeps/mach/hurd/cthreads.c -+++ b/sysdeps/mach/hurd/cthreads.c -@@ -24,7 +24,7 @@ char __libc_lock_self0[0]; - /* Placeholder for key creation routine from Hurd cthreads library. */ - int - weak_function --cthread_keycreate (cthread_key_t *key) -+__cthread_keycreate (cthread_key_t *key) - { - __set_errno (ENOSYS); - *key = -1; -@@ -34,7 +34,7 @@ cthread_keycreate (cthread_key_t *key) - /* Placeholder for key retrieval routine from Hurd cthreads library. */ - int - weak_function --cthread_getspecific (cthread_key_t key, void **pval) -+__cthread_getspecific (cthread_key_t key, void **pval) - { - *pval = NULL; - __set_errno (ENOSYS); -@@ -44,19 +44,19 @@ cthread_getspecific (cthread_key_t key, void **pval) - /* Placeholder for key setting routine from Hurd cthreads library. */ - int - weak_function --cthread_setspecific (cthread_key_t key, void *val) -+__cthread_setspecific (cthread_key_t key, void *val) - { - __set_errno (ENOSYS); - return -1; - } - --/* Call cthread_getspecific which gets a pointer to the return value instead -+/* Call __cthread_getspecific which gets a pointer to the return value instead - of just returning it. */ - void * - weak_function - __libc_getspecific (cthread_key_t key) - { - void *val; -- cthread_getspecific (key, &val); -+ __cthread_getspecific (key, &val); - return val; - } -diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/libc-lock.h -index f9f57a0a65..35233f797e 100644 ---- a/sysdeps/mach/libc-lock.h -+++ b/sysdeps/mach/libc-lock.h -@@ -223,8 +223,8 @@ struct __libc_once - used as argument to __libc_cleanup_region_start. */ - #define __libc_mutex_unlock __libc_lock_unlock - --#define __libc_key_create(KEY,DEST) cthread_keycreate (KEY) --#define __libc_setspecific(KEY,VAL) cthread_setspecific (KEY, VAL) -+#define __libc_key_create(KEY,DEST) __cthread_keycreate (KEY) -+#define __libc_setspecific(KEY,VAL) __cthread_setspecific (KEY, VAL) - void *__libc_getspecific (__libc_key_t key); - - /* Hide the definitions which are only supposed to be used inside libc in diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-timer_routines.diff glibc-2.27/debian/patches/hurd-i386/tg-timer_routines.diff --- glibc-2.27/debian/patches/hurd-i386/tg-timer_routines.diff 2016-11-30 16:53:58.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-timer_routines.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -Index: glibc/sysdeps/pthread/timer_routines.c -=================================================================== ---- glibc.orig/sysdeps/pthread/timer_routines.c -+++ glibc/sysdeps/pthread/timer_routines.c -@@ -29,7 +29,7 @@ - #include - - #include "posix-timer.h" --#include -+//#include - - - /* Number of threads used. */ -@@ -395,6 +395,9 @@ thread_func (void *arg) - { - timespec_add (&timer->expirytime, &timer->expirytime, - &timer->value.it_interval); -+#ifndef DELAYTIMER_MAX -+#define DELAYTIMER_MAX INT_MAX -+#endif - if (timer->overrun_count < DELAYTIMER_MAX) - ++timer->overrun_count; - } -@@ -481,7 +484,7 @@ __timer_thread_wakeup (struct thread_nod - pthread_cond_broadcast (&thread->cond); - } - -- -+#if 0 - /* Compare two pthread_attr_t thread attributes for exact equality. - Returns 1 if they are equal, otherwise zero if they are not equal - or contain illegal values. This version is NPTL-specific for -@@ -506,6 +509,7 @@ thread_attr_compare (const pthread_attr_ - && memcmp (ileft->cpuset, iright->cpuset, - ileft->cpusetsize) == 0))); - } -+#endif - - - /* Search the list of active threads and find one which has matching -@@ -514,6 +518,7 @@ struct thread_node * - __timer_thread_find_matching (const pthread_attr_t *desired_attr, - clockid_t desired_clock_id) - { -+#if 0 - struct list_head *iter = list_first (&thread_active_list); - - while (iter != list_null (&thread_active_list)) -@@ -526,6 +531,7 @@ __timer_thread_find_matching (const pthr - - iter = list_next (iter); - } -+#endif - - return NULL; - } diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-tls.diff glibc-2.27/debian/patches/hurd-i386/tg-tls.diff --- glibc-2.27/debian/patches/hurd-i386/tg-tls.diff 2017-09-03 20:41:15.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-tls.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,423 +0,0 @@ -From: Thomas Schwinge -Subject: [PATCH] tls - -TLS support. - -All by Samuel Thibault. - -glibc-2.8/debian/patches/hurd-i386/local-tls-support.diff 3151 - -2009-07-30 Samuel Thibault - - Align up includes as on Linux, to fix build. - * sysdeps/mach/hurd/tls.h: Include . - ---- - sysdeps/mach/thread_state.h | 3 ++ - csu/libc-start.c | 2 + - include/errno.h | 14 +++++---- - hurd/hurdfault.c | 2 + - hurd/hurdsig.c | 2 + - mach/mach.h | 3 ++ - mach/setup-thread.c | 30 +++++++++++++++++++- - sysdeps/generic/thread_state.h | 1 - sysdeps/mach/hurd/libc-lock.h | 3 ++ - sysdeps/mach/hurd/fork.c | 7 ++++ - sysdeps/mach/hurd/i386/init-first.c | 49 +++++++++++++++++++++------------ - sysdeps/mach/hurd/i386/tls.h | 53 +++++++++++++++++++++++++++++------- - sysdeps/mach/hurd/i386/trampoline.c | 2 - - sysdeps/mach/hurd/profil.c | 2 + - sysdeps/mach/hurd/setitimer.c | 3 +- - sysdeps/mach/hurd/tls.h | 2 + - sysdeps/mach/i386/thread_state.h | 11 ++++++- - 17 files changed, 150 insertions(+), 39 deletions(-) - ---- a/include/errno.h -+++ b/include/errno.h -@@ -21,13 +21,15 @@ extern int rtld_errno attribute_hidden; - - # include - --# undef errno --# if IS_IN (libc) --# define errno __libc_errno --# else --# define errno errno /* For #ifndef errno tests. */ --# endif -+# if !defined(__GNU__) -+# undef errno -+# if IS_IN (libc) -+# define errno __libc_errno -+# else -+# define errno errno /* For #ifndef errno tests. */ -+# endif - extern __thread int errno attribute_tls_model_ie; -+# endif - - # endif /* IS_IN_LIB */ - ---- a/hurd/hurdfault.c -+++ b/hurd/hurdfault.c -@@ -204,6 +204,8 @@ _hurdsig_fault_init (void) - /* This state will be restored when we fault. - It runs the function above. */ - memset (&state, 0, sizeof state); -+ -+ MACHINE_THREAD_STATE_FIX_NEW (&state); - MACHINE_THREAD_STATE_SET_PC (&state, faulted); - MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack); - ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -1266,6 +1266,8 @@ _hurdsig_init (const int *intarray, size - (vm_address_t *) &__hurd_sigthread_stack_base, - &stacksize); - assert_perror (err); -+ err = __mach_setup_tls (_hurd_msgport_thread); -+ assert_perror (err); - - __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize; - __hurd_sigthread_variables = ---- a/mach/mach.h -+++ b/mach/mach.h -@@ -100,5 +100,8 @@ kern_return_t mach_setup_thread (task_t - vm_address_t *stack_base, - vm_size_t *stack_size); - -+/* Give THREAD a TLS area. */ -+kern_return_t __mach_setup_tls (thread_t thread); -+kern_return_t mach_setup_tls (thread_t thread); - - #endif /* mach.h */ ---- a/mach/setup-thread.c -+++ b/mach/setup-thread.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include "sysdep.h" /* Defines stack direction. */ - - #define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */ -@@ -72,8 +73,35 @@ __mach_setup_thread (task_t task, thread - if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE)) - return error; - -- return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, -+ return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR, - (natural_t *) &ts, tssize); - } - - weak_alias (__mach_setup_thread, mach_setup_thread) -+ -+/* Give THREAD a TLS area. */ -+kern_return_t -+__mach_setup_tls (thread_t thread) -+{ -+ kern_return_t error; -+ struct machine_thread_state ts; -+ mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; -+ tcbhead_t *tcb; -+ -+ if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, -+ (natural_t *) &ts, &tssize)) -+ return error; -+ assert (tssize == MACHINE_THREAD_STATE_COUNT); -+ -+ tcb = _dl_allocate_tls(NULL); -+ if (!tcb) -+ return KERN_RESOURCE_SHORTAGE; -+ -+ _hurd_tls_new(thread, &ts, tcb); -+ -+ error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, -+ (natural_t *) &ts, tssize); -+ return error; -+} -+ -+weak_alias (__mach_setup_tls, mach_setup_tls) ---- a/sysdeps/generic/thread_state.h -+++ b/sysdeps/generic/thread_state.h -@@ -22,6 +22,7 @@ - - /* Replace with "i386" or "mips" or whatever. */ - -+#define MACHINE_NEW_THREAD_STATE_FLAVOR _NEW_THREAD_STATE - #define MACHINE_THREAD_STATE_FLAVOR _THREAD_STATE - #define MACHINE_THREAD_STATE_COUNT _THREAD_STATE_COUNT - ---- a/sysdeps/mach/hurd/libc-lock.h -+++ b/sysdeps/mach/hurd/libc-lock.h -@@ -20,6 +20,9 @@ - #define _LIBC_LOCK_H 1 - - #if (_LIBC - 0) || (_CTHREADS_ - 0) -+#if (_LIBC - 0) -+#include -+#endif - #include - #include - ---- a/sysdeps/mach/hurd/fork.c -+++ b/sysdeps/mach/hurd/fork.c -@@ -528,6 +528,11 @@ __fork (void) - #endif - MACHINE_THREAD_STATE_SET_PC (&state, - (unsigned long int) _hurd_msgport_receive); -+ -+ /* Do special thread setup for TLS if needed. */ -+ if (err = _hurd_tls_fork (sigthread, _hurd_msgport_thread, &state)) -+ LOSE; -+ - if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR, - (natural_t *) &state, statecount)) - LOSE; -@@ -538,7 +543,7 @@ __fork (void) - _hurd_longjmp_thread_state (&state, env, 1); - - /* Do special thread setup for TLS if needed. */ -- if (err = _hurd_tls_fork (thread, &state)) -+ if (err = _hurd_tls_fork (thread, ss->thread, &state)) - LOSE; - - if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, ---- a/sysdeps/mach/hurd/i386/init-first.c -+++ b/sysdeps/mach/hurd/i386/init-first.c -@@ -113,31 +113,11 @@ init1 (int argc, char *arg0, ...) - data block; the argument strings start there. */ - if ((void *) d == argv[0]) - { --#ifndef SHARED -- /* With a new enough linker (binutils-2.23 or better), -- the magic __ehdr_start symbol will be available and -- __libc_start_main will have done this that way already. */ -- if (_dl_phdr == NULL) -- { -- /* We may need to see our own phdrs, e.g. for TLS setup. -- Try the usual kludge to find the headers without help from -- the exec server. */ -- extern const void __executable_start; -- const ElfW(Ehdr) *const ehdr = &__executable_start; -- _dl_phdr = (const void *) ehdr + ehdr->e_phoff; -- _dl_phnum = ehdr->e_phnum; -- assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); -- } --#endif - return; - } - - #ifndef SHARED - __libc_enable_secure = d->flags & EXEC_SECURE; -- -- _dl_phdr = (ElfW(Phdr) *) d->phdr; -- _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr)); -- assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); - #endif - - _hurd_init_dtable = d->dtable; -@@ -193,6 +173,40 @@ init (int *data) - ++envp; - d = (void *) ++envp; - -+#ifndef SHARED -+ /* If we are the bootstrap task started by the kernel, -+ then after the environment pointers there is no Hurd -+ data block; the argument strings start there. */ -+ if ((void *) d == argv[0]) -+ { -+ /* With a new enough linker (binutils-2.23 or better), -+ the magic __ehdr_start symbol will be available and -+ __libc_start_main will have done this that way already. */ -+ if (_dl_phdr == NULL) -+ { -+ /* We may need to see our own phdrs, e.g. for TLS setup. -+ Try the usual kludge to find the headers without help from -+ the exec server. */ -+ extern const void __executable_start; -+ const ElfW(Ehdr) *const ehdr = &__executable_start; -+ _dl_phdr = (const void *) ehdr + ehdr->e_phoff; -+ _dl_phnum = ehdr->e_phnum; -+ assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); -+ } -+ } -+ else -+ { -+ _dl_phdr = (ElfW(Phdr) *) d->phdr; -+ _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr)); -+ assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0); -+ } -+ -+ /* We need to setup TLS before starting sigthread */ -+ extern void __pthread_initialize_minimal(void); -+ if (__pthread_initialize_minimal != NULL) -+ __pthread_initialize_minimal(); -+#endif -+ - /* The user might have defined a value for this, to get more variables. - Otherwise it will be zero on startup. We must make sure it is set - properly before before cthreads initialization, so cthreads can know ---- a/sysdeps/mach/hurd/i386/tls.h -+++ b/sysdeps/mach/hurd/i386/tls.h -@@ -56,6 +56,15 @@ typedef struct - #define TLS_TCB_AT_TP 1 - #define TLS_DTV_AT_TP 0 - -+/* Alignment requirement for TCB. -+ -+ Some processors such as Intel Atom pay a big penalty on every -+ access using a segment override if that segment's base is not -+ aligned to the size of a cache line. (See Intel 64 and IA-32 -+ Architectures Optimization Reference Manual, section 13.3.3.3, -+ "Segment Base".) On such machines, a cache line is 64 bytes. */ -+#define TCB_ALIGNMENT 64 -+ - #ifndef __ASSEMBLER__ - - /* Use i386-specific RPCs to arrange that %gs segment register prefix -@@ -70,7 +70,7 @@ _hurd_tls_init (tcbhead_t *tcb, int seco - - /* Get the first available selector. */ - int sel = -1; -- error_t err = __i386_set_gdt (tcb->self, &sel, desc); -+ kern_return_t err = __i386_set_gdt (tcb->self, &sel, desc); - if (err == MIG_BAD_ID) - { - /* Old kernel, use a per-thread LDT. */ -@@ -139,9 +139,40 @@ _hurd_tls_init (tcbhead_t *tcb, int seco - - # include - --/* Set up TLS in the new thread of a fork child, copying from our own. */ --static inline error_t __attribute__ ((unused)) --_hurd_tls_fork (thread_t child, struct i386_thread_state *state) -+/* Set up TLS in the new thread of a fork child, copying from the original. */ -+static inline kern_return_t __attribute__ ((unused)) -+_hurd_tls_fork (thread_t child, thread_t orig, struct i386_thread_state *state) -+{ -+ /* Fetch the selector set by _hurd_tls_init. */ -+ int sel; -+ asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0)); -+ if (sel == state->ds) /* _hurd_tls_init was never called. */ -+ return 0; -+ -+ struct descriptor desc, *_desc = &desc; -+ int err; -+ unsigned int count = 1; -+ -+ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ -+ err = __i386_get_ldt (orig, sel, 1, &_desc, &count); -+ else -+ err = __i386_get_gdt (orig, sel, &desc); -+ -+ assert_perror (err); -+ if (err) -+ return err; -+ -+ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ -+ err = __i386_set_ldt (child, sel, &desc, 1); -+ else -+ err = __i386_set_gdt (child, &sel, desc); -+ -+ state->gs = sel; -+ return err; -+} -+ -+static inline kern_return_t __attribute__ ((unused)) -+_hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb) - { - /* Fetch the selector set by _hurd_tls_init. */ - int sel; -@@ -149,11 +180,13 @@ _hurd_tls_fork (thread_t child, struct i - if (sel == state->ds) /* _hurd_tls_init was never called. */ - return 0; - -- tcbhead_t *const tcb = THREAD_SELF; - HURD_TLS_DESC_DECL (desc, tcb); -- error_t err; -+ kern_return_t err; -+ -+ tcb->tcb = tcb; -+ tcb->self = child; - -- if (__builtin_expect (sel, 0x50) & 4) /* LDT selector */ -+ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */ - err = __i386_set_ldt (child, sel, &desc, 1); - else - err = __i386_set_gdt (child, &sel, desc); ---- a/sysdeps/mach/hurd/i386/trampoline.c -+++ b/sysdeps/mach/hurd/i386/trampoline.c -@@ -63,7 +63,7 @@ _hurd_setup_sighandler (struct hurd_sigs - sizeof (state->basic)); - memcpy (&state->fpu, &ss->context->sc_i386_float_state, - sizeof (state->fpu)); -- state->set |= (1 << i386_THREAD_STATE) | (1 << i386_FLOAT_STATE); -+ state->set |= (1 << i386_REGS_SEGS_STATE) | (1 << i386_FLOAT_STATE); - } - } - ---- a/sysdeps/mach/hurd/profil.c -+++ b/sysdeps/mach/hurd/profil.c -@@ -68,6 +68,8 @@ update_waiter (u_short *sample_buffer, s - if (! err) - err = __mach_setup_thread (__mach_task_self (), profile_thread, - &profile_waiter, NULL, NULL); -+ if (! err) -+ err = __mach_setup_tls(profile_thread); - } - else - err = 0; ---- a/sysdeps/mach/hurd/setitimer.c -+++ b/sysdeps/mach/hurd/setitimer.c -@@ -221,11 +221,12 @@ setitimer_locked (const struct itimerval - goto out; - _hurd_itimer_thread_stack_base = 0; /* Anywhere. */ - _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */ -- if (err = __mach_setup_thread (__mach_task_self (), -+ if ((err = __mach_setup_thread (__mach_task_self (), - _hurd_itimer_thread, - &timer_thread, - &_hurd_itimer_thread_stack_base, - &_hurd_itimer_thread_stack_size)) -+ || (err = __mach_setup_tls(_hurd_itimer_thread))) - { - __thread_terminate (_hurd_itimer_thread); - _hurd_itimer_thread = MACH_PORT_NULL; ---- a/sysdeps/mach/i386/thread_state.h -+++ b/sysdeps/mach/i386/thread_state.h -@@ -21,7 +21,8 @@ - - #include - --#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE -+#define MACHINE_NEW_THREAD_STATE_FLAVOR i386_THREAD_STATE -+#define MACHINE_THREAD_STATE_FLAVOR i386_REGS_SEGS_STATE - #define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT - - #define machine_thread_state i386_thread_state -@@ -30,6 +31,14 @@ - #define SP uesp - #define SYSRETURN eax - -+#define MACHINE_THREAD_STATE_FIX_NEW(ts) do { \ -+ asm ("mov %%cs, %w0" : "=q" ((ts)->cs)); \ -+ asm ("mov %%ds, %w0" : "=q" ((ts)->ds)); \ -+ asm ("mov %%es, %w0" : "=q" ((ts)->es)); \ -+ asm ("mov %%fs, %w0" : "=q" ((ts)->fs)); \ -+ asm ("mov %%gs, %w0" : "=q" ((ts)->gs)); \ -+} while(0) -+ - struct machine_thread_all_state - { - int set; /* Mask of bits (1 << FLAVOR). */ ---- a/sysdeps/mach/thread_state.h -+++ b/sysdeps/mach/thread_state.h -@@ -37,6 +37,9 @@ - ((ts)->SP = (unsigned long int) (stack) + (size)) - #endif - #endif -+#ifndef MACHINE_THREAD_STATE_FIX_NEW -+#define MACHINE_THREAD_STATE_FIX_NEW(ts) -+#endif - - /* These functions are of use in machine-dependent signal trampoline - implementations. */ diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-tls_thread_leak.diff glibc-2.27/debian/patches/hurd-i386/tg-tls_thread_leak.diff --- glibc-2.27/debian/patches/hurd-i386/tg-tls_thread_leak.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-tls_thread_leak.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -From: Richard Braun -Subject: [PATCH] Hurd: fix port leak in TLS - -Depending on whether the thread is the main thread or not, the threading -library can have trouble determining whether the thread reference in the -TCB is valid. The simple solution is to let the threading library -initialize the TCB, and use a temporary reference when initializing TLS. - -* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Use a temporary thread -reference. - ---- - sysdeps/mach/hurd/i386/tls.h | 35 +++++++++++++++++++++++------------ - 1 file changed, 23 insertions(+), 12 deletions(-) - ---- a/sysdeps/mach/hurd/i386/tls.h -+++ b/sysdeps/mach/hurd/i386/tls.h -@@ -69,6 +69,8 @@ static inline const char * __attribute__ - _hurd_tls_init (tcbhead_t *tcb) - { - HURD_TLS_DESC_DECL (desc, tcb); -+ thread_t self = __mach_thread_self (); -+ const char *msg = NULL; - - /* This field is used by TLS accesses to get our "thread pointer" - from the TLS point of view. */ -@@ -76,25 +78,26 @@ _hurd_tls_init (tcbhead_t *tcb, int seco - from the TLS point of view. */ - tcb->tcb = tcb; - -- /* Cache our thread port. */ -- tcb->self = __mach_thread_self (); -- - /* Get the first available selector. */ - int sel = -1; -- kern_return_t err = __i386_set_gdt (tcb->self, &sel, desc); -+ kern_return_t err = __i386_set_gdt (self, &sel, desc); - if (err == MIG_BAD_ID) - { - /* Old kernel, use a per-thread LDT. */ - sel = 0x27; -- err = __i386_set_ldt (tcb->self, sel, &desc, 1); -+ err = __i386_set_ldt (self, sel, &desc, 1); - assert_perror (err); - if (err) -- return "i386_set_ldt failed"; -+ { -+ msg = "i386_set_ldt failed"; -+ goto out; -+ } - } - else if (err) - { - assert_perror (err); /* Separate from above with different line #. */ -- return "i386_set_gdt failed"; -+ msg = "i386_set_gdt failed"; -+ goto out; - } - - /* Now install the new selector. */ -@@ -107,7 +110,9 @@ _hurd_tls_init (tcbhead_t *tcb, int seco - /* Now install the new selector. */ - asm volatile ("mov %w0, %%gs" :: "q" (sel)); - -- return 0; -+out: -+ __mach_port_deallocate (__mach_task_self (), self); -+ return msg; - } - - /* Code to initially initialize the thread pointer. This might need diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-tls-threadvar.diff glibc-2.27/debian/patches/hurd-i386/tg-tls-threadvar.diff --- glibc-2.27/debian/patches/hurd-i386/tg-tls-threadvar.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-tls-threadvar.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,846 +0,0 @@ -From: Thomas Schwinge -Subject: [PATCH] tls-threadvar - -replace the custom threadvar mechanism with generic TLS. -That will fix sigaltstack. - -Note: the added reply_port and _hurd_sigstate fields should be kept last. - ---- - hurd/Versions | 6 - - hurd/hurd/signal.h | 23 ++++--- - hurd/hurd/threadvar.h | 85 ++-------------------------- - hurd/hurdsig.c | 51 ++++++++++------ - hurd/hurdstartup.c | 1 - hurd/sigunwind.c | 4 - - include/errno.h | 2 - sysdeps/mach/hurd/Versions | 4 - - sysdeps/mach/hurd/cthreads.c | 2 - sysdeps/mach/hurd/dl-sysdep.c | 19 ------ - sysdeps/mach/hurd/errno-loc.c | 22 ++++--- - sysdeps/mach/hurd/errno.c | 1 - sysdeps/mach/hurd/fork.c | 7 -- - sysdeps/mach/hurd/i386/init-first.c | 36 ----------- - sysdeps/mach/hurd/i386/makecontext-helper.c | 2 - sysdeps/mach/hurd/i386/makecontext.S | 2 - sysdeps/mach/hurd/i386/sigreturn.c | 5 - - sysdeps/mach/hurd/i386/tls.h | 29 +++++++++ - sysdeps/mach/hurd/libc-lock.h | 4 - - sysdeps/mach/hurd/libc-tsd.h | 34 ----------- - sysdeps/mach/hurd/mig-reply.c | 39 +++--------- - sysdeps/mach/hurd/profil.c | 6 - - 22 files changed, 126 insertions(+), 258 deletions(-) - ---- a/hurd/Versions -+++ b/hurd/Versions -@@ -4,14 +4,9 @@ - _end; - - # variables used in macros & inline functions -- __hurd_sigthread_stack_base; __hurd_sigthread_stack_end; -- __hurd_sigthread_variables; - __hurd_threadvar_max; - __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; - -- # functions used in macros & inline functions -- __hurd_errno_location; -- - # functions used in libmachuser and libhurduser - _S_catch_exception_raise; - _S_catch_exception_raise_state; -@@ -146,6 +141,7 @@ - HURD_CTHREADS_0.3 { - # weak refs to libthreads functions that libc calls iff libthreads in use - cthread_fork; cthread_detach; -+ pthread_getattr_np; pthread_attr_getstack; - - # variables used for detecting cthreads - _cthread_exit_routine; _cthread_init_routine; ---- a/hurd/hurd/signal.h -+++ b/hurd/hurd/signal.h -@@ -40,7 +40,6 @@ - #include /* For `struct mutex'. */ - #include /* For `jmp_buf'. */ - #include --#include /* We cache sigstate in a threadvar. */ - struct hurd_signal_preemptor; /* */ - #if defined __USE_EXTERN_INLINES && defined _LIBC - # if IS_IN (libc) || IS_IN (libpthread) -@@ -139,11 +138,9 @@ - _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * - _hurd_self_sigstate (void) - { -- struct hurd_sigstate **location = (struct hurd_sigstate **) -- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); -- if (*location == NULL) -- *location = _hurd_thread_sigstate (__mach_thread_self ()); -- return *location; -+ if (THREAD_SELF->_hurd_sigstate == NULL) -+ THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); -+ return THREAD_SELF->_hurd_sigstate; - } - # endif - #endif -@@ -180,16 +177,22 @@ - _HURD_SIGNAL_H_EXTERN_INLINE void * - _hurd_critical_section_lock (void) - { -- struct hurd_sigstate **location = (struct hurd_sigstate **) -- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); -- struct hurd_sigstate *ss = *location; -+ struct hurd_sigstate *ss; -+ -+#ifdef __LIBC_NO_TLS -+ if (__LIBC_NO_TLS()) -+ /* TLS is currently initializing, no need to enter critical section. */ -+ return NULL; -+#endif -+ -+ ss = THREAD_SELF->_hurd_sigstate; - if (ss == NULL) - { - /* The thread variable is unset; this must be the first time we've - asked for it. In this case, the critical section flag cannot - possible already be set. Look up our sigstate structure the slow - way. */ -- ss = *location = _hurd_thread_sigstate (__mach_thread_self ()); -+ ss = THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); - } - - if (! __spin_try_lock (&ss->critical_section_lock)) ---- a/hurd/hurd/threadvar.h -+++ b/hurd/hurd/threadvar.h -@@ -20,6 +20,7 @@ - #define _HURD_THREADVAR_H - - #include -+#include - - /* The per-thread variables are found by ANDing this mask - with the value of the stack pointer and then adding this offset. -@@ -30,96 +31,24 @@ - __hurd_threadvar_stack_offset to a small offset that skips the data - cthreads itself maintains at the base of each thread's stack. - -- In the single-threaded case, __hurd_threadvar_stack_mask is zero, so the -- stack pointer is ignored; and __hurd_threadvar_stack_offset gives the -- address of a small allocated region which contains the variables for the -- single thread. */ -+ In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is -+ zero, so the stack pointer is ignored. */ - - extern unsigned long int __hurd_threadvar_stack_mask; - extern unsigned long int __hurd_threadvar_stack_offset; - --/* A special case must always be made for the signal thread. Even when there -- is only one user thread and an allocated region can be used for the user -- thread's variables, the signal thread needs to have its own location for -- per-thread variables. The variables __hurd_sigthread_stack_base and -+/* The variables __hurd_sigthread_stack_base and - __hurd_sigthread_stack_end define the bounds of the stack used by the - signal thread, so that thread can always be specifically identified. */ - - extern unsigned long int __hurd_sigthread_stack_base; - extern unsigned long int __hurd_sigthread_stack_end; --extern unsigned long int *__hurd_sigthread_variables; - - --/* At the location described by the two variables above, -- there are __hurd_threadvar_max `unsigned long int's of per-thread data. */ -+/* We do not use threadvars any more, this is kept as zero for compatibility with cthreads */ - extern unsigned int __hurd_threadvar_max; - --/* These values are the indices for the standard per-thread variables. */ --enum __hurd_threadvar_index -- { -- _HURD_THREADVAR_MIG_REPLY, /* Reply port for MiG user stub functions. */ -- _HURD_THREADVAR_ERRNO, /* `errno' value for this thread. */ -- _HURD_THREADVAR_SIGSTATE, /* This thread's `struct hurd_sigstate'. */ -- _HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */ -- _HURD_THREADVAR_MALLOC, /* For use of malloc. */ -- _HURD_THREADVAR_DL_ERROR, /* For use of -ldl and dynamic linker. */ -- _HURD_THREADVAR_RPC_VARS, /* For state of RPC functions. */ -- _HURD_THREADVAR_LOCALE, /* For thread-local locale setting. */ -- _HURD_THREADVAR_CTYPE_B, /* Cache of thread-local locale data. */ -- _HURD_THREADVAR_CTYPE_TOLOWER, /* Cache of thread-local locale data. */ -- _HURD_THREADVAR_CTYPE_TOUPPER, /* Cache of thread-local locale data. */ -- _HURD_THREADVAR_MAX /* Default value for __hurd_threadvar_max. */ -- }; -- -- --#ifndef _HURD_THREADVAR_H_EXTERN_INLINE --#define _HURD_THREADVAR_H_EXTERN_INLINE __extern_inline --#endif -- --/* Return the location of the value for the per-thread variable with index -- INDEX used by the thread whose stack pointer is SP. */ -- --extern unsigned long int *__hurd_threadvar_location_from_sp -- (enum __hurd_threadvar_index __index, void *__sp); -- --#if defined __USE_EXTERN_INLINES && defined _LIBC --# if IS_IN (libc) --_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int * --__hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index, -- void *__sp) --{ -- unsigned long int __stack = (unsigned long int) __sp; -- return &((__stack >= __hurd_sigthread_stack_base && -- __stack < __hurd_sigthread_stack_end) -- ? __hurd_sigthread_variables -- : (unsigned long int *) ((__stack & __hurd_threadvar_stack_mask) + -- __hurd_threadvar_stack_offset))[__index]; --} --# endif --#endif -- --#include /* Define __thread_stack_pointer. */ -- --/* Return the location of the current thread's value for the -- per-thread variable with index INDEX. */ -- --extern unsigned long int * --__hurd_threadvar_location (enum __hurd_threadvar_index __index) __THROW -- /* This declaration tells the compiler that the value is constant -- given the same argument. We assume this won't be called twice from -- the same stack frame by different threads. */ -- __attribute__ ((__const__)); -- --#if defined __USE_EXTERN_INLINES && defined _LIBC --# if IS_IN (libc) --_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int * --__hurd_threadvar_location (enum __hurd_threadvar_index __index) --{ -- return __hurd_threadvar_location_from_sp (__index, -- __thread_stack_pointer ()); --} --# endif --#endif -- -+extern mach_port_t __hurd_reply_port0; -+#define __hurd_local_reply_port (*(__LIBC_NO_TLS() ? &__hurd_reply_port0 : &THREAD_SELF->reply_port)) - - #endif /* hurd/threadvar.h */ ---- a/hurd/hurdsig.c -+++ b/hurd/hurdsig.c -@@ -20,6 +20,7 @@ - #include - - #include /* For `struct mutex'. */ -+#include - #include - #include - -@@ -48,7 +49,6 @@ - /* These are set up by _hurdsig_init. */ - unsigned long int __hurd_sigthread_stack_base; - unsigned long int __hurd_sigthread_stack_end; --unsigned long int *__hurd_sigthread_variables; - - /* Linked-list of per-thread signal state. */ - struct hurd_sigstate *_hurd_sigstates; -@@ -234,14 +234,14 @@ - that this location can be set without faulting, or else return NULL. */ - - static mach_port_t * --interrupted_reply_port_location (struct machine_thread_all_state *thread_state, -+interrupted_reply_port_location (thread_t thread, -+ struct machine_thread_all_state *thread_state, - int sigthread) - { -- mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp -- (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP); -+ mach_port_t *portloc = &THREAD_TCB(thread, thread_state)->reply_port; - - if (sigthread && _hurdsig_catch_memory_fault (portloc)) -- /* Faulted trying to read the stack. */ -+ /* Faulted trying to read the TCB. */ - return NULL; - - /* Fault now if this pointer is bogus. */ -@@ -323,7 +323,8 @@ - our nonzero return tells the trampoline code to finish the message - receive operation before running the handler. */ - -- mach_port_t *reply = interrupted_reply_port_location (state, -+ mach_port_t *reply = interrupted_reply_port_location (ss->thread, -+ state, - sigthread); - error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout); - -@@ -835,7 +836,8 @@ - - if (! machine_get_basic_state (ss->thread, &thread_state)) - goto sigbomb; -- loc = interrupted_reply_port_location (&thread_state, 1); -+ loc = interrupted_reply_port_location (ss->thread, -+ &thread_state, 1); - if (loc && *loc != MACH_PORT_NULL) - /* This is the reply port for the context which called - sigreturn. Since we are abandoning that context entirely -@@ -901,7 +903,8 @@ - { - /* Fetch the thread variable for the MiG reply port, - and set it to MACH_PORT_NULL. */ -- mach_port_t *loc = interrupted_reply_port_location (&thread_state, -+ mach_port_t *loc = interrupted_reply_port_location (ss->thread, -+ &thread_state, - 1); - if (loc) - { -@@ -1255,7 +1258,11 @@ - - /* Start the signal thread listening on the message port. */ - -- if (__hurd_threadvar_stack_mask == 0) -+#pragma weak cthread_fork -+#pragma weak cthread_detach -+#pragma weak pthread_getattr_np -+#pragma weak pthread_attr_getstack -+ if (!cthread_fork) - { - err = __thread_create (__mach_task_self (), &_hurd_msgport_thread); - assert_perror (err); -@@ -1270,14 +1277,6 @@ - assert_perror (err); - - __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize; -- __hurd_sigthread_variables = -- malloc (__hurd_threadvar_max * sizeof (unsigned long int)); -- if (__hurd_sigthread_variables == NULL) -- __libc_fatal ("hurd: Can't allocate threadvars for signal thread\n"); -- memset (__hurd_sigthread_variables, 0, -- __hurd_threadvar_max * sizeof (unsigned long int)); -- __hurd_sigthread_variables[_HURD_THREADVAR_LOCALE] -- = (unsigned long int) &_nl_global_locale; - - /* Reinitialize the MiG support routines so they will use a per-thread - variable for the cached reply port. */ -@@ -1288,6 +1287,7 @@ - } - else - { -+ cthread_t thread; - /* When cthreads is being used, we need to make the signal thread a - proper cthread. Otherwise it cannot use mutex_lock et al, which - will be the cthreads versions. Various of the message port RPC -@@ -1297,9 +1297,20 @@ - we'll let the signal thread's per-thread variables be found as for - any normal cthread, and just leave the magic __hurd_sigthread_* - values all zero so they'll be ignored. */ --#pragma weak cthread_fork --#pragma weak cthread_detach -- cthread_detach (cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); -+ cthread_detach (thread = cthread_fork ((cthread_fn_t) &_hurd_msgport_receive, 0)); -+ -+ if (pthread_getattr_np) -+ { -+ /* Record stack layout for fork() */ -+ pthread_attr_t attr; -+ void *addr; -+ size_t size; -+ -+ pthread_getattr_np ((pthread_t) thread, &attr); -+ pthread_attr_getstack (&attr, &addr, &size); -+ __hurd_sigthread_stack_base = (uintptr_t) addr; -+ __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + size; -+ } - - /* XXX We need the thread port for the signal thread further on - in this thread (see hurdfault.c:_hurdsigfault_init). ---- a/hurd/hurdstartup.c -+++ b/hurd/hurdstartup.c -@@ -23,7 +23,6 @@ - #include - #include - #include --#include - #include - #include - #include ---- a/hurd/sigunwind.c -+++ b/hurd/sigunwind.c -@@ -18,6 +18,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -38,8 +39,7 @@ - { - /* Destroy the MiG reply port used by the signal handler, and restore - the reply port in use by the thread when interrupted. */ -- mach_port_t *reply_port = -- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY); -+ mach_port_t *reply_port = &__hurd_local_reply_port; - if (*reply_port) - { - mach_port_t port = *reply_port; ---- a/include/errno.h -+++ b/include/errno.h -@@ -24,7 +24,7 @@ - - # include - --# if !defined(__GNU__) -+# if !(defined(__GNU__) && IS_IN (rtld)) - # undef errno - # if IS_IN (libc) - # define errno __libc_errno ---- a/sysdeps/mach/hurd/Versions -+++ b/sysdeps/mach/hurd/Versions -@@ -6,6 +6,7 @@ - GLIBC_PRIVATE { - # Functions shared with the dynamic linker - __libc_read; __libc_write; __libc_lseek64; -+ __libc_lock_self0; - - _dl_init_first; - } -@@ -14,8 +15,6 @@ - ld { - GLIBC_2.0 { - # variables that must be shared with libc -- __hurd_sigthread_stack_base; __hurd_sigthread_stack_end; -- __hurd_sigthread_variables; - __hurd_threadvar_stack_mask; __hurd_threadvar_stack_offset; - - # functions that must be shared with libc -@@ -33,5 +32,6 @@ - - # functions that must be shared with libc - __libc_read; __libc_write; __libc_lseek64; -+ __libc_lock_self0; - } - } ---- a/sysdeps/mach/hurd/libc-lock.h -+++ b/sysdeps/mach/hurd/libc-lock.h -@@ -24,7 +24,6 @@ - #include - #endif - #include --#include - - /* The locking here is very inexpensive, even for inlining. */ - #define _IO_lock_inexpensive 1 -@@ -38,7 +37,8 @@ - } __libc_lock_recursive_t; - typedef __libc_lock_recursive_t __rtld_lock_recursive_t; - --#define __libc_lock_owner_self() ((void *) __hurd_threadvar_location (0)) -+extern char __libc_lock_self0[0]; -+#define __libc_lock_owner_self() (__LIBC_NO_TLS() ? &__libc_lock_self0 : THREAD_SELF) - - #else - typedef struct __libc_lock_opaque__ __libc_lock_t; ---- a/sysdeps/mach/hurd/libc-tsd.h -+++ /dev/null -@@ -1,34 +0,0 @@ --/* libc-internal interface for thread-specific data. Hurd version. -- Copyright (C) 1998-2018 Free Software Foundation, Inc. -- 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 -- . */ -- --#ifndef _LIBC_TSD_H --#define _LIBC_TSD_H 1 -- --#include -- --#define __libc_tsd_define(CLASS, TYPE, KEY) /* nothing, always have threadvars */ -- --#define __libc_tsd_address(TYPE, KEY) \ -- ((TYPE *) __hurd_threadvar_location (_HURD_THREADVAR_##KEY)) -- --#define __libc_tsd_get(TYPE, KEY) \ -- (*__libc_tsd_address (TYPE, KEY)) --#define __libc_tsd_set(TYPE, KEY, VALUE) \ -- (*__libc_tsd_address (TYPE, KEY) = (VALUE)) -- --#endif /* libc-tsd.h */ ---- a/sysdeps/mach/hurd/cthreads.c -+++ b/sysdeps/mach/hurd/cthreads.c -@@ -19,6 +19,8 @@ - #include - #include - -+char __libc_lock_self0[0]; -+ - /* Placeholder for key creation routine from Hurd cthreads library. */ - int - weak_function ---- a/sysdeps/mach/hurd/dl-sysdep.c -+++ b/sysdeps/mach/hurd/dl-sysdep.c -@@ -67,25 +67,6 @@ - - struct hurd_startup_data *_dl_hurd_data; - --/* This is used only within ld.so, via dl-minimal.c's __errno_location. */ --#undef errno --int errno attribute_hidden; -- --/* Defining these variables here avoids the inclusion of hurdsig.c. */ --unsigned long int __hurd_sigthread_stack_base; --unsigned long int __hurd_sigthread_stack_end; --unsigned long int *__hurd_sigthread_variables; -- --/* Defining these variables here avoids the inclusion of init-first.c. -- We need to provide temporary storage for the per-thread variables -- of the main user thread here, since it is used for storing the -- `errno' variable. Note that this information is lost once we -- relocate the dynamic linker. */ --static unsigned long int threadvars[_HURD_THREADVAR_MAX]; --unsigned long int __hurd_threadvar_stack_offset -- = (unsigned long int) &threadvars; --unsigned long int __hurd_threadvar_stack_mask; -- - #define FMH defined(__i386__) - #if ! FMH - # define fmh() ((void)0) ---- a/sysdeps/mach/hurd/errno-loc.c -+++ b/sysdeps/mach/hurd/errno-loc.c -@@ -16,13 +16,21 @@ - License along with the GNU C Library; if not, see - . */ - --#include --#include -- --int * -+#if IS_IN (rtld) -+/* -+ * rtld can not access TLS too early, thus rtld_errno. -+ * -+ * Instead of making __open/__close pass errno from TLS to rtld_errno, simply -+ * use a weak __errno_location using rtld_errno, which will be overriden by the -+ * libc definition. -+ */ -+static int rtld_errno; -+int * weak_function - __errno_location (void) - { -- return (int *) __hurd_threadvar_location (_HURD_THREADVAR_ERRNO); -+ return &rtld_errno; - } --strong_alias (__errno_location, __hurd_errno_location) --libc_hidden_def (__errno_location) -+libc_hidden_weak (__errno_location) -+#else -+#include <../../../csu/errno-loc.c> -+#endif ---- a/sysdeps/mach/hurd/errno.c -+++ /dev/null -@@ -1 +0,0 @@ --/* No definition of `errno' variable on the Hurd. */ ---- a/sysdeps/mach/hurd/fork.c -+++ b/sysdeps/mach/hurd/fork.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include /* For stack growth direction. */ -@@ -483,19 +484,17 @@ - (natural_t *) &state, &statecount)) - LOSE; - #ifdef STACK_GROWTH_UP --#define THREADVAR_SPACE (__hurd_threadvar_max \ -- * sizeof *__hurd_sightread_variables) - if (__hurd_sigthread_stack_base == 0) - { - state.SP &= __hurd_threadvar_stack_mask; -- state.SP += __hurd_threadvar_stack_offset + THREADVAR_SPACE; -+ state.SP += __hurd_threadvar_stack_offset; - } - else - state.SP = __hurd_sigthread_stack_base; - #else - if (__hurd_sigthread_stack_end == 0) - { -- /* The signal thread has a normal stack assigned by cthreads. -+ /* The signal thread has a stack assigned by cthreads. - The threadvar_stack variables conveniently tell us how - to get to the highest address in the stack, just below - the per-thread variables. */ ---- a/sysdeps/mach/hurd/i386/init-first.c -+++ b/sysdeps/mach/hurd/i386/init-first.c -@@ -149,15 +149,6 @@ - char **argv = (void *) (data + 1); - char **envp = &argv[argc + 1]; - struct hurd_startup_data *d; -- unsigned long int threadvars[_HURD_THREADVAR_MAX]; -- -- /* Provide temporary storage for thread-specific variables on the -- startup stack so the cthreads initialization code can use them -- for malloc et al, or so we can use malloc below for the real -- threadvars array. */ -- memset (threadvars, 0, sizeof threadvars); -- threadvars[_HURD_THREADVAR_LOCALE] = (unsigned long int) &_nl_global_locale; -- __hurd_threadvar_stack_offset = (unsigned long int) threadvars; - - /* Since the cthreads initialization code uses malloc, and the - malloc initialization code needs to get at the environment, make -@@ -204,13 +195,6 @@ - __pthread_initialize_minimal(); - #endif - -- /* The user might have defined a value for this, to get more variables. -- Otherwise it will be zero on startup. We must make sure it is set -- properly before before cthreads initialization, so cthreads can know -- how much space to leave for thread variables. */ -- if (__hurd_threadvar_max < _HURD_THREADVAR_MAX) -- __hurd_threadvar_max = _HURD_THREADVAR_MAX; -- - - /* After possibly switching stacks, call `init1' (above) with the user - code as the return address, and the argument data immediately above -@@ -226,11 +210,6 @@ - - __libc_stack_end = newsp; - -- /* Copy per-thread variables from that temporary -- area onto the new cthread stack. */ -- memcpy (__hurd_threadvar_location_from_sp (0, newsp), -- threadvars, sizeof threadvars); -- - /* Copy the argdata from the old stack to the new one. */ - newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data, - (char *) d - (char *) data); -@@ -271,25 +250,10 @@ - } - else - { -- /* We are not using cthreads, so we will have just a single allocated -- area for the per-thread variables of the main user thread. */ -- unsigned long int *array; -- unsigned int i; - int usercode; - - void call_init1 (void); - -- array = malloc (__hurd_threadvar_max * sizeof (unsigned long int)); -- if (array == NULL) -- __libc_fatal ("Can't allocate single-threaded thread variables."); -- -- /* Copy per-thread variables from the temporary array into the -- newly malloc'd space. */ -- memcpy (array, threadvars, sizeof threadvars); -- __hurd_threadvar_stack_offset = (unsigned long int) array; -- for (i = _HURD_THREADVAR_MAX; i < __hurd_threadvar_max; ++i) -- array[i] = 0; -- - /* The argument data is just above the stack frame we will unwind by - returning. Mutate our own return address to run the code below. */ - /* The following expression would typically be written as ---- a/sysdeps/mach/hurd/i386/makecontext-helper.c -+++ b/sysdeps/mach/hurd/i386/makecontext-helper.c -@@ -22,6 +22,7 @@ - #include - #include - -+#if 0 - - void - __makecontext_helper (ucontext_t *ucp) -@@ -67,3 +68,4 @@ - ucp->uc_stack.ss_size -= t_size; - } - } -+#endif ---- a/sysdeps/mach/hurd/i386/makecontext.S -+++ b/sysdeps/mach/hurd/i386/makecontext.S -@@ -27,7 +27,7 @@ - subl $4, %esp - cfi_adjust_cfa_offset (4) - movl %eax, (%esp) -- call HIDDEN_JUMPTARGET (__makecontext_helper) -+ /* call HIDDEN_JUMPTARGET (__makecontext_helper) */ - addl $4, %esp - cfi_adjust_cfa_offset (-4) - ---- a/sysdeps/mach/hurd/i386/sigreturn.c -+++ b/sysdeps/mach/hurd/i386/sigreturn.c -@@ -68,7 +68,7 @@ - - if (scp->sc_onstack) - { -- ss->sigaltstack.ss_flags &= ~SS_ONSTACK; /* XXX threadvars */ -+ ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - /* XXX cannot unlock until off sigstack */ - abort (); - } -@@ -77,8 +77,7 @@ - - /* Destroy the MiG reply port used by the signal handler, and restore the - reply port in use by the thread when interrupted. */ -- reply_port = -- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY); -+ reply_port = &__hurd_local_reply_port; - if (*reply_port) - { - mach_port_t port = *reply_port; ---- a/sysdeps/mach/hurd/i386/tls.h -+++ b/sysdeps/mach/hurd/i386/tls.h -@@ -43,6 +43,10 @@ - void *__private_tm[4]; - /* GCC split stack support. */ - void *__private_ss; -+ -+ /* Keep this field last */ -+ mach_port_t reply_port; /* This thread's reply port. */ -+ struct hurd_sigstate *_hurd_sigstate; - } tcbhead_t; - #endif - -@@ -87,6 +91,17 @@ - | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \ - } - -+# define HURD_DESC_TLS(desc) \ -+ ({ \ -+ (tcbhead_t *) ( (desc->low_word >> 16) \ -+ | ((desc->high_word & 0xff) << 16) \ -+ | (desc->high_word & 0xff000000) \ -+ );}) -+ -+#define __LIBC_NO_TLS() \ -+ ({ unsigned short ds, gs; \ -+ asm ("movw %%ds,%w0; movw %%gs,%w1" : "=q" (ds), "=q" (gs)); \ -+ ds == gs; }) - - static inline const char * __attribute__ ((unused)) - _hurd_tls_init (tcbhead_t *tcb) -@@ -137,6 +152,20 @@ - : "i" (offsetof (tcbhead_t, tcb))); \ - __tcb;}) - -+/* Return the TCB address of a thread given its state. */ -+# define THREAD_TCB(thread, thread_state) \ -+ ({ int __sel = (thread_state)->basic.gs; \ -+ struct descriptor __desc, *___desc = &__desc; \ -+ unsigned int __count = 1; \ -+ kern_return_t __err; \ -+ if (__builtin_expect (__sel, 0x48) & 4) /* LDT selector */ \ -+ __err = __i386_get_ldt ((thread), __sel, 1, &___desc, &__count); \ -+ else \ -+ __err = __i386_get_gdt ((thread), __sel, &__desc); \ -+ assert_perror (__err); \ -+ assert (__count == 1); \ -+ HURD_DESC_TLS(___desc);}) -+ - /* Install new dtv for current thread. */ - # define INSTALL_NEW_DTV(dtvp) \ - ({ asm volatile ("movl %0,%%gs:%P1" \ ---- a/sysdeps/mach/hurd/mig-reply.c -+++ b/sysdeps/mach/hurd/mig-reply.c -@@ -18,26 +18,20 @@ - #include - #include - --#define GETPORT \ -- mach_port_t *portloc = \ -- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY) --#define reply_port (*(use_threadvar ? portloc : &global_reply_port)) -- --static int use_threadvar; --static mach_port_t global_reply_port; -- - /* These functions are called by MiG-generated code. */ - -+mach_port_t __hurd_reply_port0; -+ - /* Called by MiG to get a reply port. */ - mach_port_t - __mig_get_reply_port (void) - { -- GETPORT; -- -- if (reply_port == MACH_PORT_NULL) -- reply_port = __mach_reply_port (); -+ if (__hurd_local_reply_port == MACH_PORT_NULL || -+ (&__hurd_local_reply_port != &__hurd_reply_port0 -+ && __hurd_local_reply_port == __hurd_reply_port0)) -+ __hurd_local_reply_port = __mach_reply_port (); - -- return reply_port; -+ return __hurd_local_reply_port; - } - weak_alias (__mig_get_reply_port, mig_get_reply_port) - -@@ -45,12 +39,8 @@ - void - __mig_dealloc_reply_port (mach_port_t arg) - { -- mach_port_t port; -- -- GETPORT; -- -- port = reply_port; -- reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ -+ mach_port_t port = __hurd_local_reply_port; -+ __hurd_local_reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ - - if (MACH_PORT_VALID (port)) - __mach_port_mod_refs (__mach_task_self (), port, -@@ -73,15 +63,6 @@ - void - __mig_init (void *stack) - { -- use_threadvar = stack != 0; -- -- if (use_threadvar) -- { -- /* Recycle the reply port used before multithreading was enabled. */ -- mach_port_t *portloc = (mach_port_t *) -- __hurd_threadvar_location_from_sp (_HURD_THREADVAR_MIG_REPLY, stack); -- *portloc = global_reply_port; -- global_reply_port = MACH_PORT_NULL; -- } -+ /* Do nothing. */ - } - weak_alias (__mig_init, mig_init) ---- a/sysdeps/mach/hurd/profil.c -+++ b/sysdeps/mach/hurd/profil.c -@@ -143,7 +143,7 @@ - static volatile error_t special_profil_failure; - - /* Fetch PC samples. This function must be very careful not to depend -- on Hurd threadvar variables. We arrange that by using a special -+ on Hurd TLS variables. We arrange that by using a special - stub arranged for at the end of this file. */ - static void - fetch_samples (void) -@@ -178,7 +178,7 @@ - } - - --/* This function must be very careful not to depend on Hurd threadvar -+/* This function must be very careful not to depend on Hurd TLS - variables. We arrange that by using special stubs arranged for at the - end of this file. */ - static void -@@ -269,7 +269,7 @@ - are fatal in profile_waiter anyhow. */ - #define __mig_put_reply_port(foo) - --/* Use our static variable instead of the usual threadvar mechanism for -+/* Use our static variable instead of the usual TLS mechanism for - this. */ - #define __mig_get_reply_port() profil_reply_port - diff -Nru glibc-2.27/debian/patches/hurd-i386/tg-verify.h.diff glibc-2.27/debian/patches/hurd-i386/tg-verify.h.diff --- glibc-2.27/debian/patches/hurd-i386/tg-verify.h.diff 2016-01-27 14:17:05.000000000 +0000 +++ glibc-2.27/debian/patches/hurd-i386/tg-verify.h.diff 2018-04-16 20:02:33.000000000 +0000 @@ -5,7 +5,7 @@ * include/verify.h: New file, from gnulib. -TODO: Use it in all sensible places. +TODO: Remove, not needed any more. --- include/verify.h | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff -Nru glibc-2.27/debian/patches/localedata/locales-fr.diff glibc-2.27/debian/patches/localedata/locales-fr.diff --- glibc-2.27/debian/patches/localedata/locales-fr.diff 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/localedata/locales-fr.diff 2018-04-16 20:02:33.000000000 +0000 @@ -20,7 +20,7 @@ t_fmt "%T" am_pm "";"" t_fmt_ampm "" -+date_fmt "%A %-e %B %Y, %H:%M:%S +(UTC%z)" ++date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" week 7;19971130;4 first_weekday 2 @@ -48,7 +48,7 @@ t_fmt "%T" am_pm "";"" t_fmt_ampm "" -+date_fmt "%A %-e +%B %Y, +%H:%M:%S +(UTC%z)" ++date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" week 7;19971130;1 END LC_TIME @@ -58,7 +58,7 @@ t_fmt "%T" am_pm "";"" t_fmt_ampm "" -+date_fmt "%A %-e +%B %Y, +%H:%M:%S +(UTC%z)" ++date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" week 7;19971130;4 first_weekday 2 END LC_TIME @@ -86,7 +86,7 @@ t_fmt "%T" am_pm "";"" t_fmt_ampm "" -+date_fmt "%A %-e +%B %Y, +%H:%M:%S +(UTC%z)" ++date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" week 7;19971130;4 first_weekday 2 @@ -116,7 +116,7 @@ t_fmt "%T" am_pm "";"" t_fmt_ampm "" -+date_fmt "%A %-e +%B %Y, +%H:%M:%S +(UTC%z)" ++date_fmt "%A %-e %B %Y, %H:%M:%S (UTC%z)" week 7;19971130;4 first_weekday 2 END LC_TIME diff -Nru glibc-2.27/debian/patches/series glibc-2.27/debian/patches/series --- glibc-2.27/debian/patches/series 2018-04-02 16:09:02.000000000 +0000 +++ glibc-2.27/debian/patches/series 2018-04-16 20:02:50.000000000 +0000 @@ -26,6 +26,7 @@ alpha/submitted-dl-support.diff alpha/local-string-functions.diff alpha/submitted-fts64.diff +alpha/submitted-makecontext.diff arm/local-sigaction.diff arm/unsubmitted-ldconfig-cache-abi.diff @@ -39,21 +40,21 @@ hurd-i386/local-enable-ldconfig.diff hurd-i386/tg-context_functions.diff -hurd-i386/tg-tls.diff -hurd-i386/tg-tls-threadvar.diff +hurd-i386/git-tls.diff +hurd-i386/git-tls-threadvar.diff hurd-i386/tg-sysvshm.diff -hurd-i386/tg-_dl_random.diff +hurd-i386/git-_dl_random.diff hurd-i386/tg-thread-cancel.diff hurd-i386/tg-bigmem.diff hurd-i386/local-disable-ioctls.diff hurd-i386/tg-locarchive.diff hurd-i386/tg-sendmsg-SCM_RIGHTS.diff hurd-i386/tg-sendmsg-SCM_CREDS.diff -hurd-i386/tg-grantpt.diff +hurd-i386/git-grantpt.diff hurd-i386/tg-mach-hurd-link.diff hurd-i386/local-ED.diff hurd-i386/tg-posix_thread.diff -hurd-i386/tg-gai_misc.diff +hurd-i386/git-gai_misc.diff hurd-i386/local-madvise_warn.diff hurd-i386/tg-hurdsig-fixes.diff hurd-i386/tg-hurdsig-global-dispositions.diff @@ -73,7 +74,7 @@ hurd-i386/tg-pie-sbrk.diff hurd-i386/tg-ifaddrs_v6.diff hurd-i386/tg-remap_getcwd.diff -hurd-i386/tg-exec-static.diff +hurd-i386/git-exec-static.diff hurd-i386/tg-EIEIO-fr.diff hurd-i386/tg-EGREGIOUS-fr.diff hurd-i386/tg-io_select_timeout.diff @@ -84,38 +85,41 @@ hurd-i386/tg-socketpair_flags.diff hurd-i386/tg-pipe2.diff hurd-i386/tg-libc_getspecific.diff -hurd-i386/tg-futimens.diff +hurd-i386/git-futimens.diff hurd-i386/tg-sigstate_thread_reference.diff -hurd-i386/tg-tls_thread_leak.diff +hurd-i386/git-tls_thread_leak.diff hurd-i386/submitted-bind_umask2.diff -hurd-i386/local-libpthread-stacksize.diff +hurd-i386/git-libpthread-stacksize.diff hurd-i386/tg-WRLCK-upgrade.diff -hurd-i386/tg-reboot-startup.diff +hurd-i386/git-reboot-startup.diff hurd-i386/cvs-revert-gnu-gnu-cleanup.diff hurd-i386/libpthread_pthread_types.diff hurd-i386/tg-bootstrap.diff hurd-i386/local-mach_print.diff -hurd-i386/submitted-hurd-abilist.diff +hurd-i386/git-hurd-abilist.diff #hurd-i386/submitted-anon-mmap-shared.diff hurd-i386/tg-eintr.diff hurd-i386/tg-gsync-libc.diff hurd-i386/tg-pthread_deps.diff -hurd-i386/tg-libpthread-gsync-spin.diff +hurd-i386/git-libpthread-gsync-spin.diff hurd-i386/tg-ONSTACK.diff -hurd-i386/tg-libpthread-gsync-mutex.diff -hurd-i386/tg-NOFOLLOW.diff -hurd-i386/tg-NOFOLLOW-DIRECTORY.diff +hurd-i386/git-libpthread-gsync-mutex.diff +hurd-i386/git-NOFOLLOW.diff +hurd-i386/git-NOFOLLOW-DIRECTORY.diff hurd-i386/tg-libc_rwlock_recursive.diff hurd-i386/tg-magic-pid.diff -hurd-i386/tg-mlockall.diff +hurd-i386/git-mlockall.diff hurd-i386/local-no_unsupported_ioctls.diff -hurd-i386/tg2.25-tls.diff +hurd-i386/git2.25-tls.diff hurd-i386/local-nocheck-installed-headers.diff hurd-i386/git-libpthread-2.26.diff -hurd-i386/tg-thread-linkspace.diff +hurd-i386/git-thread-linkspace.diff hurd-i386/libpthread_includes.diff hurd-i386/local-exec_filename.diff +hurd-i386/git-libpthread-trylock.diff hurd-i386/git-test-atexit-race-common.diff +hurd-i386/git-UTIME.diff +#hurd-i386/libpthread_sigs.diff i386/local-biarch.diff i386/unsubmitted-quiet-ldconfig.diff diff -Nru glibc-2.27/debian/patches/series.hurd-i386 glibc-2.27/debian/patches/series.hurd-i386 --- glibc-2.27/debian/patches/series.hurd-i386 2018-02-22 09:46:35.000000000 +0000 +++ glibc-2.27/debian/patches/series.hurd-i386 2018-04-16 20:02:33.000000000 +0000 @@ -1,16 +1,15 @@ hurd-i386/submitted-net.diff -hurd-i386/tg-gscope.diff +hurd-i386/git-gscope.diff hurd-i386/tg-bits_atomic.h_multiple_threads.diff hurd-i386/tg-unlockpt-chroot.diff hurd-i386/local-clock_gettime_MONOTONIC.diff hurd-i386/submitted-AF_LINK.diff hurd-i386/unsubmitted-mremap.diff hurd-i386/tg-verify.h.diff -hurd-i386/tg-pagesize.diff +hurd-i386/git-pagesize.diff hurd-i386/local-no-bootstrap-fs-access.diff -hurd-i386/tg-timer_routines.diff +hurd-i386/git-timer_routines.diff hurd-i386/local-versions-hack.diff hurd-i386/unsubmitted-prof-eintr.diff -#hurd-i386/submitted-malloc-setstate.diff hurd-i386/tg-glibc-2.24-restore-malloc-hook.diff hurd-i386/tg2.26-sched_param.diff diff -Nru glibc-2.27/debian/rules glibc-2.27/debian/rules --- glibc-2.27/debian/rules 2018-02-22 09:47:56.000000000 +0000 +++ glibc-2.27/debian/rules 2018-04-16 20:02:50.000000000 +0000 @@ -128,19 +128,13 @@ # Which build pass are we on? curpass = $(filter-out %_,$(subst _,_ ,$@)) -# Provide backward compatibility for the old DEB_STAGE and DEB_BUILD_PROFILE for now -ifeq ($(DEB_STAGE),stage1) - DEB_BUILD_PROFILES+=stage1 -else -ifeq ($(DEB_BUILD_PROFILE),bootstrap) - DEB_BUILD_PROFILES+=stage1 -endif -endif - ifneq ($(filter stage1,$(DEB_BUILD_PROFILES)),) DEB_ARCH_REGULAR_PACKAGES = $(libc)-dev DEB_INDEP_REGULAR_PACKAGES = DEB_UDEB_PACKAGES = + ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) + DEB_BUILD_OPTIONS+=nocheck + endif else DEB_ARCH_REGULAR_PACKAGES = $(libc) $(libc)-dev $(libc)-dbg $(libc)-pic libc-bin libc-dev-bin multiarch-support DEB_INDEP_REGULAR_PACKAGES = glibc-doc glibc-source locales diff -Nru glibc-2.27/debian/testsuite-xfail-debian.mk glibc-2.27/debian/testsuite-xfail-debian.mk --- glibc-2.27/debian/testsuite-xfail-debian.mk 2018-02-22 15:43:15.000000000 +0000 +++ glibc-2.27/debian/testsuite-xfail-debian.mk 2018-04-16 20:14:20.000000000 +0000 @@ -1046,6 +1046,23 @@ ###################################################################### +# s390 +###################################################################### +ifeq ($(config-machine)-$(config-os),s390-linux-gnu) +# https://sourceware.org/bugzilla/show_bug.cgi?id=22916 +test-xfail-tst-backtrace4 = yes +test-xfail-tst-backtrace5 = yes +# https://sourceware.org/bugzilla/show_bug.cgi?id=22917 +test-xfail-tst-cancelx20 = yes +test-xfail-tst-cancelx21 = yes + +# In some conditions the kernel might not provide a heap, causing +# some tests to fail. See bug#889817 for details. +test-xfail-tst-malloc-usable-tunables = yes +endif + + +###################################################################### # s390x ###################################################################### ifeq ($(config-machine)-$(config-os),s390x-linux-gnu)