]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/context/doc/html/context/econtext/rationale/other_apis_.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / doc / html / context / econtext / 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><h4 class="title">
27<a name="context.econtext.rationale.other_apis_"></a><a class="link" href="other_apis_.html" title="Other APIs">Other APIs
28 </a>
29</h4></div></div></div>
30<h6>
31<a name="context.econtext.rationale.other_apis_.h0"></a>
32 <span><a name="context.econtext.rationale.other_apis_.setjmp___longjmp__"></a></span><a class="link" href="other_apis_.html#context.econtext.rationale.other_apis_.setjmp___longjmp__">setjmp()/longjmp()</a>
33 </h6>
34<p>
35 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>
36 to provide non-local jumps but it does not require that <span class="emphasis"><em>longjmp()</em></span>
37 preserves the current stack frame. Therefore, jumping into a function which
38 was exited via a call to <span class="emphasis"><em>longjmp()</em></span> is undefined <sup>[<a name="context.econtext.rationale.other_apis_.f0" href="#ftn.context.econtext.rationale.other_apis_.f0" class="footnote">2</a>]</sup>.
39 </p>
40<h6>
41<a name="context.econtext.rationale.other_apis_.h1"></a>
42 <span><a name="context.econtext.rationale.other_apis_.ucontext_t"></a></span><a class="link" href="other_apis_.html#context.econtext.rationale.other_apis_.ucontext_t">ucontext_t</a>
43 </h6>
44<p>
45 Since POSIX.1-2003 <code class="computeroutput"><span class="identifier">ucontext_t</span></code>
46 is deprecated and was removed in POSIX.1-2008! The function signature of
47 <code class="computeroutput"><span class="identifier">makecontext</span><span class="special">()</span></code>
48 is:
49 </p>
50<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>
51</pre>
52<p>
53 The third argument of <code class="computeroutput"><span class="identifier">makecontext</span><span class="special">()</span></code> specifies the number of integer arguments
54 that follow which will require function pointer cast if <code class="computeroutput"><span class="identifier">func</span></code>
55 will accept those arguments which is undefined in C99 <sup>[<a name="context.econtext.rationale.other_apis_.f1" href="#ftn.context.econtext.rationale.other_apis_.f1" class="footnote">3</a>]</sup>.
56 </p>
57<p>
58 The arguments in the var-arg list are required to be integers, passing
59 pointers in var-arg list is not guaranteed to work, especially it will
60 fail for architectures where pointers are larger than integers.
61 </p>
62<p>
63 <code class="computeroutput"><span class="identifier">ucontext_t</span></code> preserves signal
64 mask between context switches which involves system calls consuming a lot
65 of CPU cycles (ucontext_t is slower by perfomance_link[factor 13x] relative
66 to <code class="computeroutput"><span class="identifier">fcontext_t</span></code>).
67 </p>
68<h6>
69<a name="context.econtext.rationale.other_apis_.h2"></a>
70 <span><a name="context.econtext.rationale.other_apis_.windows_fibers"></a></span><a class="link" href="other_apis_.html#context.econtext.rationale.other_apis_.windows_fibers">Windows
71 fibers</a>
72 </h6>
73<p>
74 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
75 stack space preventing the reuse of stacks for other context instances.
76 Because 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
77 been 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>
78 if the thread was forced to be converted to a fiber before (which is inefficient).
79 </p>
80<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>
81<span class="special">{</span>
82 <span class="identifier">ConvertThreadToFiber</span><span class="special">(</span> <span class="number">0</span><span class="special">);</span>
83 <span class="identifier">SwitchToFiber</span><span class="special">(</span> <span class="identifier">ctx</span><span class="special">);</span>
84 <span class="identifier">ConvertFiberToThread</span><span class="special">();</span>
85<span class="special">}</span>
86</pre>
87<p>
88 If the condition <code class="computeroutput"><span class="identifier">_WIN32_WINNT</span>
89 <span class="special">&gt;=</span> <span class="identifier">_WIN32_WINNT_VISTA</span></code>
90 is met function <code class="computeroutput"><span class="identifier">IsThreadAFiber</span><span class="special">()</span></code> is provided in order to detect if the
91 current thread was already converted. Unfortunately Windows XP + SP 2/3
92 defines <code class="computeroutput"><span class="identifier">_WIN32_WINNT</span> <span class="special">&gt;=</span>
93 <span class="identifier">_WIN32_WINNT_VISTA</span></code> without providing
94 <code class="computeroutput"><span class="identifier">IsThreadAFiber</span><span class="special">()</span></code>.
95 </p>
96<div class="footnotes">
97<br><hr width="100" align="left">
98<div class="footnote"><p><sup>[<a name="ftn.context.econtext.rationale.other_apis_.f0" href="#context.econtext.rationale.other_apis_.f0" class="para">2</a>] </sup>
99 ISO/IEC 9899:1999, 2005, 7.13.2.1:2
100 </p></div>
101<div class="footnote"><p><sup>[<a name="ftn.context.econtext.rationale.other_apis_.f1" href="#context.econtext.rationale.other_apis_.f1" class="para">3</a>] </sup>
102 ISO/IEC 9899:1999, 2005, J.2
103 </p></div>
104</div>
105</div>
106<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
107<td align="left"></td>
108<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Oliver Kowalke<p>
109 Distributed under the Boost Software License, Version 1.0. (See accompanying
110 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>)
111 </p>
112</div></td>
113</tr></table>
114<hr>
115<div class="spirit-nav">
116<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>
117</div>
118</body>
119</html>