This file is indexed.

/usr/share/doc/cl-cffi/cffi-sys-spec.html is in cl-cffi 1:0.19.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 2005-2006, James Bielman  <jamesjb at jamesjb.com>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. -->
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
<head>
<title>CFFI-SYS Interface Specification</title>

<meta name="description" content="CFFI-SYS Interface Specification">
<meta name="keywords" content="CFFI-SYS Interface Specification">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="#Symbol-Index" rel="index" title="Symbol Index">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
body {font-family: Georgia, serif;
      line-height: 1.3;
      padding-left: 5em; padding-right: 1em;
      padding-bottom: 1em; max-width: 60em;}
table {border-collapse: collapse}
span.roman { font-family: century schoolbook, serif; font-weight: normal; }
h1, h2, h3, h4, h5, h6 {font-family:  Helvetica, sans-serif}
h4 { margin-top: 2.5em; }
dfn {font-family: inherit; font-variant: italic; font-weight: bolder }
kbd {font-family: monospace; text-decoration: underline}
/*var {font-family: Helvetica, sans-serif; font-variant: slanted}*/
var {font-variant: slanted;}
td  {padding-right: 1em; padding-left: 1em}
sub {font-size: smaller}
.node {padding: 0; margin: 0}

pre.lisp { font-family: monospace;
           background-color: #F4F4F4; border: 1px solid #AAA;
           padding-top: 0.5em; padding-bottom: 0.5em; }

/* coloring */

.lisp-bg { background-color: #F4F4F4 ; color: black; }
.lisp-bg:hover { background-color: #F4F4F4 ; color: black; }

.symbol { font-weight: bold; color: #770055; background-color : transparent; border: 0px; margin: 0px;}
a.symbol:link { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
a.symbol:active { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
a.symbol:visited { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
a.symbol:hover { font-weight: bold; color : #229955; background-color : transparent; text-decoration: none; border: 0px; margin: 0px; }
.special { font-weight: bold; color: #FF5000; background-color: inherit; }
.keyword { font-weight: bold; color: #770000; background-color: inherit; }
.comment { font-weight: normal; color: #007777; background-color: inherit; }
.string  { font-weight: bold; color: #777777; background-color: inherit; }
.character   { font-weight: bold; color: #0055AA; background-color: inherit; }
.syntaxerror { font-weight: bold; color: #FF0000; background-color: inherit; }
span.paren1 { font-weight: bold; color: #777777; }
span.paren1:hover { color: #777777; background-color: #BAFFFF; }
span.paren2 { color: #777777; }
span.paren2:hover { color: #777777; background-color: #FFCACA; }
span.paren3 { color: #777777; }
span.paren3:hover { color: #777777; background-color: #FFFFBA; }
span.paren4 { color: #777777; }
span.paren4:hover { color: #777777; background-color: #CACAFF; }
span.paren5 { color: #777777; }
span.paren5:hover { color: #777777; background-color: #CAFFCA; }
span.paren6 { color: #777777; }
span.paren6:hover { color: #777777; background-color: #FFBAFF; }

-->
</style>


</head>

<body lang="en">
<h1 class="settitle" align="center">CFFI-SYS Interface Specification</h1>






<a name="SEC_Contents"></a>
<h2 class="contents-heading">Table of Contents</h2>

<div class="contents">

<ul class="no-bullet">
  <li><a name="toc-Introduction-1" href="#Introduction">1 Introduction</a></li>
  <li><a name="toc-Built_002dIn-Foreign-Types-1" href="#Built_002dIn-Foreign-Types">2 Built-In Foreign Types</a></li>
  <li><a name="toc-Operations-on-Built_002din-Foreign-Types" href="#Operations-on-Foreign-Types">3 Operations on Built-in Foreign Types</a></li>
  <li><a name="toc-Basic-Pointer-Operations-1" href="#Basic-Pointer-Operations">4 Basic Pointer Operations</a></li>
  <li><a name="toc-Foreign-Memory-Allocation-1" href="#Foreign-Memory-Allocation">5 Foreign Memory Allocation</a></li>
  <li><a name="toc-Memory-Access-1" href="#Memory-Access">6 Memory Access</a></li>
  <li><a name="toc-Foreign-Function-Calling-1" href="#Foreign-Function-Calling">7 Foreign Function Calling</a></li>
  <li><a name="toc-Loading-Foreign-Libraries-1" href="#Loading-Foreign-Libraries">8 Loading Foreign Libraries</a></li>
  <li><a name="toc-Foreign-Globals-1" href="#Foreign-Globals">9 Foreign Globals</a></li>
  <li><a name="toc-Symbol-Index-1" href="#Symbol-Index">Symbol Index</a></li>
</ul>
</div>


<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="cffi_002dsys"></a>
<h1 class="top">cffi-sys</h1>
<p>Copyright &copy; 2005-2006, James Bielman  &lt;jamesjb at jamesjb.com&gt;
</p>
<blockquote>
<p>Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the &ldquo;Software&rdquo;), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
</p>
<p>The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
</p>
<p><small>THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.</small>
</p></blockquote>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Introduction" accesskey="1">Introduction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Built_002dIn-Foreign-Types" accesskey="2">Built-In Foreign Types</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Operations-on-Foreign-Types" accesskey="3">Operations on Foreign Types</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Basic-Pointer-Operations" accesskey="4">Basic Pointer Operations</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Foreign-Memory-Allocation" accesskey="5">Foreign Memory Allocation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Memory-Access" accesskey="6">Memory Access</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Foreign-Function-Calling" accesskey="7">Foreign Function Calling</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Loading-Foreign-Libraries" accesskey="8">Loading Foreign Libraries</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Foreign-Globals" accesskey="9">Foreign Globals</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Symbol-Index">Symbol Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<a name="Introduction"></a>
<div class="header">
<p>
Next: <a href="#Built_002dIn-Foreign-Types" accesskey="n" rel="next">Built-In Foreign Types</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction-1"></a>
<h2 class="chapter">1 Introduction</h2>

<p><acronym>CFFI</acronym>, the Common Foreign Function Interface, purports to be
a portable foreign function interface for Common Lisp.
</p>
<p>This specification defines a set of low-level primitives that must be
defined for each Lisp implementation supported by <acronym>CFFI</acronym>.
These operators are defined in the <code>CFFI-SYS</code> package.
</p>
<p>The <code>CFFI</code> package uses the <code>CFFI-SYS</code> interface
to implement an extensible foreign type system with support for
typedefs, structures, and unions, a declarative interface for
defining foreign function calls, and automatic conversion of
foreign function arguments to/from Lisp types.
</p>
<p>Please note the following conventions that apply to everything in
<code>CFFI-SYS</code>:
</p>
<ul>
<li> Functions in <code>CFFI-SYS</code> that are low-level versions of functions
exported from the <code>CFFI</code> package begin with a leading
percent-sign (eg. <code>%mem-ref</code>).

</li><li> Where &ldquo;foreign type&rdquo; is mentioned as the kind of an argument, the
meaning is restricted to that subset of all foreign types defined in
<a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a>.  Support for higher-level types is
always defined in terms of those lower-level types in <code>CFFI</code>
proper.
</li></ul>


<hr>
<a name="Built_002dIn-Foreign-Types"></a>
<div class="header">
<p>
Next: <a href="#Operations-on-Foreign-Types" accesskey="n" rel="next">Operations on Foreign Types</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Built_002dIn-Foreign-Types-1"></a>
<h2 class="chapter">2 Built-In Foreign Types</h2>

<dl>
<dt><a name="index-_003achar"></a>Foreign Type: <strong>:char</strong></dt>
<dt><a name="index-_003aunsigned_002dchar"></a>Foreign Type: <strong>:unsigned-char</strong></dt>
<dt><a name="index-_003ashort"></a>Foreign Type: <strong>:short</strong></dt>
<dt><a name="index-_003aunsigned_002dshort"></a>Foreign Type: <strong>:unsigned-short</strong></dt>
<dt><a name="index-_003aint"></a>Foreign Type: <strong>:int</strong></dt>
<dt><a name="index-_003aunsigned_002dint"></a>Foreign Type: <strong>:unsigned-int</strong></dt>
<dt><a name="index-_003along"></a>Foreign Type: <strong>:long</strong></dt>
<dt><a name="index-_003aunsigned_002dlong"></a>Foreign Type: <strong>:unsigned-long</strong></dt>
<dt><a name="index-_003along_002dlong"></a>Foreign Type: <strong>:long-long</strong></dt>
<dt><a name="index-_003aunsigned_002dlong_002dlong"></a>Foreign Type: <strong>:unsigned-long-long</strong></dt>
<dd><p>These types correspond to the native C integer types according to the
ABI of the system the Lisp implementation is compiled against.
</p></dd></dl>

<dl>
<dt><a name="index-_003aint8"></a>Foreign Type: <strong>:int8</strong></dt>
<dt><a name="index-_003auint8"></a>Foreign Type: <strong>:uint8</strong></dt>
<dt><a name="index-_003aint16"></a>Foreign Type: <strong>:int16</strong></dt>
<dt><a name="index-_003auint16"></a>Foreign Type: <strong>:uint16</strong></dt>
<dt><a name="index-_003aint32"></a>Foreign Type: <strong>:int32</strong></dt>
<dt><a name="index-_003auint32"></a>Foreign Type: <strong>:uint32</strong></dt>
<dt><a name="index-_003aint64"></a>Foreign Type: <strong>:int64</strong></dt>
<dt><a name="index-_003auint64"></a>Foreign Type: <strong>:uint64</strong></dt>
<dd><p>Foreign integer types of specific sizes, corresponding to the C types
defined in <code>stdint.h</code>.
</p></dd></dl>

<dl>
<dt><a name="index-_003asize"></a>Foreign Type: <strong>:size</strong></dt>
<dt><a name="index-_003assize"></a>Foreign Type: <strong>:ssize</strong></dt>
<dt><a name="index-_003aptrdiff"></a>Foreign Type: <strong>:ptrdiff</strong></dt>
<dt><a name="index-_003atime"></a>Foreign Type: <strong>:time</strong></dt>
<dd><p>Foreign integer types corresponding to the standard C types (without
the <code>_t</code> suffix).
</p></dd></dl>

<p><em>Implementor&rsquo;s note: I&rsquo;m sure there are more of these that could be useful, let&rsquo;s
add any types that can&rsquo;t be defined portably to this list as
necessary.</em>
</p>
<dl>
<dt><a name="index-_003afloat"></a>Foreign Type: <strong>:float</strong></dt>
<dt><a name="index-_003adouble"></a>Foreign Type: <strong>:double</strong></dt>
<dd><p>The <code>:float</code> type represents a C <code>float</code> and a Lisp
<code>single-float</code>. <code>:double</code> represents a C <code>double</code> and a
Lisp <code>double-float</code>.
</p></dd></dl>

<dl>
<dt><a name="index-_003apointer"></a>Foreign Type: <strong>:pointer</strong></dt>
<dd><p>A foreign pointer to an object of any type, corresponding to
<code>void *</code>.
</p></dd></dl>

<dl>
<dt><a name="index-_003avoid"></a>Foreign Type: <strong>:void</strong></dt>
<dd><p>No type at all. Only valid as the return type of a function.
</p></dd></dl>


<hr>
<a name="Operations-on-Foreign-Types"></a>
<div class="header">
<p>
Next: <a href="#Basic-Pointer-Operations" accesskey="n" rel="next">Basic Pointer Operations</a>, Previous: <a href="#Built_002dIn-Foreign-Types" accesskey="p" rel="prev">Built-In Foreign Types</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Operations-on-Built_002din-Foreign-Types"></a>
<h2 class="chapter">3 Operations on Built-in Foreign Types</h2>

<dl>
<dt><a name="index-_0025foreign_002dtype_002dsize"></a>Function: <strong>%foreign-type-size</strong> <em>type &rArr; size</em></dt>
<dd><p>Return the <var>size</var>, in bytes, of objects having foreign type
<var>type</var>. An error is signalled if <var>type</var> is not a known
built-in foreign type.
</p></dd></dl>

<dl>
<dt><a name="index-_0025foreign_002dtype_002dalignment"></a>Function: <strong>%foreign-type-alignment</strong> <em>type &rArr; alignment</em></dt>
<dd><p>Return the default alignment in bytes for structure members of foreign
type <var>type</var>. An error is signalled if <var>type</var> is not a known
built-in foreign type.
</p>
<p><em>Implementor&rsquo;s note: Maybe this should take an optional keyword argument specifying an
alternate alignment system, eg. :mac68k for 68000-compatible alignment
on Darwin.</em>
</p></dd></dl>


<hr>
<a name="Basic-Pointer-Operations"></a>
<div class="header">
<p>
Next: <a href="#Foreign-Memory-Allocation" accesskey="n" rel="next">Foreign Memory Allocation</a>, Previous: <a href="#Operations-on-Foreign-Types" accesskey="p" rel="prev">Operations on Foreign Types</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Basic-Pointer-Operations-1"></a>
<h2 class="chapter">4 Basic Pointer Operations</h2>

<dl>
<dt><a name="index-pointerp"></a>Function: <strong>pointerp</strong> <em>ptr &rArr; boolean</em></dt>
<dd><p>Return true if <var>ptr</var> is a foreign pointer.
</p></dd></dl>

<dl>
<dt><a name="index-null_002dpointer"></a>Function: <strong>null-pointer</strong> <em>&rArr; pointer</em></dt>
<dd><p>Return a null foreign pointer.
</p></dd></dl>

<dl>
<dt><a name="index-null_002dpointer_002dp"></a>Function: <strong>null-pointer-p</strong> <em>ptr &rArr; boolean</em></dt>
<dd><p>Return true if <var>ptr</var> is a null foreign pointer.
</p></dd></dl>

<dl>
<dt><a name="index-make_002dpointer"></a>Function: <strong>make-pointer</strong> <em>address &rArr; pointer</em></dt>
<dd><p>Return a pointer corresponding to the numeric integer <var>address</var>.
</p></dd></dl>

<dl>
<dt><a name="index-inc_002dpointer"></a>Function: <strong>inc-pointer</strong> <em>ptr offset &rArr; pointer</em></dt>
<dd><p>Return the result of numerically incrementing <var>ptr</var> by <var>offset</var>.
</p></dd></dl>


<hr>
<a name="Foreign-Memory-Allocation"></a>
<div class="header">
<p>
Next: <a href="#Memory-Access" accesskey="n" rel="next">Memory Access</a>, Previous: <a href="#Basic-Pointer-Operations" accesskey="p" rel="prev">Basic Pointer Operations</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Foreign-Memory-Allocation-1"></a>
<h2 class="chapter">5 Foreign Memory Allocation</h2>

<dl>
<dt><a name="index-foreign_002dalloc"></a>Function: <strong>foreign-alloc</strong> <em>size &rArr; pointer</em></dt>
<dd><p>Allocate <var>size</var> bytes of foreign-addressable memory and return
a <var>pointer</var> to the allocated block. An implementation-specific
error is signalled if the memory cannot be allocated.
</p></dd></dl>

<dl>
<dt><a name="index-foreign_002dfree"></a>Function: <strong>foreign-free</strong> <em>ptr &rArr; unspecified</em></dt>
<dd><p>Free a pointer <var>ptr</var> allocated by <code>foreign-alloc</code>. The
results are undefined if <var>ptr</var> is used after being freed.
</p></dd></dl>

<dl>
<dt><a name="index-with_002dforeign_002dpointer"></a>Macro: <strong>with-foreign-pointer</strong> <em>(var size &amp;optional size-var) &amp;body body</em></dt>
<dd><p>Bind <var>var</var> to a pointer to <var>size</var> bytes of
foreign-accessible memory during <var>body</var>.  Both <var>ptr</var> and the
memory block it points to have dynamic extent and may be stack
allocated if supported by the implementation. If <var>size-var</var> is
supplied, it will be bound to <var>size</var> during <var>body</var>.
</p></dd></dl>


<hr>
<a name="Memory-Access"></a>
<div class="header">
<p>
Next: <a href="#Foreign-Function-Calling" accesskey="n" rel="next">Foreign Function Calling</a>, Previous: <a href="#Foreign-Memory-Allocation" accesskey="p" rel="prev">Foreign Memory Allocation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Memory-Access-1"></a>
<h2 class="chapter">6 Memory Access</h2>

<dl>
<dt><a name="index-_0025mem_002dref"></a>Accessor: <strong>%mem-ref</strong> <em>ptr type &amp;optional offset</em></dt>
<dd><p>Dereference a pointer <var>offset</var> bytes from <var>ptr</var> to an object
for reading (or writing when used with <code>setf</code>) of built-in type
<var>type</var>.
</p></dd></dl>

<a name="Example"></a>
<h3 class="heading">Example</h3>

<div class="lisp">
<pre class="lisp">  <span class="comment">;; An impractical example, since time returns the time as well,
  </span><span class="comment">;; but it demonstrates %MEM-REF. Better (simple) examples wanted!
  </span><span class="paren1">(<span class="lisp-bg"><i><span class="symbol">with-foreign-pointer</span></i> <span class="paren2">(<span class="lisp-bg">p <span class="paren3">(<span class="lisp-bg">foreign-type-size <span class="keyword">:time</span></span>)</span></span>)</span>
    <span class="paren2">(<span class="lisp-bg">foreign-funcall <span class="string">&quot;time&quot;</span> <span class="keyword">:pointer</span> p <span class="keyword">:time</span></span>)</span>
    <span class="paren2">(<span class="lisp-bg">%mem-ref p <span class="keyword">:time</span></span>)</span></span>)</span>
</pre></div>


<hr>
<a name="Foreign-Function-Calling"></a>
<div class="header">
<p>
Next: <a href="#Loading-Foreign-Libraries" accesskey="n" rel="next">Loading Foreign Libraries</a>, Previous: <a href="#Memory-Access" accesskey="p" rel="prev">Memory Access</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Foreign-Function-Calling-1"></a>
<h2 class="chapter">7 Foreign Function Calling</h2>

<dl>
<dt><a name="index-_0025foreign_002dfuncall"></a>Macro: <strong>%foreign-funcall</strong> <em>name {arg-type arg}* &amp;optional result-type &rArr; object</em></dt>
<dt><a name="index-_0025foreign_002dfuncall_002dpointer"></a>Macro: <strong>%foreign-funcall-pointer</strong> <em>ptr {arg-type arg}* &amp;optional result-type &rArr; object</em></dt>
<dd><p>Invoke a foreign function called <var>name</var> in the foreign source code.
</p>
<p>Each <var>arg-type</var> is a foreign type specifier, followed by
<var>arg</var>, Lisp data to be converted to foreign data of type
<var>arg-type</var>.  <var>result-type</var> is the foreign type of the
function&rsquo;s return value, and is assumed to be <code>:void</code> if not
supplied.
</p>
<p><code>%foreign-funcall-pointer</code> takes a pointer <var>ptr</var> to the
function, as returned by <code>foreign-symbol-pointer</code>, rather than a
string <var>name</var>.
</p></dd></dl>

<a name="Examples"></a>
<h3 class="heading">Examples</h3>

<div class="lisp">
<pre class="lisp">  <span class="comment">;; Calling a standard C library function:
  </span><span class="paren1">(<span class="lisp-bg">%foreign-funcall <span class="string">&quot;sqrtf&quot;</span> <span class="keyword">:float</span> 16.0 <span class="keyword">:float</span></span>)</span> &rArr; 4.0
</pre></div>

<div class="lisp">
<pre class="lisp">  <span class="comment">;; Dynamic allocation of a buffer and passing to a function:
  </span><span class="paren1">(<span class="lisp-bg"><i><span class="symbol">with-foreign-ptr</span></i> <span class="paren2">(<span class="lisp-bg">buf 255 buf-size</span>)</span>
    <span class="paren2">(<span class="lisp-bg">%foreign-funcall <span class="string">&quot;gethostname&quot;</span> <span class="keyword">:pointer</span> buf <span class="keyword">:size</span> buf-size <span class="keyword">:int</span></span>)</span>
    <span class="comment">;; Convert buf to a Lisp string using MAKE-STRING and %MEM-REF or
  </span>  <span class="comment">;; a portable CFFI function such as CFFI:FOREIGN-STRING-TO-LISP.
  </span>  </span>)</span>
</pre></div>


<hr>
<a name="Loading-Foreign-Libraries"></a>
<div class="header">
<p>
Next: <a href="#Foreign-Globals" accesskey="n" rel="next">Foreign Globals</a>, Previous: <a href="#Foreign-Function-Calling" accesskey="p" rel="prev">Foreign Function Calling</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Loading-Foreign-Libraries-1"></a>
<h2 class="chapter">8 Loading Foreign Libraries</h2>

<dl>
<dt><a name="index-_0025load_002dforeign_002dlibrary"></a>Function: <strong>%load-foreign-library</strong> <em>name &rArr; unspecified</em></dt>
<dd><p>Load the foreign shared library <var>name</var>.
</p>
<p><em>Implementor&rsquo;s note: There is a lot of behavior to decide here.  Currently I lean
toward not requiring NAME to be a full path to the library so
we can search the system library directories (maybe even get
LD_LIBRARY_PATH from the environment) as necessary.</em>
</p></dd></dl>


<hr>
<a name="Foreign-Globals"></a>
<div class="header">
<p>
Next: <a href="#Symbol-Index" accesskey="n" rel="next">Symbol Index</a>, Previous: <a href="#Loading-Foreign-Libraries" accesskey="p" rel="prev">Loading Foreign Libraries</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Foreign-Globals-1"></a>
<h2 class="chapter">9 Foreign Globals</h2>

<dl>
<dt><a name="index-foreign_002dsymbol_002dpointer"></a>Function: <strong>foreign-symbol-pointer</strong> <em>name &rArr; pointer</em></dt>
<dd><p>Return a pointer to a foreign symbol <var>name</var>.
</p></dd></dl>

<hr>
<a name="Symbol-Index"></a>
<div class="header">
<p>
Previous: <a href="#Foreign-Globals" accesskey="p" rel="prev">Foreign Globals</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Symbol-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Symbol-Index-1"></a>
<h2 class="unnumbered">Symbol Index</h2>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Symbol-Index_fn_symbol-1"><b>%</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_symbol-2"><b>:</b></a>
 &nbsp; 
<br>
<a class="summary-letter" href="#Symbol-Index_fn_letter-F"><b>F</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-M"><b>M</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-N"><b>N</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-W"><b>W</b></a>
 &nbsp; 
</td></tr></table>
<table class="index-fn" border="0">
<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_symbol-1">%</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025foreign_002dfuncall"><code>%foreign-funcall</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Function-Calling">Foreign Function Calling</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025foreign_002dfuncall_002dpointer"><code>%foreign-funcall-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Function-Calling">Foreign Function Calling</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025foreign_002dtype_002dalignment"><code>%foreign-type-alignment</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Operations-on-Foreign-Types">Operations on Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025foreign_002dtype_002dsize"><code>%foreign-type-size</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Operations-on-Foreign-Types">Operations on Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025load_002dforeign_002dlibrary"><code>%load-foreign-library</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Loading-Foreign-Libraries">Loading Foreign Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_0025mem_002dref"><code>%mem-ref</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Memory-Access">Memory Access</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_symbol-2">:</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003achar">:char</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003adouble">:double</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003afloat">:float</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aint">:int</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aint16">:int16</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aint32">:int32</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aint64">:int64</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aint8">:int8</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003along">:long</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003along_002dlong">:long-long</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003apointer">:pointer</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aptrdiff">:ptrdiff</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003ashort">:short</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003asize">:size</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003assize">:ssize</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003atime">:time</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003auint16">:uint16</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003auint32">:uint32</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003auint64">:uint64</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003auint8">:uint8</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aunsigned_002dchar">:unsigned-char</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aunsigned_002dint">:unsigned-int</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aunsigned_002dlong">:unsigned-long</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aunsigned_002dlong_002dlong">:unsigned-long-long</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003aunsigned_002dshort">:unsigned-short</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-_003avoid">:void</a>:</td><td>&nbsp;</td><td valign="top"><a href="#Built_002dIn-Foreign-Types">Built-In Foreign Types</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-F">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-foreign_002dalloc"><code>foreign-alloc</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Memory-Allocation">Foreign Memory Allocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-foreign_002dfree"><code>foreign-free</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Memory-Allocation">Foreign Memory Allocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-foreign_002dsymbol_002dpointer"><code>foreign-symbol-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Globals">Foreign Globals</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-I">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-inc_002dpointer"><code>inc-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Pointer-Operations">Basic Pointer Operations</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-M">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-make_002dpointer"><code>make-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Pointer-Operations">Basic Pointer Operations</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-N">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-null_002dpointer"><code>null-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Pointer-Operations">Basic Pointer Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-null_002dpointer_002dp"><code>null-pointer-p</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Pointer-Operations">Basic Pointer Operations</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-P">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-pointerp"><code>pointerp</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Basic-Pointer-Operations">Basic Pointer Operations</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Symbol-Index_fn_letter-W">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-with_002dforeign_002dpointer"><code>with-foreign-pointer</code></a>:</td><td>&nbsp;</td><td valign="top"><a href="#Foreign-Memory-Allocation">Foreign Memory Allocation</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Symbol-Index_fn_symbol-1"><b>%</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_symbol-2"><b>:</b></a>
 &nbsp; 
<br>
<a class="summary-letter" href="#Symbol-Index_fn_letter-F"><b>F</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-I"><b>I</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-M"><b>M</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-N"><b>N</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-P"><b>P</b></a>
 &nbsp; 
<a class="summary-letter" href="#Symbol-Index_fn_letter-W"><b>W</b></a>
 &nbsp; 
</td></tr></table>

<hr>



</body>
</html>