]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - time/time.c
time: Add 64-bit time_t support for ftime
[thirdparty/glibc.git] / time / time.c
index ec66f119df5f347a993197532458bad1c87a31ef..a4640c780ae55c022824173cf82e1f16bf2cdf8a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,96,97,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 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
    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, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
 #include <time.h>
+#include <time-clockid.h>
 
 /* Return the time now, and store it in *TIMER if not NULL.  */
 time_t
-time (timer)
-     time_t *timer;
+time (time_t *timer)
 {
-  __set_errno (ENOSYS);
+  struct timespec ts;
+  __clock_gettime (TIME_CLOCK_GETTIME_CLOCKID, &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)
-#include <stub-tag.h>