]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/errno.s
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / common / errno.s
index 1ab84539748b84864451fb530eb09b06c1805967..2ab1ad86beeabec2f00c455ae7e3bd0794988945 100644 (file)
@@ -1,31 +1,45 @@
 ;
-; Ullrich von Bassewitz, 06.06.1998
+; Ullrich von Bassewitz, 2003-08-12
 ;
-; int _errno;
-;
-; void _maperrno(void);
-; /* Map an OS error to a system independent error code */
+; Helper functions for several high level file functions.
 ;
 
-       .export         __maperrno
-       .export         __errno
-       .import         __oserror
-       .import         __osmaperrno
 
+        .include        "errno.inc"
 
 .code
 
-__maperrno:
-       lda     __oserror               ; Get the error code
-       beq     @L1                     ; Jump if no error
-       ldx     #$00                    ; Clear error
-       stx     __oserror
-       jsr     __osmaperrno            ; Map the code
-               sta     __errno
-       stx     __errno+1
-@L1:   rts
-
-
+; ----------------------------------------------------------------------------
+; 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
+        beq     fail                    ; Branch always
+
+; ----------------------------------------------------------------------------
+; 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
+        tax                             ; Did we have an error?
+        beq     ok                      ; Branch if no
+        jsr     __osmaperrno            ; Map os error into errno code
+        jsr     __seterrno              ; Save in errno
+fail:   lda     #$FF                    ; Return -1
+        tax
+ok:     rts
+
+
+; ----------------------------------------------------------------------------
 .bss
 
 __errno: