Adding allocate and free.
This commit is contained in:
@ -35,8 +35,10 @@ typedef uint64_t udcell_t;
|
||||
X("OVER", OP_OVER, DUP; tos = sp[-1]) \
|
||||
X("DROP", OP_DROP, DROP) \
|
||||
X("@", OP_AT, tos = *(cell_t *) tos) \
|
||||
X("L@", OP_LAT, tos = *(int32_t *) tos) \
|
||||
X("C@", OP_CAT, tos = *(uint8_t *) tos) \
|
||||
X("!", OP_STORE, *(cell_t *) tos = *sp; --sp; DROP) \
|
||||
X("L!", OP_LSTORE, *(int32_t *) tos = *sp; --sp; DROP) \
|
||||
X("C!", OP_CSTORE, *(uint8_t *) tos = *sp; --sp; DROP) \
|
||||
X("FILL", OP_FILL, memset((void *) sp[-1], tos, *sp); sp -= 2; DROP) \
|
||||
X("MOVE", OP_MOVE, memmove((void *) sp[-1], (void *) *sp, tos); sp -= 2; DROP) \
|
||||
|
||||
@ -47,7 +47,7 @@ CORE
|
||||
0= 0< + UM/MOD */MOD
|
||||
AND OR XOR
|
||||
DUP SWAP OVER DROP
|
||||
@ C@ ! C! FILL MOVE
|
||||
@ L@ C@ ! L! C! FILL MOVE
|
||||
SP@ SP! RP@ RP! >R R> R@
|
||||
EXECUTE BRANCH 0BRANCH DONEXT DOLIT
|
||||
ALITERAL CELL
|
||||
|
||||
@ -21,6 +21,12 @@ z" write" 3 sysfunc write
|
||||
z" lseek" 3 sysfunc lseek
|
||||
z" exit" 1 sysfunc sysexit
|
||||
z" fork" 0 sysfunc fork
|
||||
z" mmap" 6 sysfunc mmap
|
||||
z" munmap" 2 sysfunc munmap
|
||||
|
||||
( Errno )
|
||||
z" __errno_location" 0 sysfunc __errno_location
|
||||
: errno ( -- n ) __errno_location l@ ;
|
||||
|
||||
( Default Pipes )
|
||||
0 constant stdin
|
||||
@ -56,3 +62,13 @@ z" fork" 0 sysfunc fork
|
||||
: posix-bye 0 sysexit ;
|
||||
' posix-bye is bye
|
||||
|
||||
( I/O Error Helpers )
|
||||
: 0ior ( n -- n ior ) dup 0= if errno else 0 then ;
|
||||
|
||||
( Words with OS assist )
|
||||
z" malloc" 1 sysfunc malloc
|
||||
z" free" 1 sysfunc sysfree
|
||||
z" realloc" 2 sysfunc realloc
|
||||
: allocate ( n -- a ior ) malloc 0ior ;
|
||||
: free ( a -- ior ) sysfree 0 ;
|
||||
: resize ( a n -- a ior ) realloc 0ior ;
|
||||
|
||||
Reference in New Issue
Block a user