mirror of git://sourceware.org/git/glibc.git
Update.
* sysdeps/unix/sysv/linux/s390/sem_wait.c (__new_sem_wait): Make cancelable. * sysdeps/unix/sysv/linux/s390/sem_timedwait.c (__sem_timedwait): Likewise.
This commit is contained in:
parent
3e36c37d35
commit
ecf7955d55
|
|
@ -1 +1 @@
|
||||||
NPTL 0.44 by Ulrich Drepper
|
NPTL 0.45 by Ulrich Drepper
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
2003-06-08 Ulrich Drepper <drepper@redhat.com>
|
2003-06-08 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/s390/sem_wait.c (__new_sem_wait): Make
|
||||||
|
cancelable.
|
||||||
|
* sysdeps/unix/sysv/linux/s390/sem_timedwait.c (__sem_timedwait):
|
||||||
|
Likewise.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Remove
|
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Remove
|
||||||
hand-written CFI generation code. Since ENTRY/END also initiated
|
hand-written CFI generation code. Since ENTRY/END also initiated
|
||||||
CFI frames this caused two CFI sets to be generated.
|
CFI frames this caused two CFI sets to be generated.
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <internaltypes.h>
|
#include <internaltypes.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
|
#include <pthreadP.h>
|
||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -31,12 +32,18 @@ sem_timedwait (sem, abstime)
|
||||||
sem_t *sem;
|
sem_t *sem;
|
||||||
const struct timespec *abstime;
|
const struct timespec *abstime;
|
||||||
{
|
{
|
||||||
int oldval, newval;
|
/* First check for cancellation. */
|
||||||
|
CANCELLATION_P (THREAD_SELF);
|
||||||
|
|
||||||
while (1)
|
int *futex = (int *) sem;
|
||||||
|
int oldval;
|
||||||
|
int newval;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
/* Atomically decrement semaphore counter if it is > 0. */
|
/* Atomically decrement semaphore counter if it is > 0. */
|
||||||
lll_compare_and_swap ((int *) sem, oldval, newval,
|
lll_compare_and_swap (futex, oldval, newval,
|
||||||
"ltr %2,%1; jnp 1f; ahi %2,-1");
|
"ltr %2,%1; jnp 1f; ahi %2,-1");
|
||||||
/* oldval != newval if the semaphore count has been decremented. */
|
/* oldval != newval if the semaphore count has been decremented. */
|
||||||
if (oldval != newval)
|
if (oldval != newval)
|
||||||
|
|
@ -69,8 +76,14 @@ sem_timedwait (sem, abstime)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enable asynchronous cancellation. Required by the standard. */
|
||||||
|
int oldtype = __pthread_enable_asynccancel ();
|
||||||
|
|
||||||
/* Do wait. */
|
/* Do wait. */
|
||||||
int err = lll_futex_timed_wait ((int *) sem, 0, &rt);
|
err = lll_futex_timed_wait (futex, 0, &rt);
|
||||||
|
|
||||||
|
/* Disable asynchronous cancellation. */
|
||||||
|
__pthread_disable_asynccancel (oldtype);
|
||||||
|
|
||||||
/* Returned after timing out? */
|
/* Returned after timing out? */
|
||||||
if (err == -ETIMEDOUT)
|
if (err == -ETIMEDOUT)
|
||||||
|
|
@ -78,12 +91,9 @@ sem_timedwait (sem, abstime)
|
||||||
__set_errno (ETIMEDOUT);
|
__set_errno (ETIMEDOUT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle EINTR. */
|
|
||||||
if (err != 0 && err != -EWOULDBLOCK)
|
|
||||||
{
|
|
||||||
__set_errno (-err);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (err == 0 || err == -EWOULDBLOCK)
|
||||||
|
|
||||||
|
__set_errno (-err);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,35 +23,45 @@
|
||||||
#include <internaltypes.h>
|
#include <internaltypes.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
|
#include <pthreadP.h>
|
||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__new_sem_wait (sem_t *sem)
|
__new_sem_wait (sem_t *sem)
|
||||||
{
|
{
|
||||||
while (1)
|
/* First check for cancellation. */
|
||||||
|
CANCELLATION_P (THREAD_SELF);
|
||||||
|
|
||||||
|
int *futex = (int *) sem;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
int oldval;
|
int oldval;
|
||||||
int newval;
|
int newval;
|
||||||
|
|
||||||
/* Atomically decrement semaphore counter if it is > 0. */
|
/* Atomically decrement semaphore counter if it is > 0. */
|
||||||
lll_compare_and_swap ((int *) sem, oldval, newval,
|
lll_compare_and_swap (futex, oldval, newval,
|
||||||
"ltr %2,%1; jnp 1f; ahi %2,-1");
|
"ltr %2,%1; jnp 1f; ahi %2,-1");
|
||||||
|
|
||||||
/* oldval != newval if the semaphore count has been decremented. */
|
/* oldval != newval if the semaphore count has been decremented. */
|
||||||
if (oldval != newval)
|
if (oldval != newval)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Do wait. */
|
/* Enable asynchronous cancellation. Required by the standard. */
|
||||||
int err = lll_futex_wait ((int *) sem, 0);
|
int oldtype = __pthread_enable_asynccancel ();
|
||||||
|
|
||||||
/* Handle EINTR. */
|
/* Do wait. */
|
||||||
if (err != 0 && err != -EWOULDBLOCK)
|
err = lll_futex_wait (futex, 0);
|
||||||
{
|
|
||||||
__set_errno (-err);
|
/* Disable asynchronous cancellation. */
|
||||||
return -1;
|
__pthread_disable_asynccancel (oldtype);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (err == 0 || err == -EWOULDBLOCK);
|
||||||
|
|
||||||
|
__set_errno (-err);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
versioned_symbol (libpthread, __new_sem_wait, sem_wait, GLIBC_2_1);
|
versioned_symbol (libpthread, __new_sem_wait, sem_wait, GLIBC_2_1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue