[gambit-list] Calling Scheme procedure from C

Marc Feeley feeley at iro.umontreal.ca
Fri Nov 13 10:50:21 EST 2015


The structure “setup_params” contains parameters for the runtime system (e.g. the system version number, the size of the heap, the default character encoding for I/O, the debugging level).  And it also contains the program’s “linker”, a function which represents the set of Scheme modules that are part of the program.

A call to ___setup_params_reset will give default values to all the parameters in setup_params.  Then the parameters in setup_params that don’t have a default value are set explicitly with assignments (here the “version” and the “linker”).

The call to ___setup is what starts the execution of the Scheme code.  It uses the parameters in setup_params to allocate the heap, the stack, the symbol table, etc.  Then it executes sequentially each module of the program.  When ___setup returns, the Scheme code is finished executing.  Note that it is still possible after that to call Scheme functions defined with c-define.  Finally a call to ___cleanup reclaims the heap and other resources that were allocated by ___setup.

Marc

> On Nov 13, 2015, at 9:48 AM, Vijay Mathew <vijay.the.lisper at gmail.com> wrote:
> 
> I found this code in examples/pthread/pthread.c:
> 
>  ___setup_params_struct setup_params;
> 
>   ___setup_params_reset (&setup_params);
> 
>   setup_params.version = ___VERSION;
>   setup_params.linker  = SCHEME_LIBRARY_LINKER;
> 
>   ___setup (&setup_params);
> 
> What does ___setup_params_reset and ___setup do?
> 
> Thanks,
> 
> --Vijay
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list