3 #if defined(PLATFORM_ANDROID)
11 slow_get_thread_bounds (guint8 *current, guint8 **staddr, size_t *stsize)
14 FILE *f = fopen ("/proc/self/maps", "r");
16 g_error ("Could not determine thread bounds, failed to open /proc/self/maps");
18 while (fgets (buff, sizeof (buff), f)) {
22 //each line starts with the range we want: f7648000-f7709000
23 low = strtoimax (ptr, &end, 16);
25 ptr = end + 1; //skip the dash to make sure we don't get a negative number
27 high = strtoimax (ptr, &end, 16);
29 if (end && low <= (intmax_t)(size_t)current && high > (intmax_t)(size_t)current) {
30 *staddr = (guint8 *)(size_t)low;
31 *stsize = (size_t)(high - low);
36 g_error ("Could not determine thread bounds, failed to find current stack pointer in /proc/self/maps");
40 mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
43 guint8 *current = (guint8*)&attr;
48 pthread_getattr_np (pthread_self (), &attr);
49 pthread_attr_getstack (&attr, (void**)staddr, stsize);
50 pthread_attr_destroy (&attr);
52 if (*staddr && ((current <= *staddr) || (current > *staddr + *stsize)))
53 slow_get_thread_bounds (current, staddr, stsize);