[glibc] 01/02: hurd: update libpthread to fix symbol exposition
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch glibc-2.26
in repository glibc.
commit b78cd5b57c5c761b03c3f6907f0ee838d116946e
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Mon Sep 25 22:18:13 2017 +0000
hurd: update libpthread to fix symbol exposition
---
debian/patches/hurd-i386/cvs-libpthread.diff | 61 +-
.../hurd-i386/tg-libpthread-gsync-mutex.diff | 1342 ++++++++++++++------
2 files changed, 979 insertions(+), 424 deletions(-)
diff --git a/debian/patches/hurd-i386/cvs-libpthread.diff b/debian/patches/hurd-i386/cvs-libpthread.diff
index dd677f5..6e27b31 100644
--- a/debian/patches/hurd-i386/cvs-libpthread.diff
+++ b/debian/patches/hurd-i386/cvs-libpthread.diff
@@ -1,7 +1,7 @@
-git diff empty --patch-with-stat --src-prefix=glibc/libpthread/ --dst-prefix=glibc/libpthread/ f881f17267506f3ced17259a066a4d95bffb57f0
+git diff empty --patch-with-stat --src-prefix=glibc/libpthread/ --dst-prefix=glibc/libpthread/ 596061769ee34741a42eb375b1a2e06fffb4c5a3
from git.savannah.gnu.org:/srv/git/hurd/libpthread.git/
thus by construction only libpthread/ files, thus hurd-only
-Date: Sun Sep 24 23:09:59 2017 +0200
+Date: Mon Sep 25 21:47:12 2017 +0200
ChangeLog | 6 +
Makeconfig | 20 +
@@ -11,6 +11,7 @@ Date: Sun Sep 24 23:09:59 2017 +0200
configure | 2 +
configure.in | 4 +
forward.c | 281 +++++++++
+ sysdeps/pthread/pthread.h | 22 +
include/pthread/pthread.h | 835 ++++++++++++++++++++++++++
include/pthread/pthreadtypes.h | 125 ++++
libc_pthread_init.c | 35 ++
@@ -122,8 +123,8 @@ Date: Sun Sep 24 23:09:59 2017 +0200
sysdeps/generic/pt-rwlock-destroy.c | 29 +
sysdeps/generic/pt-rwlock-init.c | 45 ++
sysdeps/generic/pt-rwlock-rdlock.c | 33 +
- sysdeps/generic/pt-rwlock-timedrdlock.c | 120 ++++
- sysdeps/generic/pt-rwlock-timedwrlock.c | 103 ++++
+ sysdeps/generic/pt-rwlock-timedrdlock.c | 121 ++++
+ sysdeps/generic/pt-rwlock-timedwrlock.c | 104 ++++
sysdeps/generic/pt-rwlock-tryrdlock.c | 56 ++
sysdeps/generic/pt-rwlock-trywrlock.c | 46 ++
sysdeps/generic/pt-rwlock-unlock.c | 99 +++
@@ -154,12 +155,13 @@ Date: Sun Sep 24 23:09:59 2017 +0200
sysdeps/hurd/pt-init-specific.c | 30 +
sysdeps/hurd/pt-key-create.c | 110 ++++
sysdeps/hurd/pt-key-delete.c | 64 ++
- sysdeps/hurd/pt-key.h | 76 +++
+ sysdeps/hurd/pt-key.h | 77 +++
sysdeps/hurd/pt-kill.c | 52 ++
sysdeps/hurd/pt-setspecific.c | 48 ++
sysdeps/i386/bits/memory.h | 40 ++
sysdeps/i386/bits/pt-atomic.h | 66 ++
sysdeps/i386/bits/pthreadtypes-arch.h | 21 +
+ sysdeps/pthread/bits/thread-shared-types.h | 24 +
sysdeps/i386/machine-sp.h | 30 +
sysdeps/i386/pt-machdep.h | 29 +
sysdeps/mach/bits/spin-lock-inline.h | 90 +++
@@ -205,14 +207,12 @@ Date: Sun Sep 24 23:09:59 2017 +0200
sysdeps/pthread/bits/rwlock.h | 46 ++
sysdeps/pthread/bits/semaphore.h | 44 ++
sysdeps/pthread/bits/thread-attr.h | 47 ++
- sysdeps/pthread/bits/thread-shared-types.h | 24 +
sysdeps/pthread/bits/thread-specific.h | 25 +
sysdeps/pthread/flockfile.c | 32 +
sysdeps/pthread/ftrylockfile.c | 35 ++
sysdeps/pthread/funlockfile.c | 33 +
sysdeps/pthread/libc-lockP.h | 158 +++++
sysdeps/pthread/pthread-functions.h | 141 +++++
- sysdeps/pthread/pthread.h | 22 +
sysdeps/pthread/semaphore.h | 81 +++
tests/.cvsignore | 1 +
tests/Makefile | 40 ++
@@ -235,7 +235,7 @@ Date: Sun Sep 24 23:09:59 2017 +0200
tests/test-8.c | 60 ++
tests/test-9.c | 88 +++
tests/test-__pthread_destroy_specific-skip.c | 83 +++
- 232 files changed, 13233 insertions(+)
+ 232 files changed, 13236 insertions(+)
diff --git glibc/libpthread/ChangeLog glibc/libpthread/ChangeLog
new file mode 100644
@@ -8088,7 +8088,7 @@ index 0000000..c9ff9b2
+strong_alias (_pthread_rwlock_init, pthread_rwlock_init);
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-rdlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-rdlock.c
new file mode 100644
-index 0000000..6eca601
+index 0000000..708e3e1
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/pt-rwlock-rdlock.c
@@ -0,0 +1,33 @@
@@ -8124,13 +8124,13 @@ index 0000000..6eca601
+{
+ return __pthread_rwlock_timedrdlock_internal (rwlock, 0);
+}
-+strong_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock);
++weak_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock);
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c
new file mode 100644
-index 0000000..69bc757
+index 0000000..4cfba43
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c
-@@ -0,0 +1,120 @@
+@@ -0,0 +1,121 @@
+/* Acquire a rwlock for reading. Generic version.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -8246,17 +8246,18 @@ index 0000000..69bc757
+}
+
+int
-+pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock,
++__pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedrdlock_internal (rwlock, abstime);
+}
++weak_alias (__pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock)
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c
new file mode 100644
-index 0000000..be25629
+index 0000000..2adaf03
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c
-@@ -0,0 +1,103 @@
+@@ -0,0 +1,104 @@
+/* Acquire a rwlock for writing. Generic version.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -8355,11 +8356,12 @@ index 0000000..be25629
+}
+
+int
-+pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
++__pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedwrlock_internal (rwlock, abstime);
+}
++weak_alias (__pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock)
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c
new file mode 100644
index 0000000..30cb6cf
@@ -8476,7 +8478,7 @@ index 0000000..af8f911
+}
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-unlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-unlock.c
new file mode 100644
-index 0000000..d538544
+index 0000000..0506ae6
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/pt-rwlock-unlock.c
@@ -0,0 +1,99 @@
@@ -8578,10 +8580,10 @@ index 0000000..d538544
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+}
-+strong_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock);
++weak_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock);
diff --git glibc/libpthread/sysdeps/generic/pt-rwlock-wrlock.c glibc/libpthread/sysdeps/generic/pt-rwlock-wrlock.c
new file mode 100644
-index 0000000..68254d1
+index 0000000..c769bc6
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/pt-rwlock-wrlock.c
@@ -0,0 +1,35 @@
@@ -8619,7 +8621,7 @@ index 0000000..68254d1
+{
+ return __pthread_rwlock_timedwrlock_internal (rwlock, 0);
+}
-+strong_alias (__pthread_rwlock_wrlock, pthread_rwlock_wrlock);
++weak_alias (__pthread_rwlock_wrlock, pthread_rwlock_wrlock);
diff --git glibc/libpthread/sysdeps/generic/pt-rwlockattr-destroy.c glibc/libpthread/sysdeps/generic/pt-rwlockattr-destroy.c
new file mode 100644
index 0000000..eabfcbe
@@ -9281,7 +9283,7 @@ index 0000000..6d438bf
+strong_alias (__sem_post, sem_post);
diff --git glibc/libpthread/sysdeps/generic/sem-timedwait.c glibc/libpthread/sysdeps/generic/sem-timedwait.c
new file mode 100644
-index 0000000..7ab1583
+index 0000000..11c1391
--- /dev/null
+++ glibc/libpthread/sysdeps/generic/sem-timedwait.c
@@ -0,0 +1,100 @@
@@ -9384,7 +9386,7 @@ index 0000000..7ab1583
+ return __sem_timedwait_internal (sem, timeout);
+}
+
-+strong_alias (__sem_timedwait, sem_timedwait);
++weak_alias (__sem_timedwait, sem_timedwait);
diff --git glibc/libpthread/sysdeps/generic/sem-trywait.c glibc/libpthread/sysdeps/generic/sem-trywait.c
new file mode 100644
index 0000000..437e282
@@ -9901,10 +9903,10 @@ index 0000000..8b2c8bb
+}
diff --git glibc/libpthread/sysdeps/hurd/pt-key.h glibc/libpthread/sysdeps/hurd/pt-key.h
new file mode 100644
-index 0000000..494e01d
+index 0000000..7b6a2c2
--- /dev/null
+++ glibc/libpthread/sysdeps/hurd/pt-key.h
-@@ -0,0 +1,76 @@
+@@ -0,0 +1,77 @@
+/* pthread_key internal declatations for the Hurd version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
@@ -9926,6 +9928,7 @@ index 0000000..494e01d
+
+#include <pthread.h>
+#include <hurd/ihash.h>
++#include <libc-lockP.h>
+
+#define PTHREAD_KEY_MEMBERS \
+ hurd_ihash_t thread_specifics;
@@ -9966,20 +9969,20 @@ index 0000000..494e01d
+ int err;
+ pthread_mutexattr_t attr;
+
-+ err = pthread_mutexattr_init (&attr);
++ err = __pthread_mutexattr_init (&attr);
+ assert_perror (err);
+
-+ err = pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
++ err = __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+ assert_perror (err);
+
-+ err = pthread_mutex_init (&__pthread_key_lock, &attr);
++ err = _pthread_mutex_init (&__pthread_key_lock, &attr);
+ assert_perror (err);
+
-+ err = pthread_mutexattr_destroy (&attr);
++ err = __pthread_mutexattr_destroy (&attr);
+ assert_perror (err);
+ }
+
-+ pthread_once (&o, do_init);
++ __pthread_once (&o, do_init);
+}
diff --git glibc/libpthread/sysdeps/hurd/pt-kill.c glibc/libpthread/sysdeps/hurd/pt-kill.c
new file mode 100644
diff --git a/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff b/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff
index 5b2a56d..3eef03a 100644
--- a/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff
+++ b/debian/patches/hurd-i386/tg-libpthread-gsync-mutex.diff
@@ -1,11 +1,11 @@
-commit 7343f91b7ec3487c1f0b63bfd437bb9dd82ae2a5
+commit f6839074d25aba7e93b8672a9ed9893c0baa5e3d
Author: Agustina Arzille <avarzille@riseup.net>
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 3aa6a93..c7742e8 100644
+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;
@@ -128,73 +128,10 @@ index 0000000..a52a2ad
+#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..40a8c17
+index 0000000..2c6acd1
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-destroy.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-getprioceiling.c
-@@ -0,0 +1 @@
-+/* empty */
-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..32010a2
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-init.c
-@@ -0,0 +1 @@
-+#include "pt-mutex.c"
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-lock.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-setprioceiling.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-timedlock.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-transfer-np.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-trylock.c
-@@ -0,0 +1 @@
-+/* empty */
-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..40a8c17
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex-unlock.c
-@@ -0,0 +1 @@
-+/* empty */
-diff --git a/libpthread/sysdeps/mach/hurd/pt-mutex.c b/libpthread/sysdeps/mach/hurd/pt-mutex.c
-new file mode 100644
-index 0000000..8104fa3
---- /dev/null
-+++ b/libpthread/sysdeps/mach/hurd/pt-mutex.c
-@@ -0,0 +1,552 @@
+@@ -0,0 +1,36 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ Contributed by Agustina Arzille <avarzille@riseup.net>, 2016.
+
@@ -217,109 +154,96 @@ index 0000000..8104fa3
+#include <stdlib.h>
+#include <assert.h>
+#include <pt-internal.h>
++#include "pt-mutex.h"
+#include <hurdlock.h>
+
-+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);
-+}
-+
-+int pthread_mutexattr_destroy (pthread_mutexattr_t *attrp)
-+{
-+ (void)attrp;
-+ return (0);
-+}
-+
-+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);
-+}
-+
-+int pthread_mutexattr_gettype (const pthread_mutexattr_t *attrp, int *outp)
-+{
-+ *outp = attrp->__mutex_type;
-+ return (0);
-+}
-+
-+int pthread_mutexattr_setpshared (pthread_mutexattr_t *attrp, int pshared)
++int _pthread_mutex_destroy (pthread_mutex_t *mtxp)
+{
-+ if (pshared != PTHREAD_PROCESS_PRIVATE &&
-+ pshared != PTHREAD_PROCESS_SHARED)
-+ return (EINVAL);
-+
-+ attrp->__pshared = pshared;
-+ return (0);
-+}
++ atomic_read_barrier ();
++ if (*(volatile unsigned int *)&mtxp->__lock != 0)
++ return (EBUSY);
+
-+int pthread_mutexattr_getpshared (const pthread_mutexattr_t *attrp, int *outp)
-+{
-+ *outp = attrp->__pshared;
++ mtxp->__type = -1;
+ return (0);
+}
+
-+int pthread_mutexattr_setrobust (pthread_mutexattr_t *attrp, int robust)
-+{
-+ if (robust != PTHREAD_MUTEX_ROBUST &&
-+ robust != PTHREAD_MUTEX_STALLED)
-+ return (EINVAL);
++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 <avarzille@riseup.net>, 2016.
+
-+ attrp->__prioceiling |= robust;
-+ return (0);
-+}
++ 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.
+
-+weak_alias (pthread_mutexattr_setrobust, pthread_mutexattr_setrobust_np)
++ 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.
+
-+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);
-+}
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+weak_alias (pthread_mutexattr_getrobust, pthread_mutexattr_getrobust_np)
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
-+int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attrp, int cl)
++int pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp)
+{
-+ (void)attrp; (void)cl;
++ (void)mtxp; (void)clp;
+ return (ENOSYS);
+}
+
-+stub_warning (pthread_mutexattr_setprioceiling)
++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 <avarzille@riseup.net>, 2016.
+
-+int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *ap, int *clp)
-+{
-+ (void)ap; (void)clp;
-+ return (ENOSYS);
-+}
++ 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.
+
-+stub_warning (pthread_mutexattr_getprioceiling)
++ 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.
+
-+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);
-+}
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attrp, int *ptp)
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++static const pthread_mutexattr_t dfl_attr =
+{
-+ *ptp = attrp->__protocol;
-+ return (0);
-+}
++ .__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)
@@ -343,76 +267,36 @@ index 0000000..8104fa3
+}
+
+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 <avarzille@riseup.net>, 2016.
+
-+/* Lock routines. */
-+
-+/* Special ID used to signal an unrecoverable robust mutex. */
-+#define NOTRECOVERABLE_ID (1U << 31)
++ 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.
+
-+/* 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
++ 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.
+
-+/* 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))
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+extern int __getpid (void) __attribute__ ((const));
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
+int __pthread_mutex_lock (pthread_mutex_t *mtxp)
+{
@@ -468,63 +352,74 @@ index 0000000..8104fa3
+
+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 <avarzille@riseup.net>, 2016.
+
-+int __pthread_mutex_trylock (pthread_mutex_t *mtxp)
-+{
-+ struct __pthread *self;
-+ int ret;
++ 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.
+
-+ switch (MTX_TYPE (mtxp))
-+ {
-+ case PT_MTX_NORMAL:
-+ ret = lll_trylock (&mtxp->__lock) == 0 ? 0 : EBUSY;
-+ break;
++ 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.
+
-+ case PT_MTX_RECURSIVE:
-+ self = _pthread_self ();
-+ if (mtx_owned_p (mtxp, self, mtxp->__flags))
-+ {
-+ if (__glibc_unlikely (mtxp->__cnt + 1 == 0))
-+ return (EAGAIN);
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+ ++mtxp->__cnt;
-+ ret = 0;
-+ }
-+ else if ((ret = lll_trylock (&mtxp->__lock)) == 0)
-+ {
-+ mtx_set_owner (mtxp, self, mtxp->__flags);
-+ mtxp->__cnt = 1;
-+ }
-+ else
-+ ret = EBUSY;
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
-+ break;
++int pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp)
++{
++ (void)mtxp; (void)cl; (void)prp;
++ return (ENOSYS);
++}
+
-+ case PT_MTX_ERRORCHECK:
-+ self = _pthread_self ();
-+ if ((ret = lll_trylock (&mtxp->__lock)) == 0)
-+ mtx_set_owner (mtxp, self, mtxp->__flags);
-+ else
-+ ret = EBUSY;
-+ break;
++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 <avarzille@riseup.net>, 2016.
+
-+ 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;
++ 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.
+
-+ default:
-+ ret = EINVAL;
-+ break;
-+ }
++ 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.
+
-+ return (ret);
-+}
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock)
-+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
+int pthread_mutex_timedlock (pthread_mutex_t *mtxp,
+ const struct timespec *tsp)
@@ -581,93 +476,36 @@ index 0000000..8104fa3
+
+ 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 <avarzille@riseup.net>, 2016.
+
-+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)
-+
-+int pthread_mutex_consistent (pthread_mutex_t *mtxp)
-+{
-+ int ret = EINVAL;
-+ unsigned int val = mtxp->__lock;
++ 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.
+
-+ 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;
-+ }
++ 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.
+
-+ return (ret);
-+}
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+weak_alias (pthread_mutex_consistent, pthread_mutex_consistent_np)
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
+int __pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th)
+{
@@ -717,106 +555,571 @@ index 0000000..8104fa3
+ return (ret);
+}
+
-+strong_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np)
++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 <avarzille@riseup.net>, 2016.
+
-+int pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp)
-+{
-+ (void)mtxp; (void)cl; (void)prp;
-+ return (ENOSYS);
-+}
++ 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.
+
-+stub_warning (pthread_mutex_setprioceiling)
++ 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.
+
-+int pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp)
-+{
-+ (void)mtxp; (void)clp;
-+ return (ENOSYS);
-+}
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, see
++ <http://www.gnu.org/licenses/>.
++*/
+
-+stub_warning (pthread_mutex_getprioceiling)
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
+
-+int _pthread_mutex_destroy (pthread_mutex_t *mtxp)
++int __pthread_mutex_trylock (pthread_mutex_t *mtxp)
+{
-+ atomic_read_barrier ();
-+ if (*(volatile unsigned int *)&mtxp->__lock != 0)
-+ return (EBUSY);
++ struct __pthread *self;
++ int ret;
+
-+ mtxp->__type = -1;
-+ return (0);
++ 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_destroy, pthread_mutex_destroy)
++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 <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..ad711ac
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-destroy.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..bcfc8c8
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,32 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..cb94424
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,30 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..7639528
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-getpshared.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,30 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..746f628
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-gettype.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..4cac661
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-init.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,39 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..d399050
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,32 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..9f7f152
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,32 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..c10dfa0
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-setpshared.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,34 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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..40a8c17
+index 0000000..67ed4f5
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-mutexattr-settype.c
-@@ -0,0 +1 @@
-+/* empty */
+@@ -0,0 +1,34 @@
++/* Copyright (C) 2016 Free Software Foundation, Inc.
++ Contributed by Agustina Arzille <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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
@@ -824,3 +1127,252 @@ index 0000000..40a8c17
+++ 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 <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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 <avarzille@riseup.net>, 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 <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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 <avarzille@riseup.net>, 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
++ <http://www.gnu.org/licenses/>.
++*/
++
++#include <pthread.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <pt-internal.h>
++#include "pt-mutex.h"
++#include <hurdlock.h>
++
++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)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-glibc/glibc.git
Reply to: