]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compiler: add a new macro to set an attribute on an enum when possible
authorWilly Tarreau <w@1wt.eu>
Mon, 9 May 2022 17:45:06 +0000 (19:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 May 2022 18:32:11 +0000 (20:32 +0200)
Gcc 6 and above support placing an attribute on an enum's value. This
is convenient for marking some values as deprecated. We just need the
macro because older versions fail to parse __attribute__() there.

include/haproxy/compiler.h

index a23e62a21eeaca46d275082c046b856997c8a6b9..49356daab86a6cf8488dd8eca3436e1e7c0138c7 100644 (file)
        })
 #endif
 
+
+/* From gcc 6 and above, enum values may have attributes */
+#if __GNUC_PREREQ__(6, 0)
+#define ENUM_ATTRIBUTE(x) __attribute__(x)
+#else
+#define ENUM_ATTRIBUTE(x)
+#endif
+
 /* Some architectures have a double-word CAS, sometimes even dual-8 bytes.
  * Some architectures support unaligned accesses, others are fine with them
  * but only for non-atomic operations. Also mention those supporting unaligned