Author: gherzan Date: Thu Nov 12 19:17:36 2009 New Revision: 1680 Log: libpisa: add PISA_FORCE_INLINE and use it It relies on the always_inline attribute, a GCC specific one. Used it in _is_hit because the instruction footprint is small and it might be performance-critical routine. Modified: trunk/libpisa/global.h Modified: trunk/libpisa/global.h ============================================================================== --- trunk/libpisa/global.h Thu Nov 12 19:07:35 2009 (r1679) +++ trunk/libpisa/global.h Thu Nov 12 19:17:36 2009 (r1680) @@ -130,6 +130,25 @@ #endif /** + * Force the inlining of a function. There are 2 consequences: + * 1. inlining even at zero optimization level + * 2. make the compiler stop spitting warnings related to code size + * when you're sure that NOT inlining a function would bring some + * important performance penalty. + * + * Please USE WITH CAUTION and provide a good reason when doing so + * (in comments/commit logs). Whenever in doubt about using this, just + * go back to using "inline". + */ +#if defined(__GNUC__) && (__GNUC__ >= 4) +# define PISA_FORCE_INLINE inline __attribute__((always_inline)) +#else +# define PISA_FORCE_INLINE inline +#endif + + + +/** * Default port number of client daemon */ #define PISACD_DEFAULT_PORTNUM_CONTROL 5001 @@ -263,7 +282,7 @@ #define HIT_MASK_INV 0xfffffff0 #define HIT_PREFIX 0x20010010 -static inline int pisa_ipv6_addr_is_hit(const struct in6_addr *hit) +static PISA_FORCE_INLINE int pisa_ipv6_addr_is_hit(const struct in6_addr *hit) { uint32_t begin;