-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwmsync.c
More file actions
40 lines (36 loc) · 737 Bytes
/
Copy pathwmsync.c
File metadata and controls
40 lines (36 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <io.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int msync(void *addr, size_t len, int flags)
{
if ((flags & MS_ASYNC) | (flags & MS_INVALIDATE))
{
errno = ENOSYS;
return -1;
}
if (FlushViewOfFile(addr, len))
return 0;
switch (GetLastError())
{
case ERROR_CALL_NOT_IMPLEMENTED:
errno = ENOSYS;
return -1;
case ERROR_INVALID_HANDLE:
errno = EBADF;
return -1;
case ERROR_ACCESS_DENIED:
errno = EACCES;
return -1;
default:
errno = EINVAL;
return -1;
}
}