summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-11-30 00:36:45 +0100
committerDavid Lamparter <equinox@diac24.net>2019-11-30 00:38:32 +0100
commitfa751d15a01c976058cad8492be4b5c8226edae7 (patch)
tree5ec3d32a3b6844d196b47a06f8b2df020a76fe7f /lib
parentMerge pull request #5409 from qlyoung/bgpd-lcom-ecom-parse-fixes (diff)
downloadfrr-fa751d15a01c976058cad8492be4b5c8226edae7.tar.xz
frr-fa751d15a01c976058cad8492be4b5c8226edae7.zip
lib: gcc 4.x workaround v2 for frr_interface_info
The previous workaround only works for -O0, at higher optimization levels gcc reorders the statements in the file global scope which breaks the asm statement :(. Fixes: #4563 Fixes: #5074 Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/if.c b/lib/if.c
index f1565a089..20215640e 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1650,7 +1650,32 @@ static int lib_interface_description_destroy(enum nb_event event,
}
/* clang-format off */
+
+#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
+/* gcc versions before 5.x miscalculate the size for structs with variable
+ * length arrays (they just count it as size 0)
+ */
+struct frr_yang_module_info_size3 {
+ /* YANG module name. */
+ const char *name;
+
+ /* Northbound callbacks. */
+ const struct {
+ /* Data path of this YANG node. */
+ const char *xpath;
+
+ /* Callbacks implemented for this node. */
+ struct nb_callbacks cbs;
+
+ /* Priority - lower priorities are processed first. */
+ uint32_t priority;
+ } nodes[3];
+};
+
+const struct frr_yang_module_info_size3 frr_interface_info_size3 asm("frr_interface_info") = {
+#else
const struct frr_yang_module_info frr_interface_info = {
+#endif
.name = "frr-interface",
.nodes = {
{
@@ -1677,13 +1702,3 @@ const struct frr_yang_module_info frr_interface_info = {
},
}
};
-
-#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__)
-/* gcc versions before 5.x miscalculate the size for structs with variable
- * length arrays (they just count it as size 0)
- *
- * NB: the "." below means "current position", i.e. this line must be
- * immediately after the frr_interface_info variable!
- */
-__asm__(".size\tfrr_interface_info, .-frr_interface_info\n");
-#endif