From 8e5f6b822d7b5ff3a0d4b601188ebaa68399a4dc Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 20:05:11 +0200 Subject: [PATCH 01/14] fix setjmp.h --- include/setjmp.h | 4 ++-- libsrc/common/setjmp.s | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/setjmp.h b/include/setjmp.h index 460829e38..5fac25634 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -42,8 +42,8 @@ typedef char jmp_buf [5]; -int __fastcall__ _setjmp (jmp_buf buf); -#define setjmp _setjmp /* ISO insists on a macro */ +int __fastcall__ __setjmp (jmp_buf buf); +#define setjmp __setjmp /* ISO insists on a macro */ void __fastcall__ longjmp (jmp_buf buf, int retval) __attribute__((noreturn)); diff --git a/libsrc/common/setjmp.s b/libsrc/common/setjmp.s index a763ac3ec..886853368 100644 --- a/libsrc/common/setjmp.s +++ b/libsrc/common/setjmp.s @@ -2,15 +2,15 @@ ; 1998-06-06, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; int __fastcall__ setjmp (jmp_buf buf); +; int __fastcall__ __setjmp (jmp_buf buf); ; - .export __setjmp + .export ___setjmp .import return0 .importzp sp, ptr1 -__setjmp: +___setjmp: sta ptr1 ; Save buf stx ptr1+1 ldy #0 From 9246775ebee5aa5790d09883cb6b52277df24e6e Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 20:08:13 +0200 Subject: [PATCH 02/14] use __afailed instead of _afailed --- include/assert.h | 4 ++-- libsrc/common/_afailed.c | 2 +- libsrc/geos-common/common/_afailed.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/assert.h b/include/assert.h index a4dcd5d7f..ca8d4acc1 100644 --- a/include/assert.h +++ b/include/assert.h @@ -42,8 +42,8 @@ #ifdef NDEBUG # define assert(expr) #else -extern void __fastcall__ _afailed (const char*, unsigned); -# define assert(expr) ((expr)? (void)0 : _afailed(__FILE__, __LINE__)) +extern void __fastcall__ __afailed (const char*, unsigned); +# define assert(expr) ((expr)? (void)0 : __afailed(__FILE__, __LINE__)) #endif /* TODO: Guard with #if __CC65_STD__ >= __CC65_STD_C11__ if there diff --git a/libsrc/common/_afailed.c b/libsrc/common/_afailed.c index ab8b94ca6..01e8d5397 100644 --- a/libsrc/common/_afailed.c +++ b/libsrc/common/_afailed.c @@ -12,7 +12,7 @@ #include -void __fastcall__ _afailed (char* file, unsigned line) +void __fastcall__ __afailed (char* file, unsigned line) { raise (SIGABRT); fprintf (stderr, "ASSERTION FAILED IN %s:%u\n", file, line); diff --git a/libsrc/geos-common/common/_afailed.c b/libsrc/geos-common/common/_afailed.c index 97727d605..acc437fb0 100644 --- a/libsrc/geos-common/common/_afailed.c +++ b/libsrc/geos-common/common/_afailed.c @@ -8,7 +8,7 @@ #include #include -void _afailed (char* file, unsigned line) +void __afailed (char* file, unsigned line) { ExitTurbo(); From f70020a2b8b5bf03ddad690191a02eab4697d758 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 20:18:34 +0200 Subject: [PATCH 03/14] use __sig_ign and __sig_dft instead of _sig_ign and _sig_dft --- asminc/signal.inc | 4 ++-- include/signal.h | 8 ++++---- libsrc/common/raise.s | 4 ++-- libsrc/common/signal.s | 4 ++-- libsrc/common/sigtable.s | 12 ++++++------ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/asminc/signal.inc b/asminc/signal.inc index ebde07e42..597cad413 100644 --- a/asminc/signal.inc +++ b/asminc/signal.inc @@ -49,8 +49,8 @@ SIGCOUNT = 6 ; Number of signals .global sigtable ; Function declarations -.global __sig_ign -.global __sig_dfl +.global ___sig_ign +.global ___sig_dfl .global _signal .global _raise diff --git a/include/signal.h b/include/signal.h index 0d5f6ad09..d67cebf7c 100644 --- a/include/signal.h +++ b/include/signal.h @@ -45,12 +45,12 @@ typedef unsigned char sig_atomic_t; typedef void __fastcall__ (*__sigfunc) (int); /* Functions that implement SIG_IGN and SIG_DFL */ -void __fastcall__ _sig_ign (int); -void __fastcall__ _sig_dfl (int); +void __fastcall__ __sig_ign (int); +void __fastcall__ __sig_dfl (int); /* Standard signal handling functions */ -#define SIG_DFL _sig_dfl -#define SIG_IGN _sig_ign +#define SIG_DFL __sig_dfl +#define SIG_IGN __sig_ign #define SIG_ERR ((__sigfunc) 0x0000) /* Signal numbers */ diff --git a/libsrc/common/raise.s b/libsrc/common/raise.s index 07898ef90..205bbd471 100644 --- a/libsrc/common/raise.s +++ b/libsrc/common/raise.s @@ -33,9 +33,9 @@ _raise: ; introduce race conditions, but it's the simplest way to satisfy the ; standard). - lda #<__sig_dfl + lda #<___sig_dfl sta sigtable,x - lda #>__sig_dfl + lda #>___sig_dfl sta sigtable+1,x ; Restore the signal number and call the function diff --git a/libsrc/common/signal.s b/libsrc/common/signal.s index 333072801..40262c457 100644 --- a/libsrc/common/signal.s +++ b/libsrc/common/signal.s @@ -54,7 +54,7 @@ _signal: pla tax pla -__sig_ign: +___sig_ign: rts ; Error entry: We use our knowledge that SIG_ERR is zero here to save a byte @@ -63,6 +63,6 @@ invalidsig: lda # Date: Sun, 28 Aug 2022 20:22:25 +0200 Subject: [PATCH 04/14] use __clocks_per_sec instead of _clocks_per_sec --- include/time.h | 4 ++-- libsrc/atari/clock.s | 6 +++--- libsrc/atari7800/clocks_per_sec.s | 6 +++--- libsrc/lynx/clock.s | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/time.h b/include/time.h index 99bb1c8e3..642d68c4e 100644 --- a/include/time.h +++ b/include/time.h @@ -89,8 +89,8 @@ struct tm { # define CLOCKS_PER_SEC 10 #elif defined(__ATARI__) || defined (__LYNX__) /* Read the clock rate at runtime */ -clock_t _clocks_per_sec (void); -# define CLOCKS_PER_SEC _clocks_per_sec() +clock_t __clocks_per_sec (void); +# define CLOCKS_PER_SEC __clocks_per_sec() #endif #define CLOCK_REALTIME 0 diff --git a/libsrc/atari/clock.s b/libsrc/atari/clock.s index 853870520..42809c4a4 100644 --- a/libsrc/atari/clock.s +++ b/libsrc/atari/clock.s @@ -3,10 +3,10 @@ ; originally by Ullrich von Bassewitz and Sidney Cadot ; ; clock_t clock (void); -; clock_t _clocks_per_sec (void); +; clock_t __clocks_per_sec (void); ; - .export _clock, __clocks_per_sec + .export _clock, ___clocks_per_sec .importzp sreg .include "atari.inc" @@ -28,7 +28,7 @@ .endproc -.proc __clocks_per_sec +.proc ___clocks_per_sec ldx #$00 ; Clear byte 1 of return value stx sreg ; Clear byte 2 of return value diff --git a/libsrc/atari7800/clocks_per_sec.s b/libsrc/atari7800/clocks_per_sec.s index e2c7d9d8d..d9179448f 100644 --- a/libsrc/atari7800/clocks_per_sec.s +++ b/libsrc/atari7800/clocks_per_sec.s @@ -1,10 +1,10 @@ ; ; 2022-03-15, Karri Kaksonen ; -; clock_t _clocks_per_sec (void); +; clock_t __clocks_per_sec (void); ; - .export __clocks_per_sec + .export ___clocks_per_sec .import sreg: zp .import _paldetected @@ -17,7 +17,7 @@ ;----------------------------------------------------------------------------- ; Return the number of clock ticks in one second. ; - .proc __clocks_per_sec + .proc ___clocks_per_sec lda #0 tax diff --git a/libsrc/lynx/clock.s b/libsrc/lynx/clock.s index e29799df6..d881e5a67 100644 --- a/libsrc/lynx/clock.s +++ b/libsrc/lynx/clock.s @@ -3,13 +3,13 @@ ; 2012-02-06, Greg King ; ; clock_t clock (void); -; clock_t _clocks_per_sec (void); +; clock_t __clocks_per_sec (void); ; ; clocks_per_sec()'s test-values are based on the numbers in "set_tv.s". ; If you change the numbers there, then change them here, too. ; - .export _clock, __clocks_per_sec, clock_count + .export _clock, ___clocks_per_sec, clock_count .interruptor update_clock, 2 ; (low priority) .constructor init_clock @@ -38,7 +38,7 @@ ;----------------------------------------------------------------------------- ; Return the number of clock ticks in one second. ; -__clocks_per_sec: +___clocks_per_sec: ldx #$00 ; >50, >60, >75 ldy PBKUP lda #<75 From 5d390489a8f754abfd032af858b6ed5686553187 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 21:36:22 +0200 Subject: [PATCH 05/14] fix underscores in errno (and related) headers --- asminc/errno.inc | 8 ++++---- include/cbm.h | 8 ++++---- include/dio.h | 6 +++--- include/errno.h | 30 ++++++++++++++++++++---------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/asminc/errno.inc b/asminc/errno.inc index 1efe88cda..2e876c7ac 100644 --- a/asminc/errno.inc +++ b/asminc/errno.inc @@ -4,10 +4,10 @@ ; Variables and functions - .global __errno, __oserror - .global __osmaperrno - .global __seterrno - .global __directerrno, __mappederrno + .global ___errno, ___oserror + .global ___osmaperrno + .global ___seterrno + .global ___directerrno, ___mappederrno ; Error codes, must match the values in the C headers .enum diff --git a/include/cbm.h b/include/cbm.h index cceb76b1b..0679b2d65 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -225,7 +225,7 @@ void cbm_k_untlk (void); -/* The cbm_* I/O functions below set _oserror (see errno.h), +/* The cbm_* I/O functions below set __oserror (see errno.h), ** in case of an error. ** ** error-code BASIC error @@ -251,7 +251,7 @@ unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void ** address of the file if "data" is the null pointer (like load"name",8,1 ** in BASIC). ** Returns number of bytes that were loaded if loading was successful; -** otherwise 0, "_oserror" contains an error-code, then (see table above). +** otherwise 0, "__oserror" contains an error-code, then (see table above). */ unsigned char __fastcall__ cbm_save (const char* name, unsigned char device, @@ -274,7 +274,7 @@ void __fastcall__ cbm_close (unsigned char lfn); int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size); /* Reads up to "size" bytes from a file into "buffer". ** Returns the number of actually-read bytes, 0 if there are no bytes left. -** -1 in case of an error; then, _oserror contains an error-code (see table +** -1 in case of an error; then, __oserror contains an error-code (see table ** above). (Remember: 0 means end-of-file; -1 means error.) */ @@ -282,7 +282,7 @@ int __fastcall__ cbm_write (unsigned char lfn, const void* buffer, unsigned int size); /* Writes up to "size" bytes from "buffer" to a file. ** Returns the number of actually-written bytes, or -1 in case of an error; -** _oserror contains an error-code, then (see above table). +** __oserror contains an error-code, then (see above table). */ unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...); diff --git a/include/dio.h b/include/dio.h index 4201728cc..2521a90ff 100644 --- a/include/dio.h +++ b/include/dio.h @@ -35,9 +35,9 @@ -/* Please note: All functions in this file will set _oserror *and* return its -** value. The only exception is dio_open, which will return NULL, but _oserror -** will be set. All function will also set _oserror in case of successful +/* Please note: All functions in this file will set __oserror *and* return its +** value. The only exception is dio_open, which will return NULL, but __oserror +** will be set. All function will also set __oserror in case of successful ** execution, effectively clearing it. */ diff --git a/include/errno.h b/include/errno.h index 92d304938..c762e8b1c 100644 --- a/include/errno.h +++ b/include/errno.h @@ -45,12 +45,17 @@ /* Operating system specific error code */ -extern unsigned char _oserror; +extern unsigned char __oserror; -extern int _errno; +#if __CC65_STD__ >= __CC65_STD_CC65__ +/* define the name with just one underscore for backwards compatibility */ +#define _oserror __oserror +#endif + +extern int __errno; /* System errors go here */ -#define errno _errno +#define errno __errno /* errno must be a macro */ @@ -83,21 +88,26 @@ extern int _errno; -int __fastcall__ _osmaperrno (unsigned char oserror); -/* Map an operating system specific error code (for example from _oserror) +int __fastcall__ __osmaperrno (unsigned char oserror); +/* Map an operating system specific error code (for example from __oserror) ** into one of the E... codes above. It is user callable. */ -unsigned char __fastcall__ _seterrno (unsigned char code); +#if __CC65_STD__ >= __CC65_STD_CC65__ +/* define the name with just one underscore for backwards compatibility */ +#define _osmaperrno __osmaperrno +#endif + +unsigned char __fastcall__ __seterrno (unsigned char code); /* Set errno to a specific error code and return zero. Used by the library */ -int __fastcall__ _directerrno (unsigned char code); -/* Set errno to a specific error code, clear _oserror and return -1. Used +int __fastcall__ __directerrno (unsigned char code); +/* Set errno to a specific error code, clear __oserror and return -1. Used ** by the library. */ -int __fastcall__ _mappederrno (unsigned char code); -/* Set _oserror to the given platform specific error code. If it is a real +int __fastcall__ __mappederrno (unsigned char code); +/* Set __oserror to the given platform specific error code. If it is a real ** error code (not zero) set errno to the corresponding system error code ** and return -1. Otherwise return zero. ** Used by the library. From 2dabb65ee06cc9875b367dc0cf89f858acee3e59 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 21:52:53 +0200 Subject: [PATCH 06/14] fix errno related underscores in all libsrc/*.s files --- libsrc/apple2/close.s | 6 +++--- libsrc/apple2/devicedir.s | 6 +++--- libsrc/apple2/diocommon.s | 2 +- libsrc/apple2/dioopen.s | 4 ++-- libsrc/apple2/diosectcount.s | 6 +++--- libsrc/apple2/diosectsize.s | 2 +- libsrc/apple2/exec.s | 4 ++-- libsrc/apple2/getres.s | 2 +- libsrc/apple2/gettime.s | 6 +++--- libsrc/apple2/lseek.s | 6 +++--- libsrc/apple2/open.s | 8 ++++---- libsrc/apple2/oserror.s | 6 +++--- libsrc/apple2/read.s | 4 ++-- libsrc/apple2/rwcommon.s | 6 +++--- libsrc/apple2/settime.s | 2 +- libsrc/apple2/write.s | 6 +++--- libsrc/atari/close.s | 4 ++-- libsrc/atari/dio_cts.s | 4 ++-- libsrc/atari/dio_stc.s | 4 ++-- libsrc/atari/diopncls.s | 8 ++++---- libsrc/atari/dioqsize.s | 4 ++-- libsrc/atari/do_oserr.s | 4 ++-- libsrc/atari/exec.s | 4 ++-- libsrc/atari/getres.s | 2 +- libsrc/atari/gettime.s | 2 +- libsrc/atari/graphics.s | 8 ++++---- libsrc/atari/inviocb.s | 2 +- libsrc/atari/lseek.s | 6 +++--- libsrc/atari/open.s | 8 ++++---- libsrc/atari/oserror.s | 6 +++--- libsrc/atari/posixdirent.s | 8 ++++---- libsrc/atari/read.s | 4 ++-- libsrc/atari/settime.s | 2 +- libsrc/atari/siocall.s | 4 ++-- libsrc/atari/write.s | 4 ++-- libsrc/atmos/oserror.s | 6 +++--- libsrc/cbm/c_load.s | 4 ++-- libsrc/cbm/cbm_open.s | 6 +++--- libsrc/cbm/cbm_read.s | 8 ++++---- libsrc/cbm/cbm_write.s | 8 ++++---- libsrc/cbm/close.s | 4 ++-- libsrc/cbm/devicedir.s | 6 +++--- libsrc/cbm/open.s | 8 ++++---- libsrc/cbm/oserror.s | 4 ++-- libsrc/cbm/read.s | 8 ++++---- libsrc/cbm/write.s | 8 ++++---- libsrc/common/_directerrno.s | 10 ++++----- libsrc/common/_fopen.s | 4 ++-- libsrc/common/_mappederrno.s | 12 +++++------ libsrc/common/_oserror.s | 6 +++--- libsrc/common/_seterrno.s | 4 ++-- libsrc/common/atexit.s | 2 +- libsrc/common/chdir.s | 4 ++-- libsrc/common/fclose.s | 2 +- libsrc/common/fmisc.s | 2 +- libsrc/common/fopen.s | 2 +- libsrc/common/fread.s | 2 +- libsrc/common/fwrite.s | 2 +- libsrc/common/getcwd.s | 2 +- libsrc/common/mkdir.s | 4 ++-- libsrc/common/putenv.s | 2 +- libsrc/common/remove.s | 4 ++-- libsrc/common/rename.s | 4 ++-- libsrc/common/rmdir.s | 4 ++-- libsrc/common/signal.s | 2 +- libsrc/common/uname.s | 4 ++-- libsrc/common/ungetc.s | 2 +- libsrc/common/vsnprintf.s | 2 +- libsrc/geos-cbm/disk/dio_cts.s | 4 ++-- libsrc/geos-cbm/disk/dio_openclose.s | 6 +++--- libsrc/geos-cbm/disk/dio_qcount.s | 4 ++-- libsrc/geos-cbm/disk/dio_qsize.s | 4 ++-- libsrc/geos-cbm/disk/dio_read.s | 4 ++-- libsrc/geos-cbm/disk/dio_stc.s | 4 ++-- libsrc/geos-cbm/disk/dio_writev.s | 4 ++-- libsrc/geos-common/disk/calcblksfree.s | 4 ++-- libsrc/geos-common/disk/getptrcurdknm.s | 4 ++-- libsrc/geos-common/disk/setnextfree.s | 4 ++-- libsrc/geos-common/drivers/fio_module.s | 26 ++++++++++++------------ libsrc/geos-common/file/get1stdirentry.s | 4 ++-- libsrc/geos-common/file/getnxtdirentry.s | 4 ++-- libsrc/geos-common/file/readbyte.s | 4 ++-- libsrc/geos-common/system/oserror.s | 6 +++--- libsrc/geos-common/system/setoserror.s | 4 ++-- libsrc/lynx/open.s | 4 ++-- libsrc/lynx/oserror.s | 4 ++-- libsrc/osic1p/oserror.s | 6 +++--- libsrc/telestrat/oserror.s | 6 +++--- 88 files changed, 213 insertions(+), 213 deletions(-) diff --git a/libsrc/apple2/close.s b/libsrc/apple2/close.s index cef42b6f8..0002d081d 100644 --- a/libsrc/apple2/close.s +++ b/libsrc/apple2/close.s @@ -33,8 +33,8 @@ zerofd: lda #$00 ; Return success lda #$00 - ; Set __oserror -oserr: jmp __mappederrno + ; Set ___oserror +oserr: jmp ___mappederrno ; Set __errno -errno: jmp __directerrno +errno: jmp ___directerrno diff --git a/libsrc/apple2/devicedir.s b/libsrc/apple2/devicedir.s index 79f4c60de..abe900be1 100644 --- a/libsrc/apple2/devicedir.s +++ b/libsrc/apple2/devicedir.s @@ -45,9 +45,9 @@ _getdevicedir: ; Handle errors erange: lda #buf sta ICBAH,x ; set buffer address diff --git a/libsrc/atari/getres.s b/libsrc/atari/getres.s index f2e4874f9..9716040d8 100644 --- a/libsrc/atari/getres.s +++ b/libsrc/atari/getres.s @@ -41,7 +41,7 @@ _clock_getres: enosys: lda #ENOSYS ; Set __errno - jmp __directerrno + jmp ___directerrno ;---------------------------------------------------------------------------- ; timespec struct with tv_sec set to 1 second diff --git a/libsrc/atari/gettime.s b/libsrc/atari/gettime.s index 093d34843..df6e24021 100644 --- a/libsrc/atari/gettime.s +++ b/libsrc/atari/gettime.s @@ -105,7 +105,7 @@ errexit:jsr incsp3 ; Preserves A ; set __errno - jmp __directerrno + jmp ___directerrno ; ------- diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s index ab26ed0da..f35087aea 100644 --- a/libsrc/atari/graphics.s +++ b/libsrc/atari/graphics.s @@ -10,7 +10,7 @@ .export __graphics .import findfreeiocb - .import __oserror + .import ___oserror .import fddecusage .import clriocb .import fdtoiocb @@ -45,7 +45,7 @@ parmok: jsr findfreeiocb beq iocbok ; we found one lda #EINVAL @@ -94,7 +94,7 @@ doopen: txa lda tmp2 ; get fd ldx #0 - stx __oserror + stx ___oserror rts cioerr: sty tmp3 ; remember error code @@ -103,6 +103,6 @@ cioerr: sty tmp3 ; remember error code jsr CIOV ; close IOCB again since open failed jsr fddecusage ; and decrement usage counter of fd lda tmp3 ; put error code into A - jmp __mappederrno + jmp ___mappederrno .endproc ; __graphics diff --git a/libsrc/atari/inviocb.s b/libsrc/atari/inviocb.s index c1c27ee03..2ceb385b1 100644 --- a/libsrc/atari/inviocb.s +++ b/libsrc/atari/inviocb.s @@ -7,4 +7,4 @@ __inviocb: lda #EUNKNOWN diff --git a/libsrc/cbm/c_load.s b/libsrc/cbm/c_load.s index d81430a03..7f2a054bd 100644 --- a/libsrc/cbm/c_load.s +++ b/libsrc/cbm/c_load.s @@ -7,7 +7,7 @@ .include "cbm.inc" .export _cbm_k_load - .import __oserror + .import ___oserror .import popa .importzp ptr1 @@ -19,7 +19,7 @@ _cbm_k_load: ldy ptr1+1 jsr LOAD bcc @Ok - sta __oserror + sta ___oserror ldx ptr1 ldy ptr1+1 @Ok: txa diff --git a/libsrc/cbm/cbm_open.s b/libsrc/cbm/cbm_open.s index db4179db8..c7590af2a 100644 --- a/libsrc/cbm/cbm_open.s +++ b/libsrc/cbm/cbm_open.s @@ -15,7 +15,7 @@ ; { ; cbm_k_setlfs(lfn, device, sec_addr); ; cbm_k_setnam(name); -; return _oserror = cbm_k_open(); +; return __oserror = cbm_k_open(); ; } ; @@ -23,7 +23,7 @@ .import popa .import _cbm_k_setlfs, _cbm_k_setnam, _cbm_k_open - .import __oserror + .import ___oserror _cbm_open: jsr _cbm_k_setnam @@ -32,5 +32,5 @@ _cbm_open: jsr _cbm_k_setlfs ; Call SETLFS, pop all args jsr _cbm_k_open - sta __oserror + sta ___oserror rts diff --git a/libsrc/cbm/cbm_read.s b/libsrc/cbm/cbm_read.s index 29e0e1f19..8a9939eca 100644 --- a/libsrc/cbm/cbm_read.s +++ b/libsrc/cbm/cbm_read.s @@ -6,7 +6,7 @@ ; int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size) ; /* Reads up to "size" bytes from a file to "buffer". ; ** Returns the number of actually read bytes, 0 if there are no bytes left -; ** (EOF) or -1 in case of an error. _oserror contains an errorcode then (see +; ** (EOF) or -1 in case of an error. __oserror contains an errorcode then (see ; ** table below). ; */ ; { @@ -14,7 +14,7 @@ ; static unsigned char tmp; ; ; /* if we can't change to the inputchannel #lfn then return an error */ -; if (_oserror = cbm_k_chkin(lfn)) return -1; +; if (__oserror = cbm_k_chkin(lfn)) return -1; ; ; bytesread = 0; ; @@ -41,7 +41,7 @@ .export _cbm_read .importzp ptr1, ptr2, ptr3, tmp1 .import popax, popa - .import __oserror + .import ___oserror _cbm_read: @@ -106,7 +106,7 @@ _cbm_read: ; CHKIN failed -@E1: sta __oserror +@E1: sta ___oserror lda #$FF tax rts ; return -1 diff --git a/libsrc/cbm/cbm_write.s b/libsrc/cbm/cbm_write.s index 5ac07209c..18c6f4684 100644 --- a/libsrc/cbm/cbm_write.s +++ b/libsrc/cbm/cbm_write.s @@ -9,7 +9,7 @@ ; static unsigned int byteswritten; ; ; /* if we can't change to the outputchannel #lfn then return an error */ -; if (_oserror = cbm_k_ckout(lfn)) return -1; +; if (__oserror = cbm_k_ckout(lfn)) return -1; ; ; byteswritten = 0; ; @@ -18,7 +18,7 @@ ; } ; ; if (cbm_k_readst()) { -; _oserror = 5; /* device not present */ +; __oserror = 5; /* device not present */ ; byteswritten = -1; ; } ; @@ -33,7 +33,7 @@ .export _cbm_write .importzp ptr1, ptr2, ptr3 .import popax, popa - .import __oserror + .import ___oserror _cbm_write: @@ -87,7 +87,7 @@ _cbm_write: ; Error entry, error code is in A -@E2: sta __oserror +@E2: sta ___oserror lda #$FF tax rts ; return -1 diff --git a/libsrc/cbm/close.s b/libsrc/cbm/close.s index 7fc600e87..0cd425cf4 100644 --- a/libsrc/cbm/close.s +++ b/libsrc/cbm/close.s @@ -54,12 +54,12 @@ ldx unittab,y jsr closecmdchannel ; Close the disk command channel pla ; Get the error code from the disk - jmp __mappederrno ; Set _oserror and _errno, return 0/-1 + jmp ___mappederrno ; Set __oserror and _errno, return 0/-1 ; Error entry: The given file descriptor is not valid or not open invalidfd: lda #EBADF - jmp __directerrno ; Set _errno, clear _oserror, return -1 + jmp ___directerrno ; Set _errno, clear __oserror, return -1 .endproc diff --git a/libsrc/cbm/devicedir.s b/libsrc/cbm/devicedir.s index 3a4e6d774..25aad556b 100644 --- a/libsrc/cbm/devicedir.s +++ b/libsrc/cbm/devicedir.s @@ -32,7 +32,7 @@ jsr popa jsr diskinit beq size - jsr __mappederrno + jsr ___mappederrno bne fail ; Branch always ; Check for sufficient buf size @@ -43,7 +43,7 @@ size: lda ptr3+1 cmp #3 bcs okay ; Buf >= 3 lda #683 rts diff --git a/libsrc/geos-cbm/disk/dio_qsize.s b/libsrc/geos-cbm/disk/dio_qsize.s index bf9178035..14c8a460a 100644 --- a/libsrc/geos-cbm/disk/dio_qsize.s +++ b/libsrc/geos-cbm/disk/dio_qsize.s @@ -5,10 +5,10 @@ ; .export _dio_query_sectsize - .import __oserror + .import ___oserror _dio_query_sectsize: lda #<256 ldx #>256 - sta __oserror + sta ___oserror rts diff --git a/libsrc/geos-cbm/disk/dio_read.s b/libsrc/geos-cbm/disk/dio_read.s index ac19f9afa..4c9297e65 100644 --- a/libsrc/geos-cbm/disk/dio_read.s +++ b/libsrc/geos-cbm/disk/dio_read.s @@ -8,7 +8,7 @@ ; .export _dio_read - .import dio_params, __oserror + .import dio_params, ___oserror .include "geossym.inc" .include "jumptab.inc" @@ -18,6 +18,6 @@ _dio_read: tay bne err jsr ReadBlock - stx __oserror + stx ___oserror txa err: rts diff --git a/libsrc/geos-cbm/disk/dio_stc.s b/libsrc/geos-cbm/disk/dio_stc.s index 469df93ca..3c3c9108f 100644 --- a/libsrc/geos-cbm/disk/dio_stc.s +++ b/libsrc/geos-cbm/disk/dio_stc.s @@ -9,7 +9,7 @@ .export _dio_log_to_phys .importzp ptr1,ptr2,ptr3,tmp1,tmp2 - .import popax,__oserror + .import popax,___oserror .import sectab_1541_l, sectab_1541_h .include "dio.inc" @@ -78,7 +78,7 @@ dio_stcend: ldx #0 txa _ret: - sta __oserror + sta ___oserror rts ; return success ; errors diff --git a/libsrc/geos-cbm/disk/dio_writev.s b/libsrc/geos-cbm/disk/dio_writev.s index 9b36ed096..962d7e77f 100644 --- a/libsrc/geos-cbm/disk/dio_writev.s +++ b/libsrc/geos-cbm/disk/dio_writev.s @@ -8,7 +8,7 @@ ; .export _dio_write_verify - .import dio_params, __oserror + .import dio_params, ___oserror .include "geossym.inc" .include "jumptab.inc" @@ -18,6 +18,6 @@ _dio_write_verify: tay bne err jsr VerWriteBlock - stx __oserror + stx ___oserror txa err: rts diff --git a/libsrc/geos-common/disk/calcblksfree.s b/libsrc/geos-common/disk/calcblksfree.s index 7e1bb4f52..fec6d6690 100644 --- a/libsrc/geos-common/disk/calcblksfree.s +++ b/libsrc/geos-common/disk/calcblksfree.s @@ -5,7 +5,7 @@ ; int CalcBlksFree (void); - .import __oserror + .import ___oserror .export _CalcBlksFree .include "jumptab.inc" @@ -18,7 +18,7 @@ _CalcBlksFree: sta r5L stx r5H jsr CalcBlksFree - stx __oserror + stx ___oserror lda r4L ldx r4H rts diff --git a/libsrc/geos-common/disk/getptrcurdknm.s b/libsrc/geos-common/disk/getptrcurdknm.s index d92e5d91e..9112c9f99 100644 --- a/libsrc/geos-common/disk/getptrcurdknm.s +++ b/libsrc/geos-common/disk/getptrcurdknm.s @@ -7,7 +7,7 @@ ; (fills curName[17] with current disk's name) .importzp ptr4, ptr3 - .import __oserror + .import ___oserror .export _GetPtrCurDkNm .include "jumptab.inc" @@ -34,5 +34,5 @@ namelp: lda (ptr4),y bne namelp fin: lda #0 sta (ptr3),y - stx __oserror + stx ___oserror rts diff --git a/libsrc/geos-common/disk/setnextfree.s b/libsrc/geos-common/disk/setnextfree.s index b24f16f6f..2d43c1e36 100644 --- a/libsrc/geos-common/disk/setnextfree.s +++ b/libsrc/geos-common/disk/setnextfree.s @@ -5,7 +5,7 @@ ; struct tr_se SetNextFree (struct tr_se *startTS); - .import __oserror + .import ___oserror .import gettrse .export _SetNextFree @@ -18,7 +18,7 @@ _SetNextFree: sta r3L stx r3H jsr SetNextFree - stx __oserror + stx ___oserror lda r3L ldx r3H rts diff --git a/libsrc/geos-common/drivers/fio_module.s b/libsrc/geos-common/drivers/fio_module.s index 1314fc4c5..d4549b4ab 100644 --- a/libsrc/geos-common/drivers/fio_module.s +++ b/libsrc/geos-common/drivers/fio_module.s @@ -14,7 +14,7 @@ FILEDES = 3 ; first free to use file descriptor .importzp ptr1, ptr2, ptr3, tmp1 .import addysp, popax, popptr1 - .import __oserror + .import ___oserror .import _FindFile, _ReadByte .export _open, _close, _read @@ -65,8 +65,8 @@ _open: stx f_offset stx f_offset+1 lda #0 ; clear errors - sta __oserror - jsr __seterrno + sta ___oserror + jsr ___seterrno lda #FILEDES ; return fd sta filedesc rts @@ -75,14 +75,14 @@ _open: .byte $2c ; skip @alreadyopen: lda #EMFILE ; too many opened files (there can be only one) - jmp __directerrno ; set errno, clear oserror, return -1 + jmp ___directerrno ; set errno, clear oserror, return -1 @oserror: - jmp __mappederrno ; set platform error code, return -1 + jmp ___mappederrno ; set platform error code, return -1 _close: lda #0 - sta __oserror - jsr __seterrno ; clear errors + sta ___oserror + jsr ___seterrno ; clear errors lda #0 ; clear fd sta filedesc tax @@ -92,7 +92,7 @@ _read: ; a/x - number of bytes ; popax - buffer ptr ; popax - fd, must be == to the above one - ; return -1+__oserror or number of bytes read + ; return -1+___oserror or number of bytes read inx stx ptr1+1 @@ -111,14 +111,14 @@ _read: @filenotopen: lda #EBADF - jmp __directerrno ; Sets _errno, clears _oserror, returns -1 + jmp ___directerrno ; Sets _errno, clears __oserror, returns -1 @fileok: lda #0 sta ptr3 sta ptr3+1 ; put 0 into ptr3 (number of bytes read) - sta __oserror ; clear error flags - jsr __seterrno + sta ___oserror ; clear error flags + jsr ___seterrno lda f_track ; restore stuff for ReadByte ldx f_sector @@ -147,11 +147,11 @@ _read: bne @L2 inc ptr3+1 -@L2: lda __oserror ; was there error ? +@L2: lda ___oserror ; was there error ? beq @L3 cmp #BFR_OVERFLOW ; EOF? beq @done ; yes, we're done - jmp __mappederrno ; no, we're screwed + jmp ___mappederrno ; no, we're screwed @L3: dec ptr1 ; decrement the count bne @L0 diff --git a/libsrc/geos-common/file/get1stdirentry.s b/libsrc/geos-common/file/get1stdirentry.s index f0ad59388..2217718ea 100644 --- a/libsrc/geos-common/file/get1stdirentry.s +++ b/libsrc/geos-common/file/get1stdirentry.s @@ -5,7 +5,7 @@ ; struct filehandle* Get1stDirEntry (void); - .import __oserror, return0 + .import ___oserror, return0 .export _Get1stDirEntry .include "diskdrv.inc" @@ -13,7 +13,7 @@ _Get1stDirEntry: jsr Get1stDirEntry - stx __oserror + stx ___oserror txa bne L1 ; jump if disk error lda r5L diff --git a/libsrc/geos-common/file/getnxtdirentry.s b/libsrc/geos-common/file/getnxtdirentry.s index e8ccbf3a2..0f74a0ed8 100644 --- a/libsrc/geos-common/file/getnxtdirentry.s +++ b/libsrc/geos-common/file/getnxtdirentry.s @@ -5,7 +5,7 @@ ; struct filehandle* GetNxtDirEntry (void); - .import __oserror, return0 + .import ___oserror, return0 .export _GetNxtDirEntry .include "diskdrv.inc" @@ -13,7 +13,7 @@ _GetNxtDirEntry: jsr GetNxtDirEntry - stx __oserror + stx ___oserror txa bne L1 ; jump if disk error tya diff --git a/libsrc/geos-common/file/readbyte.s b/libsrc/geos-common/file/readbyte.s index 9a24e68df..90616a426 100644 --- a/libsrc/geos-common/file/readbyte.s +++ b/libsrc/geos-common/file/readbyte.s @@ -5,13 +5,13 @@ ; char ReadByte (void); - .import __oserror + .import ___oserror .export _ReadByte .include "jumptab.inc" _ReadByte: jsr ReadByte - stx __oserror + stx ___oserror ldx #0 rts diff --git a/libsrc/geos-common/system/oserror.s b/libsrc/geos-common/system/oserror.s index f0915fd5b..fa45f3e14 100644 --- a/libsrc/geos-common/system/oserror.s +++ b/libsrc/geos-common/system/oserror.s @@ -3,16 +3,16 @@ ; GEOS port: Maciej 'YTM/Elysium' Witkowiak ; 2.7.2001 ; -; int __fastcall__ _osmaperrno (unsigned char oserror); +; int __fastcall__ __osmaperrno (unsigned char oserror); ; /* Map a system specific error into a system independent code */ ; - .export __osmaperrno + .export ___osmaperrno .include "errno.inc" .include "const.inc" -__osmaperrno: +___osmaperrno: ldx #ErrTabSize @L1: cmp ErrTab-2,x ; Search for the error code beq @L2 ; Jump if found diff --git a/libsrc/geos-common/system/setoserror.s b/libsrc/geos-common/system/setoserror.s index adc6ad017..6fb89e96e 100644 --- a/libsrc/geos-common/system/setoserror.s +++ b/libsrc/geos-common/system/setoserror.s @@ -5,10 +5,10 @@ ; .export setoserror - .import __oserror + .import ___oserror setoserror: - stx __oserror + stx ___oserror txa ldx #0 ; X is cleared (high byte for promoting char to int) tay ; Y register is used just to save flags state diff --git a/libsrc/lynx/open.s b/libsrc/lynx/open.s index c48b8eb95..032f55a99 100644 --- a/libsrc/lynx/open.s +++ b/libsrc/lynx/open.s @@ -66,7 +66,7 @@ parmok: jsr popax beq flagsok jsr popax lda #EINVAL - jmp __directerrno + jmp ___directerrno flagsok: jsr popax @@ -74,7 +74,7 @@ flagsok: jsr _openn ldx #$00 lda #$01 - stx __oserror + stx ___oserror rts .endproc diff --git a/libsrc/lynx/oserror.s b/libsrc/lynx/oserror.s index 5570a3bb7..b2ccbf4f0 100644 --- a/libsrc/lynx/oserror.s +++ b/libsrc/lynx/oserror.s @@ -1,7 +1,7 @@ ; ; Karri Kaksonen, 2010 ; -; int __fastcall__ _osmaperrno (unsigned char oserror); +; int __fastcall__ __osmaperrno (unsigned char oserror); ; /* Map a system specific error into a system independent code */ ; @@ -9,6 +9,6 @@ .code -__osmaperrno: +___osmaperrno: rts diff --git a/libsrc/osic1p/oserror.s b/libsrc/osic1p/oserror.s index 073691a06..380c5ebb9 100644 --- a/libsrc/osic1p/oserror.s +++ b/libsrc/osic1p/oserror.s @@ -4,14 +4,14 @@ ; original by ; Stefan Haubenthal, 2011-04-18 ; -; int __fastcall__ _osmaperrno (unsigned char oserror); +; int __fastcall__ __osmaperrno (unsigned char oserror); ; /* Map a system specific error into a system independent code */ ; .include "errno.inc" - .export __osmaperrno + .export ___osmaperrno -.proc __osmaperrno +.proc ___osmaperrno lda #EUNKNOWN diff --git a/libsrc/telestrat/oserror.s b/libsrc/telestrat/oserror.s index e3b9e619a..8fe255656 100644 --- a/libsrc/telestrat/oserror.s +++ b/libsrc/telestrat/oserror.s @@ -1,14 +1,14 @@ ; ; Jede, 2017-10-27 ; -; int __fastcall__ _osmaperrno (unsigned char oserror); +; int __fastcall__ __osmaperrno (unsigned char oserror); ; /* Map a system specific error into a system independent code */ ; .include "errno.inc" - .export __osmaperrno + .export ___osmaperrno -.proc __osmaperrno +.proc ___osmaperrno lda #EUNKNOWN From 54aff47513eb19bc115880fc32f14b1d55026f31 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 22:09:44 +0200 Subject: [PATCH 07/14] fix some errno related stuff, "make all" works again --- include/errno.h | 15 ++++++++++++++- libsrc/cbm/dir.s | 4 ++-- libsrc/cbm/readdir.c | 2 +- libsrc/common/_seterrno.s | 6 +++--- libsrc/common/errno.s | 4 ++-- libsrc/common/perror.c | 2 +- libsrc/common/strerror.s | 4 ++-- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/include/errno.h b/include/errno.h index c762e8b1c..8f329e3cc 100644 --- a/include/errno.h +++ b/include/errno.h @@ -101,11 +101,21 @@ int __fastcall__ __osmaperrno (unsigned char oserror); unsigned char __fastcall__ __seterrno (unsigned char code); /* Set errno to a specific error code and return zero. Used by the library */ +#if __CC65_STD__ >= __CC65_STD_CC65__ +/* define the name with just one underscore for backwards compatibility */ +#define _seterrno __seterrno +#endif + int __fastcall__ __directerrno (unsigned char code); /* Set errno to a specific error code, clear __oserror and return -1. Used ** by the library. */ +#if __CC65_STD__ >= __CC65_STD_CC65__ +/* define the name with just one underscore for backwards compatibility */ +#define _directerrno __directerrno +#endif + int __fastcall__ __mappederrno (unsigned char code); /* Set __oserror to the given platform specific error code. If it is a real ** error code (not zero) set errno to the corresponding system error code @@ -113,7 +123,10 @@ int __fastcall__ __mappederrno (unsigned char code); ** Used by the library. */ - +#if __CC65_STD__ >= __CC65_STD_CC65__ +/* define the name with just one underscore for backwards compatibility */ +#define _mappederrno __mappederrno +#endif /* End of errno.h */ #endif diff --git a/libsrc/cbm/dir.s b/libsrc/cbm/dir.s index 808fcf982..734485aaf 100644 --- a/libsrc/cbm/dir.s +++ b/libsrc/cbm/dir.s @@ -92,8 +92,8 @@ L3: sta tmp1 ; Save returned count ; Didn't read enough bytes. This is an error for us, but errno is not set lda #EINVAL ; = 0 - sta __errno+1 + sta ___errno+1 ; lda #$00 ; A contains zero: "Unknown error" ; Load the pointer to the error message and return From df4b6f9d144a27ce1aeb1e4ef091f5c4a9548047 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Aug 2022 22:37:33 +0200 Subject: [PATCH 08/14] remove extra spaces --- libsrc/apple2/devicedir.s | 2 +- libsrc/apple2/diosectsize.s | 2 +- libsrc/apple2/lseek.s | 4 ++-- libsrc/apple2/rwcommon.s | 2 +- libsrc/atari/close.s | 2 +- libsrc/atari/diopncls.s | 4 ++-- libsrc/atari/exec.s | 2 +- libsrc/atari/graphics.s | 2 +- libsrc/atari/lseek.s | 4 ++-- libsrc/atari/read.s | 2 +- libsrc/atari/write.s | 2 +- libsrc/cbm/close.s | 4 ++-- libsrc/cbm/devicedir.s | 2 +- libsrc/cbm/open.s | 2 +- libsrc/cbm/read.s | 4 ++-- libsrc/cbm/write.s | 4 ++-- libsrc/common/_directerrno.s | 4 ++-- libsrc/common/_fopen.s | 2 +- libsrc/common/_mappederrno.s | 6 +++--- libsrc/common/chdir.s | 2 +- libsrc/common/fopen.s | 2 +- libsrc/common/fwrite.s | 2 +- libsrc/common/mkdir.s | 2 +- libsrc/common/remove.s | 2 +- libsrc/common/rmdir.s | 2 +- libsrc/common/signal.s | 2 +- libsrc/common/sigtable.s | 12 ++++++------ libsrc/common/uname.s | 2 +- libsrc/common/vsnprintf.s | 2 +- libsrc/geos-cbm/disk/dio_openclose.s | 2 +- libsrc/geos-common/drivers/fio_module.s | 14 +++++++------- 31 files changed, 51 insertions(+), 51 deletions(-) diff --git a/libsrc/apple2/devicedir.s b/libsrc/apple2/devicedir.s index abe900be1..21cabf59e 100644 --- a/libsrc/apple2/devicedir.s +++ b/libsrc/apple2/devicedir.s @@ -73,7 +73,7 @@ oserr: jsr ___mappederrno iny lda #$00 sta (ptr1),y - sta ___oserror ; Clear __oserror + sta ___oserror ; Clear __oserror ; Success, return buf lda ptr1 diff --git a/libsrc/apple2/diosectsize.s b/libsrc/apple2/diosectsize.s index 4730bd611..7d2e27a09 100644 --- a/libsrc/apple2/diosectsize.s +++ b/libsrc/apple2/diosectsize.s @@ -10,7 +10,7 @@ _dio_query_sectsize: ; Clear error - stx ___oserror ; X = 0 + stx ___oserror ; X = 0 ; Return ProDOS 8 block size txa ; X = 0 diff --git a/libsrc/apple2/lseek.s b/libsrc/apple2/lseek.s index cc6241558..be0078c1b 100644 --- a/libsrc/apple2/lseek.s +++ b/libsrc/apple2/lseek.s @@ -107,13 +107,13 @@ seek_common: einval: lda #EINVAL ; Set __errno -errno: jsr ___directerrno ; leaves -1 in AX +errno: jsr ___directerrno ; leaves -1 in AX stx sreg ; extend return value to 32 bits stx sreg+1 rts ; Set ___oserror -oserr: jsr ___mappederrno ; leaves -1 in AX +oserr: jsr ___mappederrno ; leaves -1 in AX stx sreg ; extend return value to 32 bits stx sreg+1 rts diff --git a/libsrc/apple2/rwcommon.s b/libsrc/apple2/rwcommon.s index 302b46457..769247e63 100644 --- a/libsrc/apple2/rwcommon.s +++ b/libsrc/apple2/rwcommon.s @@ -49,7 +49,7 @@ rwcommon: rwepilog: ; Return success - sta ___oserror ; A = 0 + sta ___oserror ; A = 0 lda mliparam + MLI::RW::TRANS_COUNT ldx mliparam + MLI::RW::TRANS_COUNT+1 rts diff --git a/libsrc/atari/close.s b/libsrc/atari/close.s index 63b2948f3..b5bff4173 100644 --- a/libsrc/atari/close.s +++ b/libsrc/atari/close.s @@ -18,7 +18,7 @@ jsr CIOV bmi closerr ok: ldx #0 - stx ___oserror ; clear system specific error code + stx ___oserror ; clear system specific error code txa rts diff --git a/libsrc/atari/diopncls.s b/libsrc/atari/diopncls.s index 37f25049b..f40d6bba4 100644 --- a/libsrc/atari/diopncls.s +++ b/libsrc/atari/diopncls.s @@ -49,7 +49,7 @@ _dio_open: sta sectsizetab+sst_flag,x ; set flag that drive is "open" lda #0 sta sectsizetab+sst_sectsize+1,x - sta ___oserror ; success + sta ___oserror ; success tya sta sectsizetab+sst_driveno,x stx ptr2 @@ -156,7 +156,7 @@ s128: lda #128 lda #0 ldy #sst_flag sta (ptr2),y - sta ___oserror ; success + sta ___oserror ; success tax rts ; return no error diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s index 88430e9f7..145b28e0d 100644 --- a/libsrc/atari/exec.s +++ b/libsrc/atari/exec.s @@ -148,7 +148,7 @@ copycd: lda #ATEOL pha ; remember error code jsr close ; close the IOCB (required even if open failed) pla ; put error code back into A -setmerr:jmp ___mappederrno ; update errno from OS specific error code in A +setmerr:jmp ___mappederrno ; update errno from OS specific error code in A openok: lda #>buf sta ICBAH,x ; set buffer address diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s index f35087aea..1f7844c39 100644 --- a/libsrc/atari/graphics.s +++ b/libsrc/atari/graphics.s @@ -45,7 +45,7 @@ parmok: jsr findfreeiocb beq iocbok ; we found one lda #EINVAL diff --git a/libsrc/atari/lseek.s b/libsrc/atari/lseek.s index 915ec24cf..991a86569 100644 --- a/libsrc/atari/lseek.s +++ b/libsrc/atari/lseek.s @@ -21,7 +21,7 @@ ; seeking not supported, return -1 and ENOSYS errno value no_supp:jsr incsp6 lda # Date: Mon, 29 Aug 2022 19:55:48 +0200 Subject: [PATCH 09/14] add extra underscore to heap stuff --- asminc/_heap.inc | 10 +++--- include/_heap.h | 10 +++--- include/stdlib.h | 24 +++++++++++--- libsrc/common/_heap.s | 14 ++++---- libsrc/common/_heapadd.s | 4 +-- libsrc/common/_heapblocksize.s | 4 +-- libsrc/common/_heapmaxavail.s | 16 ++++----- libsrc/common/_heapmemavail.s | 16 ++++----- libsrc/common/free.s | 60 +++++++++++++++++----------------- libsrc/common/malloc.s | 28 ++++++++-------- libsrc/common/realloc.c | 8 ++--- 11 files changed, 105 insertions(+), 89 deletions(-) diff --git a/asminc/_heap.inc b/asminc/_heap.inc index a7d6acea2..1bf80ac82 100644 --- a/asminc/_heap.inc +++ b/asminc/_heap.inc @@ -28,8 +28,8 @@ HEAP_MIN_BLOCKSIZE = .sizeof (freeblock) ; Minimum size of an allocated block HEAP_ADMIN_SPACE = .sizeof (usedblock) ; Additional space for used bock ; Variables -.global __heaporg -.global __heapptr -.global __heapend -.global __heapfirst -.global __heaplast +.global ___heaporg +.global ___heapptr +.global ___heapend +.global ___heapfirst +.global ___heaplast diff --git a/include/_heap.h b/include/_heap.h index c054cfa34..c51f864ac 100644 --- a/include/_heap.h +++ b/include/_heap.h @@ -37,11 +37,11 @@ struct freeblock { /* Variables that describe the heap */ -extern unsigned* _heaporg; /* Bottom of heap */ -extern unsigned* _heapptr; /* Current top */ -extern unsigned* _heapend; /* Upper limit */ -extern struct freeblock* _heapfirst; /* First free block in list */ -extern struct freeblock* _heaplast; /* Last free block in list */ +extern unsigned* __heaporg; /* Bottom of heap */ +extern unsigned* __heapptr; /* Current top */ +extern unsigned* __heapend; /* Upper limit */ +extern struct freeblock* __heapfirst; /* First free block in list */ +extern struct freeblock* __heaplast; /* Last free block in list */ diff --git a/include/stdlib.h b/include/stdlib.h index 99151317f..53d73bb8d 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -92,17 +92,33 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size); */ #endif -void __fastcall__ _heapadd (void* mem, size_t size); +void __fastcall__ __heapadd (void* mem, size_t size); /* Add a block to the heap */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _heapadd __heapadd +#endif -size_t __fastcall__ _heapblocksize (const void* block); +size_t __fastcall__ __heapblocksize (const void* block); /* Return the size of an allocated block */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _heapblocksize __heapblocksize +#endif -size_t _heapmemavail (void); +size_t __heapmemavail (void); /* Return the total free heap space */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _heapmemavail __heapmemavail +#endif -size_t _heapmaxavail (void); +size_t __heapmaxavail (void); /* Return the size of the largest free block on the heap */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _heapmaxavail __heapmaxavail +#endif /* Random numbers */ diff --git a/libsrc/common/_heap.s b/libsrc/common/_heap.s index 4ec8c80cd..eb680fa20 100644 --- a/libsrc/common/_heap.s +++ b/libsrc/common/_heap.s @@ -13,15 +13,15 @@ .data -__heaporg: +___heaporg: .word __BSS_RUN__+__BSS_SIZE__ ; Linker calculates this symbol -__heapptr: +___heapptr: .word __BSS_RUN__+__BSS_SIZE__ ; Dito -__heapend: +___heapend: .word __BSS_RUN__+__BSS_SIZE__ -__heapfirst: +___heapfirst: .word 0 -__heaplast: +___heaplast: .word 0 @@ -33,10 +33,10 @@ initheap: sec lda sp sbc #<__STACKSIZE__ - sta __heapend + sta ___heapend lda sp+1 sbc #>__STACKSIZE__ - sta __heapend+1 + sta ___heapend+1 rts diff --git a/libsrc/common/_heapadd.s b/libsrc/common/_heapadd.s index 14080cb5e..7695a732d 100644 --- a/libsrc/common/_heapadd.s +++ b/libsrc/common/_heapadd.s @@ -10,7 +10,7 @@ .importzp ptr1, ptr2 .import popax .import heapadd - .export __heapadd + .export ___heapadd .include "_heap.inc" @@ -19,7 +19,7 @@ ;----------------------------------------------------------------------------- ; Code -__heapadd: +___heapadd: sta ptr1 ; Store size in ptr1 stx ptr1+1 jsr popax ; Get the block pointer diff --git a/libsrc/common/_heapblocksize.s b/libsrc/common/_heapblocksize.s index db33f594c..e9b0cdad9 100644 --- a/libsrc/common/_heapblocksize.s +++ b/libsrc/common/_heapblocksize.s @@ -7,7 +7,7 @@ ; .importzp ptr1, ptr2 - .export __heapblocksize + .export ___heapblocksize .include "_heap.inc" @@ -17,7 +17,7 @@ ;----------------------------------------------------------------------------- ; Code -__heapblocksize: +___heapblocksize: ; Below the user data is a pointer that points to the start of the real ; (raw) memory block. The first word of this block is the size. To access diff --git a/libsrc/common/_heapmaxavail.s b/libsrc/common/_heapmaxavail.s index 19ae18b8d..b4e72f2d4 100644 --- a/libsrc/common/_heapmaxavail.s +++ b/libsrc/common/_heapmaxavail.s @@ -8,7 +8,7 @@ ; .importzp ptr1, ptr2 - .export __heapmaxavail + .export ___heapmaxavail .include "_heap.inc" @@ -17,22 +17,22 @@ ;----------------------------------------------------------------------------- ; Code -__heapmaxavail: +___heapmaxavail: ; size_t Size = (_heapend - _heapptr) * sizeof (*_heapend); - lda __heapend - sub __heapptr + lda ___heapend + sub ___heapptr sta ptr2 - lda __heapend+1 - sbc __heapptr+1 + lda ___heapend+1 + sbc ___heapptr+1 sta ptr2+1 ; struct freeblock* F = _heapfirst; - lda __heapfirst + lda ___heapfirst sta ptr1 - lda __heapfirst+1 + lda ___heapfirst+1 @L1: sta ptr1+1 ; while (F) { diff --git a/libsrc/common/_heapmemavail.s b/libsrc/common/_heapmemavail.s index 69aa75f8a..14ecc853a 100644 --- a/libsrc/common/_heapmemavail.s +++ b/libsrc/common/_heapmemavail.s @@ -8,7 +8,7 @@ ; .importzp ptr1, ptr2 - .export __heapmemavail + .export ___heapmemavail .include "_heap.inc" @@ -17,7 +17,7 @@ ;----------------------------------------------------------------------------- ; Code -__heapmemavail: +___heapmemavail: ; size_t Size = 0; @@ -27,9 +27,9 @@ __heapmemavail: ; struct freeblock* F = _heapfirst; - lda __heapfirst + lda ___heapfirst sta ptr1 - lda __heapfirst+1 + lda ___heapfirst+1 @L1: sta ptr1+1 ; while (F) { @@ -61,17 +61,17 @@ __heapmemavail: ; return Size + (_heapend - _heapptr) * sizeof (*_heapend); @L2: lda ptr2 - add __heapend + add ___heapend sta ptr2 lda ptr2+1 - adc __heapend+1 + adc ___heapend+1 tax lda ptr2 - sub __heapptr + sub ___heapptr sta ptr2 txa - sbc __heapptr+1 + sbc ___heapptr+1 tax lda ptr2 diff --git a/libsrc/common/free.s b/libsrc/common/free.s index 53796303c..709460ff9 100644 --- a/libsrc/common/free.s +++ b/libsrc/common/free.s @@ -105,27 +105,27 @@ _free: sta ptr2 tay lda ptr2+1 adc ptr1+1 - cpy __heapptr + cpy ___heapptr bne heapadd ; Add to free list - cmp __heapptr+1 + cmp ___heapptr+1 bne heapadd ; The pointer is located at the heap top. Lower the heap top pointer to ; release the block. @L3: lda ptr2 - sta __heapptr + sta ___heapptr lda ptr2+1 - sta __heapptr+1 + sta ___heapptr+1 ; Check if the last block in the freelist is now at heap top. If so, remove ; this block from the freelist. - lda __heaplast + lda ___heaplast sta ptr1 - ora __heaplast+1 + ora ___heaplast+1 beq @L9 ; Jump if free list empty - lda __heaplast+1 + lda ___heaplast+1 sta ptr1+1 ; Pointer to last block now in ptr1 ldy #freeblock::size @@ -136,35 +136,35 @@ _free: sta ptr2 lda (ptr1),y adc ptr1+1 - cmp __heapptr+1 + cmp ___heapptr+1 bne @L9 ; Jump if last block not on top of heap - cpx __heapptr + cpx ___heapptr bne @L9 ; Jump if last block not on top of heap ; Remove the last block lda ptr1 - sta __heapptr + sta ___heapptr lda ptr1+1 - sta __heapptr+1 + sta ___heapptr+1 ; Correct the next pointer of the now last block ldy #freeblock::prev+1 ; Offset of ->prev field lda (ptr1),y sta ptr2+1 ; Remember f->prev in ptr2 - sta __heaplast+1 + sta ___heaplast+1 dey lda (ptr1),y sta ptr2 ; Remember f->prev in ptr2 - sta __heaplast - ora __heaplast+1 ; -> prev == 0? + sta ___heaplast + ora ___heaplast+1 ; -> prev == 0? bne @L8 ; Jump if free list not empty ; Free list is now empty (A = 0) - sta __heapfirst - sta __heapfirst+1 + sta ___heapfirst + sta ___heapfirst+1 ; Done @@ -283,9 +283,9 @@ _free: sta ptr2 ; Check if the free list is empty, storing _hfirst into ptr3 for later heapadd: - lda __heapfirst + lda ___heapfirst sta ptr3 - lda __heapfirst+1 + lda ___heapfirst+1 sta ptr3+1 ora ptr3 bne SearchFreeList @@ -301,10 +301,10 @@ heapadd: lda ptr2 ldx ptr2+1 - sta __heapfirst - stx __heapfirst+1 ; _heapfirst = f; - sta __heaplast - stx __heaplast+1 ; _heaplast = f; + sta ___heapfirst + stx ___heapfirst+1 ; _heapfirst = f; + sta ___heaplast + stx ___heaplast+1 ; _heaplast = f; rts ; Done @@ -351,9 +351,9 @@ SearchFreeList: sta (ptr2),y ; Clear low byte of f->next lda ptr2 ; _heaplast = f; - sta __heaplast + sta ___heaplast lda ptr2+1 - sta __heaplast+1 + sta ___heaplast+1 ; Since we have checked the case that the freelist is empty before, if the ; right pointer is NULL, the left *cannot* be NULL here. So skip the @@ -414,9 +414,9 @@ CheckRightMerge: ; f->next is zero, this is now the last block @L1: lda ptr2 ; _heaplast = f; - sta __heaplast + sta ___heaplast lda ptr2+1 - sta __heaplast+1 + sta ___heaplast+1 jmp CheckLeftMerge ; No right merge, just set the link. @@ -451,9 +451,9 @@ CheckLeftMerge: sta (ptr2),y lda ptr2 ; _heapfirst = f; - sta __heapfirst + sta ___heapfirst lda ptr2+1 - sta __heapfirst+1 + sta ___heapfirst+1 rts ; Done @@ -510,9 +510,9 @@ CheckLeftMerge2: ; This is now the last block, do _heaplast = left @L1: lda ptr4 - sta __heaplast + sta ___heaplast lda ptr4+1 - sta __heaplast+1 + sta ___heaplast+1 rts ; Done ; No merge of the left block, just set the link. Y points to size+1 if diff --git a/libsrc/common/malloc.s b/libsrc/common/malloc.s index 3118e2e56..6872f1f2e 100644 --- a/libsrc/common/malloc.s +++ b/libsrc/common/malloc.s @@ -140,9 +140,9 @@ _malloc: ; Load a pointer to the freelist into ptr2 -@L2: lda __heapfirst +@L2: lda ___heapfirst sta ptr2 - lda __heapfirst+1 + lda ___heapfirst+1 sta ptr2+1 ; Search the freelist for a block that is big enough. We will calculate @@ -173,16 +173,16 @@ _malloc: ; We did not find a block big enough. Try to use new space from the heap top. - lda __heapptr + lda ___heapptr add ptr1 ; _heapptr + size tay - lda __heapptr+1 + lda ___heapptr+1 adc ptr1+1 bcs OutOfHeapSpace ; On overflow, we're surely out of space - cmp __heapend+1 + cmp ___heapend+1 bne @L5 - cpy __heapend + cpy ___heapend @L5: bcc TakeFromTop beq TakeFromTop @@ -196,13 +196,13 @@ Done: rts ; There is enough space left, take it from the heap top TakeFromTop: - ldx __heapptr ; p = _heapptr; + ldx ___heapptr ; p = _heapptr; stx ptr2 - ldx __heapptr+1 + ldx ___heapptr+1 stx ptr2+1 - sty __heapptr ; _heapptr += size; - sta __heapptr+1 + sty ___heapptr ; _heapptr += size; + sta ___heapptr+1 jmp FillSizeAndRet ; Done ; We found a block big enough. If the block can hold just the @@ -245,10 +245,10 @@ BlockFound: ; Do _hfirst = f->next @L1: lda (ptr2),y ; Load high byte of f->next - sta __heapfirst+1 + sta ___heapfirst+1 dey ; Points to next lda (ptr2),y ; Load low byte of f->next - sta __heapfirst + sta ___heapfirst ; Check f->next. Y points always to next if we come here @@ -275,10 +275,10 @@ BlockFound: ; Do _hlast = f->prev @L3: lda (ptr2),y ; Load low byte of f->prev - sta __heaplast + sta ___heaplast iny ; Points to prev+1 lda (ptr2),y ; Load high byte of f->prev - sta __heaplast+1 + sta ___heaplast+1 jmp RetUserPtr ; Done ; We must slice the block found. Cut off space from the upper end, so we diff --git a/libsrc/common/realloc.c b/libsrc/common/realloc.c index c47dbbb98..eeb1eeea5 100644 --- a/libsrc/common/realloc.c +++ b/libsrc/common/realloc.c @@ -74,12 +74,12 @@ void* __fastcall__ realloc (void* block, register size_t size) oldsize = b->size; /* Is the block at the current heap top? */ - if (((unsigned) b) + oldsize == ((unsigned) _heapptr)) { + if (((unsigned) b) + oldsize == ((unsigned) __heapptr)) { /* Check if we've enough memory at the heap top */ - newhptr = ((unsigned) _heapptr) - oldsize + size; - if (newhptr <= ((unsigned) _heapend)) { + newhptr = ((unsigned) __heapptr) - oldsize + size; + if (newhptr <= ((unsigned) __heapend)) { /* Ok, there's space enough */ - _heapptr = (unsigned*) newhptr; + __heapptr = (unsigned*) newhptr; b->size = size; b->start = b; return block; From 145adf61eaf482c290f36ed4df190a4f0de2031b Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 29 Aug 2022 20:10:21 +0200 Subject: [PATCH 10/14] define old names also for heap stuff --- include/_heap.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/_heap.h b/include/_heap.h index c51f864ac..62a7f4bed 100644 --- a/include/_heap.h +++ b/include/_heap.h @@ -43,7 +43,14 @@ extern unsigned* __heapend; /* Upper limit */ extern struct freeblock* __heapfirst; /* First free block in list */ extern struct freeblock* __heaplast; /* Last free block in list */ - +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _heaporg __heaporg +#define _heapptr __heapptr +#define _heapend __heapend +#define _heapfirst __heapfirst +#define _heaplast __heaplast +#endif /* End of _heap.h */ From 89c08dc6d438d8fa304b887533589f89595b4542 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 29 Aug 2022 20:52:35 +0200 Subject: [PATCH 11/14] extra underscores for _randomize and _swap --- include/stdlib.h | 12 ++++++++++-- include/string.h | 6 +++++- libsrc/apple2/randomize.s | 6 +++--- libsrc/atari/randomize.s | 6 +++--- libsrc/atari5200/randomize.s | 6 +++--- libsrc/c128/randomize.s | 6 +++--- libsrc/c16/randomize.s | 6 +++--- libsrc/c64/randomize.s | 6 +++--- libsrc/cbm510/randomize.s | 6 +++--- libsrc/cbm610/randomize.s | 6 +++--- libsrc/common/_swap.s | 6 +++--- libsrc/common/qsort.c | 4 ++-- libsrc/cx16/randomize.s | 6 +++--- libsrc/geos-common/system/randomize.s | 6 +++--- libsrc/nes/randomize.s | 6 +++--- libsrc/pet/randomize.s | 6 +++--- libsrc/plus4/randomize.s | 6 +++--- libsrc/vic20/randomize.s | 6 +++--- 18 files changed, 62 insertions(+), 50 deletions(-) diff --git a/include/stdlib.h b/include/stdlib.h index 53d73bb8d..4e7ffbd6a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -125,7 +125,11 @@ size_t __heapmaxavail (void); #define RAND_MAX 0x7FFF int rand (void); void __fastcall__ srand (unsigned seed); -void _randomize (void); /* Non-standard */ +void __randomize (void); /* Non-standard */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _randomize __randomize +#endif /* Other standard stuff */ void abort (void) __attribute__ ((noreturn)); @@ -146,7 +150,11 @@ unsigned long __fastcall__ strtoul (const char* nptr, char** endptr, int base); int __fastcall__ system (const char* s); /* Non-ANSI functions */ -void __fastcall__ _swap (void* p, void* q, size_t size); +void __fastcall__ __swap (void* p, void* q, size_t size); +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _swap __swap +#endif #if __CC65_STD__ == __CC65_STD_CC65__ char* __fastcall__ itoa (int val, char* buf, int radix); char* __fastcall__ utoa (unsigned val, char* buf, int radix); diff --git a/include/string.h b/include/string.h index 1bd83b385..bda960173 100644 --- a/include/string.h +++ b/include/string.h @@ -92,8 +92,12 @@ char* __fastcall__ strupper (char* s); char* __fastcall__ strqtok (char* s1, const char* s2); #endif -const char* __fastcall__ _stroserror (unsigned char errcode); +const char* __fastcall__ __stroserror (unsigned char errcode); /* Map an operating system error number to an error message. */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _stroserror __stroserror +#endif /* End of string.h */ diff --git a/libsrc/apple2/randomize.s b/libsrc/apple2/randomize.s index 1558d85a7..e9cd063b8 100644 --- a/libsrc/apple2/randomize.s +++ b/libsrc/apple2/randomize.s @@ -1,16 +1,16 @@ ; ; Ullrich von Bassewitz, 07.11.2002 ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "apple2.inc" -__randomize: +___randomize: ldx RNDH ; Use random value supplied by ROM lda RNDL jmp _srand ; Initialize generator diff --git a/libsrc/atari/randomize.s b/libsrc/atari/randomize.s index 915fee3bd..d004a7c19 100644 --- a/libsrc/atari/randomize.s +++ b/libsrc/atari/randomize.s @@ -1,16 +1,16 @@ ; ; Christian Groessler, 06.11.2002 ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "atari.inc" -__randomize: +___randomize: ldx VCOUNT ; Use vertical line counter as high byte lda RTCLOK+2 ; Use clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/atari5200/randomize.s b/libsrc/atari5200/randomize.s index 978ccf3f3..5c554b5f8 100644 --- a/libsrc/atari5200/randomize.s +++ b/libsrc/atari5200/randomize.s @@ -1,16 +1,16 @@ ; ; Christian Groessler, 01-Mar-2014 ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "atari5200.inc" -__randomize: +___randomize: ldx VCOUNT ; Use vertical line counter as high byte lda RTCLOK+1 ; Use clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/c128/randomize.s b/libsrc/c128/randomize.s index ae63184a4..2b7754e86 100644 --- a/libsrc/c128/randomize.s +++ b/libsrc/c128/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "c128.inc" -__randomize: +___randomize: ldx VIC_HLINE ; Use VIC rasterline as high byte lda TIME+2 ; Use 60HZ clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/c16/randomize.s b/libsrc/c16/randomize.s index 796ad118b..0d1ccaf03 100644 --- a/libsrc/c16/randomize.s +++ b/libsrc/c16/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "plus4.inc" -__randomize: +___randomize: ldx TED_VLINELO ; Use TED rasterline as high byte lda TIME+2 ; Use 60HZ clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/c64/randomize.s b/libsrc/c64/randomize.s index a875203af..da32dfc28 100644 --- a/libsrc/c64/randomize.s +++ b/libsrc/c64/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "c64.inc" -__randomize: +___randomize: ldx VIC_HLINE ; Use VIC rasterline as high byte lda TIME+2 ; Use 60HZ clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/cbm510/randomize.s b/libsrc/cbm510/randomize.s index 75c419ccb..8d21cde15 100644 --- a/libsrc/cbm510/randomize.s +++ b/libsrc/cbm510/randomize.s @@ -2,15 +2,15 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .importzp time -__randomize: +___randomize: ldx time+2 ; Use 50/60HZ clock lda time+1 jmp _srand ; Initialize generator diff --git a/libsrc/cbm610/randomize.s b/libsrc/cbm610/randomize.s index 75c419ccb..8d21cde15 100644 --- a/libsrc/cbm610/randomize.s +++ b/libsrc/cbm610/randomize.s @@ -2,15 +2,15 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .importzp time -__randomize: +___randomize: ldx time+2 ; Use 50/60HZ clock lda time+1 jmp _srand ; Initialize generator diff --git a/libsrc/common/_swap.s b/libsrc/common/_swap.s index 9ad771de1..ba3e5922d 100644 --- a/libsrc/common/_swap.s +++ b/libsrc/common/_swap.s @@ -1,15 +1,15 @@ ; ; Ullrich von Bassewitz, 1998-12-09, 2004-11-30 ; -; void __fastcall__ _swap (void* p, void* q, size_t size); +; void __fastcall__ __swap (void* p, void* q, size_t size); ; - .export __swap + .export ___swap .import popax, popptr1 .importzp ptr1, ptr2, ptr3 -__swap: eor #$FF +___swap: eor #$FF sta ptr3 txa eor #$FF diff --git a/libsrc/common/qsort.c b/libsrc/common/qsort.c index 991db3ba1..913165814 100644 --- a/libsrc/common/qsort.c +++ b/libsrc/common/qsort.c @@ -32,13 +32,13 @@ static void QuickSort (register unsigned char* Base, int Lo, int Hi, J -= Size; } if (I <= J) { - _swap (Base + I, Base + J, Size); + __swap (Base + I, Base + J, Size); I += Size; J -= Size; } } if (J != Lo) { - _swap (Base + J, Base + Lo, Size); + __swap (Base + J, Base + Lo, Size); } if (((unsigned) J) * 2 > (Hi + Lo)) { QuickSort (Base, J + Size, Hi, Size, Compare); diff --git a/libsrc/cx16/randomize.s b/libsrc/cx16/randomize.s index 3d965c82a..49051e012 100644 --- a/libsrc/cx16/randomize.s +++ b/libsrc/cx16/randomize.s @@ -1,14 +1,14 @@ ; ; 2020-05-02, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import ENTROPY_GET, _srand -__randomize: +___randomize: jsr ENTROPY_GET jmp _srand ; Initialize generator diff --git a/libsrc/geos-common/system/randomize.s b/libsrc/geos-common/system/randomize.s index 67c217d80..d8f821356 100644 --- a/libsrc/geos-common/system/randomize.s +++ b/libsrc/geos-common/system/randomize.s @@ -1,16 +1,16 @@ ; ; Ullrich von Bassewitz, 05.11.2002 ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "geossym.inc" -__randomize: +___randomize: lda random ; get random value from internal generator ldx random+1 jmp _srand ; and use it as seed diff --git a/libsrc/nes/randomize.s b/libsrc/nes/randomize.s index 8df4fb88a..a146fef1b 100644 --- a/libsrc/nes/randomize.s +++ b/libsrc/nes/randomize.s @@ -1,16 +1,16 @@ ; ; Ullrich von Bassewitz, 2003-05-02 ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "nes.inc" -__randomize: +___randomize: ldx tickcount ; Use tick clock lda tickcount+1 jmp _srand ; Initialize generator diff --git a/libsrc/pet/randomize.s b/libsrc/pet/randomize.s index 44bf4c38e..a173cf076 100644 --- a/libsrc/pet/randomize.s +++ b/libsrc/pet/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "pet.inc" -__randomize: +___randomize: ldx TIME+2 lda TIME+1 ; Use 60HZ clock jmp _srand ; Initialize generator diff --git a/libsrc/plus4/randomize.s b/libsrc/plus4/randomize.s index 796ad118b..0d1ccaf03 100644 --- a/libsrc/plus4/randomize.s +++ b/libsrc/plus4/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "plus4.inc" -__randomize: +___randomize: ldx TED_VLINELO ; Use TED rasterline as high byte lda TIME+2 ; Use 60HZ clock as low byte jmp _srand ; Initialize generator diff --git a/libsrc/vic20/randomize.s b/libsrc/vic20/randomize.s index 69cf07bb3..ac2c09a7d 100644 --- a/libsrc/vic20/randomize.s +++ b/libsrc/vic20/randomize.s @@ -2,16 +2,16 @@ ; 2002-11-05, Ullrich von Bassewitz ; 2015-09-11, Greg King ; -; void _randomize (void); +; void __randomize (void); ; /* Initialize the random number generator */ ; - .export __randomize + .export ___randomize .import _srand .include "vic20.inc" -__randomize: +___randomize: lda VIC_LINES ; Get overflow bit asl a ; Shift bit 7 into carry lda VIC_HLINE ; Get bit 1-8 of rasterline From 3b03a963754d0edb7782d3ca30bbab3e9322a09c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 29 Aug 2022 21:06:48 +0200 Subject: [PATCH 12/14] add underscores to _poserror and _stroserror --- include/stdio.h | 6 +++++- libsrc/common/_poserror.c | 4 ++-- libsrc/common/stroserr.s | 6 +++--- libsrc/geos-common/common/_poserror.c | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/stdio.h b/include/stdio.h index 84a991a98..858dd5059 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -147,7 +147,11 @@ int __fastcall__ vfscanf (FILE* f, const char* format, __va_list ap); FILE* __fastcall__ fdopen (int fd, const char* mode); /* Unix */ int __fastcall__ fileno (FILE* f); /* Unix */ #endif -void __fastcall__ _poserror (const char* msg); /* cc65 */ +void __fastcall__ __poserror (const char* msg); /* cc65 */ +#if __CC65_STD__ == __CC65_STD_CC65__ +/* define old name with one underscore for backwards compatibility */ +#define _poserror __poserror +#endif /* Masking macros for some functions */ #define getc(f) fgetc (f) /* ANSI */ diff --git a/libsrc/common/_poserror.c b/libsrc/common/_poserror.c index 2777fee98..a2a67dd3e 100644 --- a/libsrc/common/_poserror.c +++ b/libsrc/common/_poserror.c @@ -39,10 +39,10 @@ -void __fastcall__ _poserror (const char* msg) +void __fastcall__ __poserror (const char* msg) { /* Fetch the message that corresponds to _oserror */ - const char* errormsg = _stroserror (_oserror); + const char* errormsg = __stroserror (_oserror); /* Different output depending on msg */ if (msg) { diff --git a/libsrc/common/stroserr.s b/libsrc/common/stroserr.s index 25ca30daf..ae8e117f1 100644 --- a/libsrc/common/stroserr.s +++ b/libsrc/common/stroserr.s @@ -1,11 +1,11 @@ ; ; Ullrich von Bassewitz, 17.07.2002 ; -; const char* __fastcall__ _stroserror (unsigned char errcode); +; const char* __fastcall__ __stroserror (unsigned char errcode); ; /* Map an operating system error number to an error message. */ ; - .export __stroserror + .export ___stroserror .import __sys_oserrlist .importzp ptr1, tmp1 @@ -21,7 +21,7 @@ ; and terminated by an entry with length zero that is returned if the ; error code could not be found. -__stroserror: +___stroserror: sta tmp1 ; Save the error code ldy #<__sys_oserrlist diff --git a/libsrc/geos-common/common/_poserror.c b/libsrc/geos-common/common/_poserror.c index eeb3f368e..b47f0a7d9 100644 --- a/libsrc/geos-common/common/_poserror.c +++ b/libsrc/geos-common/common/_poserror.c @@ -9,9 +9,9 @@ #include #include -void __fastcall__ _poserror (const char* msg) +void __fastcall__ __poserror (const char* msg) { - const char *errmsg = _stroserror(_oserror); + const char *errmsg = __stroserror(_oserror); ExitTurbo(); if (msg && *msg) { From 5bda57de87da864e17bce5e5aec79c79420cff9d Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 29 Aug 2022 23:20:48 +0200 Subject: [PATCH 13/14] add extra underscore to _bzero, add a test for bzero/memset --- include/string.h | 2 +- libsrc/atari7800/clrscr.s | 4 +-- libsrc/atari7800/mono_clrscr.s | 4 +-- libsrc/common/calloc.s | 4 +-- libsrc/common/memset.s | 12 +++---- libsrc/geos-common/common/memset.s | 6 ++-- libsrc/pce/memset.s | 10 +++--- src/cc65/coptstop.c | 2 +- src/cc65/stdfunc.c | 2 +- src/cc65/stdnames.c | 12 +++---- src/cc65/stdnames.h | 12 +++---- test/val/bzero.c | 51 ++++++++++++++++++++++++++++++ 12 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 test/val/bzero.c diff --git a/include/string.h b/include/string.h index bda960173..854359dad 100644 --- a/include/string.h +++ b/include/string.h @@ -74,7 +74,7 @@ void* __fastcall__ memset (void* s, int c, size_t count); /* The following is an internal function, the compiler will replace memset ** with it if the fill value is zero. Never use this one directly! */ -void* __fastcall__ _bzero (void* ptr, size_t n); +void* __fastcall__ __bzero (void* ptr, size_t n); /* Non standard: */ #if __CC65_STD__ == __CC65_STD_CC65__ diff --git a/libsrc/atari7800/clrscr.s b/libsrc/atari7800/clrscr.s index f9d4938b0..a1f663ba7 100644 --- a/libsrc/atari7800/clrscr.s +++ b/libsrc/atari7800/clrscr.s @@ -4,7 +4,7 @@ .export _clrscr .import _screen - .import pushax, __bzero + .import pushax, ___bzero .include "extzp.inc" .code @@ -16,7 +16,7 @@ jsr pushax ldx #>(charsperline * screenrows) lda #<(charsperline * screenrows) - jmp __bzero + jmp ___bzero .endproc diff --git a/libsrc/atari7800/mono_clrscr.s b/libsrc/atari7800/mono_clrscr.s index 19f1fdfd6..f6f6735cb 100644 --- a/libsrc/atari7800/mono_clrscr.s +++ b/libsrc/atari7800/mono_clrscr.s @@ -4,7 +4,7 @@ .export _mono_clrscr .import _mono_screen - .import pushax, __bzero + .import pushax, ___bzero .include "extzp.inc" .code @@ -16,7 +16,7 @@ jsr pushax ldx #>(mono_charsperline * screenrows) lda #<(mono_charsperline * screenrows) - jmp __bzero + jmp ___bzero .endproc diff --git a/libsrc/common/calloc.s b/libsrc/common/calloc.s index 6e3e1bd3f..4cb701146 100644 --- a/libsrc/common/calloc.s +++ b/libsrc/common/calloc.s @@ -7,7 +7,7 @@ ; .export _calloc - .import _malloc, __bzero + .import _malloc, ___bzero .import tosumulax, pushax @@ -48,7 +48,7 @@ ClearBlock: jsr pushax ; ptr lda Size ldx Size+1 ; Size - jmp __bzero + jmp ___bzero .endproc diff --git a/libsrc/common/memset.s b/libsrc/common/memset.s index a57a90e5c..be78fc30d 100644 --- a/libsrc/common/memset.s +++ b/libsrc/common/memset.s @@ -1,6 +1,6 @@ ; ; void* __fastcall__ memset (void* ptr, int c, size_t n); -; void* __fastcall__ _bzero (void* ptr, size_t n); +; void* __fastcall__ __bzero (void* ptr, size_t n); ; void __fastcall__ bzero (void* ptr, size_t n); ; ; Ullrich von Bassewitz, 29.05.1998 @@ -8,19 +8,19 @@ ; Christian Krueger, 12.09.2009, slightly improved 12.01.2011 ; ; NOTE: bzero will return it's first argument as memset does. It is no problem -; to declare the return value as void, since it may be ignored. _bzero -; (note the leading underscore) is declared with the proper return type, -; because the compiler will replace memset by _bzero if the fill value +; to declare the return value as void, since it may be ignored. __bzero +; (note the leading underscores) is declared with the proper return type, +; because the compiler will replace memset by __bzero if the fill value ; is zero, and the optimizer looks at the return type to see if the value ; in a/x is of any use. ; - .export _memset, _bzero, __bzero + .export _memset, _bzero, ___bzero .import popax .importzp sp, ptr1, ptr2, ptr3 _bzero: -__bzero: +___bzero: sta ptr3 stx ptr3+1 ; Save n ldx #0 ; Fill with zeros diff --git a/libsrc/geos-common/common/memset.s b/libsrc/geos-common/common/memset.s index 2cb6732d1..82b7f4a87 100644 --- a/libsrc/geos-common/common/memset.s +++ b/libsrc/geos-common/common/memset.s @@ -1,14 +1,14 @@ ; ; void* memset (void* ptr, int c, size_t n); -; void* _bzero (void* ptr, size_t n); +; void* __bzero (void* ptr, size_t n); ; void bzero (void* ptr, size_t n); ; ; Maciej 'YTM/Elysium' Witkowiak, 20.08.2003 ; - .export _memset, _bzero, __bzero + .export _memset, _bzero, ___bzero .import _ClearRam, _FillRam _bzero = _ClearRam -__bzero = _ClearRam +___bzero = _ClearRam _memset = _FillRam diff --git a/libsrc/pce/memset.s b/libsrc/pce/memset.s index 45a78d533..1148e00c8 100644 --- a/libsrc/pce/memset.s +++ b/libsrc/pce/memset.s @@ -6,21 +6,21 @@ ; 1998-05-29, Ullrich von Bassewitz ; 2015-11-06, Greg King ; -; void* __fastcall__ _bzero (void* ptr, size_t n); +; void* __fastcall__ __bzero (void* ptr, size_t n); ; void __fastcall__ bzero (void* ptr, size_t n); ; void* __fastcall__ memset (void* ptr, int c, size_t n); ; ; NOTE: bzero() will return its first argument, as memset() does. It is no ; problem to declare the return value as void, because it can be ignored. -; _bzero() (note the leading underscore) is declared with the proper -; return type because the compiler will replace memset() by _bzero() if +; __bzero() (note the leading underscores) is declared with the proper +; return type because the compiler will replace memset() by __bzero() if ; the fill value is zero; and, the optimizer looks at the return type ; to see if the value in .XA is of any use. ; ; NOTE: This function uses entry points from "pce/memcpy.s"! ; - .export __bzero, _bzero, _memset + .export ___bzero, _bzero, _memset .import memcpy_getparams, memcpy_increment .import pushax, popax @@ -30,7 +30,7 @@ ; ---------------------------------------------------------------------- -__bzero: +___bzero: _bzero: pha cla ; fill with zeros jsr pushax ; (high byte isn't important) diff --git a/src/cc65/coptstop.c b/src/cc65/coptstop.c index 08f6c820e..4d0151c55 100644 --- a/src/cc65/coptstop.c +++ b/src/cc65/coptstop.c @@ -1329,7 +1329,7 @@ static unsigned Opt_a_tosult (StackOpData* D) /* The first column of these two tables must be sorted in lexical order */ static const OptFuncDesc FuncTable[] = { - { "__bzero", Opt___bzero, REG_NONE, OP_X_ZERO | OP_A_KNOWN }, + { "___bzero", Opt___bzero, REG_NONE, OP_X_ZERO | OP_A_KNOWN }, { "staspidx", Opt_staspidx, REG_NONE, OP_NONE }, { "staxspidx", Opt_staxspidx, REG_AX, OP_NONE }, { "tosaddax", Opt_tosaddax, REG_NONE, OP_NONE }, diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 5ed5ce671..fc19ce7f0 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -604,7 +604,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) DoDeferred (SQP_KEEP_EAX, &Arg3.Expr); /* Emit the actual function call. This will also cleanup the stack. */ - g_call (CF_FIXARGC, MemSet? Func_memset : Func__bzero, ParamSize); + g_call (CF_FIXARGC, MemSet? Func_memset : Func___bzero, ParamSize); if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal == 0) { diff --git a/src/cc65/stdnames.c b/src/cc65/stdnames.c index 687b53894..cdecd61a1 100644 --- a/src/cc65/stdnames.c +++ b/src/cc65/stdnames.c @@ -44,9 +44,9 @@ -const char Func__bzero[] = "_bzero"; /* Asm name of "_bzero" */ -const char Func_memcpy[] = "memcpy"; /* Asm name of "memcpy" */ -const char Func_memset[] = "memset"; /* Asm name of "memset" */ -const char Func_strcmp[] = "strcmp"; /* Asm name of "strcmp" */ -const char Func_strcpy[] = "strcpy"; /* Asm name of "strcpy" */ -const char Func_strlen[] = "strlen"; /* Asm name of "strlen" */ +const char Func___bzero[] = "__bzero"; /* C name of "__bzero" */ +const char Func_memcpy[] = "memcpy"; /* C name of "memcpy" */ +const char Func_memset[] = "memset"; /* C name of "memset" */ +const char Func_strcmp[] = "strcmp"; /* C name of "strcmp" */ +const char Func_strcpy[] = "strcpy"; /* C name of "strcpy" */ +const char Func_strlen[] = "strlen"; /* C name of "strlen" */ diff --git a/src/cc65/stdnames.h b/src/cc65/stdnames.h index dcb323924..e6497e4c3 100644 --- a/src/cc65/stdnames.h +++ b/src/cc65/stdnames.h @@ -44,12 +44,12 @@ -extern const char Func__bzero[]; /* Asm name of "_bzero" */ -extern const char Func_memcpy[]; /* Asm name of "memcpy" */ -extern const char Func_memset[]; /* Asm name of "memset" */ -extern const char Func_strcmp[]; /* Asm name of "strcmp" */ -extern const char Func_strcpy[]; /* Asm name of "strcpy" */ -extern const char Func_strlen[]; /* Asm name of "strlen" */ +extern const char Func___bzero[]; /* C name of "__bzero" */ +extern const char Func_memcpy[]; /* C name of "memcpy" */ +extern const char Func_memset[]; /* C name of "memset" */ +extern const char Func_strcmp[]; /* C name of "strcmp" */ +extern const char Func_strcpy[]; /* C name of "strcpy" */ +extern const char Func_strlen[]; /* C name of "strlen" */ diff --git a/test/val/bzero.c b/test/val/bzero.c new file mode 100644 index 000000000..4e7ed6ac1 --- /dev/null +++ b/test/val/bzero.c @@ -0,0 +1,51 @@ + +// test if memset and bzero work as expected after optimizations + +#include + +char s1[10] = { 1,2,3,4,5,6,7,8,9,10 }; +char r1[10] = { 0,0,0,0,0,6,7,8,9,10 }; + +char s2[10] = { 1,2,3,4,5,6,7,8,9,10 }; +char r2[10] = { 0,0,0,0,0,0,7,8,9,10 }; + +char s3[10] = { 1,2,3,4,5,6,7,8,9,10 }; +char r3[10] = { 0,0,0,0,0,0,0,8,9,10 }; + +char *p1, *p2, *p3; + +int res = 0; + +int main(void) +{ + /* regular bzero */ + bzero(s1, 5); + p1 = __AX__; /* this works because bzero jumps into memset */ + /* this gets converted to __bzero */ + p2 = memset(s2, 0, 6); + /* call internal __bzero (we should not do this in real code) */ + p3 = __bzero(s3, 7); + + /* check the results */ + if (memcmp(s1, r1, 10) != 0) { + res++; + } + if (memcmp(s2, r2, 10) != 0) { + res++; + } + if (memcmp(s3, r3, 10) != 0) { + res++; + } + + if (p1 != s1) { + res++; + } + if (p2 != s2) { + res++; + } + if (p3 != s3) { + res++; + } + + return res; +} From 9a9bf9f2eacdc5ad6cb1029b6e5bc174d0ee0a34 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 19 Nov 2022 18:38:00 +0100 Subject: [PATCH 14/14] update note on identifiers --- Contributing.md | 100 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 3 deletions(-) diff --git a/Contributing.md b/Contributing.md index e316b9c61..6fa5ba7c2 100644 --- a/Contributing.md +++ b/Contributing.md @@ -29,9 +29,22 @@ This is an ongoing controversial topic - everyone knows that. However, the follo The (bash) scripts used to check the above rules can be found in ```.github/check```. You can also run all checks using ```make check```. -### identifiers and symbol names +### Identifiers and Symbol names -* any symbols that are exported from source files and/or appear in header files should not be in the "_symbol" form in C, or "__symbol" form in assembly. This way we evade the problem that "_symbol" may or may not be reserved by that standard. +The C Standard defines certain identifiers and symbol names, which we can not use +in our code. Since it is not always obvious which parts of the library code will +actually end up in a linked program, the following applies to ALL of the library. + +Any non standard identifier/symbol/function that is exported from source files, +or appears in header files: + +* must not be in the "_symbol" form in C, or "__symbol" form in assembly. +* must start with (at least) two (C Code) or three (assembly code) underscores, unless the symbol appears in a non standard header file. + +This is likely more than the standard dictates us to do - but it is certainly +standard compliant - and easy to remember. + +Also see the discussion in https://github.com/cc65/cc65/issues/1796 ### misc @@ -173,7 +186,88 @@ The only exception to the above are actions that are exclusive to the github act The first step is implementing the datatype "float" as IEEE488 floats. Help welcomed! * WIP compiler/library changes are here: https://github.com/cc65/cc65/pull/1777 -* free software library with testbench is here: http://www.jhauser.us/arithmetic/ + +## Library + +### name clashes in the library + +see "Identifiers and Symbol names" above - not all identifiers have been checked +and renamed yet. The following is a list of those that still might need to be +fixed: + +``` +common + +__argc libsrc/runtime/callmain.s libsrc/cbm610/mainargs.s libsrc/cx16/mainargs.s libsrc/plus4/mainargs.s libsrc/lynx/mainargs.s libsrc/c16/mainargs.s libsrc/geos-common/system/mainargs.s libsrc/sim6502/mainargs.s libsrc/c128/mainargs.s libsrc/vic20/mainargs.s libsrc/nes/mainargs.s libsrc/atari/getargs.s libsrc/apple2/mainargs.s libsrc/cbm510/mainargs.s libsrc/telestrat/mainargs.s libsrc/c64/mainargs.s libsrc/pet/mainargs.s libsrc/atmos/mainargs.s +__argv libsrc/runtime/callmain.s libsrc/cbm610/mainargs.s libsrc/cx16/mainargs.s libsrc/plus4/mainargs.s libsrc/lynx/mainargs.s libsrc/c16/mainargs.s libsrc/geos-common/system/mainargs.s libsrc/sim6502/mainargs.s libsrc/c128/mainargs.s libsrc/vic20/mainargs.s libsrc/nes/mainargs.s libsrc/atari/getargs.s libsrc/apple2/mainargs.s libsrc/cbm510/mainargs.s libsrc/telestrat/mainargs.s libsrc/c64/mainargs.s libsrc/pet/mainargs.s libsrc/atmos/mainargs.s +__cos libsrc/common/sincos.s +__ctypeidx libsrc/common/ctype.s libsrc/common/ctypemask.s libsrc/geos-common/system/ctype.s libsrc/atari/ctype.s libsrc/cbm/ctype.s libsrc/atmos/ctype.s asminc/ctype_common.inc +__cwd libsrc/common/getcwd.s libsrc/common/_cwd.s libsrc/atari/initcwd.s libsrc/apple2/initcwd.s libsrc/apple2/initcwd.s libsrc/telestrat/initcwd.s libsrc/cbm/initcwd.s +__cwd_buf_size libsrc/common/_cwd.s +__envcount libsrc/common/searchenv.s libsrc/common/_environ.s libsrc/common/putenv.s libsrc/common/getenv.s +__environ libsrc/common/searchenv.s libsrc/common/_environ.s libsrc/common/putenv.s libsrc/common/getenv.s +__envsize libsrc/common/_environ.s libsrc/common/putenv.s +__fdesc libsrc/common/_fdesc.s libsrc/common/fopen.s +__filetab libsrc/common/_fdesc.s libsrc/common/_file.s asminc/_file.inc +__fopen libsrc/common/fopen.s libsrc/common/_fopen.s +__printf libsrc/common/vsnprintf.s libsrc/common/_printf.s libsrc/common/vfprintf.s libsrc/conio/vcprintf.s libsrc/pce/_printf.s +__scanf libsrc/common/_scanf.inc libsrc/common/vsscanf.s libsrc/conio/vcscanf.s +__sin libsrc/common/sincos.s +__sys libsrc/common/_sys.s libsrc/apple2/_sys.s +__sys_oserrlist libsrc/common/stroserr.s libsrc/geos-common/system/oserrlist.s libsrc/atari/oserrlist.s libsrc/apple2/oserrlist.s libsrc/cbm/oserrlist.s libsrc/atmos/oserrlist.s +__syschdir libsrc/common/chdir.s libsrc/atari/syschdir.s libsrc/apple2/syschdir.s libsrc/telestrat/syschdir.s libsrc/cbm/syschdir.s +__sysmkdir libsrc/common/mkdir.s libsrc/atari/sysmkdir.s libsrc/apple2/sysmkdir.s libsrc/telestrat/sysmkdir.s +__sysremove libsrc/common/remove.s libsrc/geos-common/file/sysremove.s libsrc/atari/sysremove.s libsrc/atari/sysrmdir.s libsrc/apple2/sysremove.s libsrc/apple2/sysrmdir.s libsrc/telestrat/sysremove.s libsrc/cbm/sysremove.s +__sysrename libsrc/common/rename.s libsrc/geos-common/file/sysrename.s libsrc/atari/sysrename.s libsrc/apple2/sysrename.s libsrc/cbm/sysrename.s +__sysrmdir libsrc/common/rmdir.s libsrc/atari/sysrmdir.s libsrc/apple2/sysrmdir.s +__sysuname libsrc/common/uname.s libsrc/cbm610/sysuname.s libsrc/cx16/sysuname.s libsrc/plus4/sysuname.s libsrc/lynx/sysuname.s libsrc/c16/sysuname.s libsrc/geos-common/system/sysuname.s libsrc/c128/sysuname.s libsrc/creativision/sysuname.s libsrc/vic20/sysuname.s libsrc/nes/sysuname.s libsrc/atari/sysuname.s libsrc/apple2/sysuname.s libsrc/cbm510/sysuname.s libsrc/telestrat/sysuname.s libsrc/c64/sysuname.s libsrc/pet/sysuname.s libsrc/atari5200/sysuname.s libsrc/atmos/sysuname.s + +apple2 + +__auxtype libsrc/apple2/open.s +__datetime libsrc/apple2/open.s +__dos_type libsrc/apple2/dioopen.s libsrc/apple2/curdevice.s libsrc/apple2/mainargs.s libsrc/apple2/settime.s libsrc/apple2/getdevice.s libsrc/apple2/dosdetect.s libsrc/apple2/irq.s libsrc/apple2/open.s libsrc/apple2/mli.s libsrc/apple2/getres.s +__filetype libsrc/apple2/open.s libsrc/apple2/exehdr.s + + +atari + +__defdev libsrc/atari/posixdirent.s libsrc/atari/ucase_fn.s libsrc/atari/getdefdev.s +__dos_type libsrc/atari/getargs.s libsrc/atari/exec.s libsrc/atari/settime.s libsrc/atari/syschdir.s libsrc/atari/dosdetect.s libsrc/atari/is_cmdline_dos.s libsrc/atari/sysrmdir.s libsrc/atari/gettime.s libsrc/atari/lseek.s libsrc/atari/getres.s libsrc/atari/getdefdev.s +__do_oserror libsrc/atari/posixdirent.s libsrc/atari/do_oserr.s libsrc/atari/serref.s libsrc/atari/read.s libsrc/atari/write.s libsrc/atari/close.s +__getcolor libsrc/atari/setcolor.s +__getdefdev libsrc/atari/getdefdev.s +__graphics libsrc/atari/graphics.s +__inviocb libsrc/atari/serref.s libsrc/atari/ser/atrrdev.s libsrc/atari/inviocb.s libsrc/atari/read.s libsrc/atari/write.s libsrc/atari/lseek.s libsrc/atari/close.s +__is_cmdline_dos libsrc/atari/is_cmdline_dos.s libsrc/atari/doesclrscr.s +__rest_vecs libsrc/atari/savevec.s +__rwsetup libsrc/atari/rwcommon.s libsrc/atari/read.s libsrc/atari/write.s +__save_vecs libsrc/atari/savevec.s +__scroll libsrc/atari/scroll.s +__setcolor libsrc/atari/setcolor.s +__setcolor_low libsrc/atari/setcolor.s +__sio_call libsrc/atari/diowritev.s libsrc/atari/diopncls.s libsrc/atari/siocall.s libsrc/atari/diowrite.s libsrc/atari/dioread.s + + +cbm + +__cbm_filetype libsrc/cbm/cbm_filetype.s asminc/cbm_filetype.in +__dirread libsrc/cbm/dir.inc libsrc/cbm/dir.s +__dirread1 libsrc/cbm/dir.inc libsrc/cbm/dir.s + + +lynx + +__iodat libsrc/lynx/lynx-cart.s libsrc/lynx/bootldr.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc +__iodir libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc +__sprsys libsrc/lynx/tgi/lynx-160-102-16.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc +__viddma libsrc/lynx/tgi/lynx-160-102-16.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc + + +pce + +__nmi libsrc/pce/irq.s libsrc/pce/crt0.s +``` ## Test suite