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:
parent
156e30a60d
commit
6a1e745bb2
1 changed files with 14 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue