public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Zack Weinberg <zack@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime. Date: Mon, 19 Aug 2019 18:31:00 -0000 [thread overview] Message-ID: <20190819183119.53267.qmail@sourceware.org> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 5348 bytes --] https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6df4704cd5b2240811635292b94fd3ad557139c2 commit 6df4704cd5b2240811635292b94fd3ad557139c2 Author: Zack Weinberg <zackw@panix.com> Date: Fri Aug 16 15:03:16 2019 -0400 Use clock_settime to implement stime. Unconditionally, on all ports, use clock_settime to implement stime, not settimeofday or a direct syscall. Note that the former stub implementation of stime would return -1 with errno set to EINVAL if passed a null pointer. With this change, it instead unconditionally dereferences the pointer, so any hypothetical callers that passed NULL will now segfault. I donât think this will break any non-contrived programs. * time/stime.c (stime): No longer a stub implementation. Call __clock_settime. * sysdeps/unix/stime.c: Delete file. * sysdeps/unix/sysv/linux/syscalls.list: Remove entry for stime. * include/time.h: Add libc_hidden_proto for __clock_settime. * rt/clock_settime.c, sysdeps/unix/sysv/linux/clock_settime.c: Add libc_hidden_def for __clock_settime. Diff: --- include/time.h | 1 + rt/clock_settime.c | 1 + sysdeps/unix/stime.c | 39 --------------------------------- sysdeps/unix/sysv/linux/clock_settime.c | 1 + sysdeps/unix/sysv/linux/syscalls.list | 1 - time/stime.c | 15 ++++--------- 6 files changed, 7 insertions(+), 51 deletions(-) diff --git a/include/time.h b/include/time.h index ac3163c..c0421c7 100644 --- a/include/time.h +++ b/include/time.h @@ -22,6 +22,7 @@ extern __typeof (clock_getres) __clock_getres; extern __typeof (clock_gettime) __clock_gettime; libc_hidden_proto (__clock_gettime) extern __typeof (clock_settime) __clock_settime; +libc_hidden_proto (__clock_settime) extern __typeof (clock_nanosleep) __clock_nanosleep; extern __typeof (clock_getcpuclockid) __clock_getcpuclockid; diff --git a/rt/clock_settime.c b/rt/clock_settime.c index 891925a..9c4f4fb 100644 --- a/rt/clock_settime.c +++ b/rt/clock_settime.c @@ -26,5 +26,6 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__clock_settime) weak_alias (__clock_settime, clock_settime) stub_warning (clock_settime) diff --git a/sysdeps/unix/stime.c b/sysdeps/unix/stime.c deleted file mode 100644 index b0809be..0000000 --- a/sysdeps/unix/stime.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1992-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 <stddef.h> /* For NULL. */ -#include <sys/time.h> -#include <time.h> - -/* Set the system clock to *WHEN. */ - -int -stime (const time_t *when) -{ - struct timeval tv; - - if (when == NULL) - { - __set_errno (EINVAL); - return -1; - } - - tv.tv_sec = *when; - tv.tv_usec = 0; - return __settimeofday (&tv, (struct timezone *) 0); -} diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index d837e30..ef1512c 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -34,4 +34,5 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp); } +libc_hidden_def (__clock_settime) weak_alias (__clock_settime, clock_settime) diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index e374f97..f6cb655 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -62,7 +62,6 @@ setfsgid EXTRA setfsgid i:i setfsgid setfsuid EXTRA setfsuid i:i setfsuid setpgid - setpgid i:ii __setpgid setpgid sigaltstack - sigaltstack i:PP __sigaltstack sigaltstack -stime - stime i:p stime sysinfo EXTRA sysinfo i:p __sysinfo sysinfo swapon - swapon i:si __swapon swapon swapoff - swapoff i:s __swapoff swapoff diff --git a/time/stime.c b/time/stime.c index de58c49..b4d692c 100644 --- a/time/stime.c +++ b/time/stime.c @@ -15,23 +15,16 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <errno.h> #include <time.h> -#include <stddef.h> /* Set the system clock to *WHEN. */ int stime (const time_t *when) { - if (when == NULL) - { - __set_errno (EINVAL); - return -1; - } + struct timespec ts; + ts.tv_sec = *when; + ts.tv_nsec = 0; - __set_errno (ENOSYS); - return -1; + return __clock_settime (CLOCK_REALTIME, &ts); } - -stub_warning (stime)
next reply other threads:[~2019-08-19 18:31 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-19 18:31 Zack Weinberg [this message] -- strict thread matches above, loose matches on Subject: below -- 2019-08-21 12:28 Zack Weinberg 2019-08-20 13:24 Zack Weinberg 2019-08-20 12:07 Zack Weinberg 2019-08-17 1:17 Zack Weinberg
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190819183119.53267.qmail@sourceware.org \ --to=zack@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).