]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
build: compiler attribute improvements 3983/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 29 Sep 2021 08:02:39 +0000 (10:02 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 29 Sep 2021 08:17:33 +0000 (10:17 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
meson.build
src/lxc/compiler.h

index e37c4694bb5ac82df508e7904d3422607313c461..d832eb8b321b95c3c912e9361ca97d18c9613143 100644 (file)
@@ -355,8 +355,13 @@ conf.set10('HAVE_STRCHRNUL', have)
 have = cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
 conf.set10('HAVE_OPENPTY', have)
 
-conf.set10('HAVE_COMPILER_ATTR_NONNULL', cc.has_function_attribute('nonnull'))
-conf.set10('HAVE_COMPILER_ATTR_RETURNS_NONNULL', cc.has_function_attribute('returns_nonnull'))
+foreach ccattr : ['fallthrough',
+                 'nonnull',
+                 'returns_nonnull',
+                ]
+
+        conf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
+endforeach
 
 config_h = configure_file(
         output : 'config.h',
index ec071dc83ffbafcc3f584eb9bf768748cd9e3b7c..4d62323822faa1997753f94df8de6b8fa3a28f64 100644 (file)
@@ -18,7 +18,7 @@
 #endif
 #endif
 
-#if __GNUC__ >= 7
+#if HAVE_COMPILER_ATTR_FALLTHROUGH || __GNUC__ >= 7
 #define __fallthrough __attribute__((__fallthrough__))
 #else
 #define __fallthrough /* fall through */