glibc/time
Zack Weinberg c3f9aef063 Use clock_settime to implement settimeofday.
Unconditionally, on all ports, use clock_settime to implement
settimeofday.  Remove sysdeps/unix/clock_settime.c, which implemented
clock_settime by calling settimeofday; new OS ports must henceforth
provide a real implementation of clock_settime.

Hurd had a real implementation of settimeofday but not of
clock_settime; this patch converts it into an implementation of
clock_settime.  It only supports CLOCK_REALTIME and microsecond
resolution; Hurd/Mach does not appear to have any support for
finer-resolution clocks.

The vestigial "set time zone" feature of settimeofday complicates the
generic settimeofday implementation a little.  The only remaining uses
of this feature that aren't just bugs, are using it to inform the
Linux kernel of the offset between the hardware clock and UTC, on
systems where the hardware clock doesn't run in UTC (usually because
of dual-booting with Windows).  There currently isn't any other way to
do this.  However, the callers that do this call settimeofday with
_only_ the timezone argument non-NULL.  Therefore, glibc's new
behavior is: callers of settimeofday must supply one and only one of
the two arguments.  If both arguments are non-NULL, or both arguments
are NULL, the call fails and sets errno to EINVAL.

When only the timeval argument is supplied, settimeofday calls
__clock_settime(CLOCK_REALTIME), same as stime.

When only the timezone argument is supplied, settimeofday calls a new
internal function called __settimezone.  On Linux, only, this function
will pass the timezone structure to the settimeofday system call.  On
all other operating systems, and on Linux architectures that don't
define __NR_settimeofday, __settimezone is a stub that always sets
errno to ENOSYS and returns -1.

The settimeoday syscall is enabled on Linux by the flag
COMPAT_32BIT_TIME, which is an option to either 32-bits ABIs or COMPAT
builds (defined usually by 64-bit kernels that want to support 32-bit
 ABIs, such as x86).  The idea to future 64-bit time_t only ABIs
is to not provide settimeofday syscall.

The same semantics are implemented for Linux/Alpha's GLIBC_2.0 compat
symbol for settimeofday.

There are no longer any internal callers of __settimeofday, so the
internal prototype is removed.

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>
2019-10-30 17:05:14 -03:00
..
bits/types time: Add padding for the timespec if required 2019-10-01 14:56:06 -07:00
sys Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
adjtime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
alt_digit.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
asctime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
bug-asctime_r.c
bug-asctime.c
bug-getdate1.c
bug-mktime1.c
bug-mktime4.c mktime: new test for mktime failure 2018-11-15 22:59:33 +01:00
clock_getcpuclockid.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
clock_getres.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
clock_gettime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
clock_nanosleep.c time: Introduce function to check correctness of nanoseconds value 2019-10-27 21:49:25 +01:00
clock_settime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
clock.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
clocktest.c
ctime_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ctime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
datemsk
Depend
difftime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
dysize.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
era.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ftime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getdate.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getitimer.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gettimeofday.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gmtime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
lc-time-cleanup.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
localtime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
Makefile Use clock_settime to implement settimeofday. 2019-10-30 17:05:14 -03:00
mktime-internal.h Make mktime etc. compatible with __time64_t 2019-04-30 09:02:17 -07:00
mktime.c Make mktime etc. compatible with __time64_t 2019-04-30 09:02:17 -07:00
offtime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
setitimer.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
settimeofday.c Use clock_settime to implement settimeofday. 2019-10-30 17:05:14 -03:00
settimezone.c Use clock_settime to implement settimeofday. 2019-10-30 17:05:14 -03:00
stime.c Use clock_settime to implement stime; withdraw stime. 2019-10-30 17:05:14 -03:00
strftime_l.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
strftime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
strptime_l.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
strptime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
test_time.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
time.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
time.h Use clock_settime to implement stime; withdraw stime. 2019-10-30 17:05:14 -03:00
timegm.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
timespec_get.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst_wcsftime.c Don't use the argument to time. 2019-08-21 08:26:36 -04:00
tst-clock2.c Finish move of clock_* functions to libc. [BZ #24959] 2019-09-04 14:39:38 +02:00
tst-clock_nanosleep.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-clock.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-cpuclock1.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-ftime_l.c
tst-ftime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-getdate.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-mktime2.c time/tst-mktime2: Improve test error reporting 2018-10-23 11:25:05 +02:00
tst-mktime3.c
tst-mktime.c
tst-posixtz.c
tst-strftime2.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-strftime3.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-strftime.c
tst-strptime2.c
tst-strptime3.c
tst-strptime-whitespace.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-strptime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-tzname.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-y2039.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tzfile.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tzset.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
Versions Finish move of clock_* functions to libc. [BZ #24959] 2019-09-04 14:39:38 +02:00
wcsftime_l.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
wcsftime.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00