DES-SERT - A Simple and Extensible Routing Framework for Testbeds: U S E F U L L _ MA C R O S

# U S E F U L L _ MA C R O S

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))
#define | unlikely(x) (__builtin_expect((x),0))
#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)

## Detailed Description

EXTERNAL / PUBLIC.

## Define Documentation

#define MESHIFLIST_ITERATOR_START | ( | __interface |  | ) |

Value:

    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 |  | ) |

Value:

    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.