[master] 6ae8119 Make C11 _Static_assert() available if we have it

Poul-Henning Kamp phk at FreeBSD.org
Sat May 27 13:50:06 CEST 2017


commit 6ae8119e0f96e652cc1ba7b1e298438a850f52b7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat May 27 09:50:27 2017 +0000

    Make C11 _Static_assert() available if we have it

diff --git a/configure.ac b/configure.ac
index 0c95ea0..a3adfb6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -359,6 +359,27 @@ AC_CHECK_DECL([SO_ACCEPTFILTER],
     ]
 )
 
+# Check for _Static_assert()
+# We dont' want to go all C11 on this, and we have vas.h instead
+# of assert.h, so check the brutal way
+
+save_LIBS="${LIBS}"
+LIBS=""
+AC_CACHE_CHECK([for _Static_assert],
+  [ac_cv_static_assert],
+  [AC_RUN_IFELSE(
+    [AC_LANG_PROGRAM([[
+_Static_assert(1 == sizeof(char), "didn't work");
+    ]],[[
+    ]])],
+    [ac_cv_static_assert=yes],
+    [ac_cv_static_assert=no])
+  ])
+if test "$ac_cv_static_assert" = yes; then
+   AC_DEFINE([STATIC_ASSERT], [1], [Define if _Static_assert is availabel])
+fi
+LIBS="${save_LIBS}"
+
 # Older Solaris versions define SO_{RCV,SND}TIMEO, but do not
 # implement them.
 #
diff --git a/include/vdef.h b/include/vdef.h
index f0afe09..aa9be07 100644
--- a/include/vdef.h
+++ b/include/vdef.h
@@ -125,4 +125,9 @@
 #define NEEDLESS(s)		s
 #endif
 
+#ifndef STATIC_ASSERT
+#  define _Static_assert(a,b)
+#endif
+
+
 #endif /* VDEF_H_INCLUDED */



More information about the varnish-commit mailing list