<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="ExtUnixSpecific.BigEndian.html"> <link rel="next" href="ExtUnixSpecific.HostEndian.html"> <link rel="Up" href="ExtUnixSpecific.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="ExtUnix" rel="Chapter" href="ExtUnix.html"> <link title="ExtUnixAll" rel="Chapter" href="ExtUnixAll.html"> <link title="ExtUnixSpecific" rel="Chapter" href="ExtUnixSpecific.html"><title>ExtUnixSpecific.LittleEndian</title> </head> <body> <div class="navbar"><a class="pre" href="ExtUnixSpecific.BigEndian.html" title="ExtUnixSpecific.BigEndian">Previous</a> <a class="up" href="ExtUnixSpecific.html" title="ExtUnixSpecific">Up</a> <a class="post" href="ExtUnixSpecific.HostEndian.html" title="ExtUnixSpecific.HostEndian">Next</a> </div> <h1>Module <a href="type_ExtUnixSpecific.LittleEndian.html">ExtUnixSpecific.LittleEndian</a></h1> <pre><span class="keyword">module</span> LittleEndian: <code class="code">sig</code> <a href="ExtUnixSpecific.LittleEndian.html">..</a> <code class="code">end</code></pre><div class="info"> <h2 id="2_littleendianfunctions">little endian functions</h2> <p> <b>Author:</b> Goswin von Brederlow<br> </div> <hr width="100%"> <br> Conversion functions from host to little endian byte order and back<br> <br> Conversion of 16bit integers<br> <pre><span id="VALuint16_from_host"><span class="keyword">val</span> uint16_from_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">uint16_from_host u16</code> converts an unsigned 16bit integer from host to little endian byte order<br> </div> <pre><span id="VALint16_from_host"><span class="keyword">val</span> int16_from_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">int16_from_host i16</code> converts a signed 16bit integer from host to little endian byte order<br> </div> <pre><span id="VALuint16_to_host"><span class="keyword">val</span> uint16_to_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">uint16_to_host u16</code> converts an unsigned 16bit integer from little endian to host byte order<br> </div> <pre><span id="VALint16_to_host"><span class="keyword">val</span> int16_to_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">int16_to_host i16</code> converts a signed 16bit integer from little endian to host byte order<br> </div> <br> Conversion of 31bit integeres On 64bit platforms this actualy converts 32bit integers without the need to allocate a new int32. On 32bit platforms it produces garbage. For use on 64bit platforms only!<br> <pre><span id="VALuint31_from_host"><span class="keyword">val</span> uint31_from_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">uint31_from_host u31</code> converts an unsigned 31bit integer from host to little endian byte order<br> </div> <pre><span id="VALint31_from_host"><span class="keyword">val</span> int31_from_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">int31_from_host i31</code> converts a signed 31bit integer from host to little endian byte order<br> </div> <pre><span id="VALuint31_to_host"><span class="keyword">val</span> uint31_to_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">uint31_to_host u31</code> converts an unsigned 31bit integer from little endian to host byte order<br> </div> <pre><span id="VALint31_to_host"><span class="keyword">val</span> int31_to_host</span> : <code class="type">int -> int</code></pre><div class="info"> <code class="code">int31_to_host i31</code> converts a signed 31bit integer from little endian to host byte order<br> </div> <br> Conversion of 32bit integers<br> <pre><span id="VALint32_from_host"><span class="keyword">val</span> int32_from_host</span> : <code class="type">int32 -> int32</code></pre><div class="info"> <code class="code">int32_from_host int32</code> converts a 32bit integer from host to little endian byte order<br> </div> <pre><span id="VALint32_to_host"><span class="keyword">val</span> int32_to_host</span> : <code class="type">int32 -> int32</code></pre><div class="info"> <code class="code">int32_to_host int32</code> converts a 32bit integer from little endian to host byte order<br> </div> <br> Conversion of 64bit integers<br> <pre><span id="VALint64_from_host"><span class="keyword">val</span> int64_from_host</span> : <code class="type">int64 -> int64</code></pre><div class="info"> <code class="code">int64_from_host int64</code> converts a 64bit integer from host to little endian byte order<br> </div> <pre><span id="VALint64_to_host"><span class="keyword">val</span> int64_to_host</span> : <code class="type">int64 -> int64</code></pre><div class="info"> <code class="code">int64_to_host int64</code> converts a 64bit integer from little endian to host byte order<br> </div> <pre><span id="VALunsafe_get_uint8"><span class="keyword">val</span> unsafe_get_uint8</span> : <code class="type">string -> int -> int</code></pre><div class="info"> <code class="code">unsafe_get_X str off</code> extract integer of type <code class="code">X</code> from string <code class="code">str</code> starting at offset <code class="code">off</code>. Unsigned types are 0 extended and signed types are sign extended to fill the ocaml type. Bounds checking is not performed. Use with caution and only when the program logic guarantees that the access is within bounds. <p> Note: The 31bit functions extract a 32bit integer and return it as ocaml int. On 32bit platforms this can overflow as ocaml integers are 31bit signed there. No error is reported if this occurs. Use with care.<br> </div> <pre><span id="VALunsafe_get_int8"><span class="keyword">val</span> unsafe_get_int8</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALunsafe_get_uint16"><span class="keyword">val</span> unsafe_get_uint16</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALunsafe_get_int16"><span class="keyword">val</span> unsafe_get_int16</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALunsafe_get_uint31"><span class="keyword">val</span> unsafe_get_uint31</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALunsafe_get_int31"><span class="keyword">val</span> unsafe_get_int31</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALunsafe_get_int32"><span class="keyword">val</span> unsafe_get_int32</span> : <code class="type">string -> int -> int32</code></pre><pre><span id="VALunsafe_get_int64"><span class="keyword">val</span> unsafe_get_int64</span> : <code class="type">string -> int -> int64</code></pre><pre><span id="VALget_uint8"><span class="keyword">val</span> get_uint8</span> : <code class="type">string -> int -> int</code></pre><div class="info"> <code class="code">get_X str off</code> same as <code class="code">unsafe_get_X</code> but with bounds checking.<br> </div> <pre><span id="VALget_int8"><span class="keyword">val</span> get_int8</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALget_uint16"><span class="keyword">val</span> get_uint16</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALget_int16"><span class="keyword">val</span> get_int16</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALget_uint31"><span class="keyword">val</span> get_uint31</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALget_int31"><span class="keyword">val</span> get_int31</span> : <code class="type">string -> int -> int</code></pre><pre><span id="VALget_int32"><span class="keyword">val</span> get_int32</span> : <code class="type">string -> int -> int32</code></pre><pre><span id="VALget_int64"><span class="keyword">val</span> get_int64</span> : <code class="type">string -> int -> int64</code></pre><pre><span id="VALunsafe_set_uint8"><span class="keyword">val</span> unsafe_set_uint8</span> : <code class="type">string -> int -> int -> unit</code></pre><div class="info"> <code class="code">unsafe_set_X str off v</code> stores the integer <code class="code">v</code> as type <code class="code">X</code> in string <code class="code">str</code> starting at offset <code class="code">off</code>. Bounds checking is not performed. Use with caution and only when the program logic guarantees that the access is within bounds. <p> Note: The 31bit functions store an ocaml int as 32bit integer. On 32bit platforms ocaml integers are 31bit signed and will be sign extended to 32bit first. Use with care.<br> </div> <pre><span id="VALunsafe_set_int8"><span class="keyword">val</span> unsafe_set_int8</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALunsafe_set_uint16"><span class="keyword">val</span> unsafe_set_uint16</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALunsafe_set_int16"><span class="keyword">val</span> unsafe_set_int16</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALunsafe_set_uint31"><span class="keyword">val</span> unsafe_set_uint31</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALunsafe_set_int31"><span class="keyword">val</span> unsafe_set_int31</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALunsafe_set_int32"><span class="keyword">val</span> unsafe_set_int32</span> : <code class="type">string -> int -> int32 -> unit</code></pre><pre><span id="VALunsafe_set_int64"><span class="keyword">val</span> unsafe_set_int64</span> : <code class="type">string -> int -> int64 -> unit</code></pre><pre><span id="VALset_uint8"><span class="keyword">val</span> set_uint8</span> : <code class="type">string -> int -> int -> unit</code></pre><div class="info"> <code class="code">set_X str off v</code> same as <code class="code">unsafe_set_X</code> but with bounds checking.<br> </div> <pre><span id="VALset_int8"><span class="keyword">val</span> set_int8</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALset_uint16"><span class="keyword">val</span> set_uint16</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALset_int16"><span class="keyword">val</span> set_int16</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALset_uint31"><span class="keyword">val</span> set_uint31</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALset_int31"><span class="keyword">val</span> set_int31</span> : <code class="type">string -> int -> int -> unit</code></pre><pre><span id="VALset_int32"><span class="keyword">val</span> set_int32</span> : <code class="type">string -> int -> int32 -> unit</code></pre><pre><span id="VALset_int64"><span class="keyword">val</span> set_int64</span> : <code class="type">string -> int -> int64 -> unit</code></pre></body></html>