[Olsr-dev] olsrd timer refactoring

Erik Tromp (spam-protected)
Sat Mar 1 14:16:07 CET 2008


> Which hardware/CPU BTW?

CPU Type:	Mobile DualCore Intel Core 2 Duo T5600, 1833 MHz (11 x 167)

gcc version 3.3.5 (Debian 1:3.3.5-13)


> That is very probably triggered by the "-finline-limit=50" + 
> "-Winline".

You are right.


> And
> ----  snip  ----
> #define LISTNODE2STRUCT(funcname, structname, listnodename) \ 
> static inline structname * funcname (struct list_node *ptr)\ {\
>   if (ptr) {\ 
>     return((structname *) (((olsr_u8_t *) ptr) - 
> offsetof(structname, listnodename))); \
>   } \
>   return(NULL); \
> }
> ----  snip  ----
> apparently may generate more the "50" (whatever units gcc 
> defines this to bet).
> Though I can't really understand why (basically) "return ptr != NULL ?
> ptr - constant : NULL" should generate that much code.
> 
> Solutions (in arbitrary order):
> - Removing these options shouldn't hurt the generated binary. I put it
>   in to catch too large inline functions.
> - remove the "if (ptr)" safety net from the macro and push that
>   responsibility to the caller.
>   Personally I'm not a great fan of the "the code checks for NULL and
>   fail gracefully silent" as it makes the code explode without cause.
>   But I think I know why it's in there.
> - Make the number "50" larger.

I did some tests.

The lowest value for inline-limit that worked for me was 180.

Then I replaced the explicit if-statement by a conditional expression, as
follows:

#define LISTNODE2STRUCT(funcname, structname, listnodename) \
static inline structname * funcname (struct list_node *ptr)\
{\
  return( \
    ptr != 0 ? \
      (structname *) (((olsr_u8_t *) ptr) - offsetof(structname, listnodename)) : \
      NULL); \
}

With that in place, the lowest value for inline-limit that worked was 80.

Maybe a bug in gcc ?


> The rest are trivial to fix I assume.

Agree.

Erik





More information about the Olsr-dev mailing list