1998-09-06 23:45:24 +00:00
|
|
|
#ifndef _TIME_H
|
Installed-header hygiene (BZ#20366): time.h types.
Many headers are expected to expose a subset of the type definitions
in time.h. time.h has a whole bunch of messy logic for conditionally
defining some its types and structs, but, as best I can tell, this
has never worked 100%. In particular, __need_timespec is ineffective
if _TIME_H has already been defined, which means that if you compile
#include <time.h>
#include <sched.h>
with e.g. -fsyntax-only -std=c89 -Wall -Wsystem-headers, you will get
In file included from test.c:2:0:
/usr/include/sched.h:74:57: warning: "struct timespec" declared inside
parameter list will not be visible outside of this definition or declaration
extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
^~~~~~~~
And if you want to _use_ sched_rr_get_interval in a TU compiled that
way, you're hosed.
This patch replaces all of that with small bits/types/TYPE.h headers
as introduced earlier. time.h and bits/time.h are now *much* simpler,
and a lot of other headers are slightly simpler.
* time/time.h, bits/time.h, sysdeps/unix/sysv/linux/bits/time.h:
Remove all logic conditional on __need macros. Move all the
conditionally defined types to their own headers...
* time/bits/types/clock_t.h: Define clock_t here.
* time/bits/types/clockid_t.h: Define clockid_t here.
* time/bits/types/struct_itimerspec.h: Define struct itimerspec here.
* time/bits/types/struct_timespec.h: Define struct timespec here.
* time/bits/types/struct_timeval.h: Define struct timeval here.
* time/bits/types/struct_tm.h: Define struct tm here.
* time/bits/types/time_t.h: Define time_t here.
* time/bits/types/timer_t.h: Define timer_t here.
* time/Makefile: Install the new headers.
* bits/resource.h, io/fcntl.h, io/sys/poll.h, io/sys/stat.h
* io/utime.h, misc/sys/select.h, posix/sched.h, posix/sys/times.h
* posix/sys/types.h, resolv/netdb.h, rt/aio.h, rt/mqueue.h
* signal/signal.h, pthread/semaphore.h, sysdeps/nptl/pthread.h
* sysdeps/unix/sysv/linux/alpha/bits/resource.h
* sysdeps/unix/sysv/linux/alpha/sys/acct.h
* sysdeps/unix/sysv/linux/bits/resource.h
* sysdeps/unix/sysv/linux/bits/timex.h
* sysdeps/unix/sysv/linux/mips/bits/resource.h
* sysdeps/unix/sysv/linux/net/ppp_defs.h
* sysdeps/unix/sysv/linux/sparc/bits/resource.h
* sysdeps/unix/sysv/linux/sys/acct.h
* sysdeps/unix/sysv/linux/sys/timerfd.h
* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
* time/sys/time.h, time/sys/timeb.h
Use the new bits/types headers.
* include/time.h: Remove __need logic.
* include/bits/time.h
* include/bits/types/clock_t.h, include/bits/types/clockid_t.h
* include/bits/types/time_t.h, include/bits/types/timer_t.h
* include/bits/types/struct_itimerspec.h
* include/bits/types/struct_timespec.h
* include/bits/types/struct_timeval.h
* include/bits/types/struct_tm.h:
New wrapper headers.
2016-08-24 15:54:34 +00:00
|
|
|
#include <time/time.h>
|
|
|
|
|
|
|
|
#ifndef _ISOMAC
|
2019-10-02 08:19:55 +00:00
|
|
|
# include <bits/types/struct_timeval.h>
|
Rename xlocale.h to bits/types/__locale_t.h.
xlocale.h is already a single-type micro-header, defining struct
__locale_struct and the typedefs __locale_t and locale_t. This patch
brings it into the bits/types/ scheme: there are now
bits/types/__locale_t.h which defines only __locale_struct and
__locale_t, and bits/types/locale_t.h which defines locale_t as well
as the other two. None of *our* headers need __locale_t.h, but it
appears to me that libstdc++ could make use of it.
There are a lot of external uses of xlocale.h, but all the uses I
checked had an autoconf test or equivalent for its existence. It has
never been available from other C libraries, and it has always
contained a comment reading "This file is not standardized, don't rely
on it, it can go away without warning" so I think dropping it is
pretty safe.
I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard. There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.
* locale/xlocale.h: Rename to...
* locale/bits/types/__locale_t.h: ...here. Adjust commentary.
Only define struct __locale_struct and __locale_t, not locale_t.
* locale/bits/types/locale_t.h: New file; define locale_t here.
* locale/Makefile (headers): Update to match.
* include/xlocale.h: Delete wrapper.
* include/bits/types/__locale_t.h: New wrapper.
* include/bits/types/locale_t.h: New wrapper.
* ctype/ctype.h, include/printf.h, include/time.h
* locale/langinfo.h, locale/locale.h, stdlib/monetary.h
* stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
* wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
Correct outdated comments regarding the standardization status of
the functions that take locale_t arguments.
* stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
* stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
* sysdeps/ieee754/ldbl-64-128/strtold_l.c
* wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
* wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
Don't include xlocale.h. If necessary, include locale.h instead.
* stdlib/strtold_l.c: Unconditionally include wchar.h.
2017-06-09 16:02:06 +00:00
|
|
|
# include <bits/types/locale_t.h>
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
# include <stdbool.h>
|
|
|
|
# include <time/mktime-internal.h>
|
2019-03-22 10:53:45 +00:00
|
|
|
# include <endian.h>
|
2019-10-24 21:01:40 +00:00
|
|
|
# include <time-clockid.h>
|
1998-08-09 17:39:48 +00:00
|
|
|
|
2002-08-27 23:36:31 +00:00
|
|
|
extern __typeof (strftime_l) __strftime_l;
|
2002-12-31 23:13:55 +00:00
|
|
|
libc_hidden_proto (__strftime_l)
|
2002-08-27 23:36:31 +00:00
|
|
|
extern __typeof (strptime_l) __strptime_l;
|
|
|
|
|
2002-08-03 12:09:37 +00:00
|
|
|
libc_hidden_proto (asctime)
|
|
|
|
libc_hidden_proto (mktime)
|
|
|
|
libc_hidden_proto (timelocal)
|
|
|
|
libc_hidden_proto (localtime)
|
|
|
|
libc_hidden_proto (strftime)
|
|
|
|
libc_hidden_proto (strptime)
|
|
|
|
|
2012-10-24 21:50:46 +00:00
|
|
|
extern __typeof (clock_gettime) __clock_gettime;
|
2013-06-11 05:41:11 +00:00
|
|
|
libc_hidden_proto (__clock_gettime)
|
2012-10-24 21:50:46 +00:00
|
|
|
extern __typeof (clock_settime) __clock_settime;
|
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
|
|
|
libc_hidden_proto (__clock_settime)
|
2005-07-13 06:26:17 +00:00
|
|
|
|
2019-11-05 21:37:44 +00:00
|
|
|
extern __typeof (clock_nanosleep) __clock_nanosleep;
|
|
|
|
libc_hidden_proto (__clock_nanosleep);
|
|
|
|
|
2019-10-28 17:55:22 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
extern __typeof (clock_adjtime) __clock_adjtime;
|
|
|
|
libc_hidden_proto (__clock_adjtime);
|
|
|
|
#endif
|
|
|
|
|
1998-08-09 17:39:48 +00:00
|
|
|
/* Now define the internal interfaces. */
|
|
|
|
struct tm;
|
|
|
|
|
1998-12-08 16:10:10 +00:00
|
|
|
/* Defined in mktime.c. */
|
Update.
* ctype/ctype-info.c: Declare _nl_C_LC_CTYPE_class,
_nl_C_LC_CTYPE_class32, _nl_C_LC_CTYPE_toupper, _nl_C_LC_CTYPE_tolower,
_nl_C_LC_CTYPE_class_upper, _nl_C_LC_CTYPE_class_lower,
_nl_C_LC_CTYPE_class_alpha, _nl_C_LC_CTYPE_class_digit,
_nl_C_LC_CTYPE_class_xdigit, _nl_C_LC_CTYPE_class_space,
_nl_C_LC_CTYPE_class_print, _nl_C_LC_CTYPE_class_graph,
_nl_C_LC_CTYPE_class_blank, _nl_C_LC_CTYPE_class_cntrl,
_nl_C_LC_CTYPE_class_punct, _nl_C_LC_CTYPE_class_alnum,
_nl_C_LC_CTYPE_map_toupper, _nl_C_LC_CTYPE_map_tolower, and
_nl_C_LC_CTYPE_width: Declare as hidden.
* include/locale.h: Declare _nl_locale_file_list.
* locale/C-address.c: Define _nl_C_LC_ADDRESS as hidden.
* locale/C-collate.c: Define _nl_C_LC_COLLATE as hidden.
* locale/C-identification.c: Define _nl_C_LC_IDENTIFICATION as hidden.
* locale/C-measurement.c: Define _nl_C_LC_MEASUREMENT as hidden.
* locale/C-messages.c: Define _nl_C_LC_MESSAGES as hidden.
* locale/C-monetary.c: Define _nl_C_LC_MONETARY as hidden.
* locale/C-name.c: Define _nl_C_LC_NAME as hidden.
* locale/C-numeric.c: Define _nl_C_LC_NUMERIC as hidden.
* locale/C-paper.c: Define _nl_C_LC_PAPER as hidden.
* locale/C-telephone.c: Define _nl_C_LC_TELEPHONE as hidden.
* locale/C-time.c: Define _nl_C_LC_TIME as hidden.
* locale/C-ctype.c: Define _nl_C_LC_CTYPE_class,
_nl_C_LC_CTYPE_class32, _nl_C_LC_CTYPE_toupper, _nl_C_LC_CTYPE_tolower,
_nl_C_LC_CTYPE_class_upper, _nl_C_LC_CTYPE_class_lower,
_nl_C_LC_CTYPE_class_alpha, _nl_C_LC_CTYPE_class_digit,
_nl_C_LC_CTYPE_class_xdigit, _nl_C_LC_CTYPE_class_space,
_nl_C_LC_CTYPE_class_print, _nl_C_LC_CTYPE_class_graph,
_nl_C_LC_CTYPE_class_blank, _nl_C_LC_CTYPE_class_cntrl,
_nl_C_LC_CTYPE_class_punct, _nl_C_LC_CTYPE_class_alnum,
_nl_C_LC_CTYPE_map_toupper, _nl_C_LC_CTYPE_map_tolower,
_nl_C_LC_CTYPE_width, and as hidden.
* locale/findlocale.c: Declare _nl_C as hidden.
* locale/newlocale.c: Likewise.
* locale/setlocale.c: Define _nl_C as hidden. Remove declaration of
_nl_locale_file_list.
* locale/xlocale.c: Declare _nl_C_LC_CTYPE_class,
_nl_C_LC_CTYPE_toupper, and _nl_C_LC_CTYPE_tolower as hidden.
Define _nl_C_locobj as hidden.
* malloc/mtrace.c (_mtrace_file): Define as hidden.
(_mtrace_line): Likewise.
* include/time.h: Declare __mon_yday as hidden.
* time/strptime.c [_LIBC] (__mon_yday): Remove declaration.
* libio/libioP.h: Declare __libio_codecvt as hidden.
* libio/fileops.c: Declare __libio_translit as hidden.
* libio/iofwide.c: Define __libio_translit as hidden.
* login/getutent_r.c: Define __libc_utmp_lock as hidden.
* login/getutid_r.c: Declare __libc_utmp_lock as hidden.
* login/getutline_r.c: Likewise.
* login/utmpname.c: Likewise.
* login/utmp-private.h: Declare __libc_utmp_file_functions,
__libc_utmp_unknown_functions, __libc_utmp_jump_table, and
__libc_utmp_file_name as hidden.
* locale/setlocale.c (__libc_setlocale_lock): Define as hidden.
* locale/duplocale.c (__libc_setlocale_lock): Declare as hidden.
* locale/freelocale.c: Likewise.
* locale/lc-time.c: Likewise.
* sysdeps/unix/bsd/getpt.c (__libc_ptyname1): Define as hidden.
(__libc_ptyname2): Likewise.
* sysdeps/unix/sysv/linux/ptsname.c (__libc_ptyname1): Declare as
hidden.
(__libc_ptyname2): Likewise.
* sysdeps/generic/sbrk.c: Declare __libc_multiple_libcs as hidden.
* sysdeps/arm/init-first.c (__libc_multiple_libcs): Define as hidden.
* sysdeps/generic/init-first.c: Likewise.
* sysdeps/i386/init-first.c: Likewise.
* sysdeps/mach/hurd/i386/init-first.c: Likewise.
* sysdeps/mach/hurd/mips/init-first.c: Likewise.
* sysdeps/mach/hurd/powerpc/init-first.c: Likewise.
* sysdeps/sh/init-first.c: Likewise.
* sysdeps/unix/sysv/aix/init-first.c: Likewise.
* sysdeps/unix/sysv/linux/init-first.c: Likewise.
2002-03-13 06:33:52 +00:00
|
|
|
extern const unsigned short int __mon_yday[2][13] attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
|
|
|
/* Defined in localtime.c. */
|
2002-03-12 10:25:36 +00:00
|
|
|
extern struct tm _tmbuf attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
|
|
|
/* Defined in tzset.c. */
|
2017-10-01 22:17:19 +00:00
|
|
|
extern char *__tzstring (const char *string) attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
2002-03-12 10:25:36 +00:00
|
|
|
extern int __use_tzfile attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
1999-10-19 13:53:34 +00:00
|
|
|
extern void __tzfile_read (const char *file, size_t extra,
|
2017-10-01 22:17:19 +00:00
|
|
|
char **extrap) attribute_hidden;
|
2018-10-24 20:09:34 +00:00
|
|
|
extern void __tzfile_compute (__time64_t timer, int use_localtime,
|
2003-02-01 20:53:16 +00:00
|
|
|
long int *leap_correct, int *leap_hit,
|
2017-10-01 22:17:19 +00:00
|
|
|
struct tm *tp) attribute_hidden;
|
1999-10-19 13:53:34 +00:00
|
|
|
extern void __tzfile_default (const char *std, const char *dst,
|
2019-02-03 08:55:41 +00:00
|
|
|
int stdoff, int dstoff)
|
2017-10-01 22:17:19 +00:00
|
|
|
attribute_hidden;
|
|
|
|
extern void __tzset_parse_tz (const char *tz) attribute_hidden;
|
2018-12-05 20:01:22 +00:00
|
|
|
extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
|
2017-10-01 22:07:06 +00:00
|
|
|
__THROW attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
2019-03-22 10:53:45 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __timespec64 timespec
|
|
|
|
#else
|
|
|
|
/* The glibc Y2038-proof struct __timespec64 structure for a time value.
|
|
|
|
To keep things Posix-ish, we keep the nanoseconds field a 32-bit
|
|
|
|
signed long, but since the Linux field is a 64-bit signed int, we
|
|
|
|
pad our tv_nsec with a 32-bit unnamed bit-field padding.
|
|
|
|
|
|
|
|
As a general rule the Linux kernel is ignoring upper 32 bits of
|
|
|
|
tv_nsec field. */
|
|
|
|
struct __timespec64
|
|
|
|
{
|
|
|
|
__time64_t tv_sec; /* Seconds */
|
|
|
|
# if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
__int32_t :32; /* Padding */
|
|
|
|
__int32_t tv_nsec; /* Nanoseconds */
|
|
|
|
# else
|
|
|
|
__int32_t tv_nsec; /* Nanoseconds */
|
|
|
|
__int32_t :32; /* Padding */
|
|
|
|
# endif
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-12-18 22:13:24 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __ctime64 ctime
|
|
|
|
#else
|
|
|
|
extern char *__ctime64 (const __time64_t *__timer) __THROW;
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
libc_hidden_proto (__ctime64)
|
2018-12-18 22:13:24 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-18 22:13:55 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __ctime64_r ctime_r
|
|
|
|
#else
|
|
|
|
extern char *__ctime64_r (const __time64_t *__restrict __timer,
|
|
|
|
char *__restrict __buf) __THROW;
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
libc_hidden_proto (__ctime64_r)
|
2018-12-18 22:13:55 +00:00
|
|
|
#endif
|
|
|
|
|
2018-11-20 22:57:23 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __localtime64 localtime
|
|
|
|
#else
|
|
|
|
extern struct tm *__localtime64 (const __time64_t *__timer);
|
|
|
|
libc_hidden_proto (__localtime64)
|
|
|
|
#endif
|
|
|
|
|
2012-01-08 04:57:22 +00:00
|
|
|
extern struct tm *__localtime_r (const time_t *__timer,
|
2002-03-15 09:30:44 +00:00
|
|
|
struct tm *__tp) attribute_hidden;
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
#if __TIMESIZE != 64
|
2018-12-18 22:11:08 +00:00
|
|
|
extern struct tm *__localtime64_r (const __time64_t *__timer,
|
|
|
|
struct tm *__tp);
|
|
|
|
libc_hidden_proto (__localtime64_r)
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
|
|
|
|
extern __time64_t __mktime64 (struct tm *__tp) __THROW;
|
|
|
|
libc_hidden_proto (__mktime64)
|
2018-12-18 22:11:08 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-08 04:57:22 +00:00
|
|
|
extern struct tm *__gmtime_r (const time_t *__restrict __timer,
|
1999-11-23 17:22:17 +00:00
|
|
|
struct tm *__restrict __tp);
|
2002-08-04 23:32:14 +00:00
|
|
|
libc_hidden_proto (__gmtime_r)
|
1999-10-06 03:46:48 +00:00
|
|
|
|
2018-12-18 22:11:40 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __gmtime64 gmtime
|
|
|
|
#else
|
|
|
|
extern struct tm *__gmtime64 (const __time64_t *__timer);
|
|
|
|
libc_hidden_proto (__gmtime64)
|
|
|
|
|
2018-12-18 22:12:30 +00:00
|
|
|
extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer,
|
|
|
|
struct tm *__restrict __tp);
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
libc_hidden_proto (__gmtime64_r)
|
|
|
|
|
|
|
|
extern __time64_t __timegm64 (struct tm *__tp) __THROW;
|
|
|
|
libc_hidden_proto (__timegm64)
|
2018-12-18 22:12:30 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-24 12:22:42 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __clock_settime64 __clock_settime
|
|
|
|
#else
|
|
|
|
extern int __clock_settime64 (clockid_t clock_id,
|
|
|
|
const struct __timespec64 *tp);
|
|
|
|
libc_hidden_proto (__clock_settime64)
|
|
|
|
#endif
|
|
|
|
|
2019-10-15 15:57:05 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __clock_getres64 __clock_getres
|
|
|
|
#else
|
|
|
|
extern int __clock_getres64 (clockid_t clock_id,
|
|
|
|
struct __timespec64 *tp);
|
|
|
|
libc_hidden_proto (__clock_getres64);
|
|
|
|
#endif
|
|
|
|
|
2019-10-24 10:12:16 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __utimensat64 __utimensat
|
|
|
|
#else
|
|
|
|
extern int __utimensat64 (int fd, const char *file,
|
|
|
|
const struct __timespec64 tsp[2], int flags);
|
|
|
|
libc_hidden_proto (__utimensat64);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int __utimensat64_helper (int fd, const char *file,
|
|
|
|
const struct __timespec64 tsp[2], int flags);
|
|
|
|
libc_hidden_proto (__utimensat64_helper);
|
|
|
|
|
2019-10-24 12:34:46 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __futimens64 __futimens
|
|
|
|
#else
|
|
|
|
extern int __futimens64 (int fd, const struct __timespec64 tsp[2]);
|
|
|
|
libc_hidden_proto (__futimens64);
|
|
|
|
#endif
|
|
|
|
|
2018-12-05 20:01:22 +00:00
|
|
|
/* Compute the `struct tm' representation of T,
|
1998-08-09 17:39:48 +00:00
|
|
|
offset OFFSET seconds east of UTC,
|
|
|
|
and store year, yday, mon, mday, wday, hour, min, sec into *TP.
|
|
|
|
Return nonzero if successful. */
|
2018-12-05 20:01:22 +00:00
|
|
|
extern int __offtime (__time64_t __timer,
|
1999-10-19 13:53:34 +00:00
|
|
|
long int __offset,
|
2017-10-01 22:17:19 +00:00
|
|
|
struct tm *__tp) attribute_hidden;
|
1998-08-09 17:39:48 +00:00
|
|
|
|
2017-10-01 22:17:19 +00:00
|
|
|
extern char *__asctime_r (const struct tm *__tp, char *__buf)
|
|
|
|
attribute_hidden;
|
|
|
|
extern void __tzset (void) attribute_hidden;
|
1998-08-09 17:39:48 +00:00
|
|
|
|
1998-12-08 16:10:10 +00:00
|
|
|
/* Prototype for the internal function to get information based on TZ. */
|
2018-12-05 20:01:22 +00:00
|
|
|
extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
|
2017-10-01 22:17:19 +00:00
|
|
|
struct tm *tp) attribute_hidden;
|
1998-12-08 16:10:10 +00:00
|
|
|
|
2012-01-08 04:57:22 +00:00
|
|
|
extern int __nanosleep (const struct timespec *__requested_time,
|
1999-11-23 17:22:17 +00:00
|
|
|
struct timespec *__remaining);
|
Clean pthread functions namespaces for C11 threads
This patch adds internal definition (through {libc_}hidden_{proto,def}) and
also change some strong to weak alias for symbols that might be used by C11
threads implementations.
The patchset should not change libc/libpthread functional, although object
changes are expected (since now internal symbols are used instead) and final
exported symbols through GLIBC_PRIVATE is also expanded (to cover libpthread
usage of __mmap{64}, __munmap, __mprotect).
Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).
* include/sched.h (__sched_get_priority_max): Add libc hidden proto.
(__sched_get_prioriry_min): Likewise.
* include/sys/mman.h (__mmap): Likewise.
(__mmap64): Likewise.
(__munmap): Likewise.
(__mprotect): Likewise.
* include/termios.h (__tcsetattr): Likewise.
* include/time.h (__nanosleep): Use hidden_proto instead of
libc_hidden_proto.
* posix/nanosleep.c (__nanosleep): Likewise.
* misc/Versions (libc): Export __mmap, __munmap, __mprotect,
__sched_get_priority_min, and __sched_get_priority_max under
GLIBC_PRIVATE.
* nptl/allocatestack.c (__free_stacks): Use internal definition for
libc symbols.
(change_stack_perm): Likewise.
(allocate_stack): Likewise.
* sysdeps/posix/gethostname.c: Likewise.
* nptl/tpp.c (__init_sched_fifo_prio): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
* nptl/pthreadP.h (__pthread_mutex_timedlock): Add definition.
(__pthread_key_delete): Likewise.
(__pthread_detach): Likewise.
(__pthread_cancel): Likewise.
(__pthread_mutex_trylock): Likewise.
(__pthread_mutexattr_init): Likewise.
(__pthread_mutexattr_settype): Likewise.
* nptl/pthread_cancel.c (pthread_cancel): Change to internal name and
create alias for exported one.
* nptl/pthread_join.c (pthread_join): Likewise.
* nptl/pthread_detach.c (pthread_detach): Likewise.
* nptl/pthread_key_delete.c (pthread_key_delete): Likewise.
* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
* nptl/pthread_create.c: Change static requirements for pthread
symbols.
* nptl/pthread_equal.c (__pthread_equal): Change strong alias to weak
for internal definition.
* nptl/pthread_exit.c (__pthread_exit): Likewise.
* nptl/pthread_getspecific.c (__pthread_getspecific): Likewise.
* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Likewise.
* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock): Likewise.
* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likwise.
* nptl/pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
Likewise.
* nptl/pthread_self.c (__pthread_self): Likewise.
* nptl/pthread_setspecific.c (__pthread_setspecific): Likewise.
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
* misc/mmap.c (__mmap): Add internal symbol definition.
* misc/mmap.c (__mmap64): Likewise.
* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
* sysdeps/unix/sysv/linux/mmap64.c (__mmap): Likewise.
(__mmap64): Likewise.
* sysdeps/unix/sysv/linux/i386/Versions (libc) [GLIBC_PRIVATE):
Add __uname.
2016-12-02 18:32:28 +00:00
|
|
|
hidden_proto (__nanosleep)
|
2017-10-01 22:17:19 +00:00
|
|
|
extern int __getdate_r (const char *__string, struct tm *__resbufp)
|
|
|
|
attribute_hidden;
|
2000-11-01 08:10:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Determine CLK_TCK value. */
|
2017-10-01 22:17:19 +00:00
|
|
|
extern int __getclktck (void) attribute_hidden;
|
2003-06-25 00:00:50 +00:00
|
|
|
|
|
|
|
|
2004-03-14 21:12:06 +00:00
|
|
|
/* strptime support. */
|
|
|
|
extern char * __strptime_internal (const char *rp, const char *fmt,
|
2007-07-28 19:08:57 +00:00
|
|
|
struct tm *tm, void *statep,
|
2017-10-01 22:07:06 +00:00
|
|
|
locale_t locparam) attribute_hidden;
|
2004-03-14 21:12:06 +00:00
|
|
|
|
2018-12-20 21:14:08 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __difftime64 __difftime
|
|
|
|
#else
|
|
|
|
extern double __difftime64 (__time64_t time1, __time64_t time0);
|
|
|
|
libc_hidden_proto (__difftime64)
|
|
|
|
#endif
|
|
|
|
|
2004-04-04 00:41:39 +00:00
|
|
|
extern double __difftime (time_t time1, time_t time0);
|
2004-03-14 21:12:06 +00:00
|
|
|
|
2019-06-21 20:00:23 +00:00
|
|
|
#if __TIMESIZE == 64
|
|
|
|
# define __clock_nanosleep_time64 __clock_nanosleep
|
|
|
|
#else
|
|
|
|
extern int __clock_nanosleep_time64 (clockid_t clock_id,
|
|
|
|
int flags, const struct __timespec64 *req,
|
|
|
|
struct __timespec64 *rem);
|
|
|
|
libc_hidden_proto (__clock_nanosleep_time64)
|
|
|
|
#endif
|
2004-03-14 21:12:06 +00:00
|
|
|
|
2003-06-25 00:00:50 +00:00
|
|
|
/* Use in the clock_* functions. Size of the field representing the
|
|
|
|
actual clock ID. */
|
2012-02-26 04:18:39 +00:00
|
|
|
#define CLOCK_IDFIELD_SIZE 3
|
2005-12-23 01:55:26 +00:00
|
|
|
|
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
2019-03-18 21:14:15 +00:00
|
|
|
/* Check whether T fits in time_t. */
|
|
|
|
static inline bool
|
|
|
|
in_time_t_range (__time64_t t)
|
|
|
|
{
|
|
|
|
time_t s = t;
|
|
|
|
return s == t;
|
|
|
|
}
|
|
|
|
|
2019-03-25 07:38:02 +00:00
|
|
|
/* Convert a known valid struct timeval into a struct __timespec64. */
|
|
|
|
static inline struct __timespec64
|
|
|
|
valid_timeval_to_timespec64 (const struct timeval tv)
|
|
|
|
{
|
|
|
|
struct __timespec64 ts64;
|
|
|
|
|
|
|
|
ts64.tv_sec = tv.tv_sec;
|
|
|
|
ts64.tv_nsec = tv.tv_usec * 1000;
|
|
|
|
|
|
|
|
return ts64;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a known valid struct timespec into a struct __timespec64. */
|
|
|
|
static inline struct __timespec64
|
|
|
|
valid_timespec_to_timespec64 (const struct timespec ts)
|
|
|
|
{
|
|
|
|
struct __timespec64 ts64;
|
|
|
|
|
|
|
|
ts64.tv_sec = ts.tv_sec;
|
|
|
|
ts64.tv_nsec = ts.tv_nsec;
|
|
|
|
|
|
|
|
return ts64;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a valid and within range of struct timespec, struct
|
|
|
|
__timespec64 into a struct timespec. */
|
|
|
|
static inline struct timespec
|
|
|
|
valid_timespec64_to_timespec (const struct __timespec64 ts64)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
ts.tv_sec = (time_t) ts64.tv_sec;
|
|
|
|
ts.tv_nsec = ts64.tv_nsec;
|
|
|
|
|
|
|
|
return ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a valid and within range of struct timeval struct
|
|
|
|
__timespec64 into a struct timeval. */
|
|
|
|
static inline struct timeval
|
|
|
|
valid_timespec64_to_timeval (const struct __timespec64 ts64)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
tv.tv_sec = (time_t) ts64.tv_sec;
|
|
|
|
tv.tv_usec = ts64.tv_nsec / 1000;
|
|
|
|
|
|
|
|
return tv;
|
|
|
|
}
|
2019-10-24 14:20:56 +00:00
|
|
|
|
|
|
|
/* Check if a value is in the valid nanoseconds range. Return true if
|
|
|
|
it is, false otherwise. */
|
|
|
|
static inline bool
|
|
|
|
valid_nanoseconds (__syscall_slong_t ns)
|
|
|
|
{
|
|
|
|
return __glibc_likely (0 <= ns && ns < 1000000000);
|
|
|
|
}
|
2019-10-24 21:01:40 +00:00
|
|
|
|
|
|
|
/* Helper function to get time in seconds, similar to time. */
|
|
|
|
static inline time_t
|
|
|
|
time_now (void)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
__clock_gettime (TIME_CLOCK_GETTIME_CLOCKID, &ts);
|
|
|
|
return ts.tv_sec;
|
|
|
|
}
|
1998-08-09 17:39:48 +00:00
|
|
|
#endif
|
2019-10-24 21:01:40 +00:00
|
|
|
|
1998-09-06 23:45:24 +00:00
|
|
|
#endif
|