/usr/share/html/trampoline_r.html is in libffcall1-dev 1.10+cvs20100619-4.
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 | <HEAD>
<TITLE> TRAMPOLINE_R manual page </TITLE>
</HEAD>
<BODY>
<H1>TRAMPOLINE_R manual page</H1>
<UL>
<LI> <A HREF="#Name">Name</A>
<LI> <A HREF="#Synopsis">Synopsis</A>
<LI> <A HREF="#Description">Description</A>
<LI> <A HREF="#See also">See also</A>
<LI> <A HREF="#Porting">Porting</A>
<LI> <A HREF="#Author">Author</A>
<LI> <A HREF="#Acknowledgements">Acknowledgements</A>
</UL>
<P>
<HR>
<A NAME="Name">
<H2>Name</H2>
</A>
trampoline_r - closures as first-class C functions
<A NAME="Synopsis">
<H2>Synopsis</H2>
</A>
<PRE>
<CODE>#include <trampoline_r.h></CODE>
<CODE><VAR>function</VAR> = alloc_trampoline_r(<VAR>address</VAR>, <VAR>data0</VAR>, <VAR>data1</VAR>);</CODE>
<CODE>free_trampoline_r(<VAR>function</VAR>);</CODE>
<CODE>is_trampoline_r(<VAR>function</VAR>)</CODE>
<CODE>trampoline_r_address(<VAR>function</VAR>)</CODE>
<CODE>trampoline_r_data0(<VAR>function</VAR>)</CODE>
<CODE>trampoline_r_data1(<VAR>function</VAR>)</CODE>
</PRE>
<A NAME="Description">
<H2>Description</H2>
</A>
These functions implement <EM>closures</EM> as first-class
C functions. A closure consists of a regular C function and a
piece of data which gets passed to the C function when the
closure is called.
<P>
Closures as <EM>first-class C functions</EM> means that they fit
into a function pointer and can be called exactly like any
other C function. <CODE><VAR>function</VAR> = alloc_trampoline_r(<VAR>address</VAR>, <VAR>data0</VAR>, <VAR>data1</VAR>)</CODE>
allocates a closure. When <VAR>function</VAR> gets
called, it stores in a special "lexical chain register" a
pointer to a storage area containing <VAR>data0</VAR> in its first
word and <VAR>data1</VAR> in its second word and calls the C function
at <VAR>address</VAR>. The function at <VAR>address</VAR> is responsible for
fetching <VAR>data0</VAR> and <VAR>data1</VAR> off the pointer. Note that the
"lexical chain register" is a call-used register, i.e. is
clobbered by function calls.
<P>
This is much like gcc's local functions, except that the
GNU C local functions have dynamic extent (i.e. are
deallocated when the creating function returns), while <EM>trampoline</EM>
provides functions with indefinite extent: <CODE><VAR>function</VAR></CODE>
is only deallocated when <CODE>free_trampoline_r(<VAR>function</VAR>)</CODE> is
called.
<P>
<CODE>is_trampoline_r(<VAR>function</VAR>)</CODE>
checks whether the C function <CODE><VAR>function</VAR></CODE>
was produced by a call to <CODE>alloc_trampoline_r</CODE>.
If this returns true, the arguments given to <CODE>alloc_trampoline_r</CODE>
can be retrieved:
<UL>
<LI> <CODE>trampoline_r_address(<VAR>function</VAR>)</CODE> returns <VAR>address</VAR>,
<LI> <CODE>trampoline_r_data0(<VAR>function</VAR>)</CODE> returns <VAR>data0</VAR>,
<LI> <CODE>trampoline_r_data1(<VAR>function</VAR>)</CODE> returns <VAR>data1</VAR>.
</UL>
<A NAME="See also">
<H2>See also</H2>
</A>
<A HREF="trampoline(3)"><CODE><B>trampoline</B></CODE></A>(3), <A HREF="gcc(1)"><CODE><B>gcc</B></CODE></A>(1), <A HREF="varargs(3)"><CODE><B>varargs</B></CODE></A>(3)
<A NAME="Porting">
<H2>Porting</H2>
</A>
The way gcc builds local functions is described in the gcc
source, file <SAMP>gcc-2.6.3/config/<VAR>cpu</VAR>/<VAR>cpu</VAR>.h</SAMP>.
<A NAME="Author">
<H2>Author</H2>
</A>
Bruno Haible <bruno@clisp.org>
<A NAME="Acknowledgements">
<H2>Acknowledgements</H2>
</A>
Many ideas were cribbed from the gcc source.
<P>
<HR>
<ADDRESS>TRAMPOLINE_R manual page<BR>
Bruno Haible <bruno@clisp.org>
</ADDRESS>
<P>
Last modified: 22 October 1997.
</BODY>
|