mirror of
https://github.com/cc65/cc65.git
synced 2025-04-09 10:39:40 +00:00
Merge pull request #1844 from mrdudz/underscores
Fix name conflicts in standard headers by adding more Underscores
This commit is contained in:
commit
e4f01a260d
100
Contributing.md
100
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -37,13 +37,20 @@ 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 */
|
||||
|
||||
#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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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, ...);
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
@ -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,27 +88,45 @@ 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
|
||||
#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.
|
||||
*/
|
||||
|
||||
int __fastcall__ _mappederrno (unsigned char code);
|
||||
/* Set _oserror to the given platform specific error code. If it is a real
|
||||
#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
|
||||
** and return -1. Otherwise return zero.
|
||||
** 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
|
||||
|
@ -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));
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -92,24 +92,44 @@ 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 */
|
||||
#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));
|
||||
@ -130,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);
|
||||
|
@ -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__
|
||||
@ -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 */
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -45,9 +45,9 @@ _getdevicedir:
|
||||
|
||||
; Handle errors
|
||||
erange: lda #<ERANGE
|
||||
jsr __directerrno
|
||||
jsr ___directerrno
|
||||
bne :+ ; Branch always
|
||||
oserr: jsr __mappederrno
|
||||
oserr: jsr ___mappederrno
|
||||
: lda #$00 ; Return NULL
|
||||
tax
|
||||
rts
|
||||
@ -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
|
||||
|
@ -30,6 +30,6 @@ diocommon:
|
||||
|
||||
dioepilog:
|
||||
; Return success or error
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
ldx #$00
|
||||
rts
|
||||
|
@ -24,7 +24,7 @@ _dio_open:
|
||||
lda #$28 ; "No device connected"
|
||||
|
||||
; Return oserror
|
||||
oserr: sta __oserror
|
||||
oserr: sta ___oserror
|
||||
jmp return0
|
||||
|
||||
; Return success
|
||||
@ -34,5 +34,5 @@ oserr: sta __oserror
|
||||
asl
|
||||
asl
|
||||
ldx #$00
|
||||
stx __oserror
|
||||
stx ___oserror
|
||||
rts
|
||||
|
@ -16,7 +16,7 @@ _dio_query_sectcount:
|
||||
; Set handle
|
||||
sta mliparam + MLI::ON_LINE::UNIT_NUM
|
||||
|
||||
; Get ProDOS 8 block size (clears __oserror)
|
||||
; Get ProDOS 8 block size (clears ___oserror)
|
||||
jsr _dio_query_sectsize
|
||||
|
||||
; Alloc buffer
|
||||
@ -74,7 +74,7 @@ done: lda ptr4
|
||||
rts
|
||||
|
||||
nomem: lda #$FF ; Error code for sure not used by MLI
|
||||
oserr: sta __oserror
|
||||
oserr: sta ___oserror
|
||||
|
||||
; Save total blocks for failure
|
||||
lda #$00
|
||||
@ -85,7 +85,7 @@ oserr: sta __oserror
|
||||
; Check for non-ProDOS disk
|
||||
check: cmp #$52 ; "Not a ProDOS volume"
|
||||
bne oserr
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
|
||||
; Save total blocks for a 16-sector disk
|
||||
lda #<280
|
||||
|
@ -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
|
||||
|
@ -19,8 +19,8 @@ typerr: lda #$4A ; "Incompatible file format"
|
||||
; Cleanup name
|
||||
oserr: jsr popname ; Preserves A
|
||||
|
||||
; Set __oserror
|
||||
jmp __mappederrno
|
||||
; Set ___oserror
|
||||
jmp ___mappederrno
|
||||
|
||||
_exec:
|
||||
; Save cmdline
|
||||
|
@ -52,7 +52,7 @@ _clock_getres:
|
||||
enosys: lda #ENOSYS
|
||||
|
||||
; Set __errno
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
.rodata
|
||||
|
||||
|
@ -81,13 +81,13 @@ erange: lda #ERANGE
|
||||
jsr incsp3 ; Preserves A
|
||||
|
||||
; Set __errno
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
; Cleanup stack
|
||||
oserr: jsr incsp3 ; Preserves A
|
||||
|
||||
; Set __oserror
|
||||
jmp __mappederrno
|
||||
; Set ___oserror
|
||||
jmp ___mappederrno
|
||||
|
||||
.bss
|
||||
|
||||
|
@ -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
|
||||
; Set ___oserror
|
||||
oserr: jsr ___mappederrno ; leaves -1 in AX
|
||||
stx sreg ; extend return value to 32 bits
|
||||
stx sreg+1
|
||||
rts
|
||||
|
@ -64,7 +64,7 @@ _open:
|
||||
errno: jsr incsp4 ; Preserves A
|
||||
|
||||
; Set __errno
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
; Save fdtab slot
|
||||
found: tya
|
||||
@ -147,8 +147,8 @@ oserr1: ldy tmp2 ; Restore fdtab slot
|
||||
jsr freebuffer
|
||||
pla ; Restore oserror code
|
||||
|
||||
; Set __oserror
|
||||
jmp __mappederrno
|
||||
; Set ___oserror
|
||||
jmp ___mappederrno
|
||||
|
||||
open: ldy tmp2 ; Restore fdtab slot
|
||||
|
||||
@ -209,7 +209,7 @@ done: lda tmp1 ; Restore fd
|
||||
|
||||
; Return success
|
||||
ldx #$00
|
||||
stx __oserror
|
||||
stx ___oserror
|
||||
rts
|
||||
|
||||
freebuffer:
|
||||
|
@ -1,14 +1,14 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 17.05.2000
|
||||
;
|
||||
; int __fastcall__ _osmaperrno (unsigned char oserror);
|
||||
; int __fastcall__ __osmaperrno (unsigned char oserror);
|
||||
;
|
||||
|
||||
.export __osmaperrno
|
||||
.export ___osmaperrno
|
||||
|
||||
.include "errno.inc"
|
||||
|
||||
__osmaperrno:
|
||||
___osmaperrno:
|
||||
ldx #ErrTabSize
|
||||
: cmp ErrTab-2,x ; Search for the error code
|
||||
beq :+ ; Jump if found
|
||||
|
@ -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
|
||||
|
@ -52,7 +52,7 @@ _read:
|
||||
|
||||
; Device succeeds always
|
||||
device: lda #$00
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
|
||||
; Set counter to zero
|
||||
sta ptr3
|
||||
@ -107,4 +107,4 @@ check: lda ptr3
|
||||
einval: lda #EINVAL
|
||||
|
||||
; Set __errno
|
||||
errno: jmp __directerrno
|
||||
errno: jmp ___directerrno
|
||||
|
@ -49,10 +49,10 @@ 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
|
||||
|
||||
; Set __oserror
|
||||
oserr: jmp __mappederrno
|
||||
; Set ___oserror
|
||||
oserr: jmp ___mappederrno
|
||||
|
@ -68,4 +68,4 @@ enosys: lda #ENOSYS
|
||||
erange: lda #ERANGE
|
||||
|
||||
; Set __errno
|
||||
errno: jmp __directerrno
|
||||
errno: jmp ___directerrno
|
||||
|
@ -107,8 +107,8 @@ done: lda #$00
|
||||
einval: lda #EINVAL
|
||||
|
||||
; Set __errno
|
||||
errno: jmp __directerrno
|
||||
errno: jmp ___directerrno
|
||||
|
||||
; Set __oserror
|
||||
oserr: jmp __mappederrno
|
||||
; Set ___oserror
|
||||
oserr: jmp ___mappederrno
|
||||
|
||||
|
@ -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
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
.include "atari.inc"
|
||||
.export _close
|
||||
.import __do_oserror,popax,__oserror
|
||||
.import __do_oserror,popax,___oserror
|
||||
.import fdtoiocb_down,__inviocb
|
||||
|
||||
.proc _close
|
||||
@ -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
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
;
|
||||
|
||||
.export _dio_phys_to_log
|
||||
.import popax,__oserror
|
||||
.import popax,___oserror
|
||||
.importzp ptr1,ptr2,ptr3
|
||||
.include "atari.inc"
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
ldx #0
|
||||
txa
|
||||
ret:
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
rts ; return success
|
||||
|
||||
; invalid handle
|
||||
|
@ -17,7 +17,7 @@
|
||||
.export _dio_log_to_phys
|
||||
.include "atari.inc"
|
||||
.importzp ptr1,ptr2,ptr3
|
||||
.import popax,popptr1,__oserror
|
||||
.import popax,popptr1,___oserror
|
||||
|
||||
.proc _dio_log_to_phys
|
||||
|
||||
@ -56,7 +56,7 @@ _l1: lda (ptr1,x)
|
||||
|
||||
txa
|
||||
ret:
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
rts ; return success
|
||||
|
||||
; invalid handle
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
.export _dio_open, _dio_close
|
||||
.export sectsizetab
|
||||
.import __oserror, __sio_call, _dio_read
|
||||
.import ___oserror, __sio_call, _dio_read
|
||||
.import pushax, addysp, subysp
|
||||
.importzp ptr2, sp
|
||||
.include "atari.inc"
|
||||
@ -31,7 +31,7 @@ sectsizetab:
|
||||
|
||||
_inv_drive:
|
||||
lda #NONDEV ; non-existent device
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
lda #0
|
||||
tax
|
||||
rts ; return NULL
|
||||
@ -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
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
.include "atari.inc"
|
||||
.export _dio_query_sectsize
|
||||
.importzp ptr1,tmp1
|
||||
.import popax, __oserror
|
||||
.import popax, ___oserror
|
||||
|
||||
.proc _dio_query_sectsize
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
stx ptr1+1
|
||||
|
||||
lda #0
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
|
||||
ldy #sst_sectsize+1
|
||||
lda (ptr1),y
|
||||
|
@ -1,5 +1,5 @@
|
||||
;
|
||||
; __do_oserror updates __oserror and errno. Do a JMP here right after
|
||||
; __do_oserror updates ___oserror and errno. Do a JMP here right after
|
||||
; calling CIOV. It will return with AX set to -1 ($FFFF). It expects the CIO
|
||||
; status in Y.
|
||||
;
|
||||
@ -9,4 +9,4 @@
|
||||
|
||||
__do_oserror:
|
||||
tya
|
||||
jmp __mappederrno
|
||||
jmp ___mappederrno
|
||||
|
@ -34,7 +34,7 @@ notsupp:lda #ENOSYS ; "unsupported system call"
|
||||
.byte $2C ; bit opcode, eats the next 2 bytes
|
||||
noiocb: lda #EMFILE ; "too many open files"
|
||||
jsr incsp2 ; clean up stack
|
||||
seterr: jmp __directerrno
|
||||
seterr: jmp ___directerrno
|
||||
|
||||
|
||||
; entry point
|
||||
@ -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
|
||||
|
@ -41,7 +41,7 @@ _clock_getres:
|
||||
enosys: lda #ENOSYS
|
||||
|
||||
; Set __errno
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; timespec struct with tv_sec set to 1 second
|
||||
|
@ -105,7 +105,7 @@ errexit:jsr incsp3 ; Preserves A
|
||||
|
||||
; set __errno
|
||||
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
; -------
|
||||
|
||||
|
@ -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 #<EMFILE ; "too many open files"
|
||||
seterr: jsr __mappederrno ; @@@ probably not correct to set errno here @@@
|
||||
seterr: jsr ___mappederrno ; @@@ probably not correct to set errno here @@@
|
||||
rts ; return -1
|
||||
|
||||
;invmode:ldx #>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
|
||||
|
@ -7,4 +7,4 @@
|
||||
|
||||
__inviocb:
|
||||
lda #<EINVAL
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
.export _lseek
|
||||
.import incsp6,__oserror
|
||||
.import incsp6,___oserror
|
||||
.import __inviocb,ldax0sp,ldaxysp,fdtoiocb
|
||||
.import __dos_type
|
||||
.import fd_table
|
||||
@ -21,7 +21,7 @@
|
||||
; seeking not supported, return -1 and ENOSYS errno value
|
||||
no_supp:jsr incsp6
|
||||
lda #<ENOSYS
|
||||
jsr __directerrno ; returns with $FFFF in AX
|
||||
jsr ___directerrno ; returns with $FFFF in AX
|
||||
sta sreg
|
||||
sta sreg+1
|
||||
rts
|
||||
@ -94,7 +94,7 @@ xxerr: tya
|
||||
pha
|
||||
jsr incsp6
|
||||
pla
|
||||
jsr __mappederrno ; returns with $FFFF in AX
|
||||
jsr ___mappederrno ; returns with $FFFF in AX
|
||||
sta sreg
|
||||
sta sreg+1
|
||||
rts
|
||||
|
@ -19,7 +19,7 @@
|
||||
.import findfreeiocb
|
||||
.import incsp4
|
||||
.import ldaxysp,addysp
|
||||
.import __oserror
|
||||
.import ___oserror
|
||||
.ifdef UCASE_FILENAME
|
||||
.import ucase_fn
|
||||
.endif
|
||||
@ -37,7 +37,7 @@ parmok: jsr findfreeiocb
|
||||
beq iocbok ; we found one
|
||||
|
||||
lda #<EMFILE ; "too many open files"
|
||||
seterr: jsr __directerrno
|
||||
seterr: jsr ___directerrno
|
||||
jsr incsp4 ; clean up stack
|
||||
lda #$FF
|
||||
tax
|
||||
@ -150,11 +150,11 @@ finish: php
|
||||
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
|
||||
|
||||
ok: lda tmp2 ; get fd
|
||||
ldx #0
|
||||
stx __oserror
|
||||
stx ___oserror
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -2,13 +2,13 @@
|
||||
; Christian Groessler, May-2000
|
||||
;
|
||||
; os specific error code mapping
|
||||
; int __fastcall__ _osmaperrno (unsigned char oserror);
|
||||
; int __fastcall__ __osmaperrno (unsigned char oserror);
|
||||
;
|
||||
|
||||
.include "errno.inc"
|
||||
.export __osmaperrno
|
||||
.export ___osmaperrno
|
||||
|
||||
.proc __osmaperrno
|
||||
.proc ___osmaperrno
|
||||
|
||||
cmp #$80 ; error or success
|
||||
bcs errcode ; error, jump
|
||||
|
@ -4,7 +4,7 @@
|
||||
.include "atari.inc"
|
||||
.export _opendir, _readdir, _closedir
|
||||
.import findfreeiocb, clriocb
|
||||
.import __oserror, return0, __do_oserror
|
||||
.import ___oserror, return0, __do_oserror
|
||||
.importzp ptr1, tmp1
|
||||
.ifdef DEFAULT_DEVICE
|
||||
.import __defdev
|
||||
@ -56,13 +56,13 @@
|
||||
jsr CIOV
|
||||
bmi cioerr
|
||||
lda #0
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
tax
|
||||
lda diriocb
|
||||
rts
|
||||
.endproc
|
||||
|
||||
cioerr: sty __oserror
|
||||
cioerr: sty ___oserror
|
||||
lda #CLOSE
|
||||
sta ICCOM,x
|
||||
jsr CIOV ; close IOCB again since open failed
|
||||
@ -147,7 +147,7 @@ copychar: lda (ptr1),y ; src=y dest=tmp1
|
||||
jsr CIOV
|
||||
bmi @cioerr
|
||||
ldx #0
|
||||
stx __oserror ; clear system specific error code
|
||||
stx ___oserror ; clear system specific error code
|
||||
txa
|
||||
rts
|
||||
@cioerr: jmp __do_oserror
|
||||
|
@ -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
|
||||
|
@ -5,7 +5,7 @@
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.import __rwsetup,__do_oserror,__inviocb,__oserror
|
||||
.import __rwsetup,__do_oserror,__inviocb,___oserror
|
||||
.export _read
|
||||
|
||||
_read: jsr __rwsetup ; do common setup for read and write
|
||||
@ -33,7 +33,7 @@ done: lda ICBLL,x ; buf len lo
|
||||
lda ICBLH,x ; get buf len hi
|
||||
tax ; to X
|
||||
okdone: lda #0
|
||||
sta __oserror ; clear system dependend error code
|
||||
sta ___oserror ; clear system dependend error code
|
||||
pla ; get buf len lo
|
||||
rts
|
||||
|
||||
|
@ -96,4 +96,4 @@ done: jmp return0
|
||||
; load errno code
|
||||
|
||||
enosys: lda #ENOSYS
|
||||
drcter: jmp __directerrno
|
||||
drcter: jmp ___directerrno
|
||||
|
@ -17,7 +17,7 @@
|
||||
.export __sio_call
|
||||
.include "atari.inc"
|
||||
.import popa,popax,popptr1
|
||||
.import sectsizetab,__oserror
|
||||
.import sectsizetab,___oserror
|
||||
.importzp ptr1
|
||||
|
||||
.proc __sio_call
|
||||
@ -76,7 +76,7 @@ _cont: lda #DISKID ; SIO bus ID of diskette drive
|
||||
bmi _req_err ; error occurred
|
||||
txa ; no error occurred
|
||||
_req_err:
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
rts
|
||||
|
||||
_inv_hand:
|
||||
|
@ -2,7 +2,7 @@
|
||||
; int __fastcall__ write (int fd, const void* buf, unsigned count);
|
||||
;
|
||||
.include "atari.inc"
|
||||
.import __rwsetup,__do_oserror,__inviocb,__oserror
|
||||
.import __rwsetup,__do_oserror,__inviocb,___oserror
|
||||
.export _write
|
||||
_write:
|
||||
jsr __rwsetup ; do common setup
|
||||
@ -21,7 +21,7 @@ write9:
|
||||
lda ICBLH,x ; buf len high
|
||||
tax
|
||||
lda #0
|
||||
sta __oserror ; clear system dependend error code
|
||||
sta ___oserror ; clear system dependend error code
|
||||
pla
|
||||
rts
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
;
|
||||
; 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
|
||||
ldx #>EUNKNOWN
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 #<ERANGE
|
||||
jsr __directerrno
|
||||
jsr ___directerrno
|
||||
fail: lda #0 ; Return NULL
|
||||
tax
|
||||
rts
|
||||
@ -52,7 +52,7 @@ fail: lda #0 ; Return NULL
|
||||
|
||||
okay: lda fnunit ; Set by diskinit
|
||||
jsr devicestr ; Returns 0 in A
|
||||
sta __oserror ; Clear _oserror
|
||||
sta ___oserror ; Clear __oserror
|
||||
|
||||
; Success, return buf
|
||||
|
||||
|
@ -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 #<EIO
|
||||
sta __errno
|
||||
stx __errno+1 ; X is zero
|
||||
sta ___errno
|
||||
stx ___errno+1 ; X is zero
|
||||
bne L1 ; Branch always
|
||||
|
||||
|
||||
|
@ -94,10 +94,10 @@ parmok: jsr popax ; Get flags
|
||||
|
||||
lda #EINVAL
|
||||
|
||||
; Error entry. Sets _errno, clears _oserror, returns -1
|
||||
; Error entry. Sets _errno, clears __oserror, returns -1
|
||||
|
||||
seterrno:
|
||||
jmp __directerrno
|
||||
jmp ___directerrno
|
||||
|
||||
; Error entry: Close the file and exit. OS error code is in A on entry
|
||||
|
||||
@ -113,7 +113,7 @@ closeandexit:
|
||||
|
||||
; Error entry: Set oserror and errno using error code in A and return -1
|
||||
|
||||
oserror:jmp __mappederrno
|
||||
oserror:jmp ___mappederrno
|
||||
|
||||
; Read bit is set. Add an 'r' to the name
|
||||
|
||||
@ -189,7 +189,7 @@ nofile: ; ... else use SA=0 (read)
|
||||
|
||||
txa ; Handle
|
||||
ldx #0
|
||||
stx __oserror ; Clear _oserror
|
||||
stx ___oserror ; Clear __oserror
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -2,7 +2,7 @@
|
||||
; 2000-05-17, Ullrich von Bassewitz
|
||||
; 2014-05-28, Greg King
|
||||
;
|
||||
; int __fastcall__ _osmaperrno (unsigned char oserror);
|
||||
; int __fastcall__ __osmaperrno (unsigned char oserror);
|
||||
; /* Map a system-specific error into a system-independent code. */
|
||||
;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
.code
|
||||
|
||||
__osmaperrno:
|
||||
___osmaperrno:
|
||||
ldx #ErrTabSize
|
||||
@L1: cmp ErrTab-2,x ; Search for the error code
|
||||
beq @L2 ; Jump if found
|
||||
|
@ -66,7 +66,7 @@
|
||||
|
||||
jsr CHKIN
|
||||
bcc @L3 ; Branch if ok
|
||||
jmp __mappederrno ; Store into __oserror, map to errno, return -1
|
||||
jmp ___mappederrno ; Store into ___oserror, map to errno, return -1
|
||||
|
||||
; Read the next byte
|
||||
|
||||
@ -123,10 +123,10 @@
|
||||
|
||||
done: jsr CLRCH
|
||||
|
||||
; Clear _oserror and return the number of chars read
|
||||
; Clear __oserror and return the number of chars read
|
||||
|
||||
eof: lda #0
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
lda ptr3
|
||||
ldx ptr3+1
|
||||
rts
|
||||
@ -141,7 +141,7 @@ devnotpresent:
|
||||
|
||||
invalidfd:
|
||||
lda #EBADF
|
||||
jmp __directerrno ; Sets _errno, clears _oserror, returns -1
|
||||
jmp ___directerrno ; Sets _errno, clears __oserror, returns -1
|
||||
|
||||
.endproc
|
||||
|
||||
|
@ -126,7 +126,7 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
|
||||
}
|
||||
|
||||
/* Something went wrong when parsing the directory entry */
|
||||
_errno = EIO;
|
||||
__errno = EIO;
|
||||
exitpoint:
|
||||
return 0;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@
|
||||
|
||||
jsr CKOUT
|
||||
bcc @L2
|
||||
@error: jmp __mappederrno ; Store into __oserror, map to errno, return -1
|
||||
@error: jmp ___mappederrno ; Store into ___oserror, map to errno, return -1
|
||||
|
||||
; Output the next character from the buffer
|
||||
|
||||
@ -92,10 +92,10 @@
|
||||
|
||||
@L3: jsr CLRCH
|
||||
|
||||
; Clear _oserror and return the number of chars written
|
||||
; Clear __oserror and return the number of chars written
|
||||
|
||||
lda #0
|
||||
sta __oserror
|
||||
sta ___oserror
|
||||
lda ptr3
|
||||
ldx ptr3+1
|
||||
rts
|
||||
@ -112,6 +112,6 @@ devnotpresent:
|
||||
|
||||
invalidfd:
|
||||
lda #EBADF
|
||||
jmp __directerrno ; Sets _errno, clears _oserror, returns -1
|
||||
jmp ___directerrno ; Sets _errno, clears __oserror, returns -1
|
||||
|
||||
.endproc
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
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);
|
||||
|
@ -10,14 +10,14 @@
|
||||
.macpack cpu
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; 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.
|
||||
; */
|
||||
|
||||
__directerrno:
|
||||
jsr __seterrno ; Set errno (returns with .A = 0)
|
||||
sta __oserror ; Clear __oserror
|
||||
___directerrno:
|
||||
jsr ___seterrno ; Set errno (returns with .A = 0)
|
||||
sta ___oserror ; Clear ___oserror
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
dec a
|
||||
.else
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
invmode:
|
||||
lda #EINVAL
|
||||
jsr __seterrno ; Set __errno, returns zero in A
|
||||
jsr ___seterrno ; Set __errno, returns zero in A
|
||||
tax ; a/x = 0
|
||||
jmp incsp4
|
||||
|
||||
@ -91,7 +91,7 @@ modeok: ldy #$00
|
||||
bne openok
|
||||
cmp #$FF
|
||||
bne openok
|
||||
jmp return0 ; Failure, errno/_oserror already set
|
||||
jmp return0 ; Failure, errno/__oserror already set
|
||||
|
||||
; Open call succeeded
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
||||
|
@ -11,19 +11,19 @@
|
||||
.macpack cpu
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; 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.
|
||||
; */
|
||||
|
||||
__mappederrno:
|
||||
sta __oserror ; Store the error code
|
||||
___mappederrno:
|
||||
sta ___oserror ; Store the error code
|
||||
tax ; Did we have an error?
|
||||
bze ok ; Branch if no
|
||||
jsr __osmaperrno ; Map OS error into errno code
|
||||
jsr __seterrno ; Save in errno (returns with .A = 0)
|
||||
jsr ___osmaperrno ; Map OS error into errno code
|
||||
jsr ___seterrno ; Save in errno (returns with .A = 0)
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
dec a
|
||||
.else
|
||||
|
@ -1,14 +1,14 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 16.05.2000
|
||||
;
|
||||
; extern unsigned char _oserror;
|
||||
; extern unsigned char __oserror;
|
||||
; /* Operating system specific errors from the low level functions */
|
||||
|
||||
|
||||
.export __oserror
|
||||
.export ___oserror
|
||||
|
||||
.bss
|
||||
|
||||
__oserror:
|
||||
___oserror:
|
||||
.res 1
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-05-13
|
||||
;
|
||||
; __seterrno: Will set __errno to the value in A and return zero in A. Other
|
||||
; ___seterrno: Will set ___errno to the value in A and return zero in A. Other
|
||||
; registers aren't changed. The function is C callable, but
|
||||
; currently only called from asm code.
|
||||
;
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
.code
|
||||
|
||||
.proc __seterrno
|
||||
.proc ___seterrno
|
||||
|
||||
sta __errno
|
||||
sta ___errno
|
||||
lda #0
|
||||
sta __errno+1
|
||||
sta ___errno+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
||||
; Error, no space left
|
||||
|
||||
@Error: lda #ENOSPC ; No space left
|
||||
jsr __seterrno
|
||||
jsr ___seterrno
|
||||
ldx #$FF ; Return -1
|
||||
txa
|
||||
rts
|
||||
|
@ -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
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
.export _chdir
|
||||
|
||||
.import __syschdir
|
||||
.import __mappederrno
|
||||
.import ___mappederrno
|
||||
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
@ -17,7 +17,7 @@
|
||||
.proc _chdir
|
||||
|
||||
jsr __syschdir ; Call the machine specific function
|
||||
jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
|
||||
jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
|
||||
|
||||
.endproc
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
; 2003-08-12, Ullrich von Bassewitz
|
||||
; 2015-09-24, Greg King
|
||||
;
|
||||
; extern int _errno;
|
||||
; extern int __errno;
|
||||
; /* Library errors go here. */
|
||||
;
|
||||
|
||||
@ -10,5 +10,5 @@
|
||||
|
||||
.bss
|
||||
|
||||
__errno:
|
||||
___errno:
|
||||
.word 0
|
||||
|
@ -31,7 +31,7 @@
|
||||
; File is not open
|
||||
|
||||
lda #EINVAL
|
||||
jsr __seterrno
|
||||
jsr ___seterrno
|
||||
lda #$FF ; Return -1
|
||||
tax
|
||||
rts
|
||||
|
@ -78,7 +78,7 @@ err: rts
|
||||
; If the file is not valid, fileno must set errno and return -1
|
||||
|
||||
error: lda #<EBADF
|
||||
jsr __seterrno
|
||||
jsr ___seterrno
|
||||
lda #$FF
|
||||
tax
|
||||
rts
|
||||
|
@ -36,7 +36,7 @@
|
||||
; Failed to allocate a file stream
|
||||
|
||||
lda #EMFILE
|
||||
jsr __seterrno ; Set __errno, will return 0 in A
|
||||
jsr ___seterrno ; Set __errno, will return 0 in A
|
||||
tax
|
||||
rts ; Return zero
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
; File not open or in error state
|
||||
|
||||
@L1: lda #EINVAL
|
||||
jsr __seterrno ; Set __errno, return zero in A
|
||||
jsr ___seterrno ; Set __errno, return zero in A
|
||||
tax ; a/x = 0
|
||||
jmp @L99 ; Bail out
|
||||
|
||||
|
@ -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
|
||||
|
@ -39,7 +39,7 @@
|
||||
; File not open
|
||||
|
||||
@L1: lda #EBADF
|
||||
jsr __seterrno ; Returns with A = 0
|
||||
jsr ___seterrno ; Returns with A = 0
|
||||
tax ; A = X = 0
|
||||
jmp incsp6
|
||||
|
||||
|
@ -51,7 +51,7 @@ loop: dec ptr2
|
||||
|
||||
overflow:
|
||||
lda #<ERANGE
|
||||
jsr __seterrno ; Returns 0 in A
|
||||
jsr ___seterrno ; Returns 0 in A
|
||||
tax ; Return zero
|
||||
rts
|
||||
|
||||
|
@ -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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user