2020-01-01 00:14:33 +00:00
|
|
|
/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
2003-03-03 04:57:09 +00:00
|
|
|
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
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2003-03-03 04:57:09 +00:00
|
|
|
|
|
|
|
#include <time.h>
|
2019-06-21 20:00:23 +00:00
|
|
|
#include <kernel-features.h>
|
2005-04-27 08:01:41 +00:00
|
|
|
#include <errno.h>
|
2003-03-03 04:57:09 +00:00
|
|
|
|
Update.
2003-06-15 Ulrich Drepper <drepper@redhat.com>
Fix cancellation point handling wrt exception based cleanup.
* io/Makefile: Compile fcntl.c, poll.c, and lockf.c with exceptions.
* misc/Makefile: Compile pselect.c, readv.c, writev.c, and usleep.c
with exceptions.
* posix/Makefile: Compile pread.c, pread64.c, pwrite.c, pwrite64.c,
sleep.c, wait.c, waitid.c, and waitpid.c with exceptions.
* rt/Makefile: Compile aio_suspend.c and clock_nanosleep.c with
exceptions.
* signal/Makefile: Compile sigpause.c, sigsuspend.c, sigtimedwait.c,
sigwait.c, and sigwaitinfo.c with exceptions.
* stdlib/Makefile: Compile system.c with exceptions.
* sysvipc/Makefile: Compile msgrcv.c and msgsnd.c with exceptions.
* termios/Makefile: Compile tcdrain.c with exceptions.
* sysdeps/generic/lockf.c: Add comment explaining the cancellation
situation.
* sysdeps/generic/pselect.c: Likewise.
* sysdeps/posix/sigpause.c: Likewise.
* sysdeps/posix/system.c: Likewise.
* sysdeps/posix/waitid.c: Likewise.
* sysdeps/unix/sysv/linux/sleep.c: Likewise.
* sysdeps/unix/sysv/linux/usleep.c: Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h: Major rewrite of
INTERNAL_SYSCALL to not use push inside asm statement so that
unwind info is correct around the syscall.
* sysdeps/unix/clock_nanosleep.c: Add cancellation support.
* sysdeps/unix/sysv/linux/clock_nanosleep.c: Likewise.
2003-06-15 21:22:26 +00:00
|
|
|
#include <sysdep-cancel.h>
|
2005-04-27 08:01:41 +00:00
|
|
|
#include "kernel-posix-cpu-timers.h"
|
2003-03-03 04:57:09 +00:00
|
|
|
|
Finish move of clock_* functions to libc. [BZ #24959]
In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
clock_gettime, clock_nanosleep, and clock_settime were moved from
librt.so to libc.so, leaving compatibility stubs behind. Now that the
dynamic linker no longer insists on finding versioned symbols in the
same library that originally defined them, we do not need the stubs
anymore, and this means we don't need GLIBC_PRIVATE __-prefix aliases
for most of the functions anymore either. (clock_gettime still needs
one.) For ports added before 2.17, libc.so needs to provide two
symbol versions for each, the default at GLIBC_2.17 plus a compat
version matching what librt had.
While I'm at it, move the clock_*.c files and their tests from rt/ to
time/.
2019-09-04 06:18:57 +00:00
|
|
|
#include <shlib-compat.h>
|
2003-03-03 04:57:09 +00:00
|
|
|
|
|
|
|
/* We can simply use the syscall. The CPU clocks are not supported
|
|
|
|
with this function. */
|
|
|
|
int
|
2019-06-21 20:00:23 +00:00
|
|
|
__clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req,
|
|
|
|
struct __timespec64 *rem)
|
2003-03-03 04:57:09 +00:00
|
|
|
{
|
2019-06-21 20:00:23 +00:00
|
|
|
int r;
|
|
|
|
|
2005-04-27 08:01:41 +00:00
|
|
|
if (clock_id == CLOCK_THREAD_CPUTIME_ID)
|
|
|
|
return EINVAL;
|
|
|
|
if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
|
|
|
|
clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);
|
|
|
|
|
2018-05-10 20:24:56 +00:00
|
|
|
/* If the call is interrupted by a signal handler or encounters an error,
|
|
|
|
it returns a positive value similar to errno. */
|
2019-06-21 20:00:23 +00:00
|
|
|
#ifdef __ASSUME_TIME64_SYSCALLS
|
|
|
|
# ifndef __NR_clock_nanosleep_time64
|
|
|
|
# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep
|
|
|
|
# endif
|
2020-01-29 20:38:36 +00:00
|
|
|
r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
|
2019-06-21 20:00:23 +00:00
|
|
|
flags, req, rem);
|
|
|
|
#else
|
|
|
|
# ifdef __NR_clock_nanosleep_time64
|
2020-01-29 20:38:36 +00:00
|
|
|
r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
|
2019-06-21 20:00:23 +00:00
|
|
|
flags, req, rem);
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
if (! INTERNAL_SYSCALL_ERROR_P (r))
|
2020-01-02 18:39:12 +00:00
|
|
|
return 0;
|
2020-01-29 20:38:36 +00:00
|
|
|
if (INTERNAL_SYSCALL_ERRNO (r) != ENOSYS)
|
|
|
|
return INTERNAL_SYSCALL_ERRNO (r);
|
2019-06-21 20:00:23 +00:00
|
|
|
# endif /* __NR_clock_nanosleep_time64 */
|
|
|
|
|
|
|
|
if (! in_time_t_range (req->tv_sec))
|
|
|
|
{
|
|
|
|
__set_errno (EOVERFLOW);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-11-11 16:28:37 +00:00
|
|
|
struct timespec tr32;
|
|
|
|
struct timespec ts32 = valid_timespec64_to_timespec (*req);
|
2020-01-29 20:38:36 +00:00
|
|
|
r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, clock_id, flags,
|
2020-01-02 18:39:12 +00:00
|
|
|
&ts32, &tr32);
|
2020-01-29 20:38:36 +00:00
|
|
|
if (INTERNAL_SYSCALL_ERROR_P (r))
|
2020-01-02 18:39:12 +00:00
|
|
|
{
|
2020-01-29 20:38:36 +00:00
|
|
|
if (INTERNAL_SYSCALL_ERRNO (r) == EINTR && rem != NULL
|
2020-01-02 18:39:12 +00:00
|
|
|
&& (flags & TIMER_ABSTIME) == 0)
|
|
|
|
*rem = valid_timespec_to_timespec64 (tr32);
|
|
|
|
}
|
2019-06-21 20:00:23 +00:00
|
|
|
#endif /* __ASSUME_TIME64_SYSCALLS */
|
|
|
|
|
2020-01-29 20:38:36 +00:00
|
|
|
return (INTERNAL_SYSCALL_ERROR_P (r)
|
|
|
|
? INTERNAL_SYSCALL_ERRNO (r) : 0);
|
2003-03-03 04:57:09 +00:00
|
|
|
}
|
2019-06-21 20:00:23 +00:00
|
|
|
|
|
|
|
#if __TIMESIZE != 64
|
2020-03-14 23:18:36 +00:00
|
|
|
libc_hidden_def (__clock_nanosleep_time64)
|
|
|
|
|
2019-06-21 20:00:23 +00:00
|
|
|
int
|
|
|
|
__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
|
|
|
|
struct timespec *rem)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct __timespec64 treq64, trem64;
|
|
|
|
|
|
|
|
treq64 = valid_timespec_to_timespec64 (*req);
|
|
|
|
r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64);
|
|
|
|
|
2019-11-11 16:28:37 +00:00
|
|
|
if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
|
2019-06-21 20:00:23 +00:00
|
|
|
*rem = valid_timespec64_to_timespec (trem64);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
#endif
|
2019-11-05 21:37:44 +00:00
|
|
|
libc_hidden_def (__clock_nanosleep)
|
Finish move of clock_* functions to libc. [BZ #24959]
In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
clock_gettime, clock_nanosleep, and clock_settime were moved from
librt.so to libc.so, leaving compatibility stubs behind. Now that the
dynamic linker no longer insists on finding versioned symbols in the
same library that originally defined them, we do not need the stubs
anymore, and this means we don't need GLIBC_PRIVATE __-prefix aliases
for most of the functions anymore either. (clock_gettime still needs
one.) For ports added before 2.17, libc.so needs to provide two
symbol versions for each, the default at GLIBC_2.17 plus a compat
version matching what librt had.
While I'm at it, move the clock_*.c files and their tests from rt/ to
time/.
2019-09-04 06:18:57 +00:00
|
|
|
versioned_symbol (libc, __clock_nanosleep, clock_nanosleep, GLIBC_2_17);
|
|
|
|
/* clock_nanosleep moved to libc in version 2.17;
|
|
|
|
old binaries may expect the symbol version it had in librt. */
|
|
|
|
#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17)
|
|
|
|
strong_alias (__clock_nanosleep, __clock_nanosleep_2);
|
|
|
|
compat_symbol (libc, __clock_nanosleep_2, clock_nanosleep, GLIBC_2_2);
|
|
|
|
#endif
|