This file is indexed.

/usr/share/doc/libffi5/html/The-Closure-API.html is in libffi-dev 3.0.10-3.

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
<html lang="en">
<head>
<title>The Closure API - libffi</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="libffi">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Using-libffi.html#Using-libffi" title="Using libffi">
<link rel="prev" href="Multiple-ABIs.html#Multiple-ABIs" title="Multiple ABIs">
<link rel="next" href="Closure-Example.html#Closure-Example" title="Closure Example">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is for Libffi, a portable foreign-function interface
library.

Copyright (C) 2008, 2010 Red Hat, Inc.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2, or
     (at your option) any later version.  A copy of the license is
     included in the section entitled ``GNU General Public License''.

   -->
<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="The-Closure-API"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Closure-Example.html#Closure-Example">Closure Example</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Multiple-ABIs.html#Multiple-ABIs">Multiple ABIs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Using-libffi.html#Using-libffi">Using libffi</a>
<hr>
</div>

<h3 class="section">2.5 The Closure API</h3>

<p><code>libffi</code> also provides a way to write a generic function &ndash; a
function that can accept and decode any combination of arguments. 
This can be useful when writing an interpreter, or to provide wrappers
for arbitrary functions.

   <p>This facility is called the <dfn>closure API</dfn>.  Closures are not
supported on all platforms; you can check the <code>FFI_CLOSURES</code>
define to determine whether they are supported on the current
platform. 
<a name="index-closures-36"></a><a name="index-closure-API-37"></a><a name="index-FFI_005fCLOSURES-38"></a>
Because closures work by assembling a tiny function at runtime, they
require special allocation on platforms that have a non-executable
heap.  Memory management for closures is handled by a pair of
functions:

   <p><a name="index-ffi_005fclosure_005falloc-39"></a>

<div class="defun">
&mdash; Function: <b>void</b><var> *ffi_closure_alloc </var>(<var>size_t size, void **code</var>)<var><a name="index-void-40"></a></var><br>
<blockquote><p>Allocate a chunk of memory holding <var>size</var> bytes.  This returns a
pointer to the writable address, and sets *<var>code</var> to the
corresponding executable address.

        <p><var>size</var> should be sufficient to hold a <code>ffi_closure</code> object. 
</p></blockquote></div>

   <p><a name="index-ffi_005fclosure_005ffree-41"></a>

<div class="defun">
&mdash; Function: <b>void</b><var> ffi_closure_free </var>(<var>void *writable</var>)<var><a name="index-void-42"></a></var><br>
<blockquote><p>Free memory allocated using <code>ffi_closure_alloc</code>.  The argument is
the writable address that was returned. 
</p></blockquote></div>

   <p>Once you have allocated the memory for a closure, you must construct a
<code>ffi_cif</code> describing the function call.  Finally you can prepare
the closure function:

   <p><a name="index-ffi_005fprep_005fclosure_005floc-43"></a>

<div class="defun">
&mdash; Function: <b>ffi_status</b><var> ffi_prep_closure_loc </var>(<var>ffi_closure *closure, ffi_cif *cif, void </var>(<var>*fun</var>) (<var>ffi_cif *cif, void *ret, void **args, void *user_data</var>)<var>, void *user_data, void *codeloc</var>)<var><a name="index-ffi_005fstatus-44"></a></var><br>
<blockquote><p>Prepare a closure function.

        <p><var>closure</var> is the address of a <code>ffi_closure</code> object; this is
the writable address returned by <code>ffi_closure_alloc</code>.

        <p><var>cif</var> is the <code>ffi_cif</code> describing the function parameters.

        <p><var>user_data</var> is an arbitrary datum that is passed, uninterpreted,
to your closure function.

        <p><var>codeloc</var> is the executable address returned by
<code>ffi_closure_alloc</code>.

        <p><var>fun</var> is the function which will be called when the closure is
invoked.  It is called with the arguments:
          <dl>
<dt><var>cif</var><dd>The <code>ffi_cif</code> passed to <code>ffi_prep_closure_loc</code>.

          <br><dt><var>ret</var><dd>A pointer to the memory used for the function's return value. 
<var>fun</var> must fill this, unless the function is declared as returning
<code>void</code>. 
<!-- FIXME: is this NULL for void-returning functions? -->

          <br><dt><var>args</var><dd>A vector of pointers to memory holding the arguments to the function.

          <br><dt><var>user_data</var><dd>The same <var>user_data</var> that was passed to
<code>ffi_prep_closure_loc</code>. 
</dl>

        <p><code>ffi_prep_closure_loc</code> will return <code>FFI_OK</code> if everything
went ok, and something else on error. 
<!-- FIXME: what? -->

        <p>After calling <code>ffi_prep_closure_loc</code>, you can cast <var>codeloc</var>
to the appropriate pointer-to-function type. 
</p></blockquote></div>

   <p>You may see old code referring to <code>ffi_prep_closure</code>.  This
function is deprecated, as it cannot handle the need for separate
writable and executable addresses.

   </body></html>