| \ libffi.fs shared library support package 14aug05py |
\ 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. |
\ This file is part of Gforth. |
| |
|
| \ note that the API functions have their arguments reversed and other |
\ note that the API functions have their arguments reversed and other |
| \ deviations. |
\ deviations. |
| |
|
| require libcc.fs |
|
| |
|
| c-library libffi |
c-library libffi |
| s" ffi" add-lib |
s" ffi" add-lib |
| |
|
| |
s" os-type" environment? [IF] s" darwin" string-prefix? |
| |
[IF] |
| |
\c #define MACOSX |
| |
\c #include <ffi/ffi.h> |
| |
[ELSE] |
| |
\c #include <ffi.h> |
| |
[THEN] |
| |
[ELSE] |
| \c #include <ffi.h> |
\c #include <ffi.h> |
| \c static Cell *gforth_RP; |
[THEN] |
| \c static unsigned char *gforth_LP; |
\c extern Cell *gforth_RP; |
| |
\c extern unsigned char *gforth_LP; |
| \c static void **gforth_clist; |
\c static void **gforth_clist; |
| \c static void *gforth_ritem; |
\c static void *gforth_ritem; |
| \c typedef void *Label; |
\c typedef void *Label; |
| ' ffi-arg-longlong 8 argtype' llong |
' ffi-arg-longlong 8 argtype' llong |
| ' ffi-arg-dlong 6 argtype' dlong |
' ffi-arg-dlong 6 argtype' dlong |
| ' ffi-arg-ptr &12 argtype' ptr |
' ffi-arg-ptr &12 argtype' ptr |
| |
: ints ( n -- ) 0 ?DO postpone int LOOP ; immediate |
| |
|
| ' ffi-ret-void 0 rettype' (void) |
' ffi-ret-void 0 rettype' (void) |
| ' ffi-ret-int 6 rettype' (int) |
' ffi-ret-int 6 rettype' (int) |