-extern uint64_t max_mem; /* 64-bit size of memory - limited by maxmem */
-extern uint64_t mem_actual; /* 64-bit size of memory - not limited by maxmem */
-extern uint64_t sane_size; /* Memory size to use for defaults calculations */
+extern uint64_t max_mem; /* 64-bit size of memory - limited by maxmem */
+
+/*
+ * The default pager does not handle 64-bit offsets inside its objects,
+ * so this limits the size of anonymous memory objects to 4GB minus 1 page.
+ * When we need to allocate a chunk of anonymous memory over that size,
+ * we have to allocate more than one chunk.
+ */
+#define ANON_MAX_SIZE 0xFFFFF000ULL
+/*
+ * Work-around for <rdar://problem/6626493>
+ * Break large anonymous memory areas into 128MB chunks to alleviate
+ * the cost of copying when copy-on-write is not possible because a small
+ * portion of it being wired.
+ */
+#define ANON_CHUNK_SIZE (128ULL * 1024 * 1024) /* 128MB */
+
+#ifdef XNU_KERNEL_PRIVATE
+
+extern uint64_t mem_actual; /* 64-bit size of memory - not limited by maxmem */
+extern uint64_t sane_size; /* Memory size to use for defaults calculations */