d757cd66c318ec6e87a072d2597e2606909d8c3c
[mono.git] / mono / utils / mono-threads-linux.c
1 /**
2  * \file
3  */
4
5 #include <config.h>
6
7 #if (defined(__linux__) && !defined(PLATFORM_ANDROID)) || defined(__FreeBSD_kernel__)
8
9 #include <mono/utils/mono-threads.h>
10 #include <pthread.h>
11
12 void
13 mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
14 {
15         pthread_attr_t attr;
16         gint res;
17
18         *staddr = NULL;
19         *stsize = (size_t)-1;
20
21         res = pthread_attr_init (&attr);
22         if (G_UNLIKELY (res != 0))
23                 g_error ("%s: pthread_attr_init failed with \"%s\" (%d)", __func__, g_strerror (res), res);
24
25         res = pthread_getattr_np (pthread_self (), &attr);
26         if (G_UNLIKELY (res != 0))
27                 g_error ("%s: pthread_getattr_np failed with \"%s\" (%d)", __func__, g_strerror (res), res);
28
29         res = pthread_attr_getstack (&attr, (void**)staddr, stsize);
30         if (G_UNLIKELY (res != 0))
31                 g_error ("%s: pthread_attr_getstack failed with \"%s\" (%d)", __func__, g_strerror (res), res);
32
33         res = pthread_attr_destroy (&attr);
34         if (G_UNLIKELY (res != 0))
35                 g_error ("%s: pthread_attr_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
36
37 }
38
39 #endif