1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added some utility macros

This commit is contained in:
Steffen Vogel 2016-06-08 22:32:53 +02:00
parent 156e30a60d
commit 6a1e745bb2

View file

@ -17,9 +17,11 @@
#include "log.h"
#ifdef __GNUC__
#define EXPECT(x, v) __builtin_expect(x, v)
#define LIKELY(x) __builtin_expect((x),1)
#define UNLIKELY(x) __builtin_expect((x),0)
#else
#define EXPECT(x, v) (x)
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif
/* Some color escape codes for pretty log messages */
@ -69,6 +71,16 @@
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#ifndef offsetof
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
#ifndef container_of
#define container_of(ptr, type, member) ({ const typeof( ((type *) 0)->member ) *__mptr = (ptr); \
(type *) ( (char *) __mptr - offsetof(type, member) ); \
})
#endif
/* Forward declarations */
struct settings;
struct timespec;