summaryrefslogtreecommitdiff
path: root/libguile/threads.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-12-22 10:28:23 -0500
committerAndy Wingo <wingo@pobox.com>2011-12-22 10:28:23 -0500
commitc1d5d6d755ff1613ff92efad841487c9e5bb979b (patch)
treea71e9fa58f545794bb3627901ac4a9678260044c /libguile/threads.c
parent34cf38c3a2eb143d982aa14e76888098aea468b2 (diff)
downloadguile-c1d5d6d755ff1613ff92efad841487c9e5bb979b.tar.gz
freebsd implementation of get_thread_stack_base
* configure.ac: Check for pthread_np.h and pthread_attr_get_np. Patch by Jim Pryor. * libguile/threads.c (get_thread_stack_base): Provide an implementation for FreeBSD.
Diffstat (limited to 'libguile/threads.c')
-rw-r--r--libguile/threads.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libguile/threads.c b/libguile/threads.c
index f71c83c5a..9a6e4061c 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -38,6 +38,10 @@
#include <sys/time.h>
#endif
+#if HAVE_PTHREAD_NP_H
+# include <pthread_np.h>
+#endif
+
#include <assert.h>
#include <fcntl.h>
#include <nproc.h>
@@ -141,6 +145,29 @@ get_thread_stack_base ()
return pthread_get_stackaddr_np (pthread_self ());
}
+#elif HAVE_PTHREAD_ATTR_GET_NP
+/* This one is for FreeBSD 9. */
+static void *
+get_thread_stack_base ()
+{
+ pthread_attr_t attr;
+ void *start, *end;
+ size_t size;
+
+ pthread_attr_init (&attr);
+ pthread_attr_get_np (pthread_self (), &attr);
+ pthread_attr_getstack (&attr, &start, &size);
+ pthread_attr_destroy (&attr);
+
+ end = (char *)start + size;
+
+#if SCM_STACK_GROWS_UP
+ return start;
+#else
+ return end;
+#endif
+}
+
#else
#error Threads enabled with old BDW-GC, but missing get_thread_stack_base impl. Please upgrade to libgc >= 7.1.
#endif