summaryrefslogtreecommitdiff
path: root/pfinet.old/glue-include/linux/mm.h
blob: 546776e828bb946bb2c3b390ba72f4ec64983356 (plain)
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
38
#ifndef _HACK_MM_H_
#define _HACK_MM_H_

#include <linux/kernel.h>
#include <linux/sched.h>

/* All memory addresses are presumptively valid, because they are
   all internal. */
#define verify_area(a,b,c) 0

#define VERIFY_READ 0
#define VERIFY_WRITE 0
#define GFP_ATOMIC 0
#define GFP_KERNEL 0
#define GFP_BUFFER 0
#define __GFP_WAIT 0

#include <mach.h>
#include <sys/mman.h>
#include <stdint.h>

#define PAGE_SIZE	(1 << PAGE_SHIFT)

/* The one use of this is by net/ipv4/tcp.c::tcp_init, which
   uses the power of two above `num_physpages >> (20 - PAGE_SHIFT)'
   as a starting point and halves from there the number of pages
   it tries to allocate for the hash table of TCP connections.  */
#define num_physpages	(64 << 20 >> PAGE_SHIFT) /* XXX calculate for 32MB */

static inline uintptr_t
__get_free_pages (int gfp_mask, unsigned long int order)
{
  void *ptr = mmap (0, PAGE_SIZE << order,
		    PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
  return ptr == MAP_FAILED ? 0 : (uintptr_t) ptr;
}

#endif