mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-03 02:11:08 +00:00
cc5d5852c6
The aio_suspend function has been converted to support 64 bit time. This change uses (in aio_misc.h): - __futex_abstimed_wait64 (instead of futex_reltimed_wait) - __futex_abstimed_wait_cancellable64 (instead of futex_reltimed_wait_cancellable) from ./sysdeps/nptl/futex-helpers.h The aio_suspend() accepts relative timeout, which then is converted to absolute one. The i686-gnu port (HURD) do not define DONT_NEED_AIO_MISC_COND and as it doesn't (yet) support 64 bit time it uses not converted pthread_cond_timedwait(). The __aio_suspend() is supposed to be run on ports with __TIMESIZE !=64 and __WORDSIZE==32. It internally utilizes __aio_suspend_time64() and hence the conversion from 32 bit struct timespec to 64 bit one is required. For ports supporting 64 bit time the __aio_suspend_time64() will be used either via alias (to __aio_suspend when __TIMESIZE==64) or redirection (when -D_TIME_BITS=64 is passed). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
75 lines
2.7 KiB
C
75 lines
2.7 KiB
C
/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
/* We define a special synchronization primitive for AIO. POSIX
|
|
conditional variables would be ideal but the pthread_cond_*wait
|
|
operations do not return on EINTR. This is a requirement for
|
|
correct aio_suspend and lio_listio implementations. */
|
|
|
|
#include <assert.h>
|
|
#include <nptl/pthreadP.h>
|
|
#include <futex-internal.h>
|
|
|
|
#define DONT_NEED_AIO_MISC_COND 1
|
|
|
|
#define AIO_MISC_NOTIFY(waitlist) \
|
|
do { \
|
|
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
|
|
futex_wake ((unsigned int *) waitlist->counterp, 1, FUTEX_PRIVATE); \
|
|
} while (0)
|
|
|
|
#define AIO_MISC_WAIT(result, futex, timeout, cancel) \
|
|
do { \
|
|
volatile unsigned int *futexaddr = &futex; \
|
|
unsigned int oldval = futex; \
|
|
\
|
|
if (oldval != 0) \
|
|
{ \
|
|
pthread_mutex_unlock (&__aio_requests_mutex); \
|
|
\
|
|
int status; \
|
|
do \
|
|
{ \
|
|
if (cancel) \
|
|
status = __futex_abstimed_wait_cancelable64 ( \
|
|
(unsigned int *) futexaddr, oldval, CLOCK_MONOTONIC, timeout, \
|
|
FUTEX_PRIVATE); \
|
|
else \
|
|
status = __futex_abstimed_wait64 ((unsigned int *) futexaddr, \
|
|
oldval, CLOCK_REALTIME, timeout, FUTEX_PRIVATE); \
|
|
if (status != EAGAIN) \
|
|
break; \
|
|
\
|
|
oldval = *futexaddr; \
|
|
} \
|
|
while (oldval != 0); \
|
|
\
|
|
if (status == EINTR) \
|
|
result = EINTR; \
|
|
else if (status == ETIMEDOUT) \
|
|
result = EAGAIN; \
|
|
else if (status == EOVERFLOW) \
|
|
result = EOVERFLOW; \
|
|
else \
|
|
assert (status == 0 || status == EAGAIN); \
|
|
\
|
|
pthread_mutex_lock (&__aio_requests_mutex); \
|
|
} \
|
|
} while (0)
|
|
|
|
#include_next <aio_misc.h>
|