Rework time functions a bit

- mktime: Work unsigned as time_t's type implies (shifting Y2K38 bug to 2106)
- mktime: Add unit tests
- gmtime/localtime: factorize
- gmtime/localtime: Add unit tests
- mktime/gmtime/localtime: Size optimisation (-130 bytes wrt master)
- mktime: Speed optimisation (from 23M cycles on the unit test to 2M)
This commit is contained in:
Colin Leroy-Mira
2024-01-07 22:58:45 +01:00
parent 29801a2fde
commit df193c0947
9 changed files with 268 additions and 106 deletions

20
libsrc/common/gmtime.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Colin Leroy-Mira, 2024
;
; struct tm* __fastcall__ gmtime (const time_t* timep);
;
.export _gmtime
.import __time_t_to_tm
.import ldeaxi
_gmtime:
cpx #$00 ; Check for null pointer
bne :+
cmp #$00
beq no_pointer
: jsr ldeaxi ; Load value from pointer
jmp __time_t_to_tm ; Convert it
no_pointer:
rts ; A/X already set