1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Changes from Oliver: Use posix_memalign instead of _aligned_malloc

git-svn-id: svn://svn.cc65.org/cc65/trunk@3589 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2005-08-26 12:09:43 +00:00
parent 1bc775d21d
commit 6871cc6c57

View File

@ -12,8 +12,8 @@
.import pushname, popname
.import errnoexit, oserrexit
.import __aligned_malloc, _free
.import addysp, incsp4, pushax, popax
.import _posix_memalign, _free
.import addysp, incsp4, incaxy, pushax, popax
.include "zeropage.inc"
.include "errno.inc"
@ -48,12 +48,11 @@ _open:
cpy #MAX_FDS * .sizeof(FD)
bcc :-
; Load errno codes
lda #ENOMEM ^ EMFILE
enomem: eor #ENOMEM
; Load errno code
lda #EMFILE
; Cleanup stack
jsr incsp4 ; Preserves A
errno: jsr incsp4 ; Preserves A
; Return errno
jmp errnoexit
@ -63,24 +62,24 @@ found: tya
pha
; Alloc I/O buffer
lda #<(fdtab + FD::BUFFER)
ldx #>(fdtab + FD::BUFFER)
jsr incaxy
jsr pushax
lda #$00
ldx #>$0400
jsr pushax ; Preserves A
ldx #>$0100
jsr __aligned_malloc
jsr pushax ; Preserves A
ldx #>$0400
jsr _posix_memalign
tay ; Save errno code
; Restore fdtab slot
pla
tay
sta tmp2 ; Save fdtab slot
; Get and check I/O buffer high byte
txa
beq enomem
; Set I/O buffer high byte (low byte remains zero)
sta fdtab + FD::BUFFER+1,y
sty tmp2 ; Save fdtab slot
; Check for error
tya ; Restore errno code
bne errno
; Get and save flags
jsr popax