This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: weakref GCC attribute and .weakref assembly directive
- From: Richard Henderson <rth at redhat dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, jakub at redhat dot com, drepper at redhat dot com, bkoz at redhat dot com
- Date: Tue, 8 Nov 2005 14:27:16 -0800
- Subject: Re: RFC: weakref GCC attribute and .weakref assembly directive
- References: <orek6tca8g.fsf@livre.oliva.athome.lsd.ic.unicamp.br> <orbr1ksmmn.fsf@livre.oliva.athome.lsd.ic.unicamp.br> <20051020084852.GA18500@redhat.com> <orhdbbejgs.fsf@livre.oliva.athome.lsd.ic.unicamp.br> <or4q74rgoj.fsf@livre.oliva.athome.lsd.ic.unicamp.br>
On Wed, Oct 26, 2005 at 03:27:40AM -0200, Alexandre Oliva wrote:
> * tree.h (IDENTIFIER_TRANSPARENT_ALIAS): New.
> (TREE_DEPRECATED): Adjust comment. Check for a DECL.
> * c-common.c (handle_weakref_attribute): New.
> (c_common_attribute_table): Add weakref.
> * configure.ac (HAVE_GAS_WEAKREF): Check for weakref support
> in the assembler.
> * configure, config.in: Rebuilt.
> * defaults.h (ASM_OUTPUT_WEAKREF): Define if HAVE_GAS_WEAKREF.
> * doc/extend.texi: Document weakref attribute.
> * varasm.c (ultimate_transparent_alias_target): New
> (assemble_name): Use it.
> (weak_finish_1): Split out of...
> (weak_finish): ... and deal with weakrefs in...
> (weakref_targets): ... new list.
> (globalize_decl): Clean up weakref_targets.
> (do_assemble_alias): Handle weakrefs.
> (finish_aliases_1): Do not reject weakrefs to external symbols.
> (assemble_alias): Handle weakrefs.
>
> * gcc.dg/attr-weakref-1.c, gcc.dg/attr-weakref-1a.c: New test.
> * g++.old-deja/g++.abi/vtable2.C: Use weakref instead of alias.
Ok.
> * gthr-dce.h, gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
> gthr-tpf.h: Define __gthrw. For all identifiers that might
> be weak, introduce weakrefs or non-weak aliases with __gthrw,
> and prefix all uses with __ghtrw.
Here, I think
> #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
> +# define __gthrw(name) \
> + extern __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name)))
> +#else
> +# define __gthrw(name) \
> + extern __typeof(name) __gthrw_ ## name __asm (#name)
> +#endif
this needs a fix for -fleading-underscore targets.
While attributes alias and weakref implicitly imply the leading
underscore when the target uses it (not my call), that isn't true
for directly setting the asm name. I think you need to stringize
__USER_LABEL_PREFIX__ and string concatenate it with #name.
Otherwise I think this is fine.
r~