<html lang="en"> <head> <title>GCL Specific - GCL SI Manual</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GCL SI Manual"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="prev" href="Type.html#Type" title="Type"> <link rel="next" href="C-Interface.html#C-Interface" title="C Interface"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="GCL-Specific"></a> <p> Next: <a rel="next" accesskey="n" href="C-Interface.html#C-Interface">C Interface</a>, Previous: <a rel="previous" accesskey="p" href="Type.html#Type">Type</a>, Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> <hr> </div> <h2 class="chapter">15 GCL Specific</h2> <div class="defun"> — Function: <b>SYSTEM</b> (<var>string</var>)<var><a name="index-SYSTEM-755"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Executes a Shell command as if STRING is an input to the Shell. Not all versions of GCL support this function. At least on POSIX systems, this call should return two integers represeting the exit status and any possible terminating signal respectively. </blockquote></div> <div class="defun"> — Variable: <b>*TMP-DIR*</b><var><a name="index-g_t_002aTMP_002dDIR_002a-756"></a></var><br> <blockquote><p>Package:COMPILER GCL specific: Directory in which temporary “gazonk” files used by the compiler are to be created. </blockquote></div> <div class="defun"> — Variable: <b>*IGNORE-MAXIMUM-PAGES*</b><var><a name="index-g_t_002aIGNORE_002dMAXIMUM_002dPAGES_002a-757"></a></var><br> <blockquote><p>Package:SI GCL specific: Tells the GCL memory manager whether (non-NIL) or not (NIL) it should expand memory whenever the maximum allocatable pages have been used up. </blockquote></div> <div class="defun"> — Variable: <b>*OPTIMIZE-MAXIMUM-PAGES*</b><var><a name="index-g_t_002aOPTIMIZE_002dMAXIMUM_002dPAGES_002a-758"></a></var><br> <blockquote><p>Package:SI <p>GCL specific: Tells the GCL memory manager whether to attempt to adjust the maximum allowable pages for each type to approximately optimize the garbage collection load in the current process. Defaults to T. Set to NIL if you care more about memory usage than runtime. </blockquote></div> <div class="defun"> — Function: <b>MACHINE-VERSION</b> ()<var><a name="index-MACHINE_002dVERSION-759"></a></var><br> <blockquote><p>Package:LISP <p>Returns a string that identifies the machine version of the machine on which GCL is currently running. </blockquote></div> <div class="defun"> — Function: <b>BY</b> ()<var><a name="index-BY-760"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Exits from GCL. </blockquote></div> <div class="defun"> — Macro: <b>DEFCFUN</b><var><a name="index-DEFCFUN-761"></a></var><br> <blockquote><p>Package:LISP <p>Syntax: <pre class="example"> (defcfun header n {element}*) </pre> <p>GCL specific: Defines a C-language function which calls Lisp functions and/or handles Lisp objects. HEADER gives the header of the C function as a string. Non-negative-integer is the number of the main stack entries used by the C function, primarily for protecting Lisp objects from being garbage-collected. Each ELEMENT may give a C code fragment as a string, or it may be a list ((symbol {arg}*) {place}*) which, when executed, calls the Lisp function named by SYMBOL with the specified arguments and saves the value(s) to the specified places. The DEFCFUN form has the above meanings only after compiled; The GCL interpreter simply ignores this form. <p>An example which defines a C function list2 of two arguments, but which calls the 'lisp' function CONS by name, and refers to the constant 'NIL. Note to be loaded by <code>load</code> the function should be static. <p>(defCfun "static object list2(x,y) object x,y;" 0 "object z;" ('NIL z) ((CONS y z) z) ((CONS x z) z) "return(z);" ) <p>In lisp the operations in the body would be (setq z 'nil) (setq z (cons y z)) (setq z (cons x z)) <p>Syntax: <pre class="example"> (defCfun header non-negative-integer { string | ( function-symbol { value }* ) | (( function-symbol { value }* ) { place }* ) }) value: place: { C-expr | ( C-type C-expr ) } C-function-name: C-expr: { string | symbol } C-type: { object | int | char | float | double } </pre> </blockquote></div> <div class="defun"> — Macro: <b>CLINES</b><var><a name="index-CLINES-762"></a></var><br> <blockquote><p>Package:LISP <p>Syntax: <pre class="example"> (clines {string}*) </pre> <p>GCL specific: The GCL compiler embeds STRINGs into the intermediate C language code. The interpreter ignores this form. </blockquote></div> <div class="defun"> — Function: <b>ALLOCATE</b> (<var>type number &optional </var>(<var>really-allocate nil</var>))<var><a name="index-ALLOCATE-763"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Sets the maximum number of pages for the type class of the GCL implementation type TYPE to NUMBER. If REALLY-ALLOCATE is given a non-NIL value, then the specified number of pages will be allocated immediately. </blockquote></div> <div class="defun"> — Function: <b>GBC</b> (<var>x</var>)<var><a name="index-GBC-764"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Invokes the garbage collector (GC) with the collection level specified by X. NIL as the argument causes GC to collect cells only. T as the argument causes GC to collect everything. </blockquote></div> <div class="defun"> — Function: <b>SAVE</b> (<var>pathname</var>)<var><a name="index-SAVE-765"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Saves the current GCL core image into a program file specified by PATHNAME. This function depends on the version of GCL. The function si::save-system is to be preferred in almost all circumstances. Unlike save, it makes the relocatable section permanent, and causes no future gc of currently loaded .o files. </blockquote></div> <div class="defun"> — Function: <b>HELP*</b> (<var>string &optional </var>(<var>package 'lisp</var>))<var><a name="index-HELP_002a-766"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Prints the documentation associated with those symbols in the specified package whose print names contain STRING as substring. STRING may be a symbol, in which case the print-name of that symbol is used. If PACKAGE is NIL, then all packages are searched. </blockquote></div> <div class="defun"> — Macro: <b>DEFLA</b><var><a name="index-DEFLA-767"></a></var><br> <blockquote><p>Package:LISP <p>Syntax: <pre class="example"> (defla name lambda-list {decl | doc}* {form}*) </pre> <p>GCL specific: Used to DEFine Lisp Alternative. For the interpreter, DEFLA is equivalent to DEFUN, but the compiler ignores this form. </blockquote></div> <div class="defun"> — Function: <b>PROCLAMATION</b> (<var>decl-spec</var>)<var><a name="index-PROCLAMATION-768"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Returns T if the specified declaration is globally in effect; NIL otherwise. See the doc of DECLARE for possible DECL-SPECs. </blockquote></div> <div class="defun"> — Macro: <b>DEFENTRY</b><var><a name="index-DEFENTRY-769"></a></var><br> <blockquote><p>Package:LISP <p>Syntax: <pre class="example"> (defentry name arg-types c-function) </pre> <p>GCL specific: The compiler defines a Lisp function whose body consists of a calling sequence to the C language function specified by C-FUNCTION. The interpreter ignores this form. The ARG-TYPES specifies the C types of the arguments which C-FUNCTION requires. The list of allowed types is (object char int float double string). Code will be produced to coerce from a lisp object to the appropriate type before passing the argument to the C-FUNCTION. The c-function should be of the form (c-result-type c-fname) where c-result-type is a member of (void object char int float double string). c-fname may be a symbol (in which case it will be downcased) or a string. If c-function is not a list, then (object c-function) is assumed. In order for C code to be loaded in by <code>load</code> you should declare any variables and functions to be static. If you will link them in at build time, of course you are allowed to define new externals. <pre class="example"> Sample usage: --File begin----- ;; JOE takes X a lisp string and Y a fixnum and returns a character. (clines "#include \"foo.ch\"") (defentry joe (string int) (char "our_c_fun")) ---File end------ ---File foo.ch--- /* C function for extracting the i'th element of a string */ static char our_c_fun(p,i) char *p; int i; { return p[i]; } -----File end--- </pre> <p>One must be careful of storage allocation issues when passing a string. If the C code invokes storage allocation (either by calling <code>malloc</code> or <code>make_cons</code> etc), then there is a possibility of a garbage collection, so that if the string passed was not constructed with <code>:static t</code> when its array was constructed, then it could move. If the C function may allocate storage, then you should pass a copy: <pre class="example"> (defun safe-c-string (x) (let* ((n (length x)) (a (make-array (+ n 1) :element-type 'string-char :static t :fill-pointer n))) (si::copy-array-portion x y 0 0 n) (setf (aref a n) (code-char 0))) a) </pre> </blockquote></div> <div class="defun"> — Function: <b>COPY-ARRAY-PORTION</b> (<var>x,y,i1,i2,n1</var>)<var><a name="index-COPY_002dARRAY_002dPORTION-770"></a></var><br> <blockquote><p>Package:SI Copy elements from X to Y starting at X[i1] to Y[i2] and doing N1 elements if N1 is supplied otherwise, doing the length of X - I1 elements. If the types of the arrays are not the same, this has implementation dependent results. </p></blockquote></div> <div class="defun"> — Function: <b>BYE</b> (<var> &optional </var>(<var>exit-status 0</var>))<var><a name="index-BYE-771"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: Exits from GCL with exit-status. </blockquote></div> <div class="defun"> — Function: <b>USE-FAST-LINKS</b> (<var>turn-on</var>)<var><a name="index-USE_002dFAST_002dLINKS-772"></a></var><br> <blockquote><p>Package:LISP <p>GCL specific: If TURN-ON is not nil, the fast link mechanism is enabled, so that ordinary function calls will not appear in the invocation stack, and calls will be much faster. This is the default. If you anticipate needing to see a stack trace in the debugger, then you should turn this off. </blockquote></div> <ul class="menu"> <li><a accesskey="1" href="Bignums.html#Bignums">Bignums</a> </ul> </body></html>