File: mmap.c

package info (click to toggle)
inn2 2.4.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,912 kB
  • ctags: 7,860
  • sloc: ansic: 85,104; perl: 11,427; sh: 9,863; makefile: 2,498; yacc: 1,563; python: 298; lex: 252; tcl: 7
file content (36 lines) | stat: -rw-r--r-- 771 bytes parent folder | download
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
/*  $Id: mmap.c 7598 2007-02-09 02:40:51Z eagle $
**
**  MMap manipulation routines
**
**  Written by Alex Kiernan (alex.kiernan@thus.net)
**
**  These routines work with mmap()ed memory
*/

#include "config.h"
#include "clibrary.h"
#include "portable/mmap.h"

#include "inn/messages.h"
#include "inn/mmap.h"

/*
**  Figure out what page an address is in and flush those pages
*/
void
inn__mapcntl(void *p, size_t length, int flags)
{
    int pagesize;

    pagesize = getpagesize();
    if (pagesize == -1)
        syswarn("getpagesize failed");
    else {
	char *start, *end;

	start = (char *)((size_t)p & ~(size_t)(pagesize - 1));
	end = (char *)((size_t)((char *)p + length + pagesize) &
		       ~(size_t)(pagesize - 1));
	msync(start, end - start, flags);
    }
}