This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: weakref GCC attribute and .weakref assembly directive


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]