mirror of
https://github.com/cc65/cc65.git
synced 2024-07-23 18:29:47 +00:00
Change handling of errno/seterrno to new behaviour. By Maciej Witkowiak.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4791 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
3eed1bffbc
commit
103af67585
@ -191,7 +191,7 @@ geoslib:
|
|||||||
AS=../$(AS) \
|
AS=../$(AS) \
|
||||||
AR=../$(AR) \
|
AR=../$(AR) \
|
||||||
LD=../$(LD) \
|
LD=../$(LD) \
|
||||||
AFLAGS="-t geos -I../../../asminc" \
|
AFLAGS="-t geos --forget-inc-paths -I../../../asminc" \
|
||||||
CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../../include" \
|
CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../../include" \
|
||||||
$(MAKE) -C geos || exit 1
|
$(MAKE) -C geos || exit 1
|
||||||
for i in em joystick tgi conio common runtime zlib; do \
|
for i in em joystick tgi conio common runtime zlib; do \
|
||||||
@ -199,7 +199,7 @@ geoslib:
|
|||||||
AS=$(AS) \
|
AS=$(AS) \
|
||||||
LD=$(LD) \
|
LD=$(LD) \
|
||||||
AR=$(AR) \
|
AR=$(AR) \
|
||||||
AFLAGS="-t geos -I../../asminc" \
|
AFLAGS="-t geos --forget-inc-paths -I../../asminc" \
|
||||||
CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../include" \
|
CFLAGS="-Osir -g -T -t geos --forget-inc-paths -I. -I../../include" \
|
||||||
$(MAKE) SYS=geos -C $$i || exit 1; \
|
$(MAKE) SYS=geos -C $$i || exit 1; \
|
||||||
for objfile in $$i/*.o; do \
|
for objfile in $$i/*.o; do \
|
||||||
|
@ -14,6 +14,7 @@ FILEDES = 3 ; first free to use file descriptor
|
|||||||
|
|
||||||
.include "../inc/geossym.inc"
|
.include "../inc/geossym.inc"
|
||||||
.include "../inc/const.inc"
|
.include "../inc/const.inc"
|
||||||
|
.include "errno.inc"
|
||||||
.include "fcntl.inc"
|
.include "fcntl.inc"
|
||||||
|
|
||||||
.importzp ptr1, ptr2, ptr3, tmp1
|
.importzp ptr1, ptr2, ptr3, tmp1
|
||||||
@ -58,7 +59,7 @@ _open:
|
|||||||
ldx ptr1+1
|
ldx ptr1+1
|
||||||
jsr _FindFile ; try to find the file
|
jsr _FindFile ; try to find the file
|
||||||
tax
|
tax
|
||||||
bne @error
|
bne @oserror
|
||||||
|
|
||||||
lda dirEntryBuf + OFF_DE_TR_SC ; tr&se for ReadByte (r1)
|
lda dirEntryBuf + OFF_DE_TR_SC ; tr&se for ReadByte (r1)
|
||||||
sta f_track
|
sta f_track
|
||||||
@ -71,19 +72,25 @@ _open:
|
|||||||
ldx #0 ; offset for ReadByte (r5)
|
ldx #0 ; offset for ReadByte (r5)
|
||||||
stx f_offset
|
stx f_offset
|
||||||
stx f_offset+1
|
stx f_offset+1
|
||||||
|
lda #0 ; clear errors
|
||||||
|
sta __oserror
|
||||||
|
jsr __seterrno
|
||||||
lda #FILEDES ; return fd
|
lda #FILEDES ; return fd
|
||||||
sta filedesc
|
sta filedesc
|
||||||
rts
|
rts
|
||||||
@badmode:
|
@badmode:
|
||||||
|
lda #EINVAL ; invalid parameters - invalid open mode
|
||||||
|
.byte $2c ; skip
|
||||||
@alreadyopen:
|
@alreadyopen:
|
||||||
lda #70 ; no channel
|
lda #EMFILE ; too many opened files (there can be only one)
|
||||||
sta __oserror
|
jmp __directerrno ; set errno, clear oserror, return -1
|
||||||
@error:
|
@oserror:
|
||||||
lda #$ff
|
jmp __mappederrno ; set platform error code, return -1
|
||||||
tax
|
|
||||||
rts
|
|
||||||
|
|
||||||
_close:
|
_close:
|
||||||
|
lda #0
|
||||||
|
sta __oserror
|
||||||
|
jsr __seterrno ; clear errors
|
||||||
lda #0 ; clear fd
|
lda #0 ; clear fd
|
||||||
sta filedesc
|
sta filedesc
|
||||||
tax
|
tax
|
||||||
@ -104,14 +111,21 @@ _read:
|
|||||||
sta ptr2
|
sta ptr2
|
||||||
stx ptr2+1 ; buffer ptr
|
stx ptr2+1 ; buffer ptr
|
||||||
jsr popax
|
jsr popax
|
||||||
cmp #FILEDES
|
cmp #FILEDES ; lo-byte == FILEDES
|
||||||
bne @notopen
|
bne @filenotopen
|
||||||
txa
|
txa ; hi-byte == 0
|
||||||
bne @notopen ; fd must be == FILEDES
|
beq @fileok ; fd must be == FILEDES
|
||||||
|
|
||||||
|
@filenotopen:
|
||||||
|
lda #EBADF
|
||||||
|
jmp __directerrno ; Sets _errno, clears _oserror, returns -1
|
||||||
|
|
||||||
|
@fileok:
|
||||||
lda #0
|
lda #0
|
||||||
sta ptr3
|
sta ptr3
|
||||||
sta ptr3+1 ; put 0 into ptr3 (number of bytes read)
|
sta ptr3+1 ; put 0 into ptr3 (number of bytes read)
|
||||||
|
sta __oserror ; clear error flags
|
||||||
|
jsr __seterrno
|
||||||
|
|
||||||
lda f_track ; restore stuff for ReadByte
|
lda f_track ; restore stuff for ReadByte
|
||||||
ldx f_sector
|
ldx f_sector
|
||||||
@ -143,8 +157,8 @@ _read:
|
|||||||
@L2: lda __oserror ; was there error ?
|
@L2: lda __oserror ; was there error ?
|
||||||
beq @L3
|
beq @L3
|
||||||
cmp #BFR_OVERFLOW ; EOF?
|
cmp #BFR_OVERFLOW ; EOF?
|
||||||
bne @error
|
beq @done ; yes, we're done
|
||||||
beq @done
|
jmp __mappederrno ; no, we're screwed
|
||||||
|
|
||||||
@L3: inc ptr1 ; decrement the count
|
@L3: inc ptr1 ; decrement the count
|
||||||
bne @L0
|
bne @L0
|
||||||
@ -169,14 +183,6 @@ _read:
|
|||||||
ldx ptr3+1
|
ldx ptr3+1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@notopen:
|
|
||||||
lda #61 ; File not open
|
|
||||||
@error:
|
|
||||||
sta __oserror
|
|
||||||
lda #$ff
|
|
||||||
tax
|
|
||||||
rts
|
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
filedesc: .res 1 ; file open flag - 0 (no file opened) or 1
|
filedesc: .res 1 ; file open flag - 0 (no file opened) or 1
|
||||||
f_track: .res 1 ; values preserved for ReadByte
|
f_track: .res 1 ; values preserved for ReadByte
|
||||||
|
Loading…
Reference in New Issue
Block a user