1
0
Fork 0
mirror of git://sourceware.org/git/glibc.git synced 2025-03-06 20:58:33 +01:00

htl: Fix semaphore reference

'sem' is the opaque 'sem_t', 'isem' is the actual 'struct new_sem'.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230212111044.610942-6-bugaevc@gmail.com>
This commit is contained in:
Sergey Bugaev 2023-02-12 14:10:36 +03:00 committed by Samuel Thibault
parent 48941024ba
commit 3d008a92a8

View file

@ -60,7 +60,7 @@ __sem_timedwait_internal (sem_t *restrict sem,
int cancel_oldtype = LIBC_CANCEL_ASYNC(); int cancel_oldtype = LIBC_CANCEL_ASYNC();
#if __HAVE_64B_ATOMICS #if __HAVE_64B_ATOMICS
uint64_t d = atomic_fetch_add_relaxed (&sem->data, uint64_t d = atomic_fetch_add_relaxed (&isem->data,
(uint64_t) 1 << SEM_NWAITERS_SHIFT); (uint64_t) 1 << SEM_NWAITERS_SHIFT);
pthread_cleanup_push (__sem_wait_cleanup, isem); pthread_cleanup_push (__sem_wait_cleanup, isem);
@ -72,11 +72,11 @@ __sem_timedwait_internal (sem_t *restrict sem,
/* No token, sleep. */ /* No token, sleep. */
if (timeout) if (timeout)
err = __lll_abstimed_wait_intr ( err = __lll_abstimed_wait_intr (
((unsigned int *) &sem->data) + SEM_VALUE_OFFSET, ((unsigned int *) &isem->data) + SEM_VALUE_OFFSET,
0, timeout, flags, clock_id); 0, timeout, flags, clock_id);
else else
err = __lll_wait_intr ( err = __lll_wait_intr (
((unsigned int *) &sem->data) + SEM_VALUE_OFFSET, ((unsigned int *) &isem->data) + SEM_VALUE_OFFSET,
0, flags); 0, flags);
if (err != 0 && err != KERN_INVALID_ARGUMENT) if (err != 0 && err != KERN_INVALID_ARGUMENT)
@ -92,12 +92,12 @@ __sem_timedwait_internal (sem_t *restrict sem,
} }
/* Token changed */ /* Token changed */
d = atomic_load_relaxed (&sem->data); d = atomic_load_relaxed (&isem->data);
} }
else else
{ {
/* Try to acquire and dequeue. */ /* Try to acquire and dequeue. */
if (atomic_compare_exchange_weak_acquire (&sem->data, if (atomic_compare_exchange_weak_acquire (&isem->data,
&d, d - 1 - ((uint64_t) 1 << SEM_NWAITERS_SHIFT))) &d, d - 1 - ((uint64_t) 1 << SEM_NWAITERS_SHIFT)))
{ {
/* Success */ /* Success */