~ubuntu-branches/ubuntu/vivid/gcl/vivid

« back to all changes in this revision

Viewing changes to info/gcl-si/GCL-Specific.html

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2014-05-16 17:41:33 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: package-import@ubuntu.com-20140516174133-czs0uktsjj2vkhxk
2.6.11preĀ testĀ 11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<html>
 
3
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
 
4
<head>
 
5
<title>GCL SI Manual: GCL Specific</title>
 
6
 
 
7
<meta name="description" content="GCL SI Manual: GCL Specific">
 
8
<meta name="keywords" content="GCL SI Manual: GCL Specific">
 
9
<meta name="resource-type" content="document">
 
10
<meta name="distribution" content="global">
 
11
<meta name="Generator" content="makeinfo">
 
12
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 
13
<link href="index.html#Top" rel="start" title="Top">
 
14
<link href="Function-and-Variable-Index.html#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
 
15
<link href="Function-and-Variable-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
 
16
<link href="index.html#Top" rel="up" title="Top">
 
17
<link href="Bignums.html#Bignums" rel="next" title="Bignums">
 
18
<link href="Type.html#Type" rel="prev" title="Type">
 
19
<style type="text/css">
 
20
<!--
 
21
a.summary-letter {text-decoration: none}
 
22
blockquote.smallquotation {font-size: smaller}
 
23
div.display {margin-left: 3.2em}
 
24
div.example {margin-left: 3.2em}
 
25
div.indentedblock {margin-left: 3.2em}
 
26
div.lisp {margin-left: 3.2em}
 
27
div.smalldisplay {margin-left: 3.2em}
 
28
div.smallexample {margin-left: 3.2em}
 
29
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
 
30
div.smalllisp {margin-left: 3.2em}
 
31
kbd {font-style:oblique}
 
32
pre.display {font-family: inherit}
 
33
pre.format {font-family: inherit}
 
34
pre.menu-comment {font-family: serif}
 
35
pre.menu-preformatted {font-family: serif}
 
36
pre.smalldisplay {font-family: inherit; font-size: smaller}
 
37
pre.smallexample {font-size: smaller}
 
38
pre.smallformat {font-family: inherit; font-size: smaller}
 
39
pre.smalllisp {font-size: smaller}
 
40
span.nocodebreak {white-space:nowrap}
 
41
span.nolinebreak {white-space:nowrap}
 
42
span.roman {font-family:serif; font-weight:normal}
 
43
span.sansserif {font-family:sans-serif; font-weight:normal}
 
44
ul.no-bullet {list-style: none}
 
45
-->
 
46
</style>
 
47
 
 
48
 
 
49
</head>
 
50
 
 
51
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
 
52
<a name="GCL-Specific"></a>
 
53
<div class="header">
 
54
<p>
 
55
Next: <a href="C-Interface.html#C-Interface" accesskey="n" rel="next">C Interface</a>, Previous: <a href="Type.html#Type" accesskey="p" rel="prev">Type</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Function-and-Variable-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Variable-Index.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
 
56
</div>
 
57
<hr>
 
58
<a name="GCL-Specific-1"></a>
 
59
<h2 class="chapter">15 GCL Specific</h2>
 
60
 
 
61
<dl>
 
62
<dt><a name="index-SYSTEM"></a>Function: <strong>SYSTEM</strong> <em>(string)</em></dt>
 
63
<dd><p>Package:LISP
 
64
</p>
 
65
<p>GCL specific: Executes a Shell command as if STRING is an input to the
 
66
Shell.  Not all versions of GCL support this function.  At least on
 
67
POSIX systems, this call should return two integers represeting the
 
68
exit status and any possible terminating signal respectively.
 
69
</p>
 
70
 
 
71
</dd></dl>
 
72
 
 
73
<dl>
 
74
<dt><a name="index-_002aTMP_002dDIR_002a"></a>Variable: <strong>*TMP-DIR*</strong></dt>
 
75
<dd><p>Package:COMPILER
 
76
GCL specific: Directory in which temporary &ldquo;gazonk&rdquo; files used by the
 
77
compiler are to be created.
 
78
</p>
 
79
 
 
80
</dd></dl>
 
81
 
 
82
<dl>
 
83
<dt><a name="index-_002aIGNORE_002dMAXIMUM_002dPAGES_002a"></a>Variable: <strong>*IGNORE-MAXIMUM-PAGES*</strong></dt>
 
84
<dd><p>Package:SI
 
85
GCL specific: Tells the GCL memory manager whether (non-NIL) or not (NIL) it
 
86
should expand memory whenever the maximum allocatable pages have been used
 
87
up.
 
88
</p>
 
89
 
 
90
</dd></dl>
 
91
 
 
92
<dl>
 
93
<dt><a name="index-_002aOPTIMIZE_002dMAXIMUM_002dPAGES_002a"></a>Variable: <strong>*OPTIMIZE-MAXIMUM-PAGES*</strong></dt>
 
94
<dd><p>Package:SI
 
95
</p>
 
96
<p>GCL specific: Tells the GCL memory manager whether to attempt to
 
97
adjust the maximum allowable pages for each type to approximately
 
98
optimize the garbage collection load in the current process.  Defaults
 
99
to T.  Set to NIL if you care more about memory usage than runtime.
 
100
</p>
 
101
 
 
102
</dd></dl>
 
103
 
 
104
<dl>
 
105
<dt><a name="index-MACHINE_002dVERSION"></a>Function: <strong>MACHINE-VERSION</strong> <em>()</em></dt>
 
106
<dd><p>Package:LISP
 
107
</p>
 
108
<p>Returns a string that identifies the machine version of the machine
 
109
on which GCL is currently running.
 
110
</p>
 
111
 
 
112
</dd></dl>
 
113
 
 
114
<dl>
 
115
<dt><a name="index-BY"></a>Function: <strong>BY</strong> <em>()</em></dt>
 
116
<dd><p>Package:LISP
 
117
</p>
 
118
<p>GCL specific: Exits from GCL.
 
119
</p>
 
120
 
 
121
</dd></dl>
 
122
 
 
123
<dl>
 
124
<dt><a name="index-DEFCFUN"></a>Macro: <strong>DEFCFUN</strong></dt>
 
125
<dd><p>Package:LISP
 
126
</p>
 
127
<p>Syntax:
 
128
</p><div class="example">
 
129
<pre class="example">(defcfun header n {element}*)
 
130
</pre></div>
 
131
 
 
132
 
 
133
<p>GCL specific: Defines a C-language function which calls Lisp functions
 
134
and/or handles Lisp objects.  HEADER gives the header of the C
 
135
function as a string.  Non-negative-integer is the number of the main
 
136
stack entries used by the C function, primarily for protecting Lisp
 
137
objects from being garbage-collected.  Each ELEMENT may give a C code
 
138
fragment as a string, or it may be a list
 
139
        ((symbol {arg}*) {place}*)
 
140
which, when executed, calls the Lisp function named by SYMBOL with the
 
141
specified arguments and saves the value(s) to the specified places.
 
142
The DEFCFUN form has the above meanings only after compiled;  The GCL
 
143
interpreter simply ignores this form.
 
144
</p>
 
145
<p>An example which defines a C function list2 of two arguments, but which 
 
146
calls the &rsquo;lisp&rsquo; function CONS by name, and refers to the constant &rsquo;NIL.
 
147
Note to be loaded by <code>load</code> the function should be static.
 
148
</p>
 
149
 
 
150
<p>(defCfun &quot;static object list2(x,y) object x,y;&quot; 0
 
151
              &quot;object z;&quot;
 
152
               (&rsquo;NIL z)
 
153
               ((CONS y z) z)
 
154
               ((CONS x z) z)
 
155
                &quot;return(z);&quot;
 
156
)
 
157
</p>
 
158
<p>In lisp the operations in the body would be
 
159
   (setq z &rsquo;nil)
 
160
   (setq z (cons y z))
 
161
   (setq z (cons x z))
 
162
</p>   
 
163
 
 
164
 
 
165
<p>Syntax:
 
166
</p><div class="example">
 
167
<pre class="example">
 
168
        (defCfun header non-negative-integer
 
169
                { string
 
170
                  | ( function-symbol { value }* )
 
171
                  | (( function-symbol  { value }* ) { place }* ) })
 
172
 
 
173
 
 
174
value:
 
175
place:
 
176
         { C-expr | ( C-type C-expr ) }
 
177
 
 
178
C-function-name:
 
179
C-expr:
 
180
         { string | symbol }
 
181
 
 
182
C-type:
 
183
         { object | int | char | float | double }
 
184
 
 
185
</pre></div>
 
186
 
 
187
 
 
188
 
 
189
 
 
190
</dd></dl>
 
191
 
 
192
<dl>
 
193
<dt><a name="index-CLINES"></a>Macro: <strong>CLINES</strong></dt>
 
194
<dd><p>Package:LISP
 
195
</p>
 
196
<p>Syntax:
 
197
</p><div class="example">
 
198
<pre class="example">(clines {string}*)
 
199
</pre></div>
 
200
 
 
201
<p>GCL specific:  The GCL compiler embeds STRINGs into the intermediate C
 
202
language code.  The interpreter ignores this form.
 
203
</p>
 
204
 
 
205
</dd></dl>
 
206
 
 
207
<dl>
 
208
<dt><a name="index-ALLOCATE"></a>Function: <strong>ALLOCATE</strong> <em>(type number &amp;optional (really-allocate nil))</em></dt>
 
209
<dd><p>Package:LISP
 
210
</p>
 
211
<p>GCL specific: Sets the maximum number of pages for the type class of the
 
212
GCL implementation type TYPE to NUMBER.  If REALLY-ALLOCATE is given a
 
213
non-NIL value, then the specified number of pages will be allocated
 
214
immediately.
 
215
</p>
 
216
 
 
217
</dd></dl>
 
218
 
 
219
<dl>
 
220
<dt><a name="index-GBC"></a>Function: <strong>GBC</strong> <em>(x)</em></dt>
 
221
<dd><p>Package:LISP
 
222
</p>
 
223
<p>GCL specific: Invokes the garbage collector (GC) with the collection level
 
224
specified by X.  NIL as the argument causes GC to collect cells only.  T as
 
225
the argument causes GC to collect everything.
 
226
</p>
 
227
 
 
228
</dd></dl>
 
229
 
 
230
<dl>
 
231
<dt><a name="index-SAVE"></a>Function: <strong>SAVE</strong> <em>(pathname)</em></dt>
 
232
<dd><p>Package:LISP
 
233
</p>
 
234
<p>GCL specific: Saves the current GCL core image into a program file specified
 
235
by PATHNAME.  This function depends on the version of GCL.  The function
 
236
si::save-system is to be preferred in almost all circumstances.   Unlike
 
237
save, it makes the relocatable section permanent, and causes no future gc of
 
238
currently loaded .o files.
 
239
</p>
 
240
</dd></dl>
 
241
 
 
242
<dl>
 
243
<dt><a name="index-HELP_002a"></a>Function: <strong>HELP*</strong> <em>(string &amp;optional (package 'lisp))</em></dt>
 
244
<dd><p>Package:LISP
 
245
</p>
 
246
<p>GCL specific: Prints the documentation associated with those symbols in the
 
247
specified package whose print names contain STRING as substring.  STRING may
 
248
be a symbol, in which case the print-name of that symbol is used.  If PACKAGE
 
249
is NIL, then all packages are searched.
 
250
</p>
 
251
 
 
252
</dd></dl>
 
253
 
 
254
<dl>
 
255
<dt><a name="index-DEFLA"></a>Macro: <strong>DEFLA</strong></dt>
 
256
<dd><p>Package:LISP
 
257
</p>
 
258
<p>Syntax:
 
259
</p><div class="example">
 
260
<pre class="example">(defla name lambda-list {decl | doc}* {form}*)
 
261
</pre></div>
 
262
 
 
263
<p>GCL specific: Used to DEFine Lisp Alternative.  For the interpreter, DEFLA is
 
264
equivalent to DEFUN, but the compiler ignores this form.
 
265
</p>
 
266
 
 
267
</dd></dl>
 
268
 
 
269
<dl>
 
270
<dt><a name="index-PROCLAMATION"></a>Function: <strong>PROCLAMATION</strong> <em>(decl-spec)</em></dt>
 
271
<dd><p>Package:LISP
 
272
</p>
 
273
<p>GCL specific: Returns T if the specified declaration is globally in effect;
 
274
NIL otherwise.  See the doc of DECLARE for possible DECL-SPECs.
 
275
</p>
 
276
 
 
277
</dd></dl>
 
278
 
 
279
<dl>
 
280
<dt><a name="index-DEFENTRY"></a>Macro: <strong>DEFENTRY</strong></dt>
 
281
<dd><p>Package:LISP
 
282
</p>
 
283
<p>Syntax:
 
284
</p><div class="example">
 
285
<pre class="example">(defentry name arg-types c-function)
 
286
</pre></div>
 
287
 
 
288
 
 
289
<p>GCL specific: The compiler defines a Lisp function whose body consists of a
 
290
calling sequence to the C language function specified by C-FUNCTION.  The
 
291
interpreter ignores this form.  The ARG-TYPES specifies the C types of the
 
292
arguments which C-FUNCTION requires.  The list of allowed types is (object
 
293
char int float double string).  Code will be produced to coerce from a lisp
 
294
object to the appropriate type before passing the argument to the C-FUNCTION.
 
295
The c-function should be of the form (c-result-type c-fname) where
 
296
c-result-type is a member of (void object char int float double string).
 
297
c-fname may be a symbol (in which case it will be downcased) or a string.  If
 
298
c-function is not a list, then (object c-function) is assumed.  In order
 
299
for C code to be loaded in by <code>load</code> you should declare any
 
300
variables and functions to be static.   If you will link them in
 
301
at build time, of course you are allowed to define new externals.
 
302
</p>
 
303
<div class="example">
 
304
<pre class="example">  Sample usage:
 
305
--File begin-----
 
306
;; JOE takes X a lisp string and Y a fixnum and returns a character.
 
307
(clines &quot;#include \&quot;foo.ch\&quot;&quot;)
 
308
(defentry joe (string int) (char &quot;our_c_fun&quot;))
 
309
---File end------
 
310
---File foo.ch---
 
311
/* C function for extracting the i'th element of a string */
 
312
static char our_c_fun(p,i)
 
313
char *p;
 
314
int i;
 
315
   {
 
316
        return p[i];
 
317
   }
 
318
-----File end---
 
319
</pre></div>
 
320
 
 
321
<p>One must be careful of storage allocation issues when passing a string.
 
322
If the C code invokes storage allocation (either by calling <code>malloc</code>
 
323
or <code>make_cons</code> etc), then there is a possibility of a garbage
 
324
collection, so that if the string passed was not constructed with
 
325
<code>:static t</code> when its array was constructed, then it could move.
 
326
If the C function may allocate storage, then you should pass a copy:
 
327
</p><div class="example">
 
328
<pre class="example">(defun safe-c-string (x)
 
329
  (let* ((n (length x))
 
330
         (a (make-array (+ n 1) :element-type 'string-char
 
331
           :static t :fill-pointer n)))
 
332
    (si::copy-array-portion x y 0 0 n)
 
333
    (setf (aref a n) (code-char 0)))
 
334
    a)
 
335
 
 
336
</pre></div>
 
337
 
 
338
 
 
339
</dd></dl>
 
340
<dl>
 
341
<dt><a name="index-COPY_002dARRAY_002dPORTION"></a>Function: <strong>COPY-ARRAY-PORTION</strong> <em>(x,y,i1,i2,n1)</em></dt>
 
342
<dd><p>Package:SI
 
343
Copy elements from X to Y starting at X[i1] to Y[i2] and doing N1
 
344
elements if N1 is supplied otherwise, doing the length of X - I1
 
345
elements.  If the types of the arrays are not the same, this has
 
346
implementation dependent results.
 
347
</p></dd></dl>
 
348
 
 
349
<dl>
 
350
<dt><a name="index-BYE"></a>Function: <strong>BYE</strong> <em>( &amp;optional (exit-status 0))</em></dt>
 
351
<dd><p>Package:LISP
 
352
</p>
 
353
<p>GCL specific: Exits from GCL with exit-status.
 
354
</p>
 
355
 
 
356
</dd></dl>
 
357
 
 
358
<dl>
 
359
<dt><a name="index-USE_002dFAST_002dLINKS"></a>Function: <strong>USE-FAST-LINKS</strong> <em>(turn-on)</em></dt>
 
360
<dd><p>Package:LISP
 
361
</p>
 
362
<p>GCL specific: If TURN-ON is not nil, the fast link mechanism is enabled,
 
363
so that ordinary function calls will not appear in the invocation stack,
 
364
and calls will be much faster.  This is the default.   If you anticipate
 
365
needing to see a stack trace in the debugger, then you should turn this
 
366
off.
 
367
</p>
 
368
 
 
369
</dd></dl>
 
370
 
 
371
<table class="menu" border="0" cellspacing="0">
 
372
<tr><td align="left" valign="top">&bull; <a href="Bignums.html#Bignums" accesskey="1">Bignums</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
 
373
</td></tr>
 
374
</table>
 
375
 
 
376
<hr>
 
377
<div class="header">
 
378
<p>
 
379
Next: <a href="C-Interface.html#C-Interface" accesskey="n" rel="next">C Interface</a>, Previous: <a href="Type.html#Type" accesskey="p" rel="prev">Type</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Function-and-Variable-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Variable-Index.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
 
380
</div>
 
381
 
 
382
 
 
383
 
 
384
</body>
 
385
</html>