From bee4a3307b14bd3911f6decaf62d7c649d6ecc8b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 3 Feb 2012 20:13:11 +0400 Subject: [PATCH] Implement GC_get_stack_base for Darwin if threads support is off * os_dep.c (GC_get_stack_base): Define separately for NEED_FIND_LIMIT case; tag the argument with "unused" attribute for the case when GC_UNIMPLEMENTED is returned; add implementation (as the last alternative) based on GC_get_main_stack_base (e.g., for Darwin) for the single-threaded case unless GC_stack_base has more that one field (IA-64). --- os_dep.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/os_dep.c b/os_dep.c index 03a0ca8..0f0d75a 100644 --- a/os_dep.c +++ b/os_dep.c @@ -1380,16 +1380,16 @@ GC_INNER word GC_page_size = 0; #endif /* GC_RTEMS_PTHREADS */ #ifndef HAVE_GET_STACK_BASE - /* Retrieve stack base. */ - /* Using the GC_find_limit version is risky. */ - /* On IA64, for example, there is no guard page between the */ - /* stack of one thread and the register backing store of the */ - /* next. Thus this is likely to identify way too large a */ - /* "stack" and thus at least result in disastrous performance. */ - /* FIXME - Implement better strategies here. */ - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b) - { -# ifdef NEED_FIND_LIMIT +# ifdef NEED_FIND_LIMIT + /* Retrieve stack base. */ + /* Using the GC_find_limit version is risky. */ + /* On IA64, for example, there is no guard page between the */ + /* stack of one thread and the register backing store of the */ + /* next. Thus this is likely to identify way too large a */ + /* "stack" and thus at least result in disastrous performance. */ + /* FIXME - Implement better strategies here. */ + GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b) + { int dummy; IF_CANCEL(int cancel_state;) DCL_LOCK_STATE; @@ -1407,10 +1407,20 @@ GC_INNER word GC_page_size = 0; RESTORE_CANCEL(cancel_state); UNLOCK(); return GC_SUCCESS; -# else - return GC_UNIMPLEMENTED; -# endif - } + } +# else + GC_API int GC_CALL GC_get_stack_base( + struct GC_stack_base *b GC_ATTR_UNUSED) + { +# if defined(GET_MAIN_STACKBASE_SPECIAL) && !defined(THREADS) \ + && !defined(IA64) + b->mem_base = GC_get_main_stack_base(); + return GC_SUCCESS; +# else + return GC_UNIMPLEMENTED; +# endif + } +# endif /* !NEED_FIND_LIMIT */ #endif /* !HAVE_GET_STACK_BASE */ #ifndef GET_MAIN_STACKBASE_SPECIAL -- 2.7.4