16 #include "mysys_priv.h"
18 #ifdef HAVE_SYS_MMAN_H
24 int my_msync(
int fd,
void *addr,
size_t len,
int flags)
26 msync(addr, len, flags);
27 return my_sync(fd, MYF(0));
32 static SECURITY_ATTRIBUTES mmap_security_attributes=
33 {
sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
35 void *my_mmap(
void *addr,
size_t len,
int prot,
36 int flags, File fd, my_off_t
offset)
40 HANDLE hFile= (HANDLE)my_get_osfhandle(fd);
41 DBUG_ENTER(
"my_mmap");
42 DBUG_PRINT(
"mysys", (
"map fd: %d", fd));
44 if (hFile == INVALID_HANDLE_VALUE)
45 DBUG_RETURN(MAP_FAILED);
47 hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
48 PAGE_READWRITE, 0, (DWORD) len, NULL);
50 DBUG_RETURN(MAP_FAILED);
52 ptr=MapViewOfFile(hFileMap,
53 prot & PROT_WRITE ? FILE_MAP_WRITE : FILE_MAP_READ,
54 (DWORD)(offset >> 32), (DWORD)offset, len);
62 CloseHandle(hFileMap);
66 DBUG_PRINT(
"mysys", (
"mapped addr: %p", ptr));
70 DBUG_RETURN(MAP_FAILED);
73 int my_munmap(
void *addr,
size_t len)
75 DBUG_ENTER(
"my_munmap");
76 DBUG_PRINT(
"mysys", (
"unmap addr: %p", addr));
77 DBUG_RETURN(UnmapViewOfFile(addr) ? 0 : -1);
80 int my_msync(
int fd,
void *addr,
size_t len,
int flags)
82 return FlushViewOfFile(addr, len) ? 0 : -1;