public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
@ 2019-08-20 12:07 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-20 12:07 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 8932 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=68d2df078ee09a79512a697c8164e93f2edb7934
commit 68d2df078ee09a79512a697c8164e93f2edb7934
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:11:47 2019 -0400
Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
gettimeofday and settimeofday are obsolete in POSIX and will not be
provided by Linux for future new architectures. The preferred
interfaces are clock_gettime and clock_settime.
In preparation for implementing all the other time query/set
interfaces using clock_gettime and clock_settime, remove the
generic-Unix implementations of clock_gettime and clock_settime that
forwarded to gettimeofday and settimeofday. Ports of glibc to
historic Unixes that provided these functions, but not clock_gettime
and clock_settime, are unlikely to be contributed anymore.
The removed implementations *were* being used on the Hurd.
Deal with this by converting the Hurd gettimeofday and settimeofday
implementations into clock_gettime and clock_settime implementations,
respectively. (They still only supply microsecond resolution.
I donât know enough about Hurd/Mach to know whether nanosecond-
resolution clocks are even available.) This means Hurd temporarily
has no implementation of gettimeofday or settimeofday; this will be
corrected in subsequent patches. (glibc will not fail to build in the
i386-gnu configuration, but gettimeofday and settimeofday will be
ENOSYS stubs.)
* sysdeps/unix/clock_gettime.c, sysdeps/unix/clock_settime.c:
Delete file.
* sysdeps/mach/gettimeofday.c: Rename to .../clock_gettime.c
and convert into an implementation of clock_gettime.
* sysdeps/mach/hurd/settimeofday.c: Rename to .../clock_settime.c
and convert into an implementation of clock_settime.
Diff:
---
sysdeps/mach/{gettimeofday.c => clock_gettime.c} | 25 +++++----
.../mach/hurd/{settimeofday.c => clock_settime.c} | 27 ++++-----
sysdeps/unix/clock_gettime.c | 64 ----------------------
sysdeps/unix/clock_settime.c | 54 ------------------
4 files changed, 25 insertions(+), 145 deletions(-)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/clock_gettime.c
similarity index 67%
rename from sysdeps/mach/gettimeofday.c
rename to sysdeps/mach/clock_gettime.c
index 8d0dfbb..0fe0619 100644
--- a/sysdeps/mach/gettimeofday.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -16,28 +16,31 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <stddef.h>
-#include <sys/time.h>
+#include <time.h>
#include <mach.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TS.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
kern_return_t err;
+ time_value_t tv;
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
+ if (clock_id != CLOCK_REALTIME)
+ {
+ errno = EINVAL;
+ return -1;
+ }
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ if (err = __host_get_time (__mach_host_self (), &tv))
{
errno = err;
return -1;
}
+
+ TIME_VALUE_TO_TIMESPEC (&tv, ts);
return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
+weak_alias (__clock_gettime, clock_gettime)
+libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/clock_settime.c
similarity index 71%
rename from sysdeps/mach/hurd/settimeofday.c
rename to sysdeps/mach/hurd/clock_settime.c
index bd0ffd6..a642b82 100644
--- a/sysdeps/mach/hurd/settimeofday.c
+++ b/sysdeps/mach/hurd/clock_settime.c
@@ -16,37 +16,32 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <hurd.h>
#include <hurd/port.h>
-/* Set the current time of day and timezone information.
+/* Set the current time of day.
This call is restricted to the super-user. */
int
-__settimeofday (const struct timeval *tv, const struct timezone *tz)
+__clock_settime (clockid_t clock_id, const struct timespec *ts)
{
error_t err;
mach_port_t hostpriv;
+ time_value_t tv;
- if (tz != NULL)
- {
- errno = ENOSYS;
- return -1;
- }
+ if (clock_id != CLOCK_REALTIME)
+ return __hurd_fail (EINVAL);
err = __get_privileged_ports (&hostpriv, NULL);
if (err)
return __hurd_fail (EPERM);
- /* `time_value_t' and `struct timeval' are in fact identical with the
- names changed. */
- err = __host_set_time (hostpriv, *(time_value_t *) tv);
+ TIMESPEC_TO_TIME_VALUE (&tv, ts);
+ err = __host_set_time (hostpriv, tv);
__mach_port_deallocate (__mach_task_self (), hostpriv);
- if (err)
- return __hurd_fail (err);
-
- return 0;
+ return __hurd_fail (err);
}
-
-weak_alias (__settimeofday, settimeofday)
+libc_hidden_def (__clock_settime)
+weak_alias (__clock_settime, clock_settime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
deleted file mode 100644
index 10a6c96..0000000
--- a/sysdeps/unix/clock_gettime.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <stdint.h>
-#include <time.h>
-#include <sys/time.h>
-#include <libc-internal.h>
-#include <ldsodefs.h>
-
-
-static inline int
-realtime_gettime (struct timespec *tp)
-{
- struct timeval tv;
- int retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- /* Convert into `timespec'. */
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- return retval;
-}
-
-
-/* Get current value of CLOCK and store it in TP. */
-int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
-{
- int retval = -1;
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_gettime, clock_gettime)
-libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
deleted file mode 100644
index 109a1ad..0000000
--- a/sysdeps/unix/clock_settime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <ldsodefs.h>
-
-
-/* Set CLOCK to value TP. */
-int
-__clock_settime (clockid_t clock_id, const struct timespec *tp)
-{
- int retval = -1;
-
- /* Make sure the time cvalue is OK. */
- if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- TIMESPEC_TO_TIMEVAL (&tv, tp);
- retval = __settimeofday (&tv, NULL);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_settime, clock_settime)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
@ 2019-08-22 23:03 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-22 23:03 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5509f57349a19bd4fe1bb71fd51b8a560698f3dd
commit 5509f57349a19bd4fe1bb71fd51b8a560698f3dd
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:11:47 2019 -0400
Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
gettimeofday and settimeofday are obsolete in POSIX and will not be
provided by Linux for future new architectures. The preferred
interfaces are clock_gettime and clock_settime. Ports of glibc to
historic Unixes that provided these functions, but not clock_gettime
and clock_settime, are unlikely to be contributed anymore.
Accordingly, remove the generic-Unix implementations of clock_gettime
and clock_settime that forwarded to gettimeofday and settimeofday.
New OS ports must henceforth provide some implementation of
clock_gettime and clock_settime.
The generic-Unix implementations *were* being used on the Hurd. This
patch therefore also converts the Hurd gettimeofday and settimeofday
implementations into clock_gettime and clock_settime implementations.
They only support CLOCK_REALTIME, and they only supply microsecond
resolution. Hurd/Mach does not appear to have any support for
finer-resolution or monotonic clocks. Relatedly, Hurd is currently
using sysdeps/posix/clock_getres.c for clock_getres; its output for
CLOCK_REALTIME is based on sysconf (_SC_CLK_TCK), and I do not know
whether that gives the correct result.
This means Hurd temporarily has only ENOSYS stubs for gettimeofday and
settimeofday; this will be corrected in the next two patches, which
will be squashed together with this one after review.
* sysdeps/unix/clock_gettime.c, sysdeps/unix/clock_settime.c:
Delete file.
* sysdeps/mach/gettimeofday.c: Rename to .../clock_gettime.c
and convert into an implementation of clock_gettime.
* sysdeps/mach/hurd/settimeofday.c: Rename to .../clock_settime.c
and convert into an implementation of clock_settime.
Diff:
---
sysdeps/mach/{gettimeofday.c => clock_gettime.c} | 26 ++++-----
.../mach/hurd/{settimeofday.c => clock_settime.c} | 27 ++++------
sysdeps/unix/clock_gettime.c | 56 --------------------
sysdeps/unix/clock_settime.c | 61 ----------------------
4 files changed, 24 insertions(+), 146 deletions(-)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/clock_gettime.c
similarity index 65%
rename from sysdeps/mach/gettimeofday.c
rename to sysdeps/mach/clock_gettime.c
index 8d0dfbb..8e3675e 100644
--- a/sysdeps/mach/gettimeofday.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -16,28 +16,28 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <stddef.h>
-#include <sys/time.h>
+#include <time.h>
#include <mach.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TS.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
kern_return_t err;
+ time_value_t tv;
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
-
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ if (clock_id != CLOCK_REALTIME)
{
- errno = err;
+ errno = EINVAL;
return -1;
}
+
+ /* Could theoretically fail if __mach_host_self fails due to
+ resource exhaustion, but we assume this will never happen. */
+ __host_get_time (__mach_host_self (), &tv);
+ TIME_VALUE_TO_TIMESPEC (&tv, ts);
return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
+weak_alias (__clock_gettime, clock_gettime)
+libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/clock_settime.c
similarity index 71%
rename from sysdeps/mach/hurd/settimeofday.c
rename to sysdeps/mach/hurd/clock_settime.c
index bd0ffd6..a642b82 100644
--- a/sysdeps/mach/hurd/settimeofday.c
+++ b/sysdeps/mach/hurd/clock_settime.c
@@ -16,37 +16,32 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <hurd.h>
#include <hurd/port.h>
-/* Set the current time of day and timezone information.
+/* Set the current time of day.
This call is restricted to the super-user. */
int
-__settimeofday (const struct timeval *tv, const struct timezone *tz)
+__clock_settime (clockid_t clock_id, const struct timespec *ts)
{
error_t err;
mach_port_t hostpriv;
+ time_value_t tv;
- if (tz != NULL)
- {
- errno = ENOSYS;
- return -1;
- }
+ if (clock_id != CLOCK_REALTIME)
+ return __hurd_fail (EINVAL);
err = __get_privileged_ports (&hostpriv, NULL);
if (err)
return __hurd_fail (EPERM);
- /* `time_value_t' and `struct timeval' are in fact identical with the
- names changed. */
- err = __host_set_time (hostpriv, *(time_value_t *) tv);
+ TIMESPEC_TO_TIME_VALUE (&tv, ts);
+ err = __host_set_time (hostpriv, tv);
__mach_port_deallocate (__mach_task_self (), hostpriv);
- if (err)
- return __hurd_fail (err);
-
- return 0;
+ return __hurd_fail (err);
}
-
-weak_alias (__settimeofday, settimeofday)
+libc_hidden_def (__clock_settime)
+weak_alias (__clock_settime, clock_settime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
deleted file mode 100644
index 2a82fc1..0000000
--- a/sysdeps/unix/clock_gettime.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <shlib-compat.h>
-
-/* Get current value of CLOCK and store it in TP. */
-int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
-{
- int retval = -1;
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-libc_hidden_def (__clock_gettime)
-
-versioned_symbol (libc, __clock_gettime, clock_gettime, GLIBC_2_17);
-/* clock_gettime 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_gettime, __clock_gettime_2);
-compat_symbol (libc, __clock_gettime_2, clock_gettime, GLIBC_2_2);
-#endif
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
deleted file mode 100644
index 5b39849..0000000
--- a/sysdeps/unix/clock_settime.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <shlib-compat.h>
-
-/* Set CLOCK to value TP. */
-int
-__clock_settime (clockid_t clock_id, const struct timespec *tp)
-{
- int retval = -1;
-
- /* Make sure the time cvalue is OK. */
- if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- TIMESPEC_TO_TIMEVAL (&tv, tp);
- retval = __settimeofday (&tv, NULL);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-libc_hidden_def (__clock_settime)
-
-versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17);
-/* clock_settime 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_settime, __clock_settime_2);
-compat_symbol (libc, __clock_settime_2, clock_settime, GLIBC_2_2);
-#endif
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
@ 2019-08-21 12:27 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-21 12:27 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 8932 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b04bc5697f91f35f5a3ef70d70911ffcdb485569
commit b04bc5697f91f35f5a3ef70d70911ffcdb485569
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:11:47 2019 -0400
Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
gettimeofday and settimeofday are obsolete in POSIX and will not be
provided by Linux for future new architectures. The preferred
interfaces are clock_gettime and clock_settime.
In preparation for implementing all the other time query/set
interfaces using clock_gettime and clock_settime, remove the
generic-Unix implementations of clock_gettime and clock_settime that
forwarded to gettimeofday and settimeofday. Ports of glibc to
historic Unixes that provided these functions, but not clock_gettime
and clock_settime, are unlikely to be contributed anymore.
The removed implementations *were* being used on the Hurd.
Deal with this by converting the Hurd gettimeofday and settimeofday
implementations into clock_gettime and clock_settime implementations,
respectively. (They still only supply microsecond resolution.
I donât know enough about Hurd/Mach to know whether nanosecond-
resolution clocks are even available.) This means Hurd temporarily
has no implementation of gettimeofday or settimeofday; this will be
corrected in subsequent patches. (glibc will not fail to build in the
i386-gnu configuration, but gettimeofday and settimeofday will be
ENOSYS stubs.)
* sysdeps/unix/clock_gettime.c, sysdeps/unix/clock_settime.c:
Delete file.
* sysdeps/mach/gettimeofday.c: Rename to .../clock_gettime.c
and convert into an implementation of clock_gettime.
* sysdeps/mach/hurd/settimeofday.c: Rename to .../clock_settime.c
and convert into an implementation of clock_settime.
Diff:
---
sysdeps/mach/{gettimeofday.c => clock_gettime.c} | 25 +++++----
.../mach/hurd/{settimeofday.c => clock_settime.c} | 27 ++++-----
sysdeps/unix/clock_gettime.c | 64 ----------------------
sysdeps/unix/clock_settime.c | 54 ------------------
4 files changed, 25 insertions(+), 145 deletions(-)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/clock_gettime.c
similarity index 67%
rename from sysdeps/mach/gettimeofday.c
rename to sysdeps/mach/clock_gettime.c
index 8d0dfbb..0fe0619 100644
--- a/sysdeps/mach/gettimeofday.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -16,28 +16,31 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <stddef.h>
-#include <sys/time.h>
+#include <time.h>
#include <mach.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TS.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
kern_return_t err;
+ time_value_t tv;
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
+ if (clock_id != CLOCK_REALTIME)
+ {
+ errno = EINVAL;
+ return -1;
+ }
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ if (err = __host_get_time (__mach_host_self (), &tv))
{
errno = err;
return -1;
}
+
+ TIME_VALUE_TO_TIMESPEC (&tv, ts);
return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
+weak_alias (__clock_gettime, clock_gettime)
+libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/clock_settime.c
similarity index 71%
rename from sysdeps/mach/hurd/settimeofday.c
rename to sysdeps/mach/hurd/clock_settime.c
index bd0ffd6..a642b82 100644
--- a/sysdeps/mach/hurd/settimeofday.c
+++ b/sysdeps/mach/hurd/clock_settime.c
@@ -16,37 +16,32 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <hurd.h>
#include <hurd/port.h>
-/* Set the current time of day and timezone information.
+/* Set the current time of day.
This call is restricted to the super-user. */
int
-__settimeofday (const struct timeval *tv, const struct timezone *tz)
+__clock_settime (clockid_t clock_id, const struct timespec *ts)
{
error_t err;
mach_port_t hostpriv;
+ time_value_t tv;
- if (tz != NULL)
- {
- errno = ENOSYS;
- return -1;
- }
+ if (clock_id != CLOCK_REALTIME)
+ return __hurd_fail (EINVAL);
err = __get_privileged_ports (&hostpriv, NULL);
if (err)
return __hurd_fail (EPERM);
- /* `time_value_t' and `struct timeval' are in fact identical with the
- names changed. */
- err = __host_set_time (hostpriv, *(time_value_t *) tv);
+ TIMESPEC_TO_TIME_VALUE (&tv, ts);
+ err = __host_set_time (hostpriv, tv);
__mach_port_deallocate (__mach_task_self (), hostpriv);
- if (err)
- return __hurd_fail (err);
-
- return 0;
+ return __hurd_fail (err);
}
-
-weak_alias (__settimeofday, settimeofday)
+libc_hidden_def (__clock_settime)
+weak_alias (__clock_settime, clock_settime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
deleted file mode 100644
index 10a6c96..0000000
--- a/sysdeps/unix/clock_gettime.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <stdint.h>
-#include <time.h>
-#include <sys/time.h>
-#include <libc-internal.h>
-#include <ldsodefs.h>
-
-
-static inline int
-realtime_gettime (struct timespec *tp)
-{
- struct timeval tv;
- int retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- /* Convert into `timespec'. */
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- return retval;
-}
-
-
-/* Get current value of CLOCK and store it in TP. */
-int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
-{
- int retval = -1;
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_gettime, clock_gettime)
-libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
deleted file mode 100644
index 109a1ad..0000000
--- a/sysdeps/unix/clock_settime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <ldsodefs.h>
-
-
-/* Set CLOCK to value TP. */
-int
-__clock_settime (clockid_t clock_id, const struct timespec *tp)
-{
- int retval = -1;
-
- /* Make sure the time cvalue is OK. */
- if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- TIMESPEC_TO_TIMEVAL (&tv, tp);
- retval = __settimeofday (&tv, NULL);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_settime, clock_settime)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
@ 2019-08-19 18:31 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-19 18:31 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 8932 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0a84fe552f00a3c7e86a3f105156c230b04be7ab
commit 0a84fe552f00a3c7e86a3f105156c230b04be7ab
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:11:47 2019 -0400
Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
gettimeofday and settimeofday are obsolete in POSIX and will not be
provided by Linux for future new architectures. The preferred
interfaces are clock_gettime and clock_settime.
In preparation for implementing all the other time query/set
interfaces using clock_gettime and clock_settime, remove the
generic-Unix implementations of clock_gettime and clock_settime that
forwarded to gettimeofday and settimeofday. Ports of glibc to
historic Unixes that provided these functions, but not clock_gettime
and clock_settime, are unlikely to be contributed anymore.
The removed implementations *were* being used on the Hurd.
Deal with this by converting the Hurd gettimeofday and settimeofday
implementations into clock_gettime and clock_settime implementations,
respectively. (They still only supply microsecond resolution.
I donât know enough about Hurd/Mach to know whether nanosecond-
resolution clocks are even available.) This means Hurd temporarily
has no implementation of gettimeofday or settimeofday; this will be
corrected in subsequent patches. (glibc will not fail to build in the
i386-gnu configuration, but gettimeofday and settimeofday will be
ENOSYS stubs.)
* sysdeps/unix/clock_gettime.c, sysdeps/unix/clock_settime.c:
Delete file.
* sysdeps/mach/gettimeofday.c: Rename to .../clock_gettime.c
and convert into an implementation of clock_gettime.
* sysdeps/mach/hurd/settimeofday.c: Rename to .../clock_settime.c
and convert into an implementation of clock_settime.
Diff:
---
sysdeps/mach/{gettimeofday.c => clock_gettime.c} | 25 +++++----
.../mach/hurd/{settimeofday.c => clock_settime.c} | 27 ++++-----
sysdeps/unix/clock_gettime.c | 64 ----------------------
sysdeps/unix/clock_settime.c | 54 ------------------
4 files changed, 25 insertions(+), 145 deletions(-)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/clock_gettime.c
similarity index 67%
rename from sysdeps/mach/gettimeofday.c
rename to sysdeps/mach/clock_gettime.c
index 8d0dfbb..0fe0619 100644
--- a/sysdeps/mach/gettimeofday.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -16,28 +16,31 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <stddef.h>
-#include <sys/time.h>
+#include <time.h>
#include <mach.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TS.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
kern_return_t err;
+ time_value_t tv;
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
+ if (clock_id != CLOCK_REALTIME)
+ {
+ errno = EINVAL;
+ return -1;
+ }
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ if (err = __host_get_time (__mach_host_self (), &tv))
{
errno = err;
return -1;
}
+
+ TIME_VALUE_TO_TIMESPEC (&tv, ts);
return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
+weak_alias (__clock_gettime, clock_gettime)
+libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/clock_settime.c
similarity index 71%
rename from sysdeps/mach/hurd/settimeofday.c
rename to sysdeps/mach/hurd/clock_settime.c
index bd0ffd6..a642b82 100644
--- a/sysdeps/mach/hurd/settimeofday.c
+++ b/sysdeps/mach/hurd/clock_settime.c
@@ -16,37 +16,32 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <hurd.h>
#include <hurd/port.h>
-/* Set the current time of day and timezone information.
+/* Set the current time of day.
This call is restricted to the super-user. */
int
-__settimeofday (const struct timeval *tv, const struct timezone *tz)
+__clock_settime (clockid_t clock_id, const struct timespec *ts)
{
error_t err;
mach_port_t hostpriv;
+ time_value_t tv;
- if (tz != NULL)
- {
- errno = ENOSYS;
- return -1;
- }
+ if (clock_id != CLOCK_REALTIME)
+ return __hurd_fail (EINVAL);
err = __get_privileged_ports (&hostpriv, NULL);
if (err)
return __hurd_fail (EPERM);
- /* `time_value_t' and `struct timeval' are in fact identical with the
- names changed. */
- err = __host_set_time (hostpriv, *(time_value_t *) tv);
+ TIMESPEC_TO_TIME_VALUE (&tv, ts);
+ err = __host_set_time (hostpriv, tv);
__mach_port_deallocate (__mach_task_self (), hostpriv);
- if (err)
- return __hurd_fail (err);
-
- return 0;
+ return __hurd_fail (err);
}
-
-weak_alias (__settimeofday, settimeofday)
+libc_hidden_def (__clock_settime)
+weak_alias (__clock_settime, clock_settime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
deleted file mode 100644
index 10a6c96..0000000
--- a/sysdeps/unix/clock_gettime.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <stdint.h>
-#include <time.h>
-#include <sys/time.h>
-#include <libc-internal.h>
-#include <ldsodefs.h>
-
-
-static inline int
-realtime_gettime (struct timespec *tp)
-{
- struct timeval tv;
- int retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- /* Convert into `timespec'. */
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- return retval;
-}
-
-
-/* Get current value of CLOCK and store it in TP. */
-int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
-{
- int retval = -1;
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_gettime, clock_gettime)
-libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
deleted file mode 100644
index 109a1ad..0000000
--- a/sysdeps/unix/clock_settime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <ldsodefs.h>
-
-
-/* Set CLOCK to value TP. */
-int
-__clock_settime (clockid_t clock_id, const struct timespec *tp)
-{
- int retval = -1;
-
- /* Make sure the time cvalue is OK. */
- if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- TIMESPEC_TO_TIMEVAL (&tv, tp);
- retval = __settimeofday (&tv, NULL);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_settime, clock_settime)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
@ 2019-08-17 1:17 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-17 1:17 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 8960 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=78aa72b51f6c2cd23e9253a90af54afe7ae05df2
commit 78aa72b51f6c2cd23e9253a90af54afe7ae05df2
Author: Zack Weinberg <zackw@panix.com>
Date: Fri Aug 16 15:11:47 2019 -0400
Remove implementations of clock_[gs]ettime using [gs]ettimeofday.
gettimeofday and settimeofday are obsolete in POSIX and will not be
provided by Linux for future new architectures. The preferred
interfaces are clock_gettime and clock_settime.
In preparation for implementing all the other time query/set
interfaces using clock_gettime and clock_settime, remove the
generic-Unix implementations of clock_gettime and clock_settime that
forwarded to gettimeofday and settimeofday. Ports of glibc to
historic Unixes that provided these functions, but not clock_gettime
and clock_settime, are unlikely to be contributed anymore.
The removed implementations *were* being used on the Hurd.
Deal with this by converting the Hurd gettimeofday and settimeofday
implementations into clock_gettime and clock_settime implementations,
respectively. (They still only supply microsecond resolution.
I donât know enough about Hurd/Mach to know whether nanosecond-
resolution clocks are even available.) This means Hurd temporarily
has no implementation of gettimeofday or settimeofday; this will be
corrected in subsequent patches. (glibc will not fail to build in the
i386-gnu configuration, but gettimeofday and settimeofday will be
ENOSYS stubs.)
* sysdeps/unix/clock_gettime.c, sysdeps/unix/clock_settime.c:
Delete file.
* sysdeps/mach/gettimeofday.c: Rename to .../clock_gettime.c
and convert into an implementation of clock_gettime.
* sysdeps/mach/hurd/settimeofday.c: Rename to .../clock_settime.c
and convert into an implementation of clock_settime.
Diff:
---
sysdeps/mach/{gettimeofday.c => clock_gettime.c} | 24 ++++----
.../mach/hurd/{settimeofday.c => clock_settime.c} | 23 ++++----
sysdeps/unix/clock_gettime.c | 64 ----------------------
sysdeps/unix/clock_settime.c | 54 ------------------
4 files changed, 24 insertions(+), 141 deletions(-)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/clock_gettime.c
similarity index 73%
rename from sysdeps/mach/gettimeofday.c
rename to sysdeps/mach/clock_gettime.c
index 8d0dfbb..e53c8e1 100644
--- a/sysdeps/mach/gettimeofday.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -16,28 +16,32 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <stddef.h>
+#include <time.h>
#include <sys/time.h>
#include <mach.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TS.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
kern_return_t err;
+ struct timeval tv;
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
+ if (clock_id != CLOCK_REALTIME)
+ {
+ errno = EINVAL;
+ return -1;
+ }
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ if (err = __host_get_time (__mach_host_self (), (time_value_t *) &tv))
{
errno = err;
return -1;
}
+
+ TIMEVAL_TO_TIMESPEC (&tv, ts);
return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
+weak_alias (__clock_gettime, clock_gettime)
+libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/clock_settime.c
similarity index 78%
rename from sysdeps/mach/hurd/settimeofday.c
rename to sysdeps/mach/hurd/clock_settime.c
index bd0ffd6..39018c4 100644
--- a/sysdeps/mach/hurd/settimeofday.c
+++ b/sysdeps/mach/hurd/clock_settime.c
@@ -16,23 +16,22 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <hurd.h>
#include <hurd/port.h>
-/* Set the current time of day and timezone information.
+/* Set the current time of day.
This call is restricted to the super-user. */
int
-__settimeofday (const struct timeval *tv, const struct timezone *tz)
+__clock_settime (clockid_t clock_id, const struct timespec *ts)
{
error_t err;
mach_port_t hostpriv;
+ struct timeval tv;
- if (tz != NULL)
- {
- errno = ENOSYS;
- return -1;
- }
+ if (clock_id != CLOCK_REALTIME)
+ return __hurd_fail (EINVAL);
err = __get_privileged_ports (&hostpriv, NULL);
if (err)
@@ -40,13 +39,11 @@ __settimeofday (const struct timeval *tv, const struct timezone *tz)
/* `time_value_t' and `struct timeval' are in fact identical with the
names changed. */
+ TIMESPEC_TO_TIMEVAL (&tv, ts);
err = __host_set_time (hostpriv, *(time_value_t *) tv);
__mach_port_deallocate (__mach_task_self (), hostpriv);
- if (err)
- return __hurd_fail (err);
-
- return 0;
+ return __hurd_fail (err);
}
-
-weak_alias (__settimeofday, settimeofday)
+libc_hidden_def (__clock_settime)
+weak_alias (__clock_settime, clock_settime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
deleted file mode 100644
index 10a6c96..0000000
--- a/sysdeps/unix/clock_gettime.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <stdint.h>
-#include <time.h>
-#include <sys/time.h>
-#include <libc-internal.h>
-#include <ldsodefs.h>
-
-
-static inline int
-realtime_gettime (struct timespec *tp)
-{
- struct timeval tv;
- int retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- /* Convert into `timespec'. */
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- return retval;
-}
-
-
-/* Get current value of CLOCK and store it in TP. */
-int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
-{
- int retval = -1;
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_gettime, clock_gettime)
-libc_hidden_def (__clock_gettime)
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
deleted file mode 100644
index 109a1ad..0000000
--- a/sysdeps/unix/clock_settime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1999-2019 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
- <http://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <ldsodefs.h>
-
-
-/* Set CLOCK to value TP. */
-int
-__clock_settime (clockid_t clock_id, const struct timespec *tp)
-{
- int retval = -1;
-
- /* Make sure the time cvalue is OK. */
- if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- switch (clock_id)
- {
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- TIMESPEC_TO_TIMEVAL (&tv, tp);
- retval = __settimeofday (&tv, NULL);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
- }
-
- return retval;
-}
-weak_alias (__clock_settime, clock_settime)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-08-22 23:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 12:07 [glibc/zack/y2038-preliminaries] Remove implementations of clock_[gs]ettime using [gs]ettimeofday Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2019-08-22 23:03 Zack Weinberg
2019-08-21 12:27 Zack Weinberg
2019-08-19 18:31 Zack Weinberg
2019-08-17 1:17 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).