summaryrefslogtreecommitdiff
path: root/src/mi/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mi/init.c')
-rw-r--r--src/mi/init.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mi/init.c b/src/mi/init.c
index 60a48c58..aa931998 100644
--- a/src/mi/init.c
+++ b/src/mi/init.c
@@ -39,6 +39,30 @@ static const char rcsid[] UNUSED =
long unwi_debug_level;
#endif /* UNW_DEBUG */
+long unw_page_size;
+static void
+unw_init_page_size ()
+{
+ errno = 0;
+ long result = sysconf (_SC_PAGESIZE);
+ if (result == -1)
+ {
+ if (errno != 0)
+ {
+ print_error ("Failed to get _SC_PAGESIZE: ");
+ print_error (strerror(errno));
+ print_error ("\n");
+ }
+ else
+ print_error ("Failed to get _SC_PAGESIZE, errno was not set.\n");
+
+ unw_page_size = 4096;
+ }
+ else
+ {
+ unw_page_size = result;
+ }
+}
HIDDEN void
mi_init (void)
@@ -55,6 +79,6 @@ mi_init (void)
setbuf (stderr, NULL);
}
#endif
-
- assert (sizeof (struct cursor) <= sizeof (unw_cursor_t));
+ unw_init_page_size();
+ assert(sizeof(struct cursor) <= sizeof(unw_cursor_t));
}