cygwin: Implement pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
eb206317a8
commit
8128f5482f
|
@ -1085,6 +1085,8 @@ pthread_once SIGFE
|
||||||
pthread_rwlock_destroy SIGFE
|
pthread_rwlock_destroy SIGFE
|
||||||
pthread_rwlock_init SIGFE
|
pthread_rwlock_init SIGFE
|
||||||
pthread_rwlock_rdlock SIGFE
|
pthread_rwlock_rdlock SIGFE
|
||||||
|
pthread_rwlock_timedrdlock SIGFE
|
||||||
|
pthread_rwlock_timedwrlock SIGFE
|
||||||
pthread_rwlock_tryrdlock SIGFE
|
pthread_rwlock_tryrdlock SIGFE
|
||||||
pthread_rwlock_trywrlock SIGFE
|
pthread_rwlock_trywrlock SIGFE
|
||||||
pthread_rwlock_unlock SIGFE
|
pthread_rwlock_unlock SIGFE
|
||||||
|
|
|
@ -480,12 +480,13 @@ details. */
|
||||||
313: Export fls, flsl, flsll.
|
313: Export fls, flsl, flsll.
|
||||||
314: Export explicit_bzero.
|
314: Export explicit_bzero.
|
||||||
315: Export pthread_mutex_timedlock.
|
315: Export pthread_mutex_timedlock.
|
||||||
|
316: Export pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock.
|
||||||
|
|
||||||
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
|
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
|
||||||
sigaltstack, sethostname. */
|
sigaltstack, sethostname. */
|
||||||
|
|
||||||
#define CYGWIN_VERSION_API_MAJOR 0
|
#define CYGWIN_VERSION_API_MAJOR 0
|
||||||
#define CYGWIN_VERSION_API_MINOR 315
|
#define CYGWIN_VERSION_API_MINOR 316
|
||||||
|
|
||||||
/* There is also a compatibity version number associated with the shared memory
|
/* There is also a compatibity version number associated with the shared memory
|
||||||
regions. It is incremented when incompatible changes are made to the shared
|
regions. It is incremented when incompatible changes are made to the shared
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
What's new:
|
What's new:
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
- New APIs: explicit_bzero, pthread_mutex_timedwait.
|
- New APIs: explicit_bzero.
|
||||||
|
|
||||||
|
- New APIs: pthread_mutex_timedwait, pthread_rwlock_timedrdlock,
|
||||||
|
pthread_rwlock_timedwrlock.
|
||||||
|
|
||||||
|
|
||||||
What changed:
|
What changed:
|
||||||
|
|
|
@ -1413,7 +1413,7 @@ pthread_rwlock::~pthread_rwlock ()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pthread_rwlock::rdlock ()
|
pthread_rwlock::rdlock (PLARGE_INTEGER timeout)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct RWLOCK_READER *reader;
|
struct RWLOCK_READER *reader;
|
||||||
|
@ -1435,7 +1435,7 @@ pthread_rwlock::rdlock ()
|
||||||
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
|
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
|
||||||
|
|
||||||
++waiting_readers;
|
++waiting_readers;
|
||||||
cond_readers.wait (&mtx);
|
cond_readers.wait (&mtx, timeout);
|
||||||
--waiting_readers;
|
--waiting_readers;
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
@ -1481,7 +1481,7 @@ pthread_rwlock::tryrdlock ()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pthread_rwlock::wrlock ()
|
pthread_rwlock::wrlock (PLARGE_INTEGER timeout)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
pthread_t self = pthread::self ();
|
pthread_t self = pthread::self ();
|
||||||
|
@ -1499,7 +1499,7 @@ pthread_rwlock::wrlock ()
|
||||||
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
|
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
|
||||||
|
|
||||||
++waiting_writers;
|
++waiting_writers;
|
||||||
cond_writers.wait (&mtx);
|
cond_writers.wait (&mtx, timeout);
|
||||||
--waiting_writers;
|
--waiting_writers;
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
@ -3045,6 +3045,37 @@ pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
|
||||||
return (*rwlock)->rdlock ();
|
return (*rwlock)->rdlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock,
|
||||||
|
const struct timespec *abstime)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER timeout;
|
||||||
|
|
||||||
|
pthread_testcancel ();
|
||||||
|
|
||||||
|
if (pthread_rwlock::is_initializer (rwlock))
|
||||||
|
pthread_rwlock::init (rwlock, NULL);
|
||||||
|
if (!pthread_rwlock::is_good_object (rwlock))
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
/* According to SUSv3, abstime need not be checked for validity,
|
||||||
|
if the rwlock can be locked immediately. */
|
||||||
|
if (!(*rwlock)->tryrdlock ())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
int err = pthread_convert_abstime (CLOCK_REALTIME, abstime, &timeout);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return (*rwlock)->rdlock (&timeout);
|
||||||
|
}
|
||||||
|
__except (NO_ERROR) {}
|
||||||
|
__endtry
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
|
pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
|
@ -3069,6 +3100,37 @@ pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
|
||||||
return (*rwlock)->wrlock ();
|
return (*rwlock)->wrlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock,
|
||||||
|
const struct timespec *abstime)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER timeout;
|
||||||
|
|
||||||
|
pthread_testcancel ();
|
||||||
|
|
||||||
|
if (pthread_rwlock::is_initializer (rwlock))
|
||||||
|
pthread_rwlock::init (rwlock, NULL);
|
||||||
|
if (!pthread_rwlock::is_good_object (rwlock))
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
/* According to SUSv3, abstime need not be checked for validity,
|
||||||
|
if the rwlock can be locked immediately. */
|
||||||
|
if (!(*rwlock)->trywrlock ())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
int err = pthread_convert_abstime (CLOCK_REALTIME, abstime, &timeout);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return (*rwlock)->wrlock (&timeout);
|
||||||
|
}
|
||||||
|
__except (NO_ERROR) {}
|
||||||
|
__endtry
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
|
pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
|
|
|
@ -587,10 +587,10 @@ public:
|
||||||
} *readers;
|
} *readers;
|
||||||
fast_mutex readers_mx;
|
fast_mutex readers_mx;
|
||||||
|
|
||||||
int rdlock ();
|
int rdlock (PLARGE_INTEGER timeout = NULL);
|
||||||
int tryrdlock ();
|
int tryrdlock ();
|
||||||
|
|
||||||
int wrlock ();
|
int wrlock (PLARGE_INTEGER timeout = NULL);
|
||||||
int trywrlock ();
|
int trywrlock ();
|
||||||
|
|
||||||
int unlock ();
|
int unlock ();
|
||||||
|
|
|
@ -9,7 +9,12 @@
|
||||||
<itemizedlist mark="bullet">
|
<itemizedlist mark="bullet">
|
||||||
|
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
New APIs: explicit_bzero, pthread_mutex_timedwait.
|
New APIs: explicit_bzero.
|
||||||
|
</para></listitem>
|
||||||
|
|
||||||
|
<listitem><para>
|
||||||
|
New APIs: pthread_mutex_timedwait, pthread_rwlock_timedrdlock,
|
||||||
|
pthread_rwlock_timedwrlock.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
|
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
|
|
|
@ -723,6 +723,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
||||||
pthread_rwlock_destroy
|
pthread_rwlock_destroy
|
||||||
pthread_rwlock_init
|
pthread_rwlock_init
|
||||||
pthread_rwlock_rdlock
|
pthread_rwlock_rdlock
|
||||||
|
pthread_rwlock_timedrdlock
|
||||||
|
pthread_rwlock_timedwrlock
|
||||||
pthread_rwlock_tryrdlock
|
pthread_rwlock_tryrdlock
|
||||||
pthread_rwlock_trywrlock
|
pthread_rwlock_trywrlock
|
||||||
pthread_rwlock_unlock
|
pthread_rwlock_unlock
|
||||||
|
@ -1575,8 +1577,6 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
||||||
pthread_mutexattr_getrobust
|
pthread_mutexattr_getrobust
|
||||||
pthread_mutexattr_setrobust
|
pthread_mutexattr_setrobust
|
||||||
pthread_mutex_consistent
|
pthread_mutex_consistent
|
||||||
pthread_rwlock_timedrdlock
|
|
||||||
pthread_rwlock_timedwrlock
|
|
||||||
putmsg
|
putmsg
|
||||||
setnetent
|
setnetent
|
||||||
sigtimedwait
|
sigtimedwait
|
||||||
|
|
Loading…
Reference in New Issue