From df3c43bedea8d5384a8e1c28fa1dd78ee5aaa6cd Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Thu, 27 Sep 2018 20:22:21 +0200 Subject: [PATCH] Atari: implement clock_getres() --- libsrc/apple2/getres.s | 2 +- libsrc/atari/getres.s | 51 ++++++++++++++++++++++++++++++++++++++++++ libsrc/cbm/getres.s | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 libsrc/atari/getres.s diff --git a/libsrc/apple2/getres.s b/libsrc/apple2/getres.s index 777a5df3f..6441671cc 100644 --- a/libsrc/apple2/getres.s +++ b/libsrc/apple2/getres.s @@ -1,7 +1,7 @@ ; ; Oliver Schmidt, 15.08.2018 ; -; int clock_getres (clockid_t clk_id, struct timespec *res); +; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res); ; .import __dos_type diff --git a/libsrc/atari/getres.s b/libsrc/atari/getres.s new file mode 100644 index 000000000..f2e4874f9 --- /dev/null +++ b/libsrc/atari/getres.s @@ -0,0 +1,51 @@ +; +; Oliver Schmidt, 15.8.2018 +; Christian Groessler, 27.9.2018 +; +; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res); +; + + .include "atari.inc" + .include "time.inc" + .include "errno.inc" + + .importzp ptr1 + .import incsp1, return0, __dos_type + +;---------------------------------------------------------------------------- +.code + +_clock_getres: + sta ptr1 + stx ptr1+1 + + ; Cleanup stack + jsr incsp1 + + ; Check for SpartaDOS-X 4.40 or newer + ldy #SPARTADOS + cpy __dos_type + bne enosys + ldy SDX_VERSION + cpy #$44 + bcc enosys + + ldy #.sizeof(timespec)-1 +@L1: lda time,y + sta (ptr1),y + dey + bpl @L1 + + jmp return0 + +enosys: lda #ENOSYS + + ; Set __errno + jmp __directerrno + +;---------------------------------------------------------------------------- +; timespec struct with tv_sec set to 1 second +.rodata + +time: .dword 1 + .dword 0 diff --git a/libsrc/cbm/getres.s b/libsrc/cbm/getres.s index d216a1b6a..998bac9f6 100644 --- a/libsrc/cbm/getres.s +++ b/libsrc/cbm/getres.s @@ -1,7 +1,7 @@ ; ; Oliver Schmidt, 15.8.2018 ; -; int clock_getres (clockid_t clk_id, struct timespec *res); +; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res); ; .include "time.inc" -- 2.39.5