Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Dec 1995 05:58:15 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, phk@critter.tfs.com
Cc:        current@freebsd.org, imb@scgt.oz.au, julian@ref.tfs.com, terry@lambert.org
Subject:   Re: changes in -current..TEST please
Message-ID:  <199512061858.FAA31752@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> >If you used up to date source, you would know that the above macro now
>> >looks like this:
>> 
>> >	#define MAKE_SET(set, sym, type) \
>> >		static void *const __set_##set##_sym_##sym = \
>> >			(&__set_##set##_sym_##sym, &sym, 0); \
>> >		asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym)
>> 
>> >and that it (according to the gcc manual) ensures that the compiler will
>> >not remove your static and "secretly" referenced Symbols.
>> 
>> The macro only tells the compiler about `sym'.  `type' is only referenced
>> in the stab.

>type isn't an endangered species I think...

Oops.

The manual only seems to say that the above stops the warning.  gcc-2.7
has a better method:

	static void dummy_cleanup(void) __attribute__((__unused__));

This stops the warning but doesn't stop dummy_cleanup() going away with
-O3 any better than MAKE_SET() (it goes away because it becomes static
inline.  static inlines _should_ go away).

Why not initialize a pointer to the function?  Then the function address
_is_ used provided the pointer doesn't go away.  Why does the comma
expression end with an 0 anyway?  The following seems to work right
(except it wastes a pointer):

	static void (*const foo)(void) = dummy_cleanup;

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512061858.FAA31752>