;
-; __do_oserror updates __oserror. Do a JMP here right after calling
-; CIOV. It will return with AX set to -1 ($FFFF). It expects the CIO
+; __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.
-;
-; __retminus is a routine whitch returns with AX set to -1 ($FFFF).
;
.include "errno.inc"
- .export __do_oserror, __retminus
+ .export __do_oserror
__do_oserror:
- sty __oserror ; save os dependent error code
-__retminus:
- lda #$FF
- tax ; return -1
- rts
+ tya
+ jmp __mappederrno
beq iocbok ; we found one
lda #<EMFILE ; "too many open files"
-seterr: jsr __seterrno
- lda #$FF
- tax
+seterr: jsr __mappederrno ; @@@ probably not correct to set errno here @@@
rts ; return -1
;invmode:ldx #>EINVAL
; set EINVAL error code and returns -1
;
.include "errno.inc"
- .import __retminus
.export __inviocb
__inviocb:
lda #<EINVAL
- jsr __seterrno
- jmp __retminus ; return -1
+ jmp __directerrno
; seeking not supported, return -1 and ENOSYS errno value
no_supp:jsr incsp6
lda #<ENOSYS
- jsr __seterrno ; set __errno, return zero in A
- sta __oserror
- lda #$FF
- tax
+ jsr __directerrno ; returns with $FFFF in AX
sta sreg
sta sreg+1
rts
bpl l01
; error returned from CIO
-xxerr: sty __oserror
- bmi iocberr
+xxerr: tya
+ pha
+ jsr incsp6
+ pla
+ jsr __mappederrno ; returns with $FFFF in AX
+ sta sreg
+ sta sreg+1
+ rts
; check for offset 0, SEEK_CUR (get current position)
cont: ldy #3
.import clriocb
.import fddecusage,newfd
.import findfreeiocb
- .import __do_oserror,incsp4
+ .import incsp4
.import ldaxysp,addysp
.import __oserror
.importzp tmp4,tmp2
beq iocbok ; we found one
lda #<EMFILE ; "too many open files"
-seterr: jsr __seterrno
+seterr: jsr __directerrno
jsr incsp4 ; clean up stack
lda #$FF
tax
bpl ok
jsr fddecusage ; decrement usage counter of fd as open failed
- jmp __do_oserror
+ tya ; put error code into A
+ jmp __mappederrno
ok: lda tmp2 ; get fd
ldx #0