]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use clock_settime to implement stime; withdraw stime.
authorZack Weinberg <zackw@panix.com>
Fri, 16 Aug 2019 19:03:16 +0000 (15:03 -0400)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 30 Oct 2019 20:05:14 +0000 (17:05 -0300)
Unconditionally, on all ports, use clock_settime to implement stime,
not settimeofday or a direct syscall.  Then convert stime into a
compatibility symbol and remove its prototype from time.h.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
NEWS
sysdeps/unix/stime.c [deleted file]
sysdeps/unix/sysv/linux/syscalls.list
time/stime.c
time/time.h

diff --git a/NEWS b/NEWS
index d7286841c9287d80fbe9b39d3a04f6fb3ed17931..8727b5e7f0e559571b49cac64b80d888fd5e0270 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ Deprecated and removed features, and other changes affecting compatibility:
   Request 25 to TS 18661-1, as applied for C2X.  Existing binaries that pass
   floating-point arguments directly will continue to work.
 
+* The obsolete function stime is no longer available to newly linked
+  binaries and it has been removed from <time.h> header.  This function
+  has been deprecated in favor of clock_settime.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/sysdeps/unix/stime.c b/sysdeps/unix/stime.c
deleted file mode 100644 (file)
index b40c334..0000000
+++ /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
-   <https://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);
-}
index cdcf6c127bd0f5f72decc0f8cbd1239cad3af525..70b110979ba844839e55cecf856452ee988acb67 100644 (file)
@@ -61,7 +61,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
index a53c0e86ae2e3dc5241708c28f120579b6563eaf..6ea3b6dcc1a393b57b69ca24fbfe8023d9095837 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_31)
+
 #include <time.h>
-#include <stddef.h>
 
 /* Set the system clock to *WHEN.  */
 
 int
-stime (const time_t *when)
+attribute_compat_text_section
+__stime (const time_t *when)
 {
-  if (when == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  __set_errno (ENOSYS);
-  return -1;
+  struct timespec ts;
+  ts.tv_sec = *when;
+  ts.tv_nsec = 0;
+
+  return __clock_settime (CLOCK_REALTIME, &ts);
 }
 
-stub_warning (stime)
+compat_symbol (libc, __stime, stime, GLIBC_2_0);
+#endif
index 72a1078d2cc12d892eea8f32244db8f7f435acec..7daaacce1649bf277639eda0774e400a89609c9a 100644 (file)
@@ -175,12 +175,6 @@ extern int daylight;
 extern long int timezone;
 #endif
 
-#ifdef __USE_MISC
-/* Set the system time to *WHEN.
-   This call is restricted to the superuser.  */
-extern int stime (const time_t *__when) __THROW;
-#endif
-
 
 /* Nonzero if YEAR is a leap year (every 4 years,
    except every 100th isn't, and every 400th is).  */