summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pfinet/glue-include/linux/mm.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/pfinet/glue-include/linux/mm.h b/pfinet/glue-include/linux/mm.h
index a6f28e00..546776e8 100644
--- a/pfinet/glue-include/linux/mm.h
+++ b/pfinet/glue-include/linux/mm.h
@@ -15,4 +15,24 @@
#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