summaryrefslogtreecommitdiffstats
path: root/babeld
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-02-17 20:56:48 +0100
committerDonald Sharp <sharpd@nvidia.com>2023-03-23 12:54:56 +0100
commit6a72124df9cfc4ec7dabddfae5b3ab63a1069b87 (patch)
treefafd604e588389250d17ffe0317a83473eda7845 /babeld
parentMerge pull request #13078 from opensourcerouting/fix/set_distance_zero (diff)
downloadfrr-6a72124df9cfc4ec7dabddfae5b3ab63a1069b87.tar.xz
frr-6a72124df9cfc4ec7dabddfae5b3ab63a1069b87.zip
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>
Diffstat (limited to 'babeld')
-rw-r--r--babeld/babeld.c62
-rw-r--r--babeld/babeld.h4
-rw-r--r--babeld/util.h9
3 files changed, 37 insertions, 38 deletions
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 510415593..8d25d5f28 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -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);}
-
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
- struct interface *ifp = NULL;
+#define printIfMin(a, b, c, d) \
+ if (unlikely(debug & BABEL_DEBUG_TIMEOUT)) { \
+ printIfMin(a, b, c, d); \
+ }
- *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);
+ 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);
#undef printIfMin
#endif
}
diff --git a/babeld/babeld.h b/babeld/babeld.h
index a9ffb7ee4..d8f0fd782 100644
--- a/babeld/babeld.h
+++ b/babeld/babeld.h
@@ -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)
diff --git a/babeld/util.h b/babeld/util.h
index 5e5843543..8535d4dd6 100644
--- a/babeld/util.h
+++ b/babeld/util.h
@@ -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 */