1
/* this tests whether we can use a shared writeable mmap on a file -
2
as needed for the mmap variant of FAST_SHARE_MODES */
4
#if defined(HAVE_UNISTD_H)
12
#define DATA "conftest.mmap"
22
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
25
if (fd == -1) exit(1);
27
for (i=0;i<10000;i++) {
28
write(fd,&i,sizeof(i));
34
fd = open(DATA,O_RDWR);
35
if (fd == -1) exit(1);
37
buf = (int *)mmap(NULL, 10000*sizeof(int),
38
(PROT_READ | PROT_WRITE),
39
MAP_FILE | MAP_SHARED,
42
if (buf == (int *)-1) exit(1);
44
while (count-- && buf[9124] != 55732) sleep(1);
46
if (count <= 0) exit(1);
52
fd = open(DATA,O_RDWR);
53
if (fd == -1) exit(1);
55
buf = (int *)mmap(NULL, 10000*sizeof(int),
56
(PROT_READ | PROT_WRITE),
57
MAP_FILE | MAP_SHARED,
60
if (buf == (int *)-1) exit(1);
64
while (count-- && buf[1763] != 7268) sleep(1);
68
if (count > 0) exit(0);