]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/context/doc/rationale.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / doc / rationale.qbk
CommitLineData
7c673cae
FG
1[/
2 Copyright Oliver Kowalke 2014.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt
6]
7
8[section:rationale Rationale]
9
10[heading No inline-assembler]
11
12Some newer compiler (for instance MSVC 10 for x86_64 and itanium) do not
13support inline assembler.
14[footnote [@http://msdn.microsoft.com/en-us/library/4ks26t93.aspx MSDN article
15'Inline Assembler']].
16Inlined assembler generates code bloating which is not welcome on embedded
17systems.
18
19
20[heading fcontext_t]
21
22__boost_context__ provides the low level API fcontext_t which is
23implemented in assembler to provide context swapping operations.
24fcontext_t is the part to port to new platforms.
25
26[note Context switches do not preserve the signal mask on UNIX systems.]
27
28__fcontext__ is an opaque pointer.
29
30
31
32[section Other APIs ]
33
34[heading setjmp()/longjmp()]
35
36C99 defines `setjmp()`/`longjmp()` to provide non-local jumps but it does not
37require that ['longjmp()] preserves the current stack frame. Therefore, jumping
38into a function which was exited via a call to ['longjmp()] is undefined
39[footnote ISO/IEC 9899:1999, 2005, 7.13.2.1:2].
40
41
42[heading ucontext_t]
43
44Since POSIX.1-2003 `ucontext_t` is deprecated and was removed in POSIX.1-2008!
45The function signature of `makecontext()` is:
46
47 void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
48
49The third argument of `makecontext()` specifies the number of integer arguments
50that follow which will require function pointer cast if `func` will accept those
51arguments which is undefined in C99
52[footnote ISO/IEC 9899:1999, 2005, J.2].
53
54The arguments in the var-arg list are required to be integers, passing pointers
55in var-arg list is not guaranteed to work, especially it will fail for
56architectures where pointers are larger than integers.
57
58`ucontext_t` preserves signal mask between context switches which involves system
59calls consuming a lot of CPU cycles (ucontext_t is slower by
60perfomance_link[factor 13x] relative to `fcontext_t`).
61
62
63[heading Windows fibers]
64
65A drawback of Windows Fiber API is that `CreateFiber()` does not accept a
66pointer to user allocated stack space preventing the reuse of stacks for other
67context instances. Because the Windows Fiber API requires to call
68`ConvertThreadToFiber()` if `SwitchFiber()` is called for a thread which has not
69been converted to a fiber. For the same reason `ConvertFiberToThread()`
70must be called after return from `SwitchFiber()` if the thread was forced to be
71converted to a fiber before (which is inefficient).
72
73 if ( ! is_a_fiber() )
74 {
75 ConvertThreadToFiber( 0);
76 SwitchToFiber( ctx);
77 ConvertFiberToThread();
78 }
79
80If the condition `_WIN32_WINNT >= _WIN32_WINNT_VISTA` is met function
81`IsThreadAFiber()` is provided in order to detect if the current thread was
82already converted. Unfortunately Windows XP + SP 2/3 defines
83`_WIN32_WINNT >= _WIN32_WINNT_VISTA` without providing `IsThreadAFiber()`.
84
85[endsect]
86
87
88[section x86 and floating-point env]
89
90[heading i386]
91
92"The FpCsr and the MxCsr register must be saved and restored before any call or return
93by any procedure that needs to modify them ..."
94[footnote 'Calling Conventions', Agner Fog].
95
96
97[heading x86_64]
98
99[heading Windows]
100
101MxCsr - "A callee that modifies any of the non-volatile fields within MxCsr must restore
102them before returning to its caller. Furthermore, a caller that has modified any
103of these fields must restore them to their standard values before invoking a callee ..."
104[footnote [@http://http://msdn.microsoft.com/en-us/library/yxty7t75.aspx MSDN article
105'MxCsr']].
106
107FpCsr - "A callee that modifies any of the fields within FpCsr must restore them before
108returning to its caller. Furthermore, a caller that has modified any of these
109fields must restore them to their standard values before invoking a callee ..."
110[footnote [@http://http://msdn.microsoft.com/en-us/library/ms235300.aspx MSDN article
111'FpCsr']].
112
113"The MMX and floating-point stack registers (MM0-MM7/ST0-ST7) are preserved across
114context switches. There is no explicit calling convention for these registers."
115[footnote [@http://msdn.microsoft.com/en-us/library/a32tsf7t%28VS.80%29.aspx MSDN article
116'Legacy Floating-Point Support']].
117
118"The 64-bit Microsoft compiler does not use ST(0)-ST(7)/MM0-MM7".
119[footnote 'Calling Conventions', Agner Fog].
120
121"XMM6-XMM15 must be preserved"
122[footnote [@http://msdn.microsoft.com/en-us/library/9z1stfyw%28v=vs.100%29.aspx MSDN
123article 'Register Usage']]
124
125[heading SysV]
126
127"The control bits of the MxCsr register are callee-saved (preserved across calls),
128while the status bits are caller-saved (not preserved). The x87 status word register is
129caller-saved, whereas the x87 control word (FpCsr) is callee-saved."
130[footnote SysV ABI AMD64 Architecture Processor Supplement Draft Version 0.99.4, 3.2.1].
131
132[endsect]
133
134
135[endsect]