s3:gse: add simple gensec_gse_update_send/recv() wrapper functions
[Samba.git] / lib / replace / test / shared_mremap.c
blob08040e2e595f356155f4fb5977b3637b1e76aefb
1 /* this tests whether we can use mremap */
3 #if defined(HAVE_UNISTD_H)
4 #include <unistd.h>
5 #endif
6 #ifdef HAVE_STDLIB_H
7 #include <stdlib.h>
8 #endif
9 #include <sys/mman.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #include <fcntl.h>
14 #define DATA "conftest.mmap"
16 #ifndef MAP_FILE
17 #define MAP_FILE 0
18 #endif
20 #ifndef MAP_FAILED
21 #define MAP_FAILED (int *)-1
22 #endif
24 int main(void)
26 int *buf;
27 int fd;
28 int err = 1;
30 fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0666);
31 if (fd == -1) {
32 exit(1);
35 buf = (int *)mmap(NULL, 0x1000, PROT_READ | PROT_WRITE,
36 MAP_FILE | MAP_SHARED, fd, 0);
37 if (buf == MAP_FAILED) {
38 goto done;
41 buf = mremap(buf, 0x1000, 0x2000, MREMAP_MAYMOVE);
42 if (buf == MAP_FAILED) {
43 goto done;
46 err = 0;
47 done:
48 close(fd);
49 unlink(DATA);
50 exit(err);