Mail Archives: djgpp/2000/04/26/12:06:08
From DG-UX man page
mmap(2) DG/UX R4.20MU03 mmap(2)
NAME
mmap - map pages of memory
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
void * mmap (addr, len, prot, flags, fd, off)
void * addr;
size_t len;
int prot;
int flags;
int fd;
off_t off;
DESCRIPTION
The mmap(2) call maps a memory object into the caller's address
space, based on the supplied parameters:
addr is the optional starting address for the new memory
region to map.
len is the length in bytes of the region to map.
prot assigns the access attribute for the mapped region:
read, write, execute, a combination, or no access.
flags specify the mapping mode (shared or private), and
whether the requested address must be used exactly.
fd is the file descriptor of the memory object to be
mapped into the region.
off is the offset into the file to be mapped into the
region.
The format of the call is:
pa = mmap(addr, len, prot, flags, fd, off);
The file fd, starting at offset off, is mapped into the caller's
address space. The mapping begins at address pa and extends for len
bytes. Argument prot specifies how the region may be accessed, and
flags whether changes to the file should be shared with other
processes (and other attributes).
Once a file is mapped, a process may access it using the mapped
address instead of the read/write interface. Consider the following
pseudo-code, where off is assumed to be page aligned:
fd = open(...);
lseek(fd, off, SEEK_SET);
read(fd, buf, len);
/* use data in buf */
Here is a rewrite using mmap(2):
fd = open(...);
pa = mmap((void *) 0, len, (PROT_READ | PROT_WRITE),
MAP_PRIVATE, fd, off);
/* use data at address pa */
/* ... Rest of man page omitted ... */
This is a rather common way in Unix-ish systems to share data between two or
more processes. I sincerely doubt that there is a similar facility in DOS
Hope this helps
David Hurt
In article <3906F9B2 DOT 17C6C4F5 AT home DOT com>, Robin Johnson <robbat2 AT home DOT com>
wrote:
>Could somebody at least get me some docs on what mmap() does?
>
>Hans-Bernhard Broeker wrote:
>>
>> Robin Johnson <robbat2 AT home DOT com> wrote:
>>
>> > I'm trying to port some linux stuff over to DJGPP, but all the
>> > configure scripts keep asking for mmap(), and I can't for the life
>> > of me find it.
>>
>> mmap() is not available in DJGPP. Period.
>>
>> Those Linux-borne programs will either have to get along without it,
>> or they can't be ported. Note: just because the script *checks* for
>> mmap() usually doesn't mean that the programs won't work without it,
>> yet. If it really must have mmap(), the configure script will
>> terminate with an appropriate message.
>> --
>> Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
>> Even if all the snow were burnt, ashes would remain.
>
- Raw text -