moonpool/lwt/Lwt_bytes/index.html
2025-09-26 19:08:06 +00:00

42 lines
28 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Lwt_bytes (lwt.Lwt_bytes)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.1.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">Index</a> &#x00BB; <a href="../index.html">lwt</a> &#x00BB; Lwt_bytes</nav><header class="odoc-preamble"><h1>Module <code><span>Lwt_bytes</span></code></h1><p>Byte arrays</p></header><div class="odoc-tocs"><nav class="odoc-toc odoc-local-toc"><ul><li><a href="#access">Access</a></li><li><a href="#conversions">Conversions</a></li><li><a href="#copying">Copying</a></li><li><a href="#filling">Filling</a></li><li><a href="#ios">IOs</a></li><li><a href="#memory-mapped-files">Memory mapped files</a></li></ul></nav></div><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> =
<span><span>(char, <a href="../../ocaml/Stdlib/Bigarray/index.html#type-int8_unsigned_elt">Stdlib.Bigarray.int8_unsigned_elt</a>, <a href="../../ocaml/Stdlib/Bigarray/index.html#type-c_layout">Stdlib.Bigarray.c_layout</a>)</span>
<a href="../../ocaml/Stdlib/Bigarray/Array1/index.html#type-t">Stdlib.Bigarray.Array1.t</a></span></span></code></div><div class="spec-doc"><p>Type of array of bytes.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-create"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Creates a new byte array of the given size.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-length"><a href="#val-length" class="anchor"></a><code><span><span class="keyword">val</span> length : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p>Returns the length of the given byte array.</p></div></div><h3 id="access"><a href="#access" class="anchor"></a>Access</h3><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> char</span></code></div><div class="spec-doc"><p><code>get buffer offset</code> returns the byte at offset <code>offset</code> in <code>buffer</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set"><a href="#val-set" class="anchor"></a><code><span><span class="keyword">val</span> set : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>get buffer offset value</code> changes the value of the byte at offset <code>offset</code> in <code>buffer</code> to <code>value</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_get"><a href="#val-unsafe_get" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_get : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> char</span></code></div><div class="spec-doc"><p>Same as <a href="#val-get"><code>get</code></a> but without bounds checking.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_set"><a href="#val-unsafe_set" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_set : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-set"><code>set</code></a> but without bounds checking.</p></div></div><h3 id="conversions"><a href="#conversions" class="anchor"></a>Conversions</h3><div class="odoc-spec"><div class="spec value anchored" id="val-of_bytes"><a href="#val-of_bytes" class="anchor"></a><code><span><span class="keyword">val</span> of_bytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>of_bytes buf</code> returns a newly allocated byte array with the same contents as <code>buf</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-of_string"><a href="#val-of_string" class="anchor"></a><code><span><span class="keyword">val</span> of_string : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>of_string buf</code> returns a newly allocated byte array with the same contents as <code>buf</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_bytes"><a href="#val-to_bytes" class="anchor"></a><code><span><span class="keyword">val</span> to_bytes : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bytes</span></code></div><div class="spec-doc"><p><code>to_bytes buf</code> returns newly allocated bytes with the same contents as <code>buf</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span><span class="keyword">val</span> to_string : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p><code>to_string buf</code> returns a newly allocated string with the same contents as <code>buf</code>.</p></div></div><h3 id="copying"><a href="#copying" class="anchor"></a>Copying</h3><div class="odoc-spec"><div class="spec value anchored" id="val-blit"><a href="#val-blit" class="anchor"></a><code><span><span class="keyword">val</span> blit : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>blit buf1 ofs1 buf2 ofs2 len</code> copies <code>len</code> bytes from <code>buf1</code> starting at offset <code>ofs1</code> to <code>buf2</code> starting at offset <code>ofs2</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-blit_from_string"><a href="#val-blit_from_string" class="anchor"></a><code><span><span class="keyword">val</span> blit_from_string : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit"><code>blit</code></a> but the first buffer is a <code>String.t</code> instead of a byte array.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-blit_from_bytes"><a href="#val-blit_from_bytes" class="anchor"></a><code><span><span class="keyword">val</span> blit_from_bytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit"><code>blit</code></a> but the first buffer is a <code>Bytes.t</code> instead of a byte array.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-blit_to_bytes"><a href="#val-blit_to_bytes" class="anchor"></a><code><span><span class="keyword">val</span> blit_to_bytes : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit"><code>blit</code></a> but the second buffer is a <code>Bytes.t</code> instead of a byte array.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_blit"><a href="#val-unsafe_blit" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_blit : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit"><code>blit</code></a> but without bound checking.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_blit_from_bytes"><a href="#val-unsafe_blit_from_bytes" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_blit_from_bytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit_from_bytes"><code>Lwt_bytes.blit_from_bytes</code></a> but without bounds checking.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_blit_from_string"><a href="#val-unsafe_blit_from_string" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_blit_from_string : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit_from_string"><code>Lwt_bytes.blit_from_string</code></a> but without bounds checking.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-unsafe_blit_to_bytes"><a href="#val-unsafe_blit_to_bytes" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_blit_to_bytes : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-blit_to_bytes"><code>Lwt_bytes.blit_to_bytes</code></a> but without bounds checking.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-proxy"><a href="#val-proxy" class="anchor"></a><code><span><span class="keyword">val</span> proxy : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>proxy buffer offset length</code> creates a ``proxy''. The returned byte array share the data of <code>buffer</code> but with different bounds.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-extract"><a href="#val-extract" class="anchor"></a><code><span><span class="keyword">val</span> extract : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>extract buffer offset length</code> creates a new byte array of length <code>length</code> and copy the <code>length</code> bytes of <code>buffer</code> at <code>offset</code> into it.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-copy"><a href="#val-copy" class="anchor"></a><code><span><span class="keyword">val</span> copy : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>copy buffer</code> creates a copy of the given byte array.</p></div></div><h3 id="filling"><a href="#filling" class="anchor"></a>Filling</h3><div class="odoc-spec"><div class="spec value anchored" id="val-fill"><a href="#val-fill" class="anchor"></a><code><span><span class="keyword">val</span> fill : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>fill buffer offset length value</code> puts <code>value</code> in all <code>length</code> bytes of <code>buffer</code> starting at offset <code>offset</code>.</p></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-unsafe_fill"><a href="#val-unsafe_fill" class="anchor"></a><code><span><span class="keyword">val</span> unsafe_fill : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>char <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-fill"><code>fill</code></a> but without bounds checking.</p></div></div><h3 id="ios"><a href="#ios" class="anchor"></a>IOs</h3><p>The following functions behave similarly to the ones in <a href="../Lwt_unix/index.html"><code>Lwt_unix</code></a>, except they use byte arrays instead of <code>Bytes.t</code>, and they never perform extra copies of the data.</p><div class="odoc-spec"><div class="spec value anchored" id="val-read"><a href="#val-read" class="anchor"></a><code><span><span class="keyword">val</span> read : <span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write"><a href="#val-write" class="anchor"></a><code><span><span class="keyword">val</span> write : <span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-recv"><a href="#val-recv" class="anchor"></a><code><span><span class="keyword">val</span> recv :
<span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../../ocaml/Unix/index.html#type-msg_flag">Unix.msg_flag</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-send"><a href="#val-send" class="anchor"></a><code><span><span class="keyword">val</span> send :
<span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../../ocaml/Unix/index.html#type-msg_flag">Unix.msg_flag</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-recvfrom"><a href="#val-recvfrom" class="anchor"></a><code><span><span class="keyword">val</span> recvfrom :
<span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../../ocaml/Unix/index.html#type-msg_flag">Unix.msg_flag</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(int * <a href="../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a>)</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-sendto"><a href="#val-sendto" class="anchor"></a><code><span><span class="keyword">val</span> sendto :
<span><a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span>int <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../../ocaml/Unix/index.html#type-msg_flag">Unix.msg_flag</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../../ocaml/Unix/index.html#type-sockaddr">Unix.sockaddr</a> <span class="arrow">&#45;&gt;</span></span>
<span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-io_vector"><a href="#type-io_vector" class="anchor"></a><code><span><span class="keyword">type</span> io_vector</span><span> = </span><span>{</span></code><ol><li id="type-io_vector.iov_buffer" class="def record field anchored"><a href="#type-io_vector.iov_buffer" class="anchor"></a><code><span>iov_buffer : <a href="#type-t">t</a>;</span></code></li><li id="type-io_vector.iov_offset" class="def record field anchored"><a href="#type-io_vector.iov_offset" class="anchor"></a><code><span>iov_offset : int;</span></code></li><li id="type-io_vector.iov_length" class="def record field anchored"><a href="#type-io_vector.iov_length" class="anchor"></a><code><span>iov_length : int;</span></code></li></ol><code><span>}</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-io_vector"><a href="#val-io_vector" class="anchor"></a><code><span><span class="keyword">val</span> io_vector : <span><span class="label">buffer</span>:<a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><span class="label">offset</span>:int <span class="arrow">&#45;&gt;</span></span> <span><span class="label">length</span>:int <span class="arrow">&#45;&gt;</span></span> <a href="#type-io_vector">io_vector</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-recv_msg"><a href="#val-recv_msg" class="anchor"></a><code><span><span class="keyword">val</span> recv_msg :
<span><span class="label">socket</span>:<a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">io_vectors</span>:<span><a href="#type-io_vector">io_vector</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><span>(int * <span><a href="../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span>)</span> <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../Lwt_unix/Versioned/index.html#val-recv_msg_2"><code>Lwt_unix.Versioned.recv_msg_2</code></a>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-send_msg"><a href="#val-send_msg" class="anchor"></a><code><span><span class="keyword">val</span> send_msg :
<span><span class="label">socket</span>:<a href="../Lwt_unix/index.html#type-file_descr">Lwt_unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">io_vectors</span>:<span><a href="#type-io_vector">io_vector</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">fds</span>:<span><a href="../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> list</span> <span class="arrow">&#45;&gt;</span></span>
<span>int <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Not implemented on Windows.</p><ul class="at-tags"><li class="deprecated"><span class="at-tag">deprecated</span> <p>Use <a href="../Lwt_unix/Versioned/index.html#val-send_msg_2"><code>Lwt_unix.Versioned.send_msg_2</code></a>.</p></li></ul></div></div><h3 id="memory-mapped-files"><a href="#memory-mapped-files" class="anchor"></a>Memory mapped files</h3><div class="odoc-spec"><div class="spec value anchored" id="val-map_file"><a href="#val-map_file" class="anchor"></a><code><span><span class="keyword">val</span> map_file :
<span><span class="label">fd</span>:<a href="../../ocaml/Unix/index.html#type-file_descr">Unix.file_descr</a> <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?pos</span>:int64 <span class="arrow">&#45;&gt;</span></span>
<span><span class="label">shared</span>:bool <span class="arrow">&#45;&gt;</span></span>
<span><span class="optlabel">?size</span>:int <span class="arrow">&#45;&gt;</span></span>
<span>unit <span class="arrow">&#45;&gt;</span></span>
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>map_file ~fd ?pos ~shared ?size ()</code> maps the file descriptor <code>fd</code> to an array of bytes.</p></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-mapped"><a href="#val-mapped" class="anchor"></a><code><span><span class="keyword">val</span> mapped : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p><code>mapped buffer</code> returns <code>true</code> iff <code>buffer</code> is a memory mapped file.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-advice"><a href="#type-advice" class="anchor"></a><code><span><span class="keyword">type</span> advice</span><span> = </span></code><ol><li id="type-advice.MADV_NORMAL" class="def variant constructor anchored"><a href="#type-advice.MADV_NORMAL" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_NORMAL</span></span></code></li><li id="type-advice.MADV_RANDOM" class="def variant constructor anchored"><a href="#type-advice.MADV_RANDOM" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_RANDOM</span></span></code></li><li id="type-advice.MADV_SEQUENTIAL" class="def variant constructor anchored"><a href="#type-advice.MADV_SEQUENTIAL" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_SEQUENTIAL</span></span></code></li><li id="type-advice.MADV_WILLNEED" class="def variant constructor anchored"><a href="#type-advice.MADV_WILLNEED" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_WILLNEED</span></span></code></li><li id="type-advice.MADV_DONTNEED" class="def variant constructor anchored"><a href="#type-advice.MADV_DONTNEED" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_DONTNEED</span></span></code></li><li id="type-advice.MADV_MERGEABLE" class="def variant constructor anchored"><a href="#type-advice.MADV_MERGEABLE" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_MERGEABLE</span></span></code></li><li id="type-advice.MADV_UNMERGEABLE" class="def variant constructor anchored"><a href="#type-advice.MADV_UNMERGEABLE" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_UNMERGEABLE</span></span></code></li><li id="type-advice.MADV_HUGEPAGE" class="def variant constructor anchored"><a href="#type-advice.MADV_HUGEPAGE" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_HUGEPAGE</span></span></code></li><li id="type-advice.MADV_NOHUGEPAGE" class="def variant constructor anchored"><a href="#type-advice.MADV_NOHUGEPAGE" class="anchor"></a><code><span>| </span><span><span class="constructor">MADV_NOHUGEPAGE</span></span></code></li></ol></div><div class="spec-doc"><p>Type of advise that can be sent to the kernel by the program. See the manual madvise(2) for a description of each.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-madvise"><a href="#val-madvise" class="anchor"></a><code><span><span class="keyword">val</span> madvise : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-advice">advice</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>madvise buffer pos len advice</code> advises the kernel how the program will use the memory mapped file between <code>pos</code> and <code>pos + len</code>.</p><p>This call is not available on windows.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-page_size"><a href="#val-page_size" class="anchor"></a><code><span><span class="keyword">val</span> page_size : int</span></code></div><div class="spec-doc"><p>Size of pages.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-mincore"><a href="#val-mincore" class="anchor"></a><code><span><span class="keyword">val</span> mincore : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span><span>bool array</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>mincore buffer offset states</code> tests whether the given pages are in the system memory (the RAM). The <code>offset</code> argument must be a multiple of <a href="#val-page_size"><code>page_size</code></a>. <code>states</code> is used to store the result; each cases is <code>true</code> if the corresponding page is in RAM and <code>false</code> otherwise.</p><p>This call is not available on windows and cygwin.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-wait_mincore"><a href="#val-wait_mincore" class="anchor"></a><code><span><span class="keyword">val</span> wait_mincore : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p><code>wait_mincore buffer offset</code> waits until the page containing the byte at offset <code>offset</code> is in RAM.</p><p>This functions is not available on windows and cygwin.</p></div></div></div></body></html>