newlib-cygwin/libgloss/riscv
Christoph Muellner 0cb40f415b RISC-V: Reliably initialize t0 in _times()
The current implementation does not reliably initialize t0 once.
Additionally the initialization requires two calls to _gettimeofday().
Let's sacrifice a byte to keep the initialization status
and reduce the maximum number of calls to _gettimeofday().

This has caused issues in an application that invokes clock().
The problematic situation is as follows:

1) The program calls clock() which calls _times().
2) _gettimeofday(&t0, 0) puts 0 in t0.tv_usec (because less than 1 us has
   elapsed since the beginning of time).
3) _gettimeofday(&t, 0) puts 1 in t.tv_usec (since now more than 1 us has
   elapsed since the beginning of time).
4) That call to clock() returns 1 (the value from step 3 minus the value in
   step 2).
5) The program does a second call to clock().
6) The code above still sees 0 in t0 so it tries to update t0 again and
   _gettimeofday(&t0, 0) puts 1 in t0.tv_usec.
7) The _gettimeofday(&t, 0) puts 1 in t.tv_usec (since less than 1us has
   elapsed since step 3).
8) clock() returns 0 (step 7 minus step 6) and indicates that time is
   moving backwards.

Signed-off-by: Christoph Muellner <cmuellner@gcc.gnu.org>
2021-08-04 11:44:33 +02:00
..
machine RISC-V: Using SYS_clock_gettime64 for rv32 libgloss. 2021-04-13 12:54:49 +02:00
Makefile.in RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
aclocal.m4 Add RISC-V port for libgloss 2017-08-17 14:51:05 -04:00
configure Add RISC-V port for libgloss 2017-08-17 14:51:05 -04:00
configure.in Add RISC-V port for libgloss 2017-08-17 14:51:05 -04:00
crt0.S RISC-V: Use __bss_start for the starting point of .bss. 2021-02-05 10:29:21 +01:00
internal_syscall.h Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
kernel_stat.h RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
nano.specs RISC-V: Use newlib nano specific libm. 2020-01-31 12:42:52 +01:00
nanosleep.c RISC-V: Add nanosleep functionality 2017-12-26 12:24:45 -08:00
semihost-sys_close.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_exit.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_fdtable.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_fstat.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_ftime.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_isatty.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_link.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_lseek.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_open.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_read.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_sbrk.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_stat.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_stat_common.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_unlink.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost-sys_write.c RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost.specs RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost_fdtable.h RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost_stat.h RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
semihost_syscall.h RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
sim.specs RISC-V: Add gdb sim and newlib nano support. Fix a few misc minor bugs. 2017-12-26 12:31:33 -08:00
sys_access.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_chdir.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_chmod.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_chown.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_close.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_conv_stat.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_execve.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_exit.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_faccessat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_fork.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_fstat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_fstatat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_ftime.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_getcwd.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_getpid.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_gettimeofday.c RISC-V: Using SYS_clock_gettime64 for rv32 libgloss. 2021-04-13 12:54:49 +02:00
sys_isatty.c RISC-V: isatty: return 0 on error 2018-01-18 09:21:10 +01:00
sys_kill.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_link.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_lseek.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_lstat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_open.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_openat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_read.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_sbrk.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_stat.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_sysconf.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_times.c RISC-V: Reliably initialize t0 in _times() 2021-08-04 11:44:33 +02:00
sys_unlink.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00
sys_utime.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_wait.c RISC-V: Moved syscalls to separate files to fix aliasing problems. 2017-12-26 12:27:52 -08:00
sys_write.c Only pass the minimum number of syscall arguments 2020-02-11 09:41:52 +01:00