public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime.
@ 2019-08-21 12:28 Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-21 12:28 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: 5348 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e15799360056223b21b037221a3c60c6d83be00a

commit e15799360056223b21b037221a3c60c6d83be00a
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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime.
@ 2019-08-20 13:24 Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2019-08-20 13:24 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: 5348 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=da7859ec6faf7710c142dfee755978436048db7b

commit da7859ec6faf7710c142dfee755978436048db7b
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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime.
@ 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: 5348 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4e83f317688294ccbf554920febe9c25fd489b33

commit 4e83f317688294ccbf554920febe9c25fd489b33
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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime.
@ 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: 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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime.
@ 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: 5398 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0674c2aa588c85b162e399ab691c53d3d52433d0

commit 0674c2aa588c85b162e399ab691c53d3d52433d0
Author: Zack Weinberg <zackw@panix.com>
Date:   Fri Aug 16 15:03:16 2019 -0400

    Use clock_settime to implement stime.
    
    Similarly to the previous patch: use clock_settime to implement stime,
    not settimeofday or a direct syscall.  This applies unconditionally to
    all ports.
    
    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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-21 12:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 12:28 [glibc/zack/y2038-preliminaries] Use clock_settime to implement stime Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
2019-08-20 13:24 Zack Weinberg
2019-08-20 12:07 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).