| OLD | NEW |
| 1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 | 2 |
| 3 <section id="pnacl-c-c-language-support"> | 3 <section id="pnacl-c-c-language-support"> |
| 4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1> | 4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1> |
| 5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
| 6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
| 7 <li><p class="first"><a class="reference internal" href="#source-language-suppor
t" id="id2">Source language support</a></p> | 7 <li><p class="first"><a class="reference internal" href="#source-language-suppor
t" id="id2">Source language support</a></p> |
| 8 <ul class="small-gap"> | 8 <ul class="small-gap"> |
| 9 <li><a class="reference internal" href="#versions" id="id3">Versions</a></li> | 9 <li><a class="reference internal" href="#versions" id="id3">Versions</a></li> |
| 10 <li><a class="reference internal" href="#preprocessor-definitions" id="id4">Prep
rocessor definitions</a></li> | 10 <li><a class="reference internal" href="#preprocessor-definitions" id="id4">Prep
rocessor definitions</a></li> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 <h3 id="memory-model-for-concurrent-operations">Memory Model for Concurrent Oper
ations</h3> | 64 <h3 id="memory-model-for-concurrent-operations">Memory Model for Concurrent Oper
ations</h3> |
| 65 <p>The memory model offered by PNaCl relies on the same coding guidelines | 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 | 66 as the C11/C++11 one: concurrent accesses must always occur through |
| 67 atomic primitives (offered by <a class="reference external" href="PNaClLangRef.h
tml#atomicintrinsics">atomic intrinsics</a>), and these accesses must always | 67 atomic primitives (offered by <a class="reference external" href="PNaClLangRef.h
tml#atomicintrinsics">atomic intrinsics</a>), and these accesses must always |
| 68 occur with the same size for the same memory location. Visibility of | 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 | 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> | 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 | 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 | 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 | 73 as after its creation. Accessing atomic memory location through |
| 74 non-atomic primitives is <cite>Undefined Behavior <undefined_behavior></ci
te>.</p> | 74 non-atomic primitives is <a class="reference internal" href="/native-client/refe
rence/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 | 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 | 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 | 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 retu
rn the | 78 <code>is_lock_free</code> methods and <code>atomic_is_lock_free</code> will retu
rn the |
| 79 current platform’s implementation at translation time. These macros, | 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 | 80 methods and functions are in the C11 header <code><stdatomic.h></code> and
the |
| 81 C++11 header <code><atomic></code>.</p> | 81 C++11 header <code><atomic></code>.</p> |
| 82 <p>The PNaCl toolchain supports concurrent memory accesses through legacy | 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 | 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> | 84 primitives and the underlying <a class="reference external" href="http://gcc.gnu
.org/wiki/Atomic/GCCMM">GCCMM</a> <code>__atomic_*</code> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 consistent memory barrier (equivalent to <code>__sync_synchronize()</code>). In | 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 | 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 | 178 memory accesses, though in practice the implementation attempts to also |
| 179 prevent reordering of memory accesses to objects which may escape.</p> | 179 prevent reordering of memory accesses to objects which may escape.</p> |
| 180 <p>NaCl supports a fairly wide subset of inline assembly through GCC’s | 180 <p>NaCl supports a fairly wide subset of inline assembly through GCC’s |
| 181 inline assembly syntax, with the restriction that the sandboxing model | 181 inline assembly syntax, with the restriction that the sandboxing model |
| 182 for the target architecture has to be respected.</p> | 182 for the target architecture has to be respected.</p> |
| 183 </section><section id="undefined-behavior"> | 183 </section><section id="undefined-behavior"> |
| 184 <h2 id="undefined-behavior">Undefined Behavior</h2> | 184 <h2 id="undefined-behavior">Undefined Behavior</h2> |
| 185 <p>The C and C++ languages expose some undefined behavior which is | 185 <p>The C and C++ languages expose some undefined behavior which is |
| 186 discussed in <cite>PNaCl Undefined Behavior <undefined_behavior></cite>.</
p> | 186 discussed in <a class="reference internal" href="/native-client/reference/pnacl-
undefined-behavior.html#undefined-behavior"><em>PNaCl Undefined Behavior</em></a
>.</p> |
| 187 </section><section id="floating-point"> | 187 </section><section id="floating-point"> |
| 188 <h2 id="floating-point">Floating-Point</h2> | 188 <h2 id="floating-point">Floating-Point</h2> |
| 189 <p>PNaCl exposes 32-bit and 64-bit floating point operations which are | 189 <p>PNaCl exposes 32-bit and 64-bit floating point operations which are |
| 190 mostly IEEE-754 compliant. There are a few caveats:</p> | 190 mostly IEEE-754 compliant. There are a few caveats:</p> |
| 191 <ul class="small-gap"> | 191 <ul class="small-gap"> |
| 192 <li>Some <a class="reference internal" href="/native-client/reference/pnacl-unde
fined-behavior.html#undefined-behavior-fp"><em>floating-point behavior is curren
tly left as undefined</em></a>.</li> | 192 <li>Some <a class="reference internal" href="/native-client/reference/pnacl-unde
fined-behavior.html#undefined-behavior-fp"><em>floating-point behavior is curren
tly left as undefined</em></a>.</li> |
| 193 <li>The default rounding mode is round-to-nearest and other rounding modes | 193 <li>The default rounding mode is round-to-nearest and other rounding modes |
| 194 are currently not usable, which isn’t IEEE-754 compliant. PNaCl could | 194 are currently not usable, which isn’t IEEE-754 compliant. PNaCl could |
| 195 support switching modes (the 4 modes exposed by C99 <code>FLT_ROUNDS</code> | 195 support switching modes (the 4 modes exposed by C99 <code>FLT_ROUNDS</code> |
| 196 macros).</li> | 196 macros).</li> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 <p>Neither PNaCl nor NaCl currently support asynchronous interruption | 258 <p>Neither PNaCl nor NaCl currently support asynchronous interruption |
| 259 or suspension of threads.</p> | 259 or suspension of threads.</p> |
| 260 </li> | 260 </li> |
| 261 </ul> | 261 </ul> |
| 262 <p>If PNaCl were to support either of these, the interaction of | 262 <p>If PNaCl were to support either of these, the interaction of |
| 263 <code>volatile</code> and atomics with same-thread signal handling would need | 263 <code>volatile</code> and atomics with same-thread signal handling would need |
| 264 to be carefully detailed.</p> | 264 to be carefully detailed.</p> |
| 265 </section></section></section> | 265 </section></section></section> |
| 266 | 266 |
| 267 {{/partials.standard_nacl_article}} | 267 {{/partials.standard_nacl_article}} |
| OLD | NEW |