[Gc] Re[2]: Defining USE_LIBC_PRIVATES on all glibc systems

Ivan Maidanski ivmai at mail.ru
Wed May 22 14:49:40 PDT 2013


 Hi Ludo,

I've committed part (with modifications, plus adding a commit message) of the proposed patch -  https://github.com/ivmai/bdwgc/commit/14a5128999f6590969741e7e74a2eee4157ab0ad

 The rest is incorrect (have you tested it?) or just no-op:

1.
> -#ifdef LINUX_STACKBOTTOM
> +#if defined LINUX_STACKBOTTOM || defined __GLIBC__
  STATIC ptr_t GC_linux_main_stack_base(void) ...
#endif

What's this? You define GC_linux_main_stack_base for GLIBC & !LINUX_STACKBOTTOM case but do not use it in such a case.

2.
> + || (defined(__GLIBC__) \

Syntax error (missing parenthesis)

3. Ok, let correct the syntax error, and then we will get crash at runtime (if single-threaded, otherwise GC_linux_main_stack_base is not called) because libc_stack_end points to primordial thread stack thus you should call GC_INIT from that thread.

Regards,
Ivan

Wed, 22 May 2013, 0:19 +02:00 from ludo at gnu.org (Ludovic Courtès):
>Hello,
>
>Any comments on this patch?
>
>TIA,
>Ludo’.
>
>ludo at gnu.org (Ludovic Courtès) skribis:
>
>> Currently ‘USE_LIBC_PRIVATES’ is disabled by default, and only checked
>> on GNU/Linux.  The default on GNU/Linux is to get info from /proc.
>>
>> What about using it unconditionally on glibc systems?
>>
>> On GNU/Linux, that would work even in situations where /proc is
>> unavailable (such as during early boot), and would be more efficient.
>>
>> It would also simplify things for GNU/kFreeBSD and GNU/Hurd, and allow
>> (for instance) calls to ‘GC_INIT’ from a secondary thread (as in
>> tests/initsecondarythread.c) on these platforms.
>>
>> Here’s a tentative patch:
>>
>> diff --git a/os_dep.c b/os_dep.c
>> index cb3ef43..ac5c282 100644
>> --- a/os_dep.c
>> +++ b/os_dep.c
>> @@ -1005,7 +1005,12 @@ GC_INNER word GC_page_size = 0;
>> 
>>  #endif /* HPUX_STACK_BOTTOM */
>> 
>> -#ifdef LINUX_STACKBOTTOM
>> +#ifdef __GLIBC__
>> +/* Use glibc's stack-end marker.  */
>> +# define USE_LIBC_PRIVATES
>> +#endif
>> +
>> +#if defined LINUX_STACKBOTTOM || defined __GLIBC__
>> 
>>  # include <sys/types.h>
>>  # include <sys/stat.h>
>> diff --git a/tests/initsecondarythread.c b/tests/initsecondarythread.c
>> index 4a13ca9..1973b8a 100644
>> --- a/tests/initsecondarythread.c
>> +++ b/tests/initsecondarythread.c
>> @@ -69,6 +69,7 @@ int main(void)
>>         || (defined(DARWIN) && !defined(NO_PTHREAD_GET_STACKADDR_NP)) \
>>         || (defined(LINUX) && !defined(NACL)) \
>>         || (defined(GC_SOLARIS_THREADS) && !defined(_STRICT_STDC)) \
>> +       || (defined(__GLIBC__)					  \
>>         || (!defined(STACKBOTTOM) && (defined(HEURISTIC1) \
>>            || (!defined(LINUX_STACKBOTTOM) && !defined(FREEBSD_STACKBOTTOM)))))
>>      /* GC_INIT() must be called from main thread only. */
>>
>> Thanks,
>> Ludo’.
>> _______________________________________________
>> Gc mailing list
>>  Gc at linux.hpl.hp.com
>>  http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
>_______________________________________________
>Gc mailing list
>Gc at linux.hpl.hp.com
>http://www.hpl.hp.com/hosted/linux/mail-archives/gc/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20130523/140fe455/attachment.htm


More information about the Gc mailing list