--- gforth/libffi.fs 2008/06/01 12:18:56 1.21 +++ gforth/libffi.fs 2008/08/09 21:26:21 1.28 @@ -1,6 +1,6 @@ \ libffi.fs shared library support package 14aug05py -\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006,2007 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006,2007,2008 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -21,13 +21,12 @@ \ note that the API functions have their arguments reversed and other \ deviations. -require libcc.fs +c-library libffi +s" ffi" add-lib -clear-libs s" ffi" add-lib - -\c #include -\c static Cell *gforth_RP; -\c static unsigned char *gforth_LP; +include-ffi.h-string save-c-prefix-line \ #include +\c extern Cell *gforth_RP; +\c extern unsigned char *gforth_LP; \c static void **gforth_clist; \c static void *gforth_ritem; \c typedef void *Label; @@ -142,6 +141,7 @@ c-function ffi-ret-float1 ffi_ret_float1 \c #define ffi_ret_double1(r) (*(double *)(gforth_ritem) = r) c-function ffi-ret-double1 ffi_ret_double1 r -- void : ffi-ret-double ( r -- ) ffi-ret-double1 ffi-ret-void ; +end-c-library \ common stuff, same as fflib.fs @@ -335,6 +335,7 @@ also c-decl definitions ' >dl+ ' >dl- 6 argtype dlong ' >sf+ ' >sf- 9 argtype sf ' >df+ ' >df- &10 argtype df +: ints 0 ?DO int LOOP ; ' noop 0 rettype (void) ' is>x 6 rettype (int) @@ -422,6 +423,7 @@ also cb-decl definitions ' ffi-arg-longlong 8 argtype' llong ' ffi-arg-dlong 6 argtype' dlong ' ffi-arg-ptr &12 argtype' ptr +: ints ( n -- ) 0 ?DO postpone int LOOP ; immediate ' ffi-ret-void 0 rettype' (void) ' ffi-ret-int 6 rettype' (int)