]> git.sur5r.net Git - cc65/commit
Replaced _systime with clock_gettime.
authorOliver Schmidt <ol.sc@web.de>
Wed, 15 Aug 2018 13:59:11 +0000 (15:59 +0200)
committerOliver Schmidt <ol.sc@web.de>
Wed, 15 Aug 2018 14:06:44 +0000 (16:06 +0200)
commit842c151edd04385901220c5506ecf8c7f9060c26
tree5392a8ff553af01c155d53480f65fa8e8ad8abf7
parent55a07c1dcde6920b36688263aa3eddfbb7a0ebdd
Replaced _systime with clock_gettime.

We want to add the capability to not only get the time but also set the time, but there's no "setter" for the "getter" time().

The first ones that come into mind are gettimeofday() and settimeofday(). However, they take a struct timezone argument that doesn't make sense - even the man pages says "The use of the timezone structure is obsolete; the tz argument should normally be specified as NULL." And POSIX says "Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function."

The ...timeofday() functions work with microseconds while the clock_...time() functions work with nanoseconds. Given that we expect our targets to support only 1/10 of seconds the microseconds look preferable at first sight. However, already microseconds require the cc65 data type 'long' so it's not such a relevant difference to nanoseconds. Additionally clock_getres() seems useful.

In order to avoid code duplication clock_gettime() takes over the role of the actual time getter from _systime(). So time() now calls clock_gettime() instead of _systime().

For some reason beyond my understanding _systime() was mentioned in time.h. _systime() worked exactly like e.g. _sysremove() and those _sys...() functions are all considered internal. The only reason I could see would be a performance gain of bypassing the time() wrapper. However, all known _systime() implementations internally called mktime(). And mktime() is implemented in C using an iterative algorithm so I really can't see what would be left to gain here. From that perspective I decided to just remove _systime().
20 files changed:
asminc/time.inc
doc/funcref.sgml
include/time.h
libsrc/apple2/gettime.s [new file with mode: 0644]
libsrc/apple2/systime.s [deleted file]
libsrc/atari/systime.s [deleted file]
libsrc/atmos/systime.s [deleted file]
libsrc/c128/gettime.s [new file with mode: 0644]
libsrc/c128/systime.s [deleted file]
libsrc/c16/systime.s [deleted file]
libsrc/c64/gettime.s [new file with mode: 0644]
libsrc/c64/systime.s [deleted file]
libsrc/cbm510/gettime.s [new file with mode: 0644]
libsrc/cbm510/systime.s [deleted file]
libsrc/cbm610/gettime.s [new file with mode: 0644]
libsrc/cbm610/systime.s [deleted file]
libsrc/common/time.s
libsrc/geos-common/system/gettime.c [new file with mode: 0644]
libsrc/geos-common/system/systime.c [deleted file]
libsrc/plus4/systime.s [deleted file]