~ubuntu-branches/debian/squeeze/ffcall/squeeze

« back to all changes in this revision

Viewing changes to callback/trampoline_r/trampoline_r.man

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2010-06-26 15:29:30 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100626152930-c09y01gk3szcnykn
Tags: 1.10+cvs20100619-2
Ship to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
 
 
4
TRAMPOLINE(3)                                       TRAMPOLINE(3)
 
5
 
 
6
 
 
7
NNAAMMEE
 
8
       trampoline - closures as first-class C functions
 
9
 
 
10
SSYYNNOOPPSSIISS
 
11
       ##iinncclluuddee <<ttrraammppoolliinnee__rr..hh>>
 
12
 
 
13
       ffuunnccttiioonn == aalllloocc__ttrraammppoolliinnee__rr((aaddddrreessss,, ddaattaa00,, ddaattaa11));;
 
14
 
 
15
       ffrreeee__ttrraammppoolliinnee__rr((ffuunnccttiioonn));;
 
16
 
 
17
       iiss__ttrraammppoolliinnee__rr((ffuunnccttiioonn))
 
18
       ttrraammppoolliinnee__rr__aaddddrreessss((ffuunnccttiioonn))
 
19
       ttrraammppoolliinnee__rr__ddaattaa00((ffuunnccttiioonn))
 
20
       ttrraammppoolliinnee__rr__ddaattaa11((ffuunnccttiioonn))
 
21
 
 
22
DDEESSCCRRIIPPTTIIOONN
 
23
       These  functions implement _c_l_o_s_u_r_e_s as first-class C func-
 
24
       tions.  A closure consists of a regular C function  and  a
 
25
       piece of data which gets passed to the C function when the
 
26
       closure is called.
 
27
 
 
28
       Closures as _f_i_r_s_t_-_c_l_a_s_s _C _f_u_n_c_t_i_o_n_s means  that  they  fit
 
29
       into a function pointer and can be called exactly like any
 
30
       other C function.  _f_u_n_c_t_i_o_n ==  aalllloocc__ttrraammppoolliinnee__rr((_a_d_d_r_e_s_s,,
 
31
       _d_a_t_a_0,,  _d_a_t_a_1))  allocates  a  closure.  When _f_u_n_c_t_i_o_n gets
 
32
       called, it stores in a special "lexical chain register"  a
 
33
       pointer  to  a  storage area containing _d_a_t_a_0 in its first
 
34
       word and _d_a_t_a_1 in its second word and calls the C function
 
35
       at  _a_d_d_r_e_s_s.   The  function at _a_d_d_r_e_s_s is responsible for
 
36
       fetching _d_a_t_a_0 and _d_a_t_a_1 off the pointer.  Note  that  the
 
37
       "lexical  chain register" is a call-used register, i.e. is
 
38
       clobbered by function calls.
 
39
 
 
40
       This is much like ggcccc's local functions, except  that  the
 
41
       GNU  C local functions have dynamic extent (i.e. are deal-
 
42
       located when the creating function returns), while _t_r_a_m_p_o_-
 
43
       _l_i_n_e  provides  functions with indefinite extent: _f_u_n_c_t_i_o_n
 
44
       is only deallocated  when  ffrreeee__ttrraammppoolliinnee__rr((_f_u_n_c_t_i_o_n))  is
 
45
       called.
 
46
 
 
47
       iiss__ttrraammppoolliinnee__rr((_f_u_n_c_t_i_o_n))  checks  whether  the C function
 
48
       _f_u_n_c_t_i_o_n was produced by a call to _a_l_l_o_c___t_r_a_m_p_o_l_i_n_e___r.  If
 
49
       this  returns  true,  the arguments given to _a_l_l_o_c___t_r_a_m_p_o_-
 
50
       _l_i_n_e___r can be retrieved:
 
51
 
 
52
           ttrraammppoolliinnee__rr__aaddddrreessss((_f_u_n_c_t_i_o_n)) returns _a_d_d_r_e_s_s,
 
53
 
 
54
           ttrraammppoolliinnee__rr__ddaattaa00((_f_u_n_c_t_i_o_n)) returns _d_a_t_a_0,
 
55
 
 
56
           ttrraammppoolliinnee__rr__ddaattaa11((_f_u_n_c_t_i_o_n)) returns _d_a_t_a_1.
 
57
 
 
58
 
 
59
SSEEEE AALLSSOO
 
60
       ttrraammppoolliinnee(3), ggcccc(1), vvaarraarrggss(3)
 
61
 
 
62
 
 
63
 
 
64
                         22 October 1997                        1
 
65
 
 
66
 
 
67
 
 
68
 
 
69
 
 
70
TRAMPOLINE(3)                                       TRAMPOLINE(3)
 
71
 
 
72
 
 
73
PPOORRTTIINNGG
 
74
       The way ggcccc builds local functions is described in the gcc
 
75
       source, file gcc-2.6.3/config/_c_p_u/_c_p_u.h.
 
76
 
 
77
 
 
78
AAUUTTHHOORR
 
79
       Bruno Haible <bruno@clisp.org>
 
80
 
 
81
 
 
82
AACCKKNNOOWWLLEEDDGGEEMMEENNTTSS
 
83
       Many ideas were cribbed from the gcc source.
 
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
                         22 October 1997                        2
 
131
 
 
132