[libgfc Index] [libgfc Hierarchy] [Headers]
portable memory mapping class More...
#include <utils/src/gmmap.h>
portable memory mapping class.
[public]
default constructor. It needs the name of the file to be mapped. The constructor does not acutally open the file and map it into memory. Use the mehtod map for this purpose.
file | is the file to be mapped. |
[public]
destructor unmap and close the file if still mapped.
[public]
map the portion [offset, offset+len] of 'file' to memory. If the file is already mapped, it will be unmap()'ed first before re-mapping it. returns 1 if succeed; otherwise 0.
ps | is the protection string similar to the access flag of the open(). It can be "r", "w", "x" and the combinations. |
[public]
map the full length of the file. This is equivalent to map(0, file_length, ps).
[public]
extend the file and mmap the file again. If off and len are both negative then simply mmap() the whole extended file. This is useful when the file needs to grow in size while being mapped in memory.
size_inc | is the size to extend the file. |
[public]
unmap the file and release the mapped region. returns 1 if success; otherwise 0.
[public]
gives Operating system some advice about the mapped memory usage.
advice | is the advice to be given to the VM system. possible advices are: MADV_NORMAL (0x0) MADV_RNADOM (0x1) MADV_SEQUENTIAl (0x2) MADV_WILLNEED (0x3) MADV_DONTNEED (0x4) return 1 if success, otherwise 0. |
[public]
set the flag for mapping. the flag affects only the next mmap() calls. Default is "s" for SHARED mapping. Other settings are: "p" for PRIVATE, "f" for FIXED, "n" for NORESEVE.
[public]
set the protection for mapping. the flag affects only the next mmap() call. Default is PROT_READ|PROT_WRITE.
[public]
return the pointer to the start position of mmaped memory.
[public]
return the length of the current mmaped region. access beyond the ptr()+len() is illeagl.
[public]
return the file descriptor
Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999 | Kdoc |