Coda Distributed File System
coda_mmap_anon.h
Go to the documentation of this file.
1/* BLURB lgpl
2
3 Coda File System
4 Release 5
5
6 Copyright (c) 1987-1999 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU Library General Public Licence Version 2, as
11shown in the file LICENSE. The technical and financial contributors to
12Coda are listed in the file CREDITS.
13
14 Additional copyrights
15
16#*/
17
18#ifndef CODA_MMAP_ANON_H
19#define CODA_MMAP_ANON_H
20
21#include <unistd.h>
22#include <sys/mman.h>
23
24#ifndef MAP_ANON
25#define MAP_ANON 0
26#endif
27
28#define mmap_anon(raddrptr, addrptr, len, prot) \
29 do { \
30 int fd = -1, flags = MAP_ANON | MAP_PRIVATE; \
31 if (addrptr) \
32 flags |= MAP_FIXED; \
33 if (!MAP_ANON) \
34 fd = open("/dev/zero", O_RDWR); \
35 raddrptr = mmap((char *)addrptr, len, prot, flags, fd, 0); \
36 if (fd != -1) \
37 close(fd); \
38 } while (0);
39
40#endif /* CODA_MMAP_ANON_H */