From 380f5107906a71a2d4430ddafee18b24d4ef16c2 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 15 Oct 2024 09:02:46 +0300 Subject: [PATCH] Use pthread_getattr_np() to get stack base on Cosmo Issue #666 (bdwgc). * include/private/gcconfig.h [COSMO] (LINUX_STACKBOTTOM): Do not define. * include/private/gcconfig.h [COSMO] (HEURISTIC1, USE_GET_STACKBASE_FOR_MAIN): Define macro. * include/private/gcconfig.h [COSMO && NO_PTHREAD_GETATTR_NP] (HAVE_PTHREAD_GETATTR_NP): Likewise. * include/private/gcconfig.h [COSMO] (STACK_GRAN): Define macro (with some fake value). --- include/private/gcconfig.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 930e58af7..7ce3c521f 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -809,7 +809,11 @@ EXTERN_C_BEGIN #ifdef COSMO # define OS_TYPE "COSMO" -# define LINUX_STACKBOTTOM +# define HEURISTIC1 /* relies on pthread_attr_getstack actually */ +# define STACK_GRAN 0x1000000 +# ifndef USE_GET_STACKBASE_FOR_MAIN +# define USE_GET_STACKBASE_FOR_MAIN +# endif extern int __data_start[] __attribute__((__weak__)); # define DATASTART ((ptr_t)__data_start) extern int _end[]; @@ -3122,8 +3126,8 @@ extern ptr_t GC_data_start; #endif /* Outline pthread primitives to use in GC_get_[main_]stack_base. */ -#if ((defined(FREEBSD) && defined(__GLIBC__)) /* kFreeBSD */ \ - || defined(LINUX) || defined(KOS) || defined(NETBSD)) \ +#if ((defined(FREEBSD) && defined(__GLIBC__)) /* kFreeBSD */ \ + || defined(COSMO) || defined(LINUX) || defined(KOS) || defined(NETBSD)) \ && !defined(NO_PTHREAD_GETATTR_NP) # define HAVE_PTHREAD_GETATTR_NP 1 #elif defined(FREEBSD) && !defined(__GLIBC__) \