Attributes of functions

Paul TBBle Hampson Paul.Hampson at Pobox.com
Sat Sep 17 18:01:11 CEST 2005


On Sat, Sep 17, 2005 at 05:29:18PM +0200, Nicolas Baradakis wrote:
> Among other things, Primoz Bratanic has send to me a patch that adds
> attributes to some of the functions. I think it is a good idea, I can
> see only avantages to it:
> - it makes the code more explicit for the reader.
> - it helps the compiler to produce a more performant binary.
> - it makes audit easier.

> I'd like to know whether I can apply this patch. There're two
> different methods to use the attributes of functions:

> --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
##ifndef __GNUC__
##  define  __attribute__(x)  /*NOTHING*/
##endif

> static void __attribute__((noreturn)) usage(void)
> --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

> Or perhaps this one a little friendlier:

> --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
##ifdef __GNUC__
##  define NORETURN __attribute__(noreturn)
##else
##  define NORETURN /*NOTHING*/
##endif

> static void NORETURN usage(void)
> --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---

I'm only working with gcc, so I don't mind if we use gcc extensions myself...

Are the attributes likely to vary between compilers we care about? (as opposed
to simply present or absent)

If so, then the latter is neccessary... If not, the former is sufficient, and
prolly cleaner.

If doing the latter roll out the #defines into a seperate header file, so that
porting to other compilers is centralised... (If you weren't going to do that
already)

Oh wow, I think I just discovered why autoconf was written... ^_^

-- 
-----------------------------------------------------------
Paul "TBBle" Hampson, MCSE
8th year CompSci/Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
Paul.Hampson at Pobox.Com

Of course Pacman didn't influence us as kids. If it did,
we'd be running around in darkened rooms, popping pills and
listening to repetitive music.
 -- Kristian Wilson, Nintendo, Inc, 1989

License: http://creativecommons.org/licenses/by/2.1/au/
-----------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freeradius.org/pipermail/freeradius-devel/attachments/20050918/9a30e58d/attachment.pgp>


More information about the Freeradius-Devel mailing list