public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/y2038-preliminaries] Use clock_gettime to implement time. Date: Tue, 10 Sep 2019 17:20:00 -0000 [thread overview] Message-ID: <20190910172013.61676.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=95062ebe070a05a9afd2bfa76f13af47128dec15 commit 95062ebe070a05a9afd2bfa76f13af47128dec15 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Wed Sep 4 18:12:24 2019 +0000 Use clock_gettime to implement time. Consolidate generic time implementation to use clock_gettime. Linux ports that still use either time or gettime syscall or vDSO are not changed. * time/time.c (time): No longer a stub implementation. Call __clock_gettime. * sysdeps/unix/sysv/linux/powerpc/time.c: Use new generic implementation. * sysdeps/posix/time.c * sysdeps/unix/sysv/linux/sparc/sparc64/time.c * sysdeps/unix/sysv/linux/time.c: Remove file. Diff: --- sysdeps/posix/time.c | 40 --------------------------- sysdeps/unix/sysv/linux/powerpc/time.c | 2 +- sysdeps/unix/sysv/linux/sparc/sparc64/time.c | 1 - sysdeps/unix/sysv/linux/time.c | 41 ---------------------------- time/time.c | 12 ++++---- 5 files changed, 6 insertions(+), 90 deletions(-) diff --git a/sysdeps/posix/time.c b/sysdeps/posix/time.c deleted file mode 100644 index e1b3bc8..0000000 --- a/sysdeps/posix/time.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1991-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 <stddef.h> /* For NULL. */ -#include <time.h> -#include <sys/time.h> - - -/* Return the current time as a `time_t' and also put it in *T if T is - not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */ -time_t -time (time_t *t) -{ - struct timeval tv; - time_t result; - - if (__gettimeofday (&tv, (struct timezone *) NULL)) - result = (time_t) -1; - else - result = (time_t) tv.tv_sec; - - if (t != NULL) - *t = result; - return result; -} -libc_hidden_def (time) diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index cb3e8b9..cfb1644 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -79,6 +79,6 @@ libc_hidden_def (time) #else -#include <sysdeps/posix/time.c> +#include <time/time.c> #endif /* !SHARED */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c b/sysdeps/unix/sysv/linux/sparc/sparc64/time.c deleted file mode 100644 index 509b580..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/posix/time.c> diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c deleted file mode 100644 index 1978f6d..0000000 --- a/sysdeps/unix/sysv/linux/time.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2005-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 <stddef.h> -#include <time.h> - -#include <sysdep.h> - -#ifdef __NR_time - -time_t -time (time_t *t) -{ - INTERNAL_SYSCALL_DECL (err); - time_t res = INTERNAL_SYSCALL (time, err, 1, NULL); - /* There cannot be any error. */ - if (t != NULL) - *t = res; - return res; -} -libc_hidden_def (time) - -#else - -# include <sysdeps/posix/time.c> - -#endif diff --git a/time/time.c b/time/time.c index 88612d6..bae0fd1 100644 --- a/time/time.c +++ b/time/time.c @@ -15,19 +15,17 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <errno.h> #include <time.h> /* Return the time now, and store it in *TIMER if not NULL. */ time_t time (time_t *timer) { - __set_errno (ENOSYS); + struct timespec ts; + __clock_gettime (CLOCK_REALTIME, &ts); - if (timer != NULL) - *timer = (time_t) -1; - return (time_t) -1; + if (timer) + *timer = ts.tv_sec; + return ts.tv_sec; } libc_hidden_def (time) - -stub_warning (time)
next reply other threads:[~2019-09-10 17:20 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-10 17:20 Adhemerval Zanella [this message] 2019-10-25 11:25 Adhemerval Zanella
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=20190910172013.61676.qmail@sourceware.org \ --to=azanella@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).