util: move 'unused_fn' macro to from rb.h to util.h
This commit is contained in:
parent
1ad34ec3f3
commit
2b57c726c8
18
src/rb.h
18
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) \
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user