--- gforth/struct.fs 1994/02/11 16:30:47 1.1 +++ gforth/struct.fs 1994/07/29 11:16:26 1.2 @@ -1,4 +1,4 @@ -\ $Id: struct.fs,v 1.1 1994/02/11 16:30:47 anton Exp $ +\ $Id: struct.fs,v 1.2 1994/07/29 11:16:26 anton Exp $ \ Usage example: \ @@ -12,15 +12,6 @@ \ 1 cells: field enum-method \ end-struct ext-wordlist-map \ with the fields search-method,...,enum-method -\ 2, 2constant and nalign should be somewhere else -: 2, ( w1 w2 -- ) - here 2 cells allot 2! ; - -: 2constant ( w1 w2 -- ) - create 2, - does> ( -- w1 w2 ) - 2@ ; - : nalign ( addr1 n -- addr2 ) \ addr2 is the aligned version of addr1 wrt the alignment size n 1- tuck + swap invert and ; @@ -61,4 +52,15 @@ \ dfloats 1 dfloats ; \ \ : sfloats: ( n -- size align ) -\ sfloats 1 sfloats ; \ No newline at end of file +\ sfloats 1 sfloats ; + +: struct-align ( size align -- ) + dp @ swap nalign dp ! + drop ; + +: struct-allot ( size align -- addr ) + over swap struct-align + here swap allot ; + +: struct-allocate ( size align -- addr ) + drop allocate ;