12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <chapter xml:id="memory.h">
- <title><tt>__vic/memory.h</tt></title>
- <p>Memory-related utilities.</p>
- <chapter xml:id="load_unaligned">
- <title><tt>load_unaligned()</tt></title>
- <code-block lang="C++"><![CDATA[
- template<class T>
- T load_unaligned(const void *p);
- ]]></code-block>
- <p>Load value from potentially unaligned address without causing bus error
- (<tt>SIGBUS</tt>).</p>
- <section><title>Example</title>
- <code-block lang="C++"><![CDATA[
- const void *p = ...;
- // int data = *static_cast<const int *>(p); // potential bus error
- int data = __vic::load_unaligned<int>(p);
- ]]></code-block>
- </section>
- </chapter>
- <chapter xml:id="store_unaligned">
- <title><tt>store_unaligned()</tt></title>
- <code-block lang="C++"><![CDATA[
- template<class T>
- void store_unaligned(void *p, T v);
- ]]></code-block>
- <p>Store value to potentially unaligned address without causing bus error
- (<tt>SIGBUS</tt>).</p>
- <section><title>Example</title>
- <code-block lang="C++"><![CDATA[
- void *p = ...;
- // *static_cast<int *>(p) = 123; // potential bus error
- __vic::store_unaligned(p, 123);
- ]]></code-block>
- </section>
- </chapter>
- </chapter>
|