Macros
[DES-SERT Library]
EXTERNAL / PUBLIC. More...
![]() |
Defines | |
#define | MESHIFLIST_ITERATOR_START(__interface) |
A convenience macro to safely iterate the list of mesh interfaces. | |
#define | MESHIFLIST_ITERATOR_STOP } pthread_rwlock_unlock(&dessert_cfglock) |
A convenience macro to safely iterate the list of mesh interfaces. | |
#define | TIMEVAL_ADD(__tv, __sec, __usec) |
A convenience macro to safely add __sec seconds and __usec microseconds to the struct timeval __tv in an invariant respecting manner. | |
#define | likely(x) (__builtin_expect((x),1)) |
Branch prediction optimization macros. | |
#define | unlikely(x) (__builtin_expect((x),0)) |
Branch prediction optimization macros. | |
#define | __dessert_assert(func, file, line, e) ((void)_dessert_log(LOG_EMERG, func, file, line, "assertion `%s' failed!\n", e), abort) |
#define | assert(e) (__builtin_expect(!(e), 0) ? __dessert_assert(__FUNCTION__, __FILE__, __LINE__, #e) : (void)0) |
Assertion Macro. |
Detailed Description
EXTERNAL / PUBLIC.
Define Documentation
#define assert | ( | e | ) | (__builtin_expect(!(e), 0) ? __dessert_assert(__FUNCTION__, __FILE__, __LINE__, #e) : (void)0) |
Assertion Macro.
The assertion macro enables to crash the daemon when a particular condition does not apply. In contrast to the standard C library assert, a message will be written using the logging feature of DES-SERT
#define likely | ( | x | ) | (__builtin_expect((x),1)) |
Branch prediction optimization macros.
You can give the compiler a hint if it is likely or unlikely that a particular condition will apply. In this way the branch prediction can be optimized.
#define MESHIFLIST_ITERATOR_START | ( | __interface | ) |
pthread_rwlock_rdlock(&dessert_cfglock); \ DL_FOREACH(dessert_meshiflist_get(), __interface) {
A convenience macro to safely iterate the list of mesh interfaces.
- Parameters:
-
__interface pointer to a temporal dessert_meshif_t
- Warning:
- You must pair it with an ending MESHIFLIST_ITERATOR_STOP() macro! Please find an usage example in the Examples paragraph below.
- Examples:
- The do_something() function will be called for every mesh interface in the list.
dessert_meshif_t *iface; MESHIFLIST_ITERATOR_START(iface) do_something(iface); // do something to every iface MESHIFLIST_ITERATOR_STOP;
#define MESHIFLIST_ITERATOR_STOP } pthread_rwlock_unlock(&dessert_cfglock) |
A convenience macro to safely iterate the list of mesh interfaces.
- See also:
- MESHIFLIST_ITERATOR_START()
#define TIMEVAL_ADD | ( | __tv, | |||
__sec, | |||||
__usec | ) |
do { \ (__tv)->tv_sec += __sec; \ (__tv)->tv_usec += __usec; \ if((__tv)->tv_usec >= 1000000) { \ ++(__tv)->tv_sec; \ (__tv)->tv_usec -= 1000000; \ } \ } while(0)
A convenience macro to safely add __sec seconds and __usec microseconds to the struct
timeval
__tv in an invariant respecting manner.
- Parameters:
-
__tv the struct
timeval
to add to__sec the number of seconds to add up to __tv->tv_sec __usec the number of microseconds to add up to __tv.->tv_usec
DESCRIPTION:
The GNU C Library Documentation states about the tv_usec
member of the struct
timeval:
This is the rest of the elapsed time (a fraction of a second), represented as the number of microseconds. It is always less than one million.
#define unlikely | ( | x | ) | (__builtin_expect((x),0)) |
Branch prediction optimization macros.
You can give the compiler a hint if it is likely or unlikely that a particular condition will apply. In this way the branch prediction can be optimized.