summaryrefslogtreecommitdiff
path: root/lib/typesafe.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-05-21 16:43:38 -0400
committerGitHub <noreply@github.com>2019-05-21 16:43:38 -0400
commit5349270f128c81769b0bc99c8cbcbcb1e3d1034e (patch)
tree108a2cec1cce02032550d07068ac8ecee32e404d /lib/typesafe.h
parent173c7642f2d7e1b2f897002c4cab3278a0730e22 (diff)
parent156d4463e4631016a854a3d6a918ebdbd7ea8635 (diff)
Merge pull request #4374 from opensourcerouting/typesafe-minor-fixes
Minor fixes in the typesafe API for better C++ compatibility
Diffstat (limited to 'lib/typesafe.h')
-rw-r--r--lib/typesafe.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/typesafe.h b/lib/typesafe.h
index 6df3a07efe..0a4ed69e4e 100644
--- a/lib/typesafe.h
+++ b/lib/typesafe.h
@@ -23,19 +23,23 @@
#include <assert.h>
#include "compiler.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* generic macros for all list-like types */
-#define for_each(prefix, head, item) \
+#define frr_each(prefix, head, item) \
for (item = prefix##_first(head); item; \
item = prefix##_next(head, item))
-#define for_each_safe(prefix, head, item) \
+#define frr_each_safe(prefix, head, item) \
for (typeof(prefix##_next_safe(head, NULL)) prefix##_safe = \
prefix##_next_safe(head, \
(item = prefix##_first(head))); \
item; \
item = prefix##_safe, \
prefix##_safe = prefix##_next_safe(head, prefix##_safe))
-#define for_each_from(prefix, head, item, from) \
+#define frr_each_from(prefix, head, item, from) \
for (item = from, from = prefix##_next_safe(head, item); \
item; \
item = from, from = prefix##_next_safe(head, from))
@@ -850,6 +854,10 @@ extern void typesafe_skiplist_del(struct sskip_head *head,
const struct sskip_item *b));
extern struct sskip_item *typesafe_skiplist_pop(struct sskip_head *head);
+#ifdef __cplusplus
+}
+#endif
+
/* this needs to stay at the end because both files include each other.
* the resolved order is typesafe.h before typerb.h
*/