History log of /openbsd-current/lib/libc/gen/times.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.10 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.9 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 02-Mar-2018 cheloha

Return monotonically increasing values.

The latest POSIX description of times(3) (and all others I can find)
suggests that times(3) should return monotonically increasing values
and that these values are only useful for real time interval measurement.
All extant uses of times(3) confirm that this expectation is shared by
application programmers.

So, change gettimeofday(2) to clock_gettime(2)/CLOCK_MONOTONIC to ensure
the return value increases monotonically, even if the system clock is
changed by the superuser. Then update the manpage accordingly.

While we're updating the manpage, move the information about the return
values to a new RETURN VALUES section to bring times.3 up to speed with
other library man pages.

Manpage changes kicked around on tech@ with millert@ and jmc@.

times.3 ok millert@ tb@ jmc@
times.c ok millert@ tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.7 02-Nov-2015 mmcc

(struct timezone *)0 -> NULL


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 16-Jan-2015 deraadt

Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.5 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.4 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.3 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.9 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 02-Mar-2018 cheloha

Return monotonically increasing values.

The latest POSIX description of times(3) (and all others I can find)
suggests that times(3) should return monotonically increasing values
and that these values are only useful for real time interval measurement.
All extant uses of times(3) confirm that this expectation is shared by
application programmers.

So, change gettimeofday(2) to clock_gettime(2)/CLOCK_MONOTONIC to ensure
the return value increases monotonically, even if the system clock is
changed by the superuser. Then update the manpage accordingly.

While we're updating the manpage, move the information about the return
values to a new RETURN VALUES section to bring times.3 up to speed with
other library man pages.

Manpage changes kicked around on tech@ with millert@ and jmc@.

times.3 ok millert@ tb@ jmc@
times.c ok millert@ tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.7 02-Nov-2015 mmcc

(struct timezone *)0 -> NULL


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 16-Jan-2015 deraadt

Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.5 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.4 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.3 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.8 02-Mar-2018 cheloha

Return monotonically increasing values.

The latest POSIX description of times(3) (and all others I can find)
suggests that times(3) should return monotonically increasing values
and that these values are only useful for real time interval measurement.
All extant uses of times(3) confirm that this expectation is shared by
application programmers.

So, change gettimeofday(2) to clock_gettime(2)/CLOCK_MONOTONIC to ensure
the return value increases monotonically, even if the system clock is
changed by the superuser. Then update the manpage accordingly.

While we're updating the manpage, move the information about the return
values to a new RETURN VALUES section to bring times.3 up to speed with
other library man pages.

Manpage changes kicked around on tech@ with millert@ and jmc@.

times.3 ok millert@ tb@ jmc@
times.c ok millert@ tb@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.7 02-Nov-2015 mmcc

(struct timezone *)0 -> NULL


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 16-Jan-2015 deraadt

Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.5 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.4 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.3 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.7 02-Nov-2015 mmcc

(struct timezone *)0 -> NULL


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 16-Jan-2015 deraadt

Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.5 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.4 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.3 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision