diff options
author | Samuel Thibault <sthibault@debian.org> | 2009-05-28 01:31:00 +0000 |
---|---|---|
committer | Samuel Thibault <sthibault@debian.org> | 2009-05-28 01:31:00 +0000 |
commit | 093007a61419bb3cd86ec4386a2433b81a467f12 (patch) | |
tree | fae543a808aaf90417b6ae5e549699962711081c /debian | |
parent | 07034c18144f3bf68b5ada5fd1338777f869eb80 (diff) |
* debian/patches/libpthread_recursive_mutex_initializer.patch: New patch
to fix the recursive mutex initializers usage in libraries not linking
against libpthread.
Diffstat (limited to 'debian')
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/patches/libpthread_recursive_mutex_initializer.patch | 303 | ||||
-rw-r--r-- | debian/patches/series | 2 |
3 files changed, 307 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog index d4cee716..d78c17d5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,11 +53,12 @@ hurd (20080921-1) UNRELEASED; urgency=low libpthread. * debian/patches/libpthread_setcancel.patch: New patch to fix configuration of octave3.0. - * debian/patches/libpthread_no_recursive_mutex_initializer.patch: New patch - to drop undefined references to __pthread_recursive_mutexattr. * debian/patches/extern_inline_fix.patch: New patch from Marc Dequène to fix extern inline declarations. * debian/patches/exec_fix.patch: New patch to fix random hang of exec. + * debian/patches/libpthread_recursive_mutex_initializer.patch: New patch + to fix the recursive mutex initializers usage in libraries not linking + against libpthread. -- Michael Banck <mbanck@debian.org> Sat, 13 Sep 2008 23:43:27 +0200 diff --git a/debian/patches/libpthread_recursive_mutex_initializer.patch b/debian/patches/libpthread_recursive_mutex_initializer.patch new file mode 100644 index 00000000..d9332b70 --- /dev/null +++ b/debian/patches/libpthread_recursive_mutex_initializer.patch @@ -0,0 +1,303 @@ +Index: libpthread/include/pthread/pthread.h +=================================================================== +--- libpthread/include/pthread/pthread.h.orig 2009-05-27 23:53:05.000000000 +0000 ++++ libpthread/include/pthread/pthread.h 2009-05-27 23:53:40.000000000 +0000 +@@ -313,6 +313,8 @@ + /* Static initializer for recursive mutexes. */ + + #ifdef __USE_GNU ++# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ ++ __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER + # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ + __PTHREAD_RECURSIVE_MUTEX_INITIALIZER + #endif +Index: libpthread/sysdeps/generic/pt-mutex-destroy.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-destroy.c.orig 2008-08-12 15:07:49.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-destroy.c 2009-05-27 23:53:40.000000000 +0000 +@@ -26,7 +26,8 @@ + int + _pthread_mutex_destroy (pthread_mutex_t *mutex) + { +- if (mutex->attr == &__pthread_recursive_mutexattr) ++ if (mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR ++ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR) + /* Static attributes. */ + ; + else +Index: libpthread/sysdeps/generic/pt-mutex-init.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-init.c.orig 2008-08-12 15:07:49.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-init.c 2009-05-27 23:53:40.000000000 +0000 +@@ -35,14 +35,11 @@ + /* The default attributes. */ + return 0; + +- if (attr == &__pthread_recursive_mutexattr) +- /* Non-default but known attributes. */ +- { +- mutex->attr = attr; +- return 0; +- } ++ if (! mutex->attr ++ || mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR ++ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR) ++ mutex->attr = malloc (sizeof *attr); + +- mutex->attr = malloc (sizeof *attr); + if (! mutex->attr) + return ENOMEM; + +Index: libpthread/sysdeps/generic/pt-mutex-timedlock.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-timedlock.c.orig 2008-10-02 12:00:42.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-timedlock.c 2009-05-27 23:53:40.000000000 +0000 +@@ -31,6 +31,12 @@ + const struct timespec *abstime) + { + struct __pthread *self; ++ const struct __pthread_mutexattr *attr = mutex->attr; ++ ++ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR) ++ attr = &__pthread_errorcheck_mutexattr; ++ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR) ++ attr = &__pthread_recursive_mutexattr; + + __pthread_spin_lock (&mutex->__lock); + if (__pthread_spin_trylock (&mutex->__held) == 0) +@@ -50,8 +56,8 @@ + #endif + #endif + +- if (mutex->attr) +- switch (mutex->attr->mutex_type) ++ if (attr) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_NORMAL: + break; +@@ -75,7 +81,7 @@ + self = _pthread_self (); + assert (self); + +- if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL) ++ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL) + { + #if defined(ALWAYS_TRACK_MUTEX_OWNER) + assert (mutex->owner != self); +@@ -83,7 +89,7 @@ + } + else + { +- switch (mutex->attr->mutex_type) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_ERRORCHECK: + if (mutex->owner == self) +@@ -108,7 +114,7 @@ + } + + #if !defined(ALWAYS_TRACK_MUTEX_OWNER) +- if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL) ++ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL) + #endif + assert (mutex->owner); + +@@ -147,14 +153,14 @@ + __pthread_block (self); + + #if !defined(ALWAYS_TRACK_MUTEX_OWNER) +- if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL) ++ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL) + #endif + { + assert (mutex->owner == self); + } + +- if (mutex->attr) +- switch (mutex->attr->mutex_type) ++ if (attr) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_NORMAL: + break; +Index: libpthread/sysdeps/generic/pt-mutex-transfer-np.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-transfer-np.c.orig 2008-10-02 12:00:40.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-transfer-np.c 2009-05-27 23:53:40.000000000 +0000 +@@ -29,13 +29,20 @@ + assert (mutex->owner == _pthread_self ()); + + struct __pthread *thread = __pthread_getid (tid); ++ const struct __pthread_mutexattr *attr = mutex->attr; ++ + if (! thread) + return ESRCH; + + if (thread == _pthread_self ()) + return 0; + +- if (mutex->attr && mutex->attr->mutex_type == PTHREAD_MUTEX_ERRORCHECK) ++ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR) ++ attr = &__pthread_errorcheck_mutexattr; ++ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR) ++ attr = &__pthread_recursive_mutexattr; ++ ++ if (attr && attr->mutex_type == PTHREAD_MUTEX_ERRORCHECK) + { + + if (mutex->owner != _pthread_self ()) +@@ -46,7 +53,7 @@ + + #ifndef NDEBUG + # if !defined(ALWAYS_TRACK_MUTEX_OWNER) +- if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL) ++ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL) + # endif + { + mutex->owner = thread; +Index: libpthread/sysdeps/generic/pt-mutex-trylock.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-trylock.c.orig 2009-05-27 23:53:39.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-trylock.c 2009-05-27 23:53:40.000000000 +0000 +@@ -29,6 +29,12 @@ + { + int err; + struct __pthread *self; ++ const struct __pthread_mutexattr *attr = mutex->attr; ++ ++ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR) ++ attr = &__pthread_errorcheck_mutexattr; ++ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR) ++ attr = &__pthread_recursive_mutexattr; + + __pthread_spin_lock (&mutex->__lock); + if (__pthread_spin_trylock (&mutex->__held) == 0) +@@ -48,8 +54,8 @@ + #endif + #endif + +- if (mutex->attr) +- switch (mutex->attr->mutex_type) ++ if (attr) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_NORMAL: + break; +@@ -70,10 +76,10 @@ + + err = EBUSY; + +- if (mutex->attr) ++ if (attr) + { + self = _pthread_self (); +- switch (mutex->attr->mutex_type) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_NORMAL: + break; +Index: libpthread/sysdeps/generic/pt-mutex-unlock.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutex-unlock.c.orig 2008-10-02 12:00:37.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutex-unlock.c 2009-05-27 23:53:40.000000000 +0000 +@@ -28,10 +28,16 @@ + __pthread_mutex_unlock (pthread_mutex_t *mutex) + { + struct __pthread *wakeup; +- ++ const struct __pthread_mutexattr *attr = mutex->attr; ++ ++ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR) ++ attr = &__pthread_errorcheck_mutexattr; ++ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR) ++ attr = &__pthread_recursive_mutexattr; ++ + __pthread_spin_lock (&mutex->__lock); + +- if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL) ++ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL) + { + #if defined(ALWAYS_TRACK_MUTEX_OWNER) + # ifndef NDEBUG +@@ -45,7 +51,7 @@ + #endif + } + else +- switch (mutex->attr->mutex_type) ++ switch (attr->mutex_type) + { + case PTHREAD_MUTEX_ERRORCHECK: + case PTHREAD_MUTEX_RECURSIVE: +@@ -55,7 +61,7 @@ + return EPERM; + } + +- if (mutex->attr->mutex_type == PTHREAD_MUTEX_RECURSIVE) ++ if (attr->mutex_type == PTHREAD_MUTEX_RECURSIVE) + if (--mutex->locks > 0) + { + __pthread_spin_unlock (&mutex->__lock); +@@ -82,7 +88,7 @@ + + #ifndef NDEBUG + # if !defined (ALWAYS_TRACK_MUTEX_OWNER) +- if (mutex->attr && mutex->attr->mutex_type != PTHREAD_MUTEX_NORMAL) ++ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL) + # endif + { + mutex->owner = wakeup; +Index: libpthread/sysdeps/generic/pt-mutexattr.c +=================================================================== +--- libpthread/sysdeps/generic/pt-mutexattr.c.orig 2008-08-12 15:07:49.000000000 +0000 ++++ libpthread/sysdeps/generic/pt-mutexattr.c 2009-05-27 23:53:40.000000000 +0000 +@@ -28,6 +28,14 @@ + mutex_type: PTHREAD_MUTEX_DEFAULT + }; + ++const struct __pthread_mutexattr __pthread_errorcheck_mutexattr = ++{ ++ prioceiling: 0, ++ protocol: PTHREAD_PRIO_NONE, ++ pshared: PTHREAD_PROCESS_PRIVATE, ++ mutex_type: PTHREAD_MUTEX_ERRORCHECK ++}; ++ + const struct __pthread_mutexattr __pthread_recursive_mutexattr = + { + prioceiling: 0, +Index: libpthread/sysdeps/generic/bits/mutex.h +=================================================================== +--- libpthread/sysdeps/generic/bits/mutex.h.orig 2009-01-10 13:22:27.000000000 +0000 ++++ libpthread/sysdeps/generic/bits/mutex.h 2009-05-27 23:53:40.000000000 +0000 +@@ -57,9 +57,17 @@ + # define __PTHREAD_MUTEX_INITIALIZER \ + { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 } + ++# define __PTHREAD_ERRORCHECK_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_ERRORCHECK + 1)) ++ ++# define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \ ++ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \ ++ __PTHREAD_ERRORCHECK_MUTEXATTR, 0, 0, 0 } ++ ++# define __PTHREAD_RECURSIVE_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_RECURSIVE + 1)) ++ + # define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ + { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \ +- (struct __pthread_mutexattr *) &__pthread_recursive_mutexattr, 0, 0, 0 } ++ __PTHREAD_RECURSIVE_MUTEXATTR, 0, 0, 0 } + + # endif + #endif /* Not __pthread_mutex_defined. */ +Index: libpthread/sysdeps/generic/bits/mutex-attr.h +=================================================================== +--- libpthread/sysdeps/generic/bits/mutex-attr.h.orig 2009-05-27 23:59:37.000000000 +0000 ++++ libpthread/sysdeps/generic/bits/mutex-attr.h 2009-05-27 23:59:44.000000000 +0000 +@@ -35,6 +35,7 @@ + }; + + /* Attributes for a recursive mutex. */ ++extern const struct __pthread_mutexattr __pthread_errorcheck_mutexattr; + extern const struct __pthread_mutexattr __pthread_recursive_mutexattr; + + #endif /* bits/mutex-attr.h */ diff --git a/debian/patches/series b/debian/patches/series index 904f4e3b..9365185c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -26,6 +26,6 @@ dir_acces_fix.patch -p0 libports_stability.patch -p0 libpthread_fix.patch -p0 libpthread_setcancel.patch -p0 -libpthread_no_recursive_mutex_initializer.patch -p0 extern_inline_fix.patch -p1 exec_fix.patch -p0 +libpthread_recursive_mutex_initializer.patch -p0 |