From a32a7b58cebc2838de2ffd94e679d3e1ec9d493a Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Sun, 10 Dec 2017 13:16:31 +0100 Subject: [PATCH] Lib: Fix macro/keyword collisions Old code breaks with some versions of bison --- lib/buffer.h | 6 +++++- lib/flowspec.h | 2 +- lib/timer.h | 2 +- proto/static/static.h | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/buffer.h b/lib/buffer.h index 6fc18852..cd9bab86 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -13,10 +13,14 @@ #include "lib/resource.h" #include "sysdep/config.h" -#define BUFFER(type) struct { type *data; uint used, size; } +#define BUFFER_(type) struct { type *data; uint used, size; } #define BUFFER_TYPE(v) typeof(* (v).data) #define BUFFER_SIZE(v) ((v).size * sizeof(* (v).data)) +#ifndef PARSER +#define BUFFER(type) BUFFER_(type) +#endif + #define BUFFER_INIT(v,pool,isize) \ ({ \ (v).used = 0; \ diff --git a/lib/flowspec.h b/lib/flowspec.h index 4fe23da1..fa90c70d 100644 --- a/lib/flowspec.h +++ b/lib/flowspec.h @@ -91,7 +91,7 @@ const byte *flow6_next_part(const byte *pos, const byte *end); /* A data structure for keep a state of flow builder */ struct flow_builder { - BUFFER(byte) data; + BUFFER_(byte) data; enum flow_type this_type; enum flow_type last_type; u16 last_op_offset; /* Position of last operator in data.data */ diff --git a/lib/timer.h b/lib/timer.h index eeb7dcb7..ed8f0d02 100644 --- a/lib/timer.h +++ b/lib/timer.h @@ -30,7 +30,7 @@ typedef struct timer struct timeloop { - BUFFER(timer *) timers; + BUFFER_(timer *) timers; btime last_time; btime real_time; }; diff --git a/proto/static/static.h b/proto/static/static.h index b202c0b1..a3c30b87 100644 --- a/proto/static/static.h +++ b/proto/static/static.h @@ -25,7 +25,7 @@ struct static_proto { struct proto p; struct event *event; /* Event for announcing updated routes */ - BUFFER(struct static_route *) marked; /* Routes marked for reannouncement */ + BUFFER_(struct static_route *) marked; /* Routes marked for reannouncement */ rtable *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */ rtable *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */ };