From 1bfd39ee20cd2f94156d3c3140cd45135c55822b Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 9 Jul 2013 23:39:42 +0200 Subject: [PATCH 1/2] close IOCB if open failed -- otherwise is is still marked as "in use" --- libsrc/atari/graphics.s | 11 ++++++++--- libsrc/atari/open.s | 8 ++++++-- libsrc/atari/posixdirent.s | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s index 60f2ff789..1c6856296 100644 --- a/libsrc/atari/graphics.s +++ b/libsrc/atari/graphics.s @@ -10,7 +10,7 @@ .export __graphics .import findfreeiocb - .import __do_oserror,__oserror + .import __oserror .import fddecusage .import clriocb .import fdtoiocb @@ -96,8 +96,13 @@ doopen: txa stx __oserror rts -cioerr: jsr fddecusage ; decrement usage counter of fd as open failed - jmp __do_oserror +cioerr: sty tmp3 ; remember error code + lda #CLOSE + sta ICCOM,x + 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 .endproc ; __graphics diff --git a/libsrc/atari/open.s b/libsrc/atari/open.s index 8aeff9ed4..306cf52c2 100644 --- a/libsrc/atari/open.s +++ b/libsrc/atari/open.s @@ -140,8 +140,12 @@ finish: php plp bpl ok - jsr fddecusage ; decrement usage counter of fd as open failed - tya ; put error code into A + sty tmp3 ; remember error code + lda #CLOSE + sta ICCOM,x + 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 ok: lda tmp2 ; get fd diff --git a/libsrc/atari/posixdirent.s b/libsrc/atari/posixdirent.s index 3417e4bfc..a722b3b06 100644 --- a/libsrc/atari/posixdirent.s +++ b/libsrc/atari/posixdirent.s @@ -63,6 +63,9 @@ .endproc cioerr: sty __oserror + lda #CLOSE + sta ICCOM,x + jsr CIOV ; close IOCB again since open failed jmp return0 .proc _readdir From cf7f7b9ef2a73e564fb68d4b33b605b3af1067ca Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 10 Jul 2013 02:37:09 -0400 Subject: [PATCH 2/2] Fixed ld65's precalculation of memory-area sizes. Before this fix, BSS-type and ZP-type segments never were counted. Now, they are counted if their memory areas are filled. (It must be done because their places in the output file are filled.) The fix allows us to build programs for the CBM510 and CBM610 platforms. We won't see an "Internal error" diagnostic message about a bad file-offset. --- src/ld65/config.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ld65/config.c b/src/ld65/config.c index 76518cafd..a5d6ff39b 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2012, Ullrich von Bassewitz */ +/* (c) 1998-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -1959,8 +1959,11 @@ unsigned CfgProcess (void) /* Calculate the new address */ Addr += S->Seg->Size; - /* If this segment goes out to the file, increase the file size */ - if ((S->Flags & SF_BSS) == 0 && S->Load == M) { + /* If this segment will go out to the file, or its place + * in the file will be filled, then increase the file size. + */ + if (S->Load == M && + ((S->Flags & SF_BSS) == 0 || (M->Flags & MF_FILL) != 0)) { M->F->Size += Addr - StartAddr; }