* thread.cc (pthread_mutex::pthread_mutex): Change default type
to PTHREAD_MUTEX_NORMAL. (pthread_mutex::unlock): Return EPERM if the mutex has no owner and the mutex type is PTHREAD_MUTEX_ERRORCHECK, as on Linux. (pthread_mutexattr::pthread_mutexattr): Ditto. (pthread_mutex_unlock): Do not fail if mutex is a normal mutex initializer. * include/pthread.h (PTHREAD_MUTEX_INITIALIZER): Redefine as PTHREAD_NORMAL_MUTEX_INITIALIZER_NP.
This commit is contained in:
parent
87375c75b3
commit
4866e86cb1
|
@ -1,3 +1,15 @@
|
||||||
|
2014-07-14 Yaakov Selkowitz <yselkowitz@cygwin.com>
|
||||||
|
|
||||||
|
* thread.cc (pthread_mutex::pthread_mutex): Change default type
|
||||||
|
to PTHREAD_MUTEX_NORMAL.
|
||||||
|
(pthread_mutex::unlock): Return EPERM if the mutex has no owner and
|
||||||
|
the mutex type is PTHREAD_MUTEX_ERRORCHECK, as on Linux.
|
||||||
|
(pthread_mutexattr::pthread_mutexattr): Ditto.
|
||||||
|
(pthread_mutex_unlock): Do not fail if mutex is a normal mutex
|
||||||
|
initializer.
|
||||||
|
* include/pthread.h (PTHREAD_MUTEX_INITIALIZER): Redefine as
|
||||||
|
PTHREAD_NORMAL_MUTEX_INITIALIZER_NP.
|
||||||
|
|
||||||
2014-07-09 Corinna Vinschen <corinna@vinschen.de>
|
2014-07-09 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* thread.cc (pthread::create): Use PTHREAD_DEFAULT_STACKSIZE stacksize
|
* thread.cc (pthread::create): Use PTHREAD_DEFAULT_STACKSIZE stacksize
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern "C"
|
||||||
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP (pthread_mutex_t)18
|
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP (pthread_mutex_t)18
|
||||||
#define PTHREAD_NORMAL_MUTEX_INITIALIZER_NP (pthread_mutex_t)19
|
#define PTHREAD_NORMAL_MUTEX_INITIALIZER_NP (pthread_mutex_t)19
|
||||||
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP (pthread_mutex_t)20
|
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP (pthread_mutex_t)20
|
||||||
#define PTHREAD_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
#define PTHREAD_MUTEX_INITIALIZER PTHREAD_NORMAL_MUTEX_INITIALIZER_NP
|
||||||
#define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 }
|
#define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 }
|
||||||
#if defined(_POSIX_THREAD_PRIO_INHERIT) && _POSIX_THREAD_PRIO_INHERIT >= 0
|
#if defined(_POSIX_THREAD_PRIO_INHERIT) && _POSIX_THREAD_PRIO_INHERIT >= 0
|
||||||
#define PTHREAD_PRIO_NONE 0
|
#define PTHREAD_PRIO_NONE 0
|
||||||
|
|
|
@ -1709,7 +1709,7 @@ pthread_mutex::pthread_mutex (pthread_mutexattr *attr) :
|
||||||
tid (0),
|
tid (0),
|
||||||
#endif
|
#endif
|
||||||
recursion_counter (0), condwaits (0),
|
recursion_counter (0), condwaits (0),
|
||||||
type (PTHREAD_MUTEX_ERRORCHECK),
|
type (PTHREAD_MUTEX_NORMAL),
|
||||||
pshared (PTHREAD_PROCESS_PRIVATE)
|
pshared (PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL);
|
win32_obj_id = ::CreateEvent (&sec_none_nih, false, false, NULL);
|
||||||
|
@ -1777,7 +1777,7 @@ pthread_mutex::unlock ()
|
||||||
if (type == PTHREAD_MUTEX_NORMAL)
|
if (type == PTHREAD_MUTEX_NORMAL)
|
||||||
/* no error checking */;
|
/* no error checking */;
|
||||||
else if (no_owner ())
|
else if (no_owner ())
|
||||||
res = type == PTHREAD_MUTEX_ERRORCHECK ? EINVAL : 0;
|
res = type == PTHREAD_MUTEX_ERRORCHECK ? EPERM : 0;
|
||||||
else if (!pthread::equal (owner, self))
|
else if (!pthread::equal (owner, self))
|
||||||
res = EPERM;
|
res = EPERM;
|
||||||
if (!res && recursion_counter > 0 && --recursion_counter == 0)
|
if (!res && recursion_counter > 0 && --recursion_counter == 0)
|
||||||
|
@ -1851,7 +1851,7 @@ pthread_mutex::_fixup_after_fork ()
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutexattr::pthread_mutexattr ():verifyable_object (PTHREAD_MUTEXATTR_MAGIC),
|
pthread_mutexattr::pthread_mutexattr ():verifyable_object (PTHREAD_MUTEXATTR_MAGIC),
|
||||||
pshared (PTHREAD_PROCESS_PRIVATE), mutextype (PTHREAD_MUTEX_ERRORCHECK)
|
pshared (PTHREAD_PROCESS_PRIVATE), mutextype (PTHREAD_MUTEX_NORMAL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3159,7 +3159,7 @@ extern "C" int
|
||||||
pthread_mutex_unlock (pthread_mutex_t *mutex)
|
pthread_mutex_unlock (pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
if (pthread_mutex::is_initializer (mutex))
|
if (pthread_mutex::is_initializer (mutex))
|
||||||
return EPERM;
|
pthread_mutex::init (mutex, NULL, *mutex);
|
||||||
if (!pthread_mutex::is_good_object (mutex))
|
if (!pthread_mutex::is_good_object (mutex))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return (*mutex)->unlock ();
|
return (*mutex)->unlock ();
|
||||||
|
|
Loading…
Reference in New Issue