1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel namespaces make math sequences layouts
4 alien.c-types alien.structs cpu.architecture ;
7 : large-struct? ( ctype -- ? )
8 dup c-struct? [ struct-small-enough? not ] [ drop f ] if ;
10 : alien-parameters ( params -- seq )
12 swap return>> large-struct? [ "void*" prefix ] when ;
14 : alien-return ( params -- ctype )
15 return>> dup large-struct? [ drop "void" ] when ;
17 : c-type-stack-align ( type -- align )
18 dup c-type-stack-align? [ c-type-align ] [ drop cell ] if ;
20 : parameter-align ( n type -- n delta )
21 [ c-type-stack-align align dup ] [ drop ] 2bi - ;
23 : parameter-sizes ( types -- total offsets )
24 #! Compute stack frame locations.
27 [ parameter-align drop dup , ] keep stack-size +