diff options
| author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-03-09 11:03:48 +0100 |
|---|---|---|
| committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-03-09 11:03:48 +0100 |
| commit | d0edb72a0c9bc1a28197ab4566928f7ee63a6d43 (patch) | |
| tree | 6d524fb16d2dd1aa9f2d98529ef1de7a39f52700 /gl/m4/assert_h.m4 | |
| parent | 9fdc82f0543c6e2891c7079f70297f92e8ef4619 (diff) | |
| parent | 269718094177fb8a7e3d3005d1310495009fe8c4 (diff) | |
| download | monitoring-plugins-d0edb72.tar.gz | |
Merge branch 'master' into RincewindsHat-patch-1
Diffstat (limited to 'gl/m4/assert_h.m4')
| -rw-r--r-- | gl/m4/assert_h.m4 | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4 new file mode 100644 index 00000000..abba4fa3 --- /dev/null +++ b/gl/m4/assert_h.m4 | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | # assert-h.m4 | ||
| 2 | dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | dnl From Paul Eggert. | ||
| 8 | |||
| 9 | AC_DEFUN([gl_ASSERT_H], | ||
| 10 | [ | ||
| 11 | AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], | ||
| 12 | [gl_save_CFLAGS=$CFLAGS | ||
| 13 | for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do | ||
| 14 | AS_CASE([$gl_working], | ||
| 15 | [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"]) | ||
| 16 | |||
| 17 | AC_COMPILE_IFELSE( | ||
| 18 | [AC_LANG_PROGRAM( | ||
| 19 | [[#if defined __clang__ && __STDC_VERSION__ < 202311 | ||
| 20 | #pragma clang diagnostic error "-Wc2x-extensions" | ||
| 21 | #pragma clang diagnostic error "-Wc++17-extensions" | ||
| 22 | #endif | ||
| 23 | #ifdef INCLUDE_ASSERT_H | ||
| 24 | #include <assert.h> | ||
| 25 | #endif | ||
| 26 | static_assert (2 + 2 == 4, "arithmetic does not work"); | ||
| 27 | static_assert (2 + 2 == 4); | ||
| 28 | ]], | ||
| 29 | [[ | ||
| 30 | static_assert (sizeof (char) == 1, "sizeof does not work"); | ||
| 31 | static_assert (sizeof (char) == 1); | ||
| 32 | ]])], | ||
| 33 | [gl_cv_static_assert=$gl_working], | ||
| 34 | [gl_cv_static_assert=no]) | ||
| 35 | CFLAGS=$gl_save_CFLAGS | ||
| 36 | test "$gl_cv_static_assert" != no && break | ||
| 37 | done]) | ||
| 38 | |||
| 39 | GL_GENERATE_ASSERT_H=false | ||
| 40 | AS_CASE([$gl_cv_static_assert], | ||
| 41 | [yes*keyword*], | ||
| 42 | [AC_DEFINE([HAVE_C_STATIC_ASSERT], [1], | ||
| 43 | [Define to 1 if the static_assert keyword works.])], | ||
| 44 | [no], | ||
| 45 | [GL_GENERATE_ASSERT_H=true | ||
| 46 | gl_NEXT_HEADERS([assert.h])]) | ||
| 47 | |||
| 48 | dnl The "zz" puts this toward config.h's end, to avoid potential | ||
| 49 | dnl collisions with other definitions. #undef assert so that | ||
| 50 | dnl programs are not tempted to use it without specifically | ||
| 51 | dnl including assert.h. Break the #undef apart with a comment | ||
| 52 | dnl so that 'configure' does not comment it out. | ||
| 53 | AH_VERBATIM([zzstatic_assert], | ||
| 54 | [#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ | ||
| 55 | && (!defined __cplusplus \ | ||
| 56 | || (__cpp_static_assert < 201411 \ | ||
| 57 | && __GNUG__ < 6 && __clang_major__ < 6))) | ||
| 58 | #include <assert.h> | ||
| 59 | #undef/**/assert | ||
| 60 | /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments. | ||
| 61 | We need it also to be invocable with a single argument. */ | ||
| 62 | #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus | ||
| 63 | #undef/**/static_assert | ||
| 64 | #define static_assert _Static_assert | ||
| 65 | #endif | ||
| 66 | #endif]) | ||
| 67 | ]) | ||
