diff --git a/src/rb.h b/src/rb.h index 3fcbc9d..4472403 100644 --- a/src/rb.h +++ b/src/rb.h @@ -23,6 +23,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef WEPOLL_RB_H_ +#define WEPOLL_RB_H_ + +#include "util.h" + /* * A red-black tree is a binary search tree with the node color as an * extra attribute. It fulfills a set of conditions: @@ -35,15 +40,6 @@ * The maximum height of a red-black tree is 2lg (n+1). */ -#ifndef WEPOLL_RB_H_ -#define WEPOLL_RB_H_ - -#ifdef __clang__ -#define RB_UNUSED __attribute__((__unused__)) -#else -#define RB_UNUSED /* empty */ -#endif - /* clang-format off */ /* Macros that define a red-black tree */ @@ -123,7 +119,7 @@ struct { \ #define RB_PROTOTYPE(name, type, field, cmp) \ RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) #define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, static RB_UNUSED) + RB_PROTOTYPE_INTERNAL(name, type, field, cmp, static unused_fn) #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ @@ -142,7 +138,7 @@ attr struct type *name##_RB_MINMAX(struct name *, int); \ #define RB_GENERATE(name, type, field, cmp) \ RB_GENERATE_INTERNAL(name, type, field, cmp,) #define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, static RB_UNUSED) + RB_GENERATE_INTERNAL(name, type, field, cmp, static unused_fn) #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ attr void \ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ diff --git a/src/util.h b/src/util.h index ce9af95..2db67c8 100644 --- a/src/util.h +++ b/src/util.h @@ -20,6 +20,12 @@ typedef intptr_t ssize_t; #define unused_var(v) ((void) (v)) +#ifdef __clang__ +#define unused_fn __attribute__((__unused__)) +#else +#define unused_fn /* nothing */ +#endif + #if defined(_MSC_VER) && _MSC_VER < 1900 /* Polyfill `inline` for msvc 12 (Visual Studio 2013) */ #define inline __inline