File: coda_mmap_anon.h

package info (click to toggle)
rvm 1.13%2Bdebian-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,800 kB
  • ctags: 2,012
  • sloc: ansic: 20,307; sh: 8,996; makefile: 115
file content (37 lines) | stat: -rw-r--r-- 984 bytes parent folder | download | duplicates (2)
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
/* BLURB gpl

                           Coda File System
                              Release 5

          Copyright (c) 1987-1999 Carnegie Mellon University
                  Additional copyrights listed below

This  code  is  distributed "AS IS" without warranty of any kind under
the terms of the GNU General Public Licence Version 2, as shown in the
file  LICENSE.  The  technical and financial  contributors to Coda are
listed in the file CREDITS.

                        Additional copyrights

#*/

#ifndef CODA_MMAP_ANON_H
#define CODA_MMAP_ANON_H

#include <unistd.h>
#include <sys/mman.h>

#ifndef MAP_ANON
#define MAP_ANON 0
#endif

#define mmap_anon(raddrptr, addrptr, len, prot) do { \
    int fd = -1, flags = MAP_ANON | MAP_PRIVATE; \
    if (addrptr) flags |= MAP_FIXED; \
    if (!MAP_ANON) fd = open("/dev/zero", O_RDWR); \
    raddrptr = mmap((char *)addrptr, len, prot, flags, fd, 0); \
    if (fd != -1) close(fd); \
} while(0);

#endif /* CODA_MMAP_ANON_H */