[master] 1a0d149 Have I ever mentioned how much I hate the ISO-C people and the ****heads in the gcc&llvm projects who cannot cooperate on usability features ?
Poul-Henning Kamp
phk at FreeBSD.org
Wed Oct 4 09:29:09 UTC 2017
commit 1a0d149db00a20b2edf19f56793ec99e0e6ccf14
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 4 09:27:17 2017 +0000
Have I ever mentioned how much I hate the ISO-C people and the
****heads in the gcc&llvm projects who cannot cooperate on
usability features ?
Fixes #2449
diff --git a/configure.ac b/configure.ac
index 5e20c0a..cf8f9b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -368,27 +368,6 @@ 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 70f8178..12093bf 100644
--- a/include/vdef.h
+++ b/include/vdef.h
@@ -127,8 +127,28 @@
#define NEEDLESS(s) s
#endif
-#ifndef STATIC_ASSERT
-# define _Static_assert(a,b)
+
+/*
+ * Most of this nightmare is stolen from FreeBSD's <cdefs.h>
+ */
+#if defined(_Static_assert)
+ /* Nothing, somebody already did this for us */
+#elif defined(__has_extension) && __has_extension(c_static_assert)
+ /* Nothing, we should be fine */
+#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
+ __has_extension(cxx_static_assert)
+# define _Static_assert(x, y) static_assert(x, y)
+#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
+ /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
+#else
+# if defined(__COUNTER__)
+# define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
+# else
+# define _Static_assert(x, y) __Static_assert(x, __LINE__)
+# endif
+# define __Static_assert(x, y) ___Static_assert(x, y)
+# define ___Static_assert(x, y) \
+ typedef char __assert_ ## y[(x) ? 1 : -1] __unused
#endif
#endif /* VDEF_H_INCLUDED */
More information about the varnish-commit
mailing list