]> git.sur5r.net Git - cc65/blob - libsrc/atari/getres.s
Atari: implement clock_getres()
[cc65] / libsrc / atari / getres.s
1 ;
2 ; Oliver Schmidt, 15.8.2018
3 ; Christian Groessler, 27.9.2018
4 ;
5 ; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res);
6 ;
7
8         .include        "atari.inc"
9         .include        "time.inc"
10         .include        "errno.inc"
11
12         .importzp       ptr1
13         .import         incsp1, return0, __dos_type
14
15 ;----------------------------------------------------------------------------
16 .code
17
18 _clock_getres:
19         sta     ptr1
20         stx     ptr1+1
21
22         ; Cleanup stack
23         jsr     incsp1
24
25         ; Check for SpartaDOS-X 4.40 or newer
26         ldy     #SPARTADOS
27         cpy     __dos_type
28         bne     enosys
29         ldy     SDX_VERSION
30         cpy     #$44
31         bcc     enosys
32
33         ldy     #.sizeof(timespec)-1
34 @L1:    lda     time,y
35         sta     (ptr1),y
36         dey
37         bpl     @L1
38
39         jmp     return0
40
41 enosys: lda     #ENOSYS
42
43         ; Set __errno
44         jmp     __directerrno
45
46 ;----------------------------------------------------------------------------
47 ; timespec struct with tv_sec set to 1 second
48 .rodata
49
50 time:   .dword  1
51         .dword  0