mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-28 11:50:21 +00:00
babeld, lib, nhrpd: Add likely and unlikely macros
We have 2 competing versions of likely and unlikely in babeld and nhrpd. Standardize onto lower case versions and consolidate in the code. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
9cc377d4d7
commit
6a72124df9
@ -441,37 +441,39 @@ babel_fill_with_next_timeout(struct timeval *tv)
|
||||
#if (defined NO_DEBUG)
|
||||
#define printIfMin(a,b,c,d)
|
||||
#else
|
||||
#define printIfMin(a,b,c,d) \
|
||||
if (UNLIKELY(debug & BABEL_DEBUG_TIMEOUT)) {printIfMin(a,b,c,d);}
|
||||
#define printIfMin(a, b, c, d) \
|
||||
if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) { \
|
||||
printIfMin(a, b, c, d); \
|
||||
}
|
||||
|
||||
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
|
||||
struct interface *ifp = NULL;
|
||||
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
|
||||
struct interface *ifp = NULL;
|
||||
|
||||
*tv = check_neighbours_timeout;
|
||||
printIfMin(tv, 0, "check_neighbours_timeout", NULL);
|
||||
timeval_min_sec(tv, expiry_time);
|
||||
printIfMin(tv, 1, "expiry_time", NULL);
|
||||
timeval_min_sec(tv, source_expiry_time);
|
||||
printIfMin(tv, 1, "source_expiry_time", NULL);
|
||||
timeval_min(tv, &resend_time);
|
||||
printIfMin(tv, 1, "resend_time", NULL);
|
||||
FOR_ALL_INTERFACES(vrf, ifp) {
|
||||
babel_interface_nfo *babel_ifp = NULL;
|
||||
if(!if_up(ifp))
|
||||
continue;
|
||||
babel_ifp = babel_get_if_nfo(ifp);
|
||||
timeval_min(tv, &babel_ifp->flush_timeout);
|
||||
printIfMin(tv, 1, "flush_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->hello_timeout);
|
||||
printIfMin(tv, 1, "hello_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->update_timeout);
|
||||
printIfMin(tv, 1, "update_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->update_flush_timeout);
|
||||
printIfMin(tv, 1, "update_flush_timeout",ifp->name);
|
||||
}
|
||||
timeval_min(tv, &unicast_flush_timeout);
|
||||
printIfMin(tv, 1, "unicast_flush_timeout", NULL);
|
||||
printIfMin(tv, 2, NULL, NULL);
|
||||
*tv = check_neighbours_timeout;
|
||||
printIfMin(tv, 0, "check_neighbours_timeout", NULL);
|
||||
timeval_min_sec(tv, expiry_time);
|
||||
printIfMin(tv, 1, "expiry_time", NULL);
|
||||
timeval_min_sec(tv, source_expiry_time);
|
||||
printIfMin(tv, 1, "source_expiry_time", NULL);
|
||||
timeval_min(tv, &resend_time);
|
||||
printIfMin(tv, 1, "resend_time", NULL);
|
||||
FOR_ALL_INTERFACES (vrf, ifp) {
|
||||
babel_interface_nfo *babel_ifp = NULL;
|
||||
if (!if_up(ifp))
|
||||
continue;
|
||||
babel_ifp = babel_get_if_nfo(ifp);
|
||||
timeval_min(tv, &babel_ifp->flush_timeout);
|
||||
printIfMin(tv, 1, "flush_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->hello_timeout);
|
||||
printIfMin(tv, 1, "hello_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->update_timeout);
|
||||
printIfMin(tv, 1, "update_timeout", ifp->name);
|
||||
timeval_min(tv, &babel_ifp->update_flush_timeout);
|
||||
printIfMin(tv, 1, "update_flush_timeout", ifp->name);
|
||||
}
|
||||
timeval_min(tv, &unicast_flush_timeout);
|
||||
printIfMin(tv, 1, "unicast_flush_timeout", NULL);
|
||||
printIfMin(tv, 2, NULL, NULL);
|
||||
#undef printIfMin
|
||||
#endif
|
||||
}
|
||||
|
@ -26,12 +26,8 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
#define ATTRIBUTE(x) __attribute__ (x)
|
||||
#define LIKELY(_x) __builtin_expect(!!(_x), 1)
|
||||
#define UNLIKELY(_x) __builtin_expect(!!(_x), 0)
|
||||
#else
|
||||
#define ATTRIBUTE(x) /**/
|
||||
#define LIKELY(_x) !!(_x)
|
||||
#define UNLIKELY(_x) !!(_x)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
|
||||
|
@ -122,10 +122,11 @@ extern const unsigned char v4prefix[16];
|
||||
#define BABEL_DEBUG_ROUTE (1 << 5)
|
||||
#define BABEL_DEBUG_ALL (0xFFFF)
|
||||
|
||||
#define debugf(level, ...) \
|
||||
do { \
|
||||
if(UNLIKELY(debug & level)) zlog_debug(__VA_ARGS__); \
|
||||
} while(0)
|
||||
#define debugf(level, ...) \
|
||||
do { \
|
||||
if (unlikely(debug & level)) \
|
||||
zlog_debug(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#endif /* NO_DEBUG */
|
||||
|
||||
|
@ -439,6 +439,14 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
|
||||
#pragma diag_suppress 167
|
||||
#endif /* __INTELISENSE__ */
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
#define likely(_x) __builtin_expect(!!(_x), 1)
|
||||
#define unlikely(_x) __builtin_expect(!!(_x), 0)
|
||||
#else
|
||||
#define likely(_x) !!(_x)
|
||||
#define unlikely(_x) !!(_x)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,13 +1,5 @@
|
||||
#include "log.h"
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
#define likely(_x) __builtin_expect(!!(_x), 1)
|
||||
#define unlikely(_x) __builtin_expect(!!(_x), 0)
|
||||
#else
|
||||
#define likely(_x) !!(_x)
|
||||
#define unlikely(_x) !!(_x)
|
||||
#endif
|
||||
|
||||
#define NHRP_DEBUG_COMMON (1 << 0)
|
||||
#define NHRP_DEBUG_KERNEL (1 << 1)
|
||||
#define NHRP_DEBUG_IF (1 << 2)
|
||||
|
Loading…
Reference in New Issue
Block a user