AC_CHECK_FUNCS(pthread_attr_getstack pthread_attr_getstacksize)
AC_CHECK_FUNCS(pthread_get_stacksize_np pthread_get_stackaddr_np)
+ dnl **********************************
+ dnl *** Check for mincore ***
+ dnl **********************************
+ AC_MSG_CHECKING(for mincore)
+ AC_TRY_LINK([
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ ], [
+ mincore(NULL, 0, NULL);
+ ], [
+ # Yes, we have it...
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_MINCORE, 1, [Have mincore])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+
dnl ***********************************
dnl *** Checks for working __thread ***
dnl ***********************************
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)
return aligned;
}
#endif
+
+int
+mono_pages_not_faulted (void *addr, size_t size)
+{
+#ifdef HAVE_MINCORE
+ 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
+ return -1;
+#endif
+}