1 {{+bindTo:partials.standard_nacl_article}}
3 <section id=
"pnacl-c-c-language-support">
4 <h1 id=
"pnacl-c-c-language-support">PNaCl C/C++ Language Support
</h1>
5 <div class=
"contents local" id=
"contents" style=
"display: none">
7 <li><p class=
"first"><a class=
"reference internal" href=
"#source-language-support" id=
"id3">Source language support
</a></p>
9 <li><a class=
"reference internal" href=
"#versions" id=
"id4">Versions
</a></li>
10 <li><a class=
"reference internal" href=
"#preprocessor-definitions" id=
"id5">Preprocessor definitions
</a></li>
13 <li><p class=
"first"><a class=
"reference internal" href=
"#memory-model-and-atomics" id=
"id6">Memory Model and Atomics
</a></p>
14 <ul class=
"small-gap">
15 <li><a class=
"reference internal" href=
"#memory-model-for-concurrent-operations" id=
"id7">Memory Model for Concurrent Operations
</a></li>
16 <li><a class=
"reference internal" href=
"#atomic-memory-ordering-constraints" id=
"id8">Atomic Memory Ordering Constraints
</a></li>
17 <li><a class=
"reference internal" href=
"#volatile-memory-accesses" id=
"id9">Volatile Memory Accesses
</a></li>
20 <li><a class=
"reference internal" href=
"#threading" id=
"id10">Threading
</a></li>
21 <li><a class=
"reference internal" href=
"#setjmp-and-longjmp" id=
"id11"><code>setjmp
</code> and
<code>longjmp
</code></a></li>
22 <li><a class=
"reference internal" href=
"#c-exception-handling" id=
"id12">C++ Exception Handling
</a></li>
23 <li><a class=
"reference internal" href=
"#inline-assembly" id=
"id13">Inline Assembly
</a></li>
24 <li><p class=
"first"><a class=
"reference internal" href=
"#portable-simd-vectors" id=
"id14">Portable SIMD Vectors
</a></p>
25 <ul class=
"small-gap">
26 <li><a class=
"reference internal" href=
"#hand-coding-vector-extensions" id=
"id15">Hand-Coding Vector Extensions
</a></li>
27 <li><a class=
"reference internal" href=
"#auto-vectorization" id=
"id16">Auto-Vectorization
</a></li>
30 <li><a class=
"reference internal" href=
"#undefined-behavior" id=
"id17">Undefined Behavior
</a></li>
31 <li><a class=
"reference internal" href=
"#floating-point" id=
"id18">Floating-Point
</a></li>
32 <li><a class=
"reference internal" href=
"#computed-goto" id=
"id19">Computed
<code>goto
</code></a></li>
33 <li><p class=
"first"><a class=
"reference internal" href=
"#future-directions" id=
"id20">Future Directions
</a></p>
34 <ul class=
"small-gap">
35 <li><a class=
"reference internal" href=
"#inter-process-communication" id=
"id21">Inter-Process Communication
</a></li>
36 <li><a class=
"reference internal" href=
"#posix-style-signal-handling" id=
"id22">POSIX-style Signal Handling
</a></li>
41 </div><h2 id=
"source-language-support">Source language support
</h2>
42 <p>The currently supported languages are C and C++. The PNaCl toolchain is
43 based on recent Clang, which fully supports C++
11 and most of C11. A
44 detailed status of the language support is available
<a class=
"reference external" href=
"http://clang.llvm.org/cxx_status.html">here
</a>.
</p>
45 <p>For information on using languages other than C/C++, see the
<a class=
"reference internal" href=
"/native-client/faq.html#other-languages"><em>FAQ
46 section on other languages
</em></a>.
</p>
47 <p>As for the standard libraries, the PNaCl toolchain is currently based on
48 <code>libc++
</code>, and the
<code>newlib
</code> standard C library.
<code>libstdc++
</code> is also
49 supported but its use is discouraged; see
<a class=
"reference internal" href=
"/native-client/devguide/devcycle/building.html#building-cpp-libraries"><em>C++ standard libraries
</em></a>
51 <h3 id=
"versions">Versions
</h3>
52 <p>Version information can be obtained:
</p>
53 <ul class=
"small-gap">
54 <li>Clang/LLVM: run
<code>pnacl-clang -v
</code>.
</li>
55 <li><code>newlib
</code>: use the
<code>_NEWLIB_VERSION
</code> macro.
</li>
56 <li><code>libc++
</code>: use the
<code>_LIBCPP_VERSION
</code> macro.
</li>
57 <li><code>libstdc++
</code>: use the
<code>_GLIBCXX_VERSION
</code> macro.
</li>
59 <h3 id=
"preprocessor-definitions">Preprocessor definitions
</h3>
60 <p>When compiling C/C++ code, the PNaCl toolchain defines the
<code>__pnacl__
</code>
61 macro. In addition,
<code>__native_client__
</code> is defined for compatibility
62 with other NaCl toolchains.
</p>
63 <h2 id=
"memory-model-and-atomics"><span id=
"id1"></span>Memory Model and Atomics
</h2>
64 <h3 id=
"memory-model-for-concurrent-operations">Memory Model for Concurrent Operations
</h3>
65 <p>The memory model offered by PNaCl relies on the same coding guidelines
66 as the C11/C++
11 one: concurrent accesses must always occur through
67 atomic primitives (offered by
<a class=
"reference internal" href=
"/native-client/reference/pnacl-bitcode-abi.html#bitcode-atomicintrinsics"><em>atomic intrinsics
</em></a>), and these accesses must always
68 occur with the same size for the same memory location. Visibility of
69 stores is provided on a happens-before basis that relates memory
70 locations to each other as the C11/C++
11 standards do.
</p>
71 <p>Non-atomic memory accesses may be reordered, separated, elided or fused
72 according to C and C++
’s memory model before the pexe is created as well
73 as after its creation. Accessing atomic memory location through
74 non-atomic primitives is
<a class=
"reference internal" href=
"/native-client/reference/pnacl-undefined-behavior.html#undefined-behavior"><em>Undefined Behavior
</em></a>.
</p>
75 <p>As in C11/C++
11 some atomic accesses may be implemented with locks on
76 certain platforms. The
<code>ATOMIC_*_LOCK_FREE
</code> macros will always be
77 <code>1</code>, signifying that all types are sometimes lock-free. The
78 <code>is_lock_free
</code> methods and
<code>atomic_is_lock_free
</code> will return the
79 current platform
’s implementation at translation time. These macros,
80 methods and functions are in the C11 header
<code><stdatomic.h
></code> and the
81 C++
11 header
<code><atomic
></code>.
</p>
82 <p>The PNaCl toolchain supports concurrent memory accesses through legacy
83 GCC-style
<code>__sync_*
</code> builtins, as well as through C11/C++
11 atomic
84 primitives and the underlying
<a class=
"reference external" href=
"http://gcc.gnu.org/wiki/Atomic/GCCMM">GCCMM
</a> <code>__atomic_*
</code>
85 primitives.
<code>volatile
</code> memory accesses can also be used, though these
86 are discouraged. See
<a class=
"reference internal" href=
"#volatile-memory-accesses">Volatile Memory Accesses
</a>.
</p>
87 <p>PNaCl supports concurrency and parallelism with some restrictions:
</p>
88 <ul class=
"small-gap">
89 <li>Threading is explicitly supported and has no restrictions over what
90 prevalent implementations offer. See
<a class=
"reference internal" href=
"#threading">Threading
</a>.
</li>
91 <li><code>volatile
</code> and atomic operations are address-free (operations on the
92 same memory location via two different addresses work atomically), as
93 intended by the C11/C++
11 standards. This is critical in supporting
94 synchronous
“external modifications
” such as mapping underlying memory
95 at multiple locations.
</li>
96 <li>Inter-process communication through shared memory is currently not
97 supported. See
<a class=
"reference internal" href=
"#future-directions">Future Directions
</a>.
</li>
98 <li>Signal handling isn
’t supported, PNaCl therefore promotes all
99 primitives to cross-thread (instead of single-thread). This may change
100 at a later date. Note that using atomic operations which aren
’t
101 lock-free may lead to deadlocks when handling asynchronous
102 signals. See
<a class=
"reference internal" href=
"#future-directions">Future Directions
</a>.
</li>
103 <li>Direct interaction with device memory isn
’t supported, and there is no
104 intent to support it. The embedding sandbox
’s runtime can offer APIs
105 to indirectly access devices.
</li>
107 <p>Setting up the above mechanisms requires assistance from the embedding
108 sandbox
’s runtime (e.g. NaCl
’s Pepper APIs), but using them once setup
109 can be done through regular C/C++ code.
</p>
110 <h3 id=
"atomic-memory-ordering-constraints">Atomic Memory Ordering Constraints
</h3>
111 <p>Atomics follow the same ordering constraints as in regular C11/C++
11,
112 but all accesses are promoted to sequential consistency (the strongest
113 memory ordering) at pexe creation time. We plan to support more of the
114 C11/C++
11 memory orderings in the future.
</p>
115 <p>Some additional restrictions, following the C11/C++
11 standards:
</p>
116 <ul class=
"small-gap">
117 <li>Atomic accesses must at least be naturally aligned.
</li>
118 <li>Some accesses may not actually be atomic on certain platforms,
119 requiring an implementation that uses global locks.
</li>
120 <li>An atomic memory location must always be accessed with atomic
121 primitives, and these primitives must always be of the same bit size
122 for that location.
</li>
123 <li>Not all memory orderings are valid for all atomic operations.
</li>
125 <h3 id=
"volatile-memory-accesses">Volatile Memory Accesses
</h3>
126 <p>The C11/C++
11 standards mandate that
<code>volatile
</code> accesses execute in
127 program order (but are not fences, so other memory operations can
128 reorder around them), are not necessarily atomic, and can’t be
129 elided. They can be separated into smaller width accesses.
</p>
130 <p>Before any optimizations occur, the PNaCl toolchain transforms
131 <code>volatile
</code> loads and stores into sequentially consistent
<code>volatile
</code>
132 atomic loads and stores, and applies regular compiler optimizations
133 along the above guidelines. This orders
<code>volatiles
</code> according to the
134 atomic rules, and means that fences (including
<code>__sync_synchronize
</code>)
135 act in a better-defined manner. Regular memory accesses still do not
136 have ordering guarantees with
<code>volatile
</code> and atomic accesses, though
137 the internal representation of
<code>__sync_synchronize
</code> attempts to
138 prevent reordering of memory accesses to objects which may escape.
</p>
139 <p>Relaxed ordering could be used instead, but for the first release it is
140 more conservative to apply sequential consistency. Future releases may
141 change what happens at compile-time, but already-released pexes will
142 continue using sequential consistency.
</p>
143 <p>The PNaCl toolchain also requires that
<code>volatile
</code> accesses be at least
144 naturally aligned, and tries to guarantee this alignment.
</p>
145 <p>The above guarantees ease the support of legacy (i.e. non-C11/C++
11)
146 code, and combined with builtin fences these programs can do meaningful
147 cross-thread communication without changing code. They also better
148 reflect the original code
’s intent and guarantee better portability.
</p>
149 <h2 id=
"threading"><span id=
"language-support-threading"></span>Threading
</h2>
150 <p>Threading is explicitly supported through C11/C++
11’s threading
151 libraries as well as POSIX threads.
</p>
152 <p>Communication between threads should use atomic primitives as described
153 in
<a class=
"reference internal" href=
"#id1">Memory Model and Atomics
</a>.
</p>
154 <h2 id=
"setjmp-and-longjmp"><code>setjmp
</code> and
<code>longjmp
</code></h2>
155 <p>PNaCl and NaCl support
<code>setjmp
</code> and
<code>longjmp
</code> without any
156 restrictions beyond C
’s.
</p>
157 <h2 id=
"c-exception-handling"><span id=
"exception-handling"></span>C++ Exception Handling
</h2>
158 <p>PNaCl currently supports C++ exception handling through
<code>setjmp()
</code> and
159 <code>longjmp()
</code>, which can be enabled with the
<code>--pnacl-exceptions=sjlj
</code> linker
160 flag (set with
<code>LDFLAGS
</code> when using Make). Exceptions are disabled by default
161 so that faster and smaller code is generated, and
<code>throw
</code> statements are
162 replaced with calls to
<code>abort()
</code>. The usual
<code>-fno-exceptions
</code> flag is also
163 supported, though the default is
<code>-fexceptions
</code>. PNaCl will support full
164 zero-cost exception handling in the future.
</p>
166 When using
<a class=
"reference external" href=
"https://code.google.com/p/naclports">naclports
</a> or other prebuilt static libraries, you don
’t
167 need to recompile because the exception handling support is
168 implemented at link time (when all the static libraries are put
169 together with your application).
171 <p>NaCl supports full zero-cost C++ exception handling.
</p>
172 <h2 id=
"inline-assembly">Inline Assembly
</h2>
173 <p>Inline assembly isn
’t supported by PNaCl because it isn
’t portable. The
174 one current exception is the common compiler barrier idiom
175 <code>asm(
"":::
"memory
")
</code>, which gets transformed to a sequentially
176 consistent memory barrier (equivalent to
<code>__sync_synchronize()
</code>). In
177 PNaCl this barrier is only guaranteed to order
<code>volatile
</code> and atomic
178 memory accesses, though in practice the implementation attempts to also
179 prevent reordering of memory accesses to objects which may escape.
</p>
180 <p>PNaCl supports
<a class=
"reference internal" href=
"#portable-simd-vectors"><em>Portable SIMD Vectors
</em></a>,
181 which are traditionally expressed through target-specific intrinsics or
183 <p>NaCl supports a fairly wide subset of inline assembly through GCC
’s
184 inline assembly syntax, with the restriction that the sandboxing model
185 for the target architecture has to be respected.
</p>
186 <h2 id=
"portable-simd-vectors"><span id=
"id2"></span>Portable SIMD Vectors
</h2>
187 <p>SIMD vectors aren
’t part of the C/C++ standards and are traditionally
188 very hardware-specific. Portable Native Client offers a portable version
189 of SIMD vector datatypes and operations which map well to modern
190 architectures and offer performance which matches or approaches
191 hardware-specific uses.
</p>
192 <p>SIMD vector support was added to Portable Native Client for version
37 of Chrome
193 and more features, including performance enhancements, have been added in
194 subsequent releases, see the
<a class=
"reference internal" href=
"/native-client/sdk/release-notes.html#sdk-release-notes"><em>Release Notes
</em></a> for more
196 <h3 id=
"hand-coding-vector-extensions">Hand-Coding Vector Extensions
</h3>
197 <p>The initial vector support in Portable Native Client adds
<a class=
"reference external" href=
"http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors">LLVM vectors
</a>
198 and
<a class=
"reference external" href=
"http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html">GCC vectors
</a> since these
199 are well supported by different hardware platforms and don
’t require any
200 new compiler intrinsics.
</p>
201 <p>Vector types can be used through the
<code>vector_size
</code> attribute:
</p>
202 <pre class=
"prettyprint">
203 #define VECTOR_BYTES
16
204 typedef int v4s __attribute__((vector_size(VECTOR_BYTES)));
208 c = a + b; /* c = {
6,
8,
10,
12} */
209 d = b
>> a; /* d = {
2,
1,
0,
0} */
211 <p>Vector comparisons are represented as a bitmask as wide as the compared
212 elements of all
<code>0</code> or all
<code>1</code>:
</p>
213 <pre class=
"prettyprint">
214 typedef int v4s __attribute__((vector_size(
16)));
216 v4s limit = {
32,
64,
128,
256};
217 v4s mask = in
> limit;
218 v4s ret = in
& mask;
222 <p>Vector datatypes are currently expected to be
128-bit wide with one of the
223 following element types, and they
’re expected to be aligned to the underlying
224 element
’s bit width (loads and store will otherwise be broken up into scalar
225 accesses to prevent faults):
</p>
226 <table border=
"1" class=
"docutils">
229 <thead valign=
"bottom">
230 <tr class=
"row-odd"><th class=
"head">Type
</th>
231 <th class=
"head">Num Elements
</th>
232 <th class=
"head">Vector Bit Width
</th>
233 <th class=
"head">Expected Bit Alignment
</th>
237 <tr class=
"row-even"><td><code>uint8_t
</code></td>
242 <tr class=
"row-odd"><td><code>int8_t
</code></td>
247 <tr class=
"row-even"><td><code>uint16_t
</code></td>
252 <tr class=
"row-odd"><td><code>int16_t
</code></td>
257 <tr class=
"row-even"><td><code>uint32_t
</code></td>
262 <tr class=
"row-odd"><td><code>int32_t
</code></td>
267 <tr class=
"row-even"><td><code>float
</code></td>
274 <p>64-bit integers and double-precision floating point will be supported in
275 a future release, as will
256-bit and
512-bit vectors.
</p>
276 <p>Vector element bit width alignment can be stated explicitly (this is assumed by
277 PNaCl, but not necessarily by other compilers), and smaller alignments can also
279 <pre class=
"prettyprint">
280 typedef int v4s_element __attribute__((vector_size(
16), aligned(
4)));
281 typedef int v4s_unaligned __attribute__((vector_size(
16), aligned(
1)));
283 <p>The following operators are supported on vectors:
</p>
284 <table border=
"1" class=
"docutils">
288 <tr class=
"row-odd"><td>unary
<code>+
</code>,
<code>-
</code></td>
290 <tr class=
"row-even"><td><code>++
</code>,
<code>--
</code></td>
292 <tr class=
"row-odd"><td><code>+
</code>,
<code>-
</code>,
<code>*
</code>,
<code>/
</code>,
<code>%
</code></td>
294 <tr class=
"row-even"><td><code>&</code>,
<code>|
</code>,
<code>^
</code>,
<code>~
</code></td>
296 <tr class=
"row-odd"><td><code>>></code>,
<code><<</code></td>
298 <tr class=
"row-even"><td><code>!
</code>,
<code>&&</code>,
<code>||
</code></td>
300 <tr class=
"row-odd"><td><code>==
</code>,
<code>!=
</code>,
<code>></code>,
<code><</code>,
<code>>=
</code>,
<code><=
</code></td>
302 <tr class=
"row-even"><td><code>=
</code></td>
306 <p>C-style casts can be used to convert one vector type to another without
307 modifying the underlying bits.
<code>__builtin_convertvector
</code> can be used
308 to convert from one type to another provided both types have the same
309 number of elements, truncating when converting from floating-point to
311 <pre class=
"prettyprint">
312 typedef unsigned v4u __attribute__((vector_size(
16)));
313 typedef float v4f __attribute__((vector_size(
16)));
314 v4u a = {
0x3f19999a,
0x40000000,
0x40490fdb,
0x66ff0c30};
315 v4f b = (v4f) a; /* b = {
0.6,
2,
3.14159,
6.02214e+23} */
316 v4u c = __builtin_convertvector(b, v4u); /* c = {
0,
2,
3,
0} */
318 <p>It is also possible to use array-style indexing into vectors to extract
319 individual elements using
<code>[]
</code>.
</p>
320 <pre class=
"prettyprint">
321 typedef unsigned v4u __attribute__((vector_size(
16)));
322 template
<typename T
>
323 void print(const T v) {
324 for (size_t i =
0; i != sizeof(v) / sizeof(v[
0]); ++i)
325 std::cout
<< v[i]
<< ' ';
326 std::cout
<< std::endl;
329 <p>Vector shuffles (often called permutation or swizzle) operations are
330 supported through
<code>__builtin_shufflevector
</code>. The builtin has two
331 vector arguments of the same element type, followed by a list of
332 constant integers that specify the element indices of the first two
333 vectors that should be extracted and returned in a new vector. These
334 element indices are numbered sequentially starting with the first
335 vector, continuing into the second vector. Thus, if
<code>vec1
</code> is a
336 4-element vector, index
<code>5</code> would refer to the second element of
337 <code>vec2
</code>. An index of
<code>-
1</code> can be used to indicate that the
338 corresponding element in the returned vector is a don’t care and can be
339 optimized by the backend.
</p>
340 <p>The result of
<code>__builtin_shufflevector
</code> is a vector with the same
341 element type as
<code>vec1
</code> /
<code>vec2
</code> but that has an element count equal
342 to the number of indices specified.
</p>
343 <pre class=
"prettyprint">
344 // identity operation - return
4-element vector v1.
345 __builtin_shufflevector(v1, v1,
0,
1,
2,
3)
347 //
"Splat
" element
0 of v1 into a
4-element result.
348 __builtin_shufflevector(v1, v1,
0,
0,
0,
0)
350 // Reverse
4-element vector v1.
351 __builtin_shufflevector(v1, v1,
3,
2,
1,
0)
353 // Concatenate every other element of
4-element vectors v1 and v2.
354 __builtin_shufflevector(v1, v2,
0,
2,
4,
6)
356 // Concatenate every other element of
8-element vectors v1 and v2.
357 __builtin_shufflevector(v1, v2,
0,
2,
4,
6,
8,
10,
12,
14)
359 // Shuffle v1 with some elements being undefined
360 __builtin_shufflevector(v1, v1,
3, -
1,
1, -
1)
362 <p>One common use of
<code>__builtin_shufflevector
</code> is to perform
363 vector-scalar operations:
</p>
364 <pre class=
"prettyprint">
365 typedef int v4s __attribute__((vector_size(
16)));
366 v4s shift_right_by(v4s shift_me, int shift_amount) {
367 v4s tmp = {shift_amount};
368 return shift_me
>> __builtin_shuffle_vector(tmp, tmp,
0,
0,
0,
0);
371 <h3 id=
"auto-vectorization">Auto-Vectorization
</h3>
372 <p>Auto-vectorization is currently not enabled for Portable Native Client,
373 but will be in a future release.
</p>
374 <h2 id=
"undefined-behavior">Undefined Behavior
</h2>
375 <p>The C and C++ languages expose some undefined behavior which is
376 discussed in
<a class=
"reference internal" href=
"/native-client/reference/pnacl-undefined-behavior.html#undefined-behavior"><em>PNaCl Undefined Behavior
</em></a>.
</p>
377 <h2 id=
"floating-point"><span id=
"c-cpp-floating-point"></span>Floating-Point
</h2>
378 <p>PNaCl exposes
32-bit and
64-bit floating point operations which are
379 mostly IEEE-
754 compliant. There are a few caveats:
</p>
380 <ul class=
"small-gap">
381 <li>Some
<a class=
"reference internal" href=
"/native-client/reference/pnacl-undefined-behavior.html#undefined-behavior-fp"><em>floating-point behavior is currently left as undefined
</em></a>.
</li>
382 <li>The default rounding mode is round-to-nearest and other rounding modes
383 are currently not usable, which isn
’t IEEE-
754 compliant. PNaCl could
384 support switching modes (the
4 modes exposed by C99
<code>FLT_ROUNDS
</code>
386 <li>Signaling
<code>NaN
</code> never fault.
</li>
387 <li><p class=
"first">Fast-math optimizations are currently supported before
<em>pexe
</em> creation
388 time. A
<em>pexe
</em> loses all fast-math information when it is
389 created. Fast-math translation could be enabled at a later date,
390 potentially at a perf-function granularity. This wouldn
’t affect
391 already-existing
<em>pexe
</em>; it would be an opt-in feature.
</p>
392 <ul class=
"small-gap">
393 <li>Fused-multiply-add have higher precision and often execute faster;
394 PNaCl currently disallows them in the
<em>pexe
</em> because they aren
’t
395 supported on all platforms and can
’t realistically be
396 emulated. PNaCl could (but currently doesn
’t) only generate them in
397 the backend if fast-math were specified and the hardware supports
399 <li>Transcendentals aren
’t exposed by PNaCl
’s ABI; they are part of the
400 math library that is included in the
<em>pexe
</em>. PNaCl could, but
401 currently doesn
’t, use hardware support if fast-math were provided
402 in the
<em>pexe
</em>.
</li>
406 <h2 id=
"computed-goto">Computed
<code>goto
</code></h2>
407 <p>PNaCl supports computed
<code>goto
</code>, a non-standard GCC extension to C used
408 by some interpreters, by lowering them to
<code>switch
</code> statements. The
409 resulting use of
<code>switch
</code> might not be as fast as the original
410 indirect branches. If you are compiling a program that has a
411 compile-time option for using computed
<code>goto
</code>, it
’s possible that the
412 program will run faster with the option turned off (e.g., if the program
413 does extra work to take advantage of computed
<code>goto
</code>).
</p>
414 <p>NaCl supports computed
<code>goto
</code> without any transformation.
</p>
415 <h2 id=
"future-directions">Future Directions
</h2>
416 <h3 id=
"inter-process-communication">Inter-Process Communication
</h3>
417 <p>Inter-process communication through shared memory is currently not
418 supported by PNaCl/NaCl. When implemented, it may be limited to
419 operations which are lock-free on the current platform (
<code>is_lock_free
</code>
420 methods). It will rely on the address-free properly discussed in
<a class=
"reference internal" href=
"#memory-model-for-concurrent-operations">Memory
421 Model for Concurrent Operations
</a>.
</p>
422 <h3 id=
"posix-style-signal-handling">POSIX-style Signal Handling
</h3>
423 <p>POSIX-style signal handling really consists of two different features:
</p>
424 <ul class=
"small-gap">
425 <li><p class=
"first"><strong>Hardware exception handling
</strong> (synchronous signals): The ability
426 to catch hardware exceptions (such as memory access faults and
427 division by zero) using a signal handler.
</p>
428 <p>PNaCl currently doesn
’t support hardware exception handling.
</p>
429 <p>NaCl supports hardware exception handling via the
430 <code><nacl/nacl_exception.h
></code> interface.
</p>
432 <li><p class=
"first"><strong>Asynchronous interruption of threads
</strong> (asynchronous signals): The
433 ability to asynchronously interrupt the execution of a thread,
434 forcing the thread to run a signal handler.
</p>
435 <p>A similar feature is
<strong>thread suspension
</strong>: The ability to
436 asynchronously suspend and resume a thread and inspect or modify its
437 execution state (such as register state).
</p>
438 <p>Neither PNaCl nor NaCl currently support asynchronous interruption
439 or suspension of threads.
</p>
442 <p>If PNaCl were to support either of these, the interaction of
443 <code>volatile
</code> and atomics with same-thread signal handling would need
444 to be carefully detailed.
</p>
447 {{/partials.standard_nacl_article}}