chiark / gitweb /
xfoo => mfoo, add comment
[inn-innduct.git] / lib / mmap.c
1 /*  $Id: mmap.c 7598 2007-02-09 02:40:51Z eagle $
2 **
3 **  MMap manipulation routines
4 **
5 **  Written by Alex Kiernan (alex.kiernan@thus.net)
6 **
7 **  These routines work with mmap()ed memory
8 */
9
10 #include "config.h"
11 #include "clibrary.h"
12 #include "portable/mmap.h"
13
14 #include "inn/messages.h"
15 #include "inn/mmap.h"
16
17 /*
18 **  Figure out what page an address is in and flush those pages
19 */
20 void
21 inn__mapcntl(void *p, size_t length, int flags)
22 {
23     int pagesize;
24
25     pagesize = getpagesize();
26     if (pagesize == -1)
27         syswarn("getpagesize failed");
28     else {
29         char *start, *end;
30
31         start = (char *)((size_t)p & ~(size_t)(pagesize - 1));
32         end = (char *)((size_t)((char *)p + length + pagesize) &
33                        ~(size_t)(pagesize - 1));
34         msync(start, end - start, flags);
35     }
36 }