mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2026-04-26 22:17:45 +00:00
Implement memalignment (C23).
Note that this returns the actual alignment of the address, which can be greater than what can be used with alignas. In IIGS-specific code, it could be used to test for page or bank alignment.
This commit is contained in:
1 parent
374022f4bf
commit
52a6cd1b41
1 file changed
+34
+34
@@ -778,6 +778,40 @@ ret stx n
|
||||
creturn 2:n
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* size_t memalignment(const void *p)
|
||||
*
|
||||
* Inputs:
|
||||
* p - a pointer
|
||||
*
|
||||
* Outputs:
|
||||
* The maximum alignment satisfied by p.
|
||||
*
|
||||
****************************************************************
|
||||
*
|
||||
memalignment start
|
||||
|
||||
csubroutine (4:p)
|
||||
|
||||
lda p compute alignment = p & -p
|
||||
beq lb1
|
||||
eor #$ffff
|
||||
inc a
|
||||
and p
|
||||
sta p
|
||||
stz p+2
|
||||
bra ret
|
||||
|
||||
lb1 lda p+2
|
||||
eor #$ffff
|
||||
inc a
|
||||
and p+2
|
||||
sta p+2
|
||||
|
||||
ret creturn 4:p
|
||||
end
|
||||
|
||||
****************************************************************
|
||||
*
|
||||
* void qsort(base, count, size, compar)
|
||||
|
||||
Reference in new issue
Block a user