]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/context/doc/html/context/rationale/other_apis_.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / doc / html / context / rationale / other_apis_.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4<title>Other APIs</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Context">
8<link rel="up" href="../rationale.html" title="Rationale">
9<link rel="prev" href="../rationale.html" title="Rationale">
10<link rel="next" href="x86_and_floating_point_env.html" title="x86 and floating-point env">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="x86_and_floating_point_env.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="context.rationale.other_apis_"></a><a class="link" href="other_apis_.html" title="Other APIs">Other APIs </a>
28</h3></div></div></div>
29<h5>
30<a name="context.rationale.other_apis_.h0"></a>
31 <span><a name="context.rationale.other_apis_.setjmp___longjmp__"></a></span><a class="link" href="other_apis_.html#context.rationale.other_apis_.setjmp___longjmp__">setjmp()/longjmp()</a>
32 </h5>
33<p>
34 C99 defines <code class="computeroutput"><span class="identifier">setjmp</span><span class="special">()</span></code>/<code class="computeroutput"><span class="identifier">longjmp</span><span class="special">()</span></code>
35 to provide non-local jumps but it does not require that <span class="emphasis"><em>longjmp()</em></span>
36 preserves the current stack frame. Therefore, jumping into a function which
37 was exited via a call to <span class="emphasis"><em>longjmp()</em></span> is undefined <sup>[<a name="context.rationale.other_apis_.f0" href="#ftn.context.rationale.other_apis_.f0" class="footnote">2</a>]</sup>.
38 </p>
39<h5>
40<a name="context.rationale.other_apis_.h1"></a>
41 <span><a name="context.rationale.other_apis_.ucontext_t"></a></span><a class="link" href="other_apis_.html#context.rationale.other_apis_.ucontext_t">ucontext_t</a>
42 </h5>
43<p>
44 Since POSIX.1-2003 <code class="computeroutput"><span class="identifier">ucontext_t</span></code>
45 is deprecated and was removed in POSIX.1-2008! The function signature of
46 <code class="computeroutput"><span class="identifier">makecontext</span><span class="special">()</span></code>
47 is:
48 </p>
49<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">makecontext</span><span class="special">(</span><span class="identifier">ucontext_t</span> <span class="special">*</span><span class="identifier">ucp</span><span class="special">,</span> <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">func</span><span class="special">)(),</span> <span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="special">...);</span>
50</pre>
51<p>
52 The third argument of <code class="computeroutput"><span class="identifier">makecontext</span><span class="special">()</span></code> specifies the number of integer arguments
53 that follow which will require function pointer cast if <code class="computeroutput"><span class="identifier">func</span></code>
54 will accept those arguments which is undefined in C99 <sup>[<a name="context.rationale.other_apis_.f1" href="#ftn.context.rationale.other_apis_.f1" class="footnote">3</a>]</sup>.
55 </p>
56<p>
57 The arguments in the var-arg list are required to be integers, passing pointers
58 in var-arg list is not guaranteed to work, especially it will fail for architectures
59 where pointers are larger than integers.
60 </p>
61<p>
62 <code class="computeroutput"><span class="identifier">ucontext_t</span></code> preserves signal
63 mask between context switches which involves system calls consuming a lot
64 of CPU cycles (ucontext_t is slower by perfomance_link[factor 13x] relative
65 to <code class="computeroutput"><span class="identifier">fcontext_t</span></code>).
66 </p>
67<h5>
68<a name="context.rationale.other_apis_.h2"></a>
69 <span><a name="context.rationale.other_apis_.windows_fibers"></a></span><a class="link" href="other_apis_.html#context.rationale.other_apis_.windows_fibers">Windows
70 fibers</a>
71 </h5>
72<p>
73 A drawback of Windows Fiber API is that <code class="computeroutput"><span class="identifier">CreateFiber</span><span class="special">()</span></code> does not accept a pointer to user allocated
74 stack space preventing the reuse of stacks for other context instances. Because
75 the Windows Fiber API requires to call <code class="computeroutput"><span class="identifier">ConvertThreadToFiber</span><span class="special">()</span></code> if <code class="computeroutput"><span class="identifier">SwitchFiber</span><span class="special">()</span></code> is called for a thread which has not been
76 converted to a fiber. For the same reason <code class="computeroutput"><span class="identifier">ConvertFiberToThread</span><span class="special">()</span></code> must be called after return from <code class="computeroutput"><span class="identifier">SwitchFiber</span><span class="special">()</span></code>
77 if the thread was forced to be converted to a fiber before (which is inefficient).
78 </p>
79<pre class="programlisting"><span class="keyword">if</span> <span class="special">(</span> <span class="special">!</span> <span class="identifier">is_a_fiber</span><span class="special">()</span> <span class="special">)</span>
80<span class="special">{</span>
81 <span class="identifier">ConvertThreadToFiber</span><span class="special">(</span> <span class="number">0</span><span class="special">);</span>
82 <span class="identifier">SwitchToFiber</span><span class="special">(</span> <span class="identifier">ctx</span><span class="special">);</span>
83 <span class="identifier">ConvertFiberToThread</span><span class="special">();</span>
84<span class="special">}</span>
85</pre>
86<p>
87 If the condition <code class="computeroutput"><span class="identifier">_WIN32_WINNT</span> <span class="special">&gt;=</span> <span class="identifier">_WIN32_WINNT_VISTA</span></code>
88 is met function <code class="computeroutput"><span class="identifier">IsThreadAFiber</span><span class="special">()</span></code> is provided in order to detect if the current
89 thread was already converted. Unfortunately Windows XP + SP 2/3 defines
90 <code class="computeroutput"><span class="identifier">_WIN32_WINNT</span> <span class="special">&gt;=</span>
91 <span class="identifier">_WIN32_WINNT_VISTA</span></code> without providing
92 <code class="computeroutput"><span class="identifier">IsThreadAFiber</span><span class="special">()</span></code>.
93 </p>
94<div class="footnotes">
95<br><hr width="100" align="left">
96<div class="footnote"><p><sup>[<a name="ftn.context.rationale.other_apis_.f0" href="#context.rationale.other_apis_.f0" class="para">2</a>] </sup>
97 ISO/IEC 9899:1999, 2005, 7.13.2.1:2
98 </p></div>
99<div class="footnote"><p><sup>[<a name="ftn.context.rationale.other_apis_.f1" href="#context.rationale.other_apis_.f1" class="para">3</a>] </sup>
100 ISO/IEC 9899:1999, 2005, J.2
101 </p></div>
102</div>
103</div>
104<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
105<td align="left"></td>
106<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Oliver Kowalke<p>
107 Distributed under the Boost Software License, Version 1.0. (See accompanying
108 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
109 </p>
110</div></td>
111</tr></table>
112<hr>
113<div class="spirit-nav">
114<a accesskey="p" href="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="x86_and_floating_point_env.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
115</div>
116</body>
117</html>