Loading...
Searching...
No Matches
omMmap.c File Reference
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <sys/mman.h>`

Go to the source code of this file.

## Functions

static void * | omVallocMmap (size_t size)
static int | omVfreeMmap (void *addr, size_t size)

## Function Documentation

## omVallocMmap()

void * omVallocMmap | ( | size_t | size | ) |

inline static

Definition at line 15 of file omMmap.c.

{
void* addr;
#ifndef MAP_ANONYMOUS
static int fd = -1;
#endif
#ifdef MAP_ANONYMOUS
#ifndef __CYGWIN__
/* under cygwin, MAP_PRIVATE|MAP_ANONYMOUS fails */
addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#else
/* however, the following works */
addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, -1, 0);
#endif
#else /* !MAP_ANONYMOUS */
if (fd < 0)
{
fd = open("/dev/zero", O_RDWR);
if (fd < 0) return NULL;
}
addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
#endif
if (addr == (void*) -1) return NULL;
return addr;
}
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
NULL
#define NULL
Definition omList.c:12
fd
int status int fd
Definition si_signals.h:69
open
int status int void size_t count open
Definition si_signals.h:83

## omVfreeMmap()

int omVfreeMmap | ( | void * | addr,
|  | size_t | size )

inline static

Definition at line 43 of file omMmap.c.

{
return munmap(addr, size);
}