next up previous contents index
Next: 5.4.2 unmap: Release a Up: 5.4 oskit_bufio: Buffer-based I/O Previous: 5.4 oskit_bufio: Buffer-based I/O

5.4.1 map: Map some or all of this buffer into locally accessible memory

 

SYNOPSIS

#include <oskit/io/bufio.h>

OSKIT_COMDECL map(oskit_bufio_t *io, [out] void **addr, oskit_off_t offset, oskit_size_t amount);

DESCRIPTION

This method attempts to map some or all of this buffer into memory directly accessible to the client, so that the client can access it using loads and stores. The operation may or may not succeed, depending on the parameters and the implementation of the object; if it fails, the client must be prepared to fall back to the basic read and write methods. If the mapping operation succeeds, the pointer returned is not guaranteed to have any particular alignment.

If a call to the map method requests only a subset of the buffer to be mapped, the object may actually map more than the requested amount; however, since no information is passed back indicating how much of the buffer was actually mapped, the client must only attempt to access the region it requested.

Note that this method does not necessarily twiddle with virtual memory, as its name may seem to imply; in fact in most cases in which it is implemented at all, it just returns a pointer to a buffer if the data is already in locally-accessible memory.

PARAMETERS

io
The object whose contents are to be mapped.
addr
On success, the method returns in this parameter the address at which the client can directly access the requested buffer region.
offset
The offset into the buffer of the region to be mapped.
size
The size of the region to be mapped.

RETURNS

Returns 0 on success, or an error code specified in <oskit/error.h>, on error.



University of Utah Flux Research Group