Synesis Software

Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members  

/src/mmap.c File Reference

#include <windows.h>
#include <errno.h>
#include <sys/mman.h>

Functions

void * mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
 Maps a file into memory, and returns a pointer to it.

int munmap (void *addr, size_t len)
 Deletes a mapped region.

int msync (void *addr, size_t len, int flags)
 Writes any dirty pages within the given range to disk.


Function Documentation

void* mmap void *    addr,
size_t    len,
int    prot,
int    flags,
int    fd,
off_t    offset
 

Maps a file into memory, and returns a pointer to it.

Parameters:
addr  Suggested address for the mapping
len  The number of bytes in the mapped region. The combination of len and offset must not exceed the length of the mapped file
prot  Either PROT_NONE, or a combination of the other PROT_* flags
flags  One of MAP_PRIVATE, MAP_ANONYMOUS or MAP_FIXED.
fd  The file descriptor of the file to map, or -1 to allocate an anonymous map
offset  The offset within the file to start the mapped region
Return values:
pointer  to mapped region if successful
MAP_FAILED  if failed
Note:
The current implementation supports the following three modes: 1. Read-only file; 2. Read-write file; 3. Anonymous Read-write block of system paging file.

int msync void *    addr,
size_t    len,
int    flags
 

Writes any dirty pages within the given range to disk.

Parameters:
addr  The base address of the mapped region
len  The length of the mapped region to flush to disk. Will be rounded up to next page boundary.
flags  Ignored

int munmap void *    addr,
size_t    len
 

Deletes a mapped region.

The munmap() system call deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory references.

Parameters:
addr  The base address of the mapped region to unmap
len  The length of the mapped region. Ignore in the Win32 implementation
Return values:
0  if successful
-1  if failed

UNIX Emulation for Win32 Libraries documentation © Synesis Software Pty Ltd, 2002-2005