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>
160 linker flag. Exceptions are disabled by default so that faster and
161 smaller code is generated, and
<code>throw
</code> statements are replaced with
162 calls to
<code>abort()
</code>. The usual
<code>-fno-exceptions
</code> flag is also
163 supported. PNaCl will support full zero-cost exception handling in the
165 <p>NaCl supports full zero-cost C++ exception handling.
</p>
166 <h2 id=
"inline-assembly">Inline Assembly
</h2>
167 <p>Inline assembly isn
’t supported by PNaCl because it isn
’t portable. The
168 one current exception is the common compiler barrier idiom
169 <code>asm(
"":::
"memory
")
</code>, which gets transformed to a sequentially
170 consistent memory barrier (equivalent to
<code>__sync_synchronize()
</code>). In
171 PNaCl this barrier is only guaranteed to order
<code>volatile
</code> and atomic
172 memory accesses, though in practice the implementation attempts to also
173 prevent reordering of memory accesses to objects which may escape.
</p>
174 <p>PNaCl supports
<a class=
"reference internal" href=
"#portable-simd-vectors"><em>Portable SIMD Vectors
</em></a>,
175 which are traditionally expressed through target-specific intrinsics or
177 <p>NaCl supports a fairly wide subset of inline assembly through GCC
’s
178 inline assembly syntax, with the restriction that the sandboxing model
179 for the target architecture has to be respected.
</p>
180 <h2 id=
"portable-simd-vectors"><span id=
"id2"></span>Portable SIMD Vectors
</h2>
181 <p>SIMD vectors aren
’t part of the C/C++ standards and are traditionally
182 very hardware-specific. Portable Native Client offers a portable version
183 of SIMD vector datatypes and operations which map well to modern
184 architectures and offer performance which matches or approaches
185 hardware-specific uses.
</p>
186 <p>SIMD vector support was added to Portable Native Client for version
37 of Chrome
187 and more features, including performance enhancements, have been added in
188 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
190 <h3 id=
"hand-coding-vector-extensions">Hand-Coding Vector Extensions
</h3>
191 <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>
192 and
<a class=
"reference external" href=
"http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html">GCC vectors
</a> since these
193 are well supported by different hardware platforms and don
’t require any
194 new compiler intrinsics.
</p>
195 <p>Vector types can be used through the
<code>vector_size
</code> attribute:
</p>
196 <pre class=
"prettyprint">
197 #define VECTOR_BYTES
16
198 typedef int v4s __attribute__((vector_size(VECTOR_BYTES)));
202 c = a + b; /* c = {
6,
8,
10,
12} */
203 d = b
>> a; /* d = {
2,
1,
0,
0} */
205 <p>Vector comparisons are represented as a bitmask as wide as the compared
206 elements of all
<code>0</code> or all
<code>1</code>:
</p>
207 <pre class=
"prettyprint">
208 typedef int v4s __attribute__((vector_size(
16)));
210 v4s limit = {
32,
64,
128,
256};
211 v4s mask = in
> limit;
212 v4s ret = in
& mask;
216 <p>Vector datatypes are currently expected to be
128-bit wide with one of the
217 following element types, and they
’re expected to be aligned to the underlying
218 element
’s bit width (loads and store will otherwise be broken up into scalar
219 accesses to prevent faults):
</p>
220 <table border=
"1" class=
"docutils">
223 <thead valign=
"bottom">
224 <tr class=
"row-odd"><th class=
"head">Type
</th>
225 <th class=
"head">Num Elements
</th>
226 <th class=
"head">Vector Bit Width
</th>
227 <th class=
"head">Expected Bit Alignment
</th>
231 <tr class=
"row-even"><td><code>uint8_t
</code></td>
236 <tr class=
"row-odd"><td><code>int8_t
</code></td>
241 <tr class=
"row-even"><td><code>uint16_t
</code></td>
246 <tr class=
"row-odd"><td><code>int16_t
</code></td>
251 <tr class=
"row-even"><td><code>uint32_t
</code></td>
256 <tr class=
"row-odd"><td><code>int32_t
</code></td>
261 <tr class=
"row-even"><td><code>float
</code></td>
268 <p>64-bit integers and double-precision floating point will be supported in
269 a future release, as will
256-bit and
512-bit vectors.
</p>
270 <p>Vector element bit width alignment can be stated explicitly (this is assumed by
271 PNaCl, but not necessarily by other compilers), and smaller alignments can also
273 <pre class=
"prettyprint">
274 typedef int v4s_element __attribute__((vector_size(
16), aligned(
4)));
275 typedef int v4s_unaligned __attribute__((vector_size(
16), aligned(
1)));
277 <p>The following operators are supported on vectors:
</p>
278 <table border=
"1" class=
"docutils">
282 <tr class=
"row-odd"><td>unary
<code>+
</code>,
<code>-
</code></td>
284 <tr class=
"row-even"><td><code>++
</code>,
<code>--
</code></td>
286 <tr class=
"row-odd"><td><code>+
</code>,
<code>-
</code>,
<code>*
</code>,
<code>/
</code>,
<code>%
</code></td>
288 <tr class=
"row-even"><td><code>&</code>,
<code>|
</code>,
<code>^
</code>,
<code>~
</code></td>
290 <tr class=
"row-odd"><td><code>>></code>,
<code><<</code></td>
292 <tr class=
"row-even"><td><code>!
</code>,
<code>&&</code>,
<code>||
</code></td>
294 <tr class=
"row-odd"><td><code>==
</code>,
<code>!=
</code>,
<code>></code>,
<code><</code>,
<code>>=
</code>,
<code><=
</code></td>
296 <tr class=
"row-even"><td><code>=
</code></td>
300 <p>C-style casts can be used to convert one vector type to another without
301 modifying the underlying bits.
<code>__builtin_convertvector
</code> can be used
302 to convert from one type to another provided both types have the same
303 number of elements, truncating when converting from floating-point to
305 <pre class=
"prettyprint">
306 typedef unsigned v4u __attribute__((vector_size(
16)));
307 typedef float v4f __attribute__((vector_size(
16)));
308 v4u a = {
0x3f19999a,
0x40000000,
0x40490fdb,
0x66ff0c30};
309 v4f b = (v4f) a; /* b = {
0.6,
2,
3.14159,
6.02214e+23} */
310 v4u c = __builtin_convertvector(b, v4u); /* c = {
0,
2,
3,
0} */
312 <p>It is also possible to use array-style indexing into vectors to extract
313 individual elements using
<code>[]
</code>.
</p>
314 <pre class=
"prettyprint">
315 typedef unsigned v4u __attribute__((vector_size(
16)));
316 template
<typename T
>
317 void print(const T v) {
318 for (size_t i =
0; i != sizeof(v) / sizeof(v[
0]); ++i)
319 std::cout
<< v[i]
<< ' ';
320 std::cout
<< std::endl;
323 <p>Vector shuffles (often called permutation or swizzle) operations are
324 supported through
<code>__builtin_shufflevector
</code>. The builtin has two
325 vector arguments of the same element type, followed by a list of
326 constant integers that specify the element indices of the first two
327 vectors that should be extracted and returned in a new vector. These
328 element indices are numbered sequentially starting with the first
329 vector, continuing into the second vector. Thus, if
<code>vec1
</code> is a
330 4-element vector, index
<code>5</code> would refer to the second element of
331 <code>vec2
</code>. An index of
<code>-
1</code> can be used to indicate that the
332 corresponding element in the returned vector is a don’t care and can be
333 optimized by the backend.
</p>
334 <p>The result of
<code>__builtin_shufflevector
</code> is a vector with the same
335 element type as
<code>vec1
</code> /
<code>vec2
</code> but that has an element count equal
336 to the number of indices specified.
</p>
337 <pre class=
"prettyprint">
338 // identity operation - return
4-element vector v1.
339 __builtin_shufflevector(v1, v1,
0,
1,
2,
3)
341 //
"Splat
" element
0 of v1 into a
4-element result.
342 __builtin_shufflevector(v1, v1,
0,
0,
0,
0)
344 // Reverse
4-element vector v1.
345 __builtin_shufflevector(v1, v1,
3,
2,
1,
0)
347 // Concatenate every other element of
4-element vectors v1 and v2.
348 __builtin_shufflevector(v1, v2,
0,
2,
4,
6)
350 // Concatenate every other element of
8-element vectors v1 and v2.
351 __builtin_shufflevector(v1, v2,
0,
2,
4,
6,
8,
10,
12,
14)
353 // Shuffle v1 with some elements being undefined
354 __builtin_shufflevector(v1, v1,
3, -
1,
1, -
1)
356 <p>One common use of
<code>__builtin_shufflevector
</code> is to perform
357 vector-scalar operations:
</p>
358 <pre class=
"prettyprint">
359 typedef int v4s __attribute__((vector_size(
16)));
360 v4s shift_right_by(v4s shift_me, int shift_amount) {
361 v4s tmp = {shift_amount};
362 return shift_me
>> __builtin_shuffle_vector(tmp, tmp,
0,
0,
0,
0);
365 <h3 id=
"auto-vectorization">Auto-Vectorization
</h3>
366 <p>Auto-vectorization is currently not enabled for Portable Native Client,
367 but will be in a future release.
</p>
368 <h2 id=
"undefined-behavior">Undefined Behavior
</h2>
369 <p>The C and C++ languages expose some undefined behavior which is
370 discussed in
<a class=
"reference internal" href=
"/native-client/reference/pnacl-undefined-behavior.html#undefined-behavior"><em>PNaCl Undefined Behavior
</em></a>.
</p>
371 <h2 id=
"floating-point"><span id=
"c-cpp-floating-point"></span>Floating-Point
</h2>
372 <p>PNaCl exposes
32-bit and
64-bit floating point operations which are
373 mostly IEEE-
754 compliant. There are a few caveats:
</p>
374 <ul class=
"small-gap">
375 <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>
376 <li>The default rounding mode is round-to-nearest and other rounding modes
377 are currently not usable, which isn
’t IEEE-
754 compliant. PNaCl could
378 support switching modes (the
4 modes exposed by C99
<code>FLT_ROUNDS
</code>
380 <li>Signaling
<code>NaN
</code> never fault.
</li>
381 <li><p class=
"first">Fast-math optimizations are currently supported before
<em>pexe
</em> creation
382 time. A
<em>pexe
</em> loses all fast-math information when it is
383 created. Fast-math translation could be enabled at a later date,
384 potentially at a perf-function granularity. This wouldn
’t affect
385 already-existing
<em>pexe
</em>; it would be an opt-in feature.
</p>
386 <ul class=
"small-gap">
387 <li>Fused-multiply-add have higher precision and often execute faster;
388 PNaCl currently disallows them in the
<em>pexe
</em> because they aren
’t
389 supported on all platforms and can
’t realistically be
390 emulated. PNaCl could (but currently doesn
’t) only generate them in
391 the backend if fast-math were specified and the hardware supports
393 <li>Transcendentals aren
’t exposed by PNaCl
’s ABI; they are part of the
394 math library that is included in the
<em>pexe
</em>. PNaCl could, but
395 currently doesn
’t, use hardware support if fast-math were provided
396 in the
<em>pexe
</em>.
</li>
400 <h2 id=
"computed-goto">Computed
<code>goto
</code></h2>
401 <p>PNaCl supports computed
<code>goto
</code>, a non-standard GCC extension to C used
402 by some interpreters, by lowering them to
<code>switch
</code> statements. The
403 resulting use of
<code>switch
</code> might not be as fast as the original
404 indirect branches. If you are compiling a program that has a
405 compile-time option for using computed
<code>goto
</code>, it
’s possible that the
406 program will run faster with the option turned off (e.g., if the program
407 does extra work to take advantage of computed
<code>goto
</code>).
</p>
408 <p>NaCl supports computed
<code>goto
</code> without any transformation.
</p>
409 <h2 id=
"future-directions">Future Directions
</h2>
410 <h3 id=
"inter-process-communication">Inter-Process Communication
</h3>
411 <p>Inter-process communication through shared memory is currently not
412 supported by PNaCl/NaCl. When implemented, it may be limited to
413 operations which are lock-free on the current platform (
<code>is_lock_free
</code>
414 methods). It will rely on the address-free properly discussed in
<a class=
"reference internal" href=
"#memory-model-for-concurrent-operations">Memory
415 Model for Concurrent Operations
</a>.
</p>
416 <h3 id=
"posix-style-signal-handling">POSIX-style Signal Handling
</h3>
417 <p>POSIX-style signal handling really consists of two different features:
</p>
418 <ul class=
"small-gap">
419 <li><p class=
"first"><strong>Hardware exception handling
</strong> (synchronous signals): The ability
420 to catch hardware exceptions (such as memory access faults and
421 division by zero) using a signal handler.
</p>
422 <p>PNaCl currently doesn
’t support hardware exception handling.
</p>
423 <p>NaCl supports hardware exception handling via the
424 <code><nacl/nacl_exception.h
></code> interface.
</p>
426 <li><p class=
"first"><strong>Asynchronous interruption of threads
</strong> (asynchronous signals): The
427 ability to asynchronously interrupt the execution of a thread,
428 forcing the thread to run a signal handler.
</p>
429 <p>A similar feature is
<strong>thread suspension
</strong>: The ability to
430 asynchronously suspend and resume a thread and inspect or modify its
431 execution state (such as register state).
</p>
432 <p>Neither PNaCl nor NaCl currently support asynchronous interruption
433 or suspension of threads.
</p>
436 <p>If PNaCl were to support either of these, the interaction of
437 <code>volatile
</code> and atomics with same-thread signal handling would need
438 to be carefully detailed.
</p>
441 {{/partials.standard_nacl_article}}