[gforth] / gforth / libffi.fs  

gforth: gforth/libffi.fs

Diff for /gforth/libffi.fs between version 1.28 and 1.32

version 1.28, Sat Aug 9 21:26:21 2008 UTC version 1.32, Sun Dec 27 01:00:52 2009 UTC
Line 24 
Line 24 
 c-library libffi  c-library libffi
 s" ffi" add-lib  s" ffi" add-lib
   
   \ The ffi.h of XCode needs the following line, and it should not hurt elsewhere
   \c #define MACOSX
 include-ffi.h-string save-c-prefix-line \ #include <ffi.h>  include-ffi.h-string save-c-prefix-line \ #include <ffi.h>
 \c extern Cell *gforth_RP;  \c #include <stdio.h>
 \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 #ifndef HAS_BACKLINK
   \c static void **saved_gforth_pointers;
   \c #endif
 \c typedef void *Label;  \c typedef void *Label;
 \c typedef Label *Xt;  \c typedef Label *Xt;
 \c Label *gforth_engine(Xt *ip, Cell *sp, Cell *rp0, Float *fp, unsigned char *lp);  
 \c static void gforth_callback_ffi(ffi_cif * cif, void * resp, void ** args, void * ip)  \c static void gforth_callback_ffi(ffi_cif * cif, void * resp, void ** args, void * ip)
 \c {  \c {
   \c #ifndef HAS_BACKLINK
   \c   void **gforth_pointers = saved_gforth_pointers;
   \c #endif
   \c   {
 \c   Cell *rp1 = gforth_RP;  \c   Cell *rp1 = gforth_RP;
 \c   Cell *sp = gforth_SP;  \c   Cell *sp = gforth_SP;
 \c   Float *fp = gforth_FP;  \c   Float *fp = gforth_FP;
Line 44 
Line 51 
 \c   gforth_clist = args;  \c   gforth_clist = args;
 \c   gforth_ritem = resp;  \c   gforth_ritem = resp;
 \c  \c
 \c   gforth_engine((Xt *)ip, sp, rp1, fp, lp);  \c     gforth_engine((Xt *)ip, sp, rp1, fp, lp, gforth_UP);
 \c  \c
 \c   /* restore global variables */  \c   /* restore global variables */
 \c   gforth_RP = rp1;  \c   gforth_RP = rp1;
Line 54 
Line 61 
 \c   gforth_clist = clist;  \c   gforth_clist = clist;
 \c   gforth_ritem = ritem;  \c   gforth_ritem = ritem;
 \c }  \c }
   \c }
   
 \c static void* ffi_types[] =  \c static void* ffi_types[] =
 \c     { &ffi_type_void,  \c     { &ffi_type_void,
Line 75 
Line 83 
 \c                        (ffi_type *)rtype, (ffi_type **)atypes)  \c                        (ffi_type *)rtype, (ffi_type **)atypes)
 c-function ffi-prep-cif ffi_prep_cif1 a n a a -- n  c-function ffi-prep-cif ffi_prep_cif1 a n a a -- n
   
   \c #ifdef HAS_BACKLINK
   \c #define ffi_call1(a_avalues, a_rvalue ,a_ip ,a_cif) \
   \c             ffi_call((ffi_cif *)a_cif, (void(*)())a_ip, \
   \c                      (void *)a_rvalue, (void **)a_avalues)
   \c #else
 \c #define ffi_call1(a_avalues, a_rvalue ,a_ip ,a_cif) \  \c #define ffi_call1(a_avalues, a_rvalue ,a_ip ,a_cif) \
   \c             (saved_gforth_pointers = gforth_pointers), \
 \c             ffi_call((ffi_cif *)a_cif, (void(*)())a_ip, \  \c             ffi_call((ffi_cif *)a_cif, (void(*)())a_ip, \
 \c                      (void *)a_rvalue, (void **)a_avalues)  \c                      (void *)a_rvalue, (void **)a_avalues)
   \c #endif
 c-function ffi-call ffi_call1 a a a a -- void  c-function ffi-call ffi_call1 a a a a -- void
   
 \c #define ffi_prep_closure1(a_ip, a_cif, a_closure) \  \c #define ffi_prep_closure1(a_ip, a_cif, a_closure) \
Line 216 
Line 231 
     here thisproc @ 2 cells + ! parse-name s,      here thisproc @ 2 cells + ! parse-name s,
     thislib @ thisproc @ @proc ;      thislib @ thisproc @ @proc ;
   
   : func@ >body cell+ @ ;
   : func' ' func@ ;
   : [func'] postpone ['] postpone func@ ; immediate restrict
   
 \ stuff for libffi  \ stuff for libffi
   
 \ libffi uses a parameter array for the input  \ libffi uses a parameter array for the input
Line 255 
Line 274 
 : sf>x  ( -- r )  retbuf sf@ ;  : sf>x  ( -- r )  retbuf sf@ ;
 : df>x  ( -- r )  retbuf df@ ;  : df>x  ( -- r )  retbuf df@ ;
   
 wordlist constant cifs  table constant cifs
   
 Variable cifbuf $40 allot \ maximum: 64 parameters  Variable cifbuf $40 allot \ maximum: 64 parameters
 : cifreset  cifbuf cell+ cifbuf ! ;  : cifreset  cifbuf cell+ cifbuf ! ;


Generate output suitable for use with a patch program
Legend:
Removed from v.1.28  
changed lines
  Added in v.1.32

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help