|
||
Interface status: | externallyDefinedApi |
PROT_NONE 0x00
Protections are chosen from these bits, or-ed together. no permissions.
Interface status: | externallyDefinedApi |
PROT_READ 0x01
Protections are chosen from these bits, or-ed together. pages can be read.
Interface status: | externallyDefinedApi |
PROT_WRITE 0x02
Protections are chosen from these bits, or-ed together. pages can be written.
Interface status: | externallyDefinedApi |
PROT_EXEC 0x04
Protections are chosen from these bits, or-ed together. pages can be executed.
Interface status: | externallyDefinedApi |
MAP_FIXED 0x0010
map addr must be exactly as requested.
Interface status: | externallyDefinedApi |
MS_SYNC 0x0000
msync(void *,size_t,int)
msync(void *,size_t,int)
flags. msync synchronously.
Interface status: | externallyDefinedApi |
MS_ASYNC 0x0001
msync(void *,size_t,int)
msync(void *,size_t,int)
flags. return immediately.
Interface status: | externallyDefinedApi |
MS_INVALIDATE 0x0002
msync(void *,size_t,int)
msync(void *,size_t,int)
flags. invalidate all cached data.
Interface status: | externallyDefinedApi |
IMPORT_C void* mmap(void *, size_t, int, int, int, off_t);
The mmap system call causes the pages starting at addr and continuing for at most len bytes to be mapped from the object described by fildes, starting at byte offset offset. If len is not a multiple of the pagesize, the mapped region may extend past the specified range. Any such extension beyond the end of the mapped object will be zero-filled.
If addr is non-zero, it is used as a hint to the system. (As a convenience to the system, the actual address of the region may differ from the address supplied). If addr is zero, an address will be selected by the system. The actual starting address of the region is returned. A successful mmap deletes any previous mapping in the allocated address range.
The protections (region accessibility) are specified in the prot argument by or'ing the following values:
PROT_READ Pages may be read.
PROT_WRITE Pages may be written.
PROT_EXEC Pages may be executed.
PROT_NONE This protection mode is currently not supported.
The flags argument specifies the type of the mapped object, mapping options and whether modifications made to the mapped copy of the page are private to the process or are to be shared with other references. Sharing, mapping type and options are specified in the flags argument by or'ing the following values:
MAP_PRIVATE Modifications are private.
MAP_SHARED Modifications are shared.
MAP_FIXED, MAP_FILE, MAP_ANON, MAP_HASSEMAPHORE, MAP_STACK, MAP_NOSYNC -- These flags are currently not supported.
The close system call does not unmap pages, see munmap for further information.
The current design does not allow a process to specify the location of swap space. In the future we may define an additional mapping type, MAP_SWAP, in which the file descriptor argument specifies a file or device to which swapping should be done.
Examples:
/* Detailed description : Example to create a mapped memory to a file region.
Precondition : None
/
#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(void)
{
int fd = -1;
char* mapaddr;
int len = getpagesize();
int prot = PROT_WRITE | PROT_READ;
if((fd = open("C:\Test.txt", O_RDWR | O_CREAT, 0666) ) < 0){
printf("File open failed");
}
mapaddr = (char*)mmap((void*)0, len, prot, MAP_SHARED, fd, 0);
if(mapaddr == MAP_FAILED){
printf("mmap on file failed");
}
printf("mmap on file succeeded");
}
|
mprotect(const void *,size_t,int)
mprotect(const void *,size_t,int)
...msync(void *,size_t,int)
msync(void *,size_t,int)
The msync system call writes any modified pages back to the file system. If len ...munmap(void *,size_t)
munmap(void *,size_t)
...getpagesize(void)
getpagesize(void)
The getpagesize function returns the number of bytes in a page. Page granularity...Interface status: | externallyDefinedApi |
IMPORT_C int mprotect(const void *, size_t, int);
The mprotect system call changes the specified pages to have protection prot. Not all implementations will guarantee protection on a page basis; the granularity of protection changes may be as large as an entire region. A region is the virtual address space defined by the start and end addresses of a struct vm_map_entry .
NOTE: This interface is not functionally supported in Symbian OS, only build supported.
|
|
msync(void *,size_t,int)
msync(void *,size_t,int)
The msync system call writes any modified pages back to the file system. If len ...munmap(void *,size_t)
munmap(void *,size_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int msync(void *, size_t, int);
MS_ASYNC
This flag is currently not supported.
MS_SYNC
Perform synchronous writes
MS_INVALIDATE
Invalidate all cached data
The msync system call writes any modified pages back to the file system. If len is non-zero only those pages containing addr and len-1 succeeding locations will be examined. The flags argument may be specified as follows:
MS_ASYNC This flag is currently not supported. MS_SYNC Perform synchronous writes MS_INVALIDATE Invalidate all cached data
Examples:
/*
Detailed description: Example to sync changes on mapped memory to file.
Precondition: None
*/
# 133 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 134 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 135 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 136 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 137 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
int main(void)
{
int fd = -1;
char* mapaddr;
int len = getpagesize();
int prot = 0x02 | 0x01 ;
if((fd = open("C:\Test.txt", 0x0002 | 0x0200 , 0666) ) < 0)
{
printf("File open failed");
}
mapaddr = (char*)mmap((void*)0, len, prot, 0x0001 , fd, 0);
if(mapaddr == ((void *)-1) )
{
printf("mmap on file failed");
}
strcpy(mapaddr, "This is a write through mapped memory ");
if(-1 == msync(mapaddr, len, 0x0000 ))
{
printf("Sync on mapped memory to file failed");
}
printf("Sync on mapped memory to file succeeded");
}
|
|
mprotect(const void *,size_t,int)
mprotect(const void *,size_t,int)
...munmap(void *,size_t)
munmap(void *,size_t)
...Interface status: | externallyDefinedApi |
IMPORT_C int munmap(void *, size_t);
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. The current implementation does not support partial deletion of mapped memory, i.e if offset to offset+len section of memory was mapped using mmap the entire section of memory offset+len will be deleted.
Examples:
/*
Detailed description: Example to create a mapped memory to a file region.
Precondition: None
*/
# 192 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 193 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 194 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
# 195 "d:/EPOC/release/9.4/common/generic/openenv/core/include/sys/mman.dosc" 2
int main(void)
{
int fd = -1;
char* mapaddr;
int len = getpagesize();
int prot = 0x02 | 0x01 ;
if((fd = open("C:\Test.txt", 0x0002 | 0x0200 , 0666) ) < 0){
printf("File open failed");
}
mapaddr = (char*)mmap((void*)0, len, prot, 0x0001 , fd, 0);
if(mapaddr == ((void *)-1) ){
printf("mmap on file failed");
}
printf("mmap on file succeeded");
}
|
|