summaryrefslogtreecommitdiffstats
path: root/m4/ax_c__generic.m4
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2016-11-23 15:49:10 +0000
commit87649cf32bd0e14d5a903fb85b01e9f41a253540 (patch)
treebbefda6dac074aeb87529592e8e5064f69cbe024 /m4/ax_c__generic.m4
parentImported Upstream version 1.3.0+dfsg (diff)
downloadnetdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.tar.xz
netdata-87649cf32bd0e14d5a903fb85b01e9f41a253540.zip
New upstream version 1.4.0+dfsgupstream/1.4.0+dfsg
Diffstat (limited to 'm4/ax_c__generic.m4')
-rw-r--r--m4/ax_c__generic.m428
1 files changed, 28 insertions, 0 deletions
diff --git a/m4/ax_c__generic.m4 b/m4/ax_c__generic.m4
new file mode 100644
index 00000000..0c4dd52c
--- /dev/null
+++ b/m4/ax_c__generic.m4
@@ -0,0 +1,28 @@
+# https://lists.gnu.org/archive/html/autoconf-commit/2012-12/msg00004.html
+# AC_C__GENERIC
+# -------------
+# Define HAVE_C__GENERIC if _Generic works, a la C11.
+AN_IDENTIFIER([_Generic], [AC_C__GENERIC])
+AC_DEFUN([AC_C__GENERIC],
+[AC_CACHE_CHECK([for _Generic], ac_cv_c__Generic,
+[AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [[int
+ main (int argc, char **argv)
+ {
+ int a = _Generic (argc, int: argc = 1);
+ int *b = &_Generic (argc, default: argc);
+ char ***c = _Generic (argv, int: argc, default: argv ? &argv : 0);
+ _Generic (1 ? 0 : b, int: a, default: b) = &argc;
+ _Generic (a = 1, default: a) = 3;
+ return a + !b + !c;
+ }
+ ]])],
+ [ac_cv_c__Generic=yes],
+ [ac_cv_c__Generic=no])])
+if test $ac_cv_c__Generic = yes; then
+ AC_DEFINE([HAVE_C__GENERIC], 1,
+ [Define to 1 if C11-style _Generic works.])
+fi
+])# AC_C__GENERIC
+