change %ALLOT to return the aligned address of the data structure
This commit is contained in:
parent
21eb4fafc4
commit
688fe7369e
13
startup.4th
13
startup.4th
|
|
@ -1451,9 +1451,16 @@ VARIABLE TOTAL
|
||||||
: ENDSTRUCT ( align offset "<spaces?>name" -- )
|
: ENDSTRUCT ( align offset "<spaces?>name" -- )
|
||||||
OVER ALIGNED-TO 2CONSTANT ;
|
OVER ALIGNED-TO 2CONSTANT ;
|
||||||
|
|
||||||
|
\ Accessors for type descriptors
|
||||||
|
: %SIZEOF ( align size -- size ) NIP ;
|
||||||
|
: %ALIGNOF ( align size -- align ) DROP ;
|
||||||
|
|
||||||
\ Reserve data or heap space for a data structure given alignment and size
|
\ Reserve data or heap space for a data structure given alignment and size
|
||||||
: %ALLOT ( align bytes -- a-addr ) SWAP ALIGN-TO ALLOT ;
|
\ It is assumed that ALLOCATE (but not ALLOT) returns an address suitably
|
||||||
: %ALLOCATE ( align bytes -- a-addr ) NIP ALLOCATE ;
|
\ aligned for any primitive data type; %ALLOCATE is not suitable for data
|
||||||
|
\ structures with unusually high alignment requirements
|
||||||
|
: %ALLOT ( align bytes -- a-addr ) SWAP ALIGN-TO HERE SWAP ALLOT ;
|
||||||
|
: %ALLOCATE ( align bytes -- a-addr ) %SIZEOF ALLOCATE ;
|
||||||
|
|
||||||
>>SYSTEM
|
>>SYSTEM
|
||||||
|
|
||||||
|
|
@ -1821,7 +1828,7 @@ ENDSTRUCT termios%
|
||||||
|
|
||||||
>>SYSTEM
|
>>SYSTEM
|
||||||
|
|
||||||
CREATE SCRATCH-TERMIOS termios% %ALLOT
|
termios% %ALLOT CONSTANT SCRATCH-TERMIOS
|
||||||
|
|
||||||
>>FORTH
|
>>FORTH
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue