}
#if 0
-static void
-collect_faulted_cards (void)
-{
-#define CARD_PAGES (CARD_COUNT_IN_BYTES / 4096)
- int i, count = 0;
- unsigned char faulted [CARD_PAGES] = { 0 };
- mincore (sgen_cardtable, CARD_COUNT_IN_BYTES, faulted);
-
- for (i = 0; i < CARD_PAGES; ++i) {
- if (faulted [i])
- ++count;
- }
-
- printf ("TOTAL card pages %d faulted %d\n", CARD_PAGES, count);
-}
-
void
sgen_card_table_dump_obj_card (char *object, size_t size, void *dummy)
{
mono-math.c \
mono-mmap.c \
mono-mmap.h \
+ mono-mmap-internal.h \
mono-mutex.c \
mono-mutex.h \
mono-networkinterfaces.c \
--- /dev/null
+/*
+ * mono-mmap-internal.h: Internal virtual memory stuff.
+ *
+ * Copyright (C) 2014 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __MONO_UTILS_MMAP_INTERNAL_H__
+#define __MONO_UTILS_MMAP_INTERNAL_H__
+
+#include "mono-compiler.h"
+
+int mono_pages_not_faulted (void *addr, size_t length) MONO_INTERNAL;
+
+#endif /* __MONO_UTILS_MMAP_INTERNAL_H__ */
+
#endif
#include "mono-mmap.h"
+#include "mono-mmap-internal.h"
#include "mono-proclib.h"
#ifndef MAP_ANONYMOUS
return 0;
}
+int
+mono_pages_not_faulted (void *addr, size_t length)
+{
+ return -1;
+}
+
#else
#if defined(HAVE_MMAP)
}
#endif // __native_client__
+int
+mono_pages_not_faulted (void *addr, size_t size)
+{
+ int i;
+ gint64 count;
+ int pagesize = mono_pagesize ();
+ int npages = (size + pagesize - 1) / pagesize;
+ char *faulted = g_malloc0 (sizeof (char*) * npages);
+
+ if (mincore (addr, size, faulted) != 0) {
+ count = -1;
+ } else {
+ count = 0;
+ for (i = 0; i < npages; ++i) {
+ if (faulted [i] != 0)
+ ++count;
+ }
+ }
+
+ g_free (faulted);
+
+ return count;
+}
+
#else
/* dummy malloc-based implementation */
}
return 0;
}
+
+int
+mono_pages_not_faulted (void *addr, size_t length)
+{
+ return -1;
+}
+
#endif // HAVE_MMAP
#if defined(HAVE_SHM_OPEN) && !defined (DISABLE_SHARED_PERFCOUNTERS)