2015-09-25 18:06:58 +00:00
|
|
|
;
|
|
|
|
; 2003-08-12, Ullrich von Bassewitz
|
|
|
|
; 2015-09-24, Greg King
|
|
|
|
;
|
|
|
|
; Helper function for several high-level file functions.
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "errno.inc"
|
|
|
|
|
|
|
|
.macpack generic
|
|
|
|
.macpack cpu
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
2022-08-28 19:52:53 +00:00
|
|
|
; int __fastcall__ __mappederrno (unsigned char code);
|
|
|
|
; /* Set __oserror to the given platform-specific error code. If it is a real
|
2015-09-25 18:06:58 +00:00
|
|
|
; ** error code (not zero), set errno to the corresponding system error code,
|
|
|
|
; ** and return -1. Otherwise, return zero.
|
|
|
|
; ** Used by the library.
|
|
|
|
; */
|
|
|
|
|
2022-08-28 19:52:53 +00:00
|
|
|
___mappederrno:
|
2022-08-28 20:37:33 +00:00
|
|
|
sta ___oserror ; Store the error code
|
2015-09-25 18:06:58 +00:00
|
|
|
tax ; Did we have an error?
|
|
|
|
bze ok ; Branch if no
|
2022-08-28 20:37:33 +00:00
|
|
|
jsr ___osmaperrno ; Map OS error into errno code
|
|
|
|
jsr ___seterrno ; Save in errno (returns with .A = 0)
|
2015-09-25 18:06:58 +00:00
|
|
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
|
|
|
dec a
|
|
|
|
.else
|
|
|
|
lda #$FF ; Return -1 if error
|
|
|
|
.endif
|
|
|
|
tax
|
|
|
|
ok: rts
|