]> granicus.if.org Git - gc/commit
Support GC_init (and get_stack_base) from non-main thread on FreeBSD
authorIvan Maidanski <ivmai@mail.ru>
Wed, 27 Sep 2017 23:06:31 +0000 (02:06 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 11 Oct 2017 05:10:18 +0000 (08:10 +0300)
commit6f57a9df0969aba4fe28fd7ec6f218de0d7f8488
tree54fa10be5c89955e1de929d306372800dfdcc984
parent32a54f385be0d4aba03ccc935e842c9ca77ccae1
Support GC_init (and get_stack_base) from non-main thread on FreeBSD
(Cherry-pick commits 49d7fe739ca0b5 from 'master' branch.)

Issue #180 (bdwgc).

Now GC_get_[main_]stack_base uses pthread_attr_get_np() and
pthread_attr_getstack() to determine the stack base address.

* include/private/gcconfig.h [(FREEBSD && __GLIBC__ || LINUX
|| PLATFORM_ANDROID) && !NO_PTHREAD_GETATTR_NP]
(HAVE_PTHREAD_GETATTR_NP): New macro.
* include/private/gcconfig.h [FREEBSD && !__GLIBC__
&& !NO_PTHREAD_ATTR_GET_NP] (HAVE_PTHREAD_NP_H,
HAVE_PTHREAD_ATTR_GET_NP): Likewise.
* os_dep.c [(HAVE_PTHREAD_ATTR_GET_NP || HAVE_PTHREAD_GETATTR_NP)
&& (THREADS || USE_GET_STACKBASE_FOR_MAIN) && HAVE_PTHREAD_NP_H]:
Include pthread_np.h.
* os_dep.c [!BEOS && !AMIGA && !OS2 && !MSWIN32 && !MSWINCE
&& !CYGWIN32 && !GC_OPENBSD_THREADS] (include pthread.h,
GC_get_main_stack_base): Check presence of HAVE_PTHREAD_ATTR_GET_NP,
HAVE_PTHREAD_GETATTR_NP macros instead of LINUX, PLATFORM_ANDROID,
NO_PTHREAD_GETATTR_NP.
* os_dep.c [HAVE_PTHREAD_GETATTR_NP && (USE_GET_STACKBASE_FOR_MAIN
|| THREADS && !REDIRECT_MALLOC)] (GC_get_main_stack_base): Call
pthread_attr_init, pthread_attr_get_np and pthread_attr_getstack
to determine the stack base address of the current thread (fall back
to GC_freebsd_main_stack_base in case of failure).
* os_dep.c [!HAVE_GET_STACK_BASE] (GC_get_stack_base): Check presence
of THREADS, HAVE_PTHREAD_ATTR_GET_NP, HAVE_PTHREAD_GETATTR_NP,
HAVE_PTHREAD_NP_H macros instead of GC_LINUX_THREADS, PLATFORM_ANDROID,
NO_PTHREAD_GETATTR_NP.
* os_dep.c [HAVE_PTHREAD_GETATTR_NP && THREADS && !HAVE_GET_STACK_BASE]
(GC_get_stack_base): Call pthread_attr_init, pthread_attr_get_np and
pthread_attr_getstack to determine the stack base address of the
current thread.
include/private/gcconfig.h
os_dep.c