Changeset c7021d9


Ignore:
Timestamp:
05/29/14 16:00:48 (7 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
9b42f3e
Parents:
5809145
Message:

Added m4 macros to check for gcc compiler attributes

Instead of relying on GNUC, we now individually check
whether each attribute is supported by the C compiler and set
preprocessor macros accordingly.

Removed similar attribute definitions from wandio.h, as these are
not used at all by libwandio.

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • configure.in

    r10f924c rc7021d9  
    111111gl_VISIBILITY
    112112
     113gcc_PACKED
     114gcc_DEPRECATED
     115gcc_UNUSED
     116gcc_PURE
     117gcc_FORMAT
    113118       
    114119# Check for libtool
  • lib/libtrace.h.in

    r10f924c rc7021d9  
    153153#endif
    154154
    155 /* Function does not depend on anything but its
    156  * parameters, used to hint gcc's optimisations
    157  *
    158  * TODO: Find a way to check for these that is not gcc-specific
    159  */
    160 #if __GNUC__ >= 3
     155/* Ensure these gcc optimisation attributes are defined consistently,
     156 * without requiring users to need to have access to the config.h
     157 * generated by running configure.
     158 */
     159
     160#define LT_USE_PACKED @HAVE_ATTRIBUTE_PACKED@
     161#define LT_USE_UNUSED @HAVE_ATTRIBUTE_UNUSED@
     162#define LT_USE_DEPRECATED @HAVE_ATTRIBUTE_DEPRECATED@
     163#define LT_USE_PURE @HAVE_ATTRIBUTE_PURE@
     164#define LT_USE_PRINTF @HAVE_ATTRIBUTE_FORMAT@
     165
     166#if LT_USE_PACKED
     167#  define PACKED __attribute__((packed))
     168#else
     169#  define PACKED
     170#endif
     171
     172#if LT_USE_UNUSED
     173#  define UNUSED __attribute__((unused))
     174#else
     175#  define UNUSED
     176#endif
     177
     178#if LT_USE_DEPRECATED
    161179#  define DEPRECATED __attribute__((deprecated))
    162 #  define SIMPLE_FUNCTION __attribute__((pure))
    163 #  define UNUSED __attribute__((unused))
    164 #  define PACKED __attribute__((packed))
    165 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
    166180#else
    167181#  define DEPRECATED
     182#endif
     183
     184#if LT_USE_PURE
     185#  define SIMPLE_FUNCTION __attribute__((pure))
     186#else
    168187#  define SIMPLE_FUNCTION
    169 #  define UNUSED
    170 #  define PACKED
    171 #  define PRINTF(formatpos,argpos)
     188#endif
     189
     190#if LT_USE_PRINTF
     191#  define PRINTF(formatpos, argpos) __attribute__((format(printf,formatpos, argpos)))
     192#else
     193#  define PRINTF(formatpos, argpos)
    172194#endif
    173195
  • libwandio/wandio.h

    r10f924c rc7021d9  
    5151
    5252// TODO: Use a proper check for these attribute rather than gcc version check
    53 #if __GNUC__ >= 3
    54 #  define DEPRECATED __attribute__((deprecated))
    55 #  define SIMPLE_FUNCTION __attribute__((pure))
    56 #  define UNUSED __attribute__((unused))
    57 #  define PACKED __attribute__((packed))
    58 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
    59 #else
    60 #  define DEPRECATED
    61 #  define SIMPLE_FUNCTION
    62 #  define UNUSED
    63 #  define PACKED
    64 #  define PRINTF(formatpos,argpos)
    65 #endif
    66 
    6753
    6854/** @file
Note: See TracChangeset for help on using the changeset viewer.