diff options
author | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 22:49:18 (GMT) |
---|---|---|
committer | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 22:49:18 (GMT) |
commit | a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch) | |
tree | 8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/fpurge.m4 | |
parent | ca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz |
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
Diffstat (limited to 'gl/m4/fpurge.m4')
-rw-r--r-- | gl/m4/fpurge.m4 | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4 new file mode 100644 index 0000000..b365409 --- /dev/null +++ b/gl/m4/fpurge.m4 | |||
@@ -0,0 +1,73 @@ | |||
1 | # fpurge.m4 serial 12 | ||
2 | dnl Copyright (C) 2007, 2009-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 | AC_DEFUN([gl_FUNC_FPURGE], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | ||
10 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
11 | AC_CHECK_HEADERS_ONCE([stdio_ext.h]) | ||
12 | AC_CHECK_FUNCS_ONCE([fpurge]) | ||
13 | AC_CHECK_FUNCS_ONCE([__fpurge]) | ||
14 | AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]]) | ||
15 | if test "x$ac_cv_func_fpurge" = xyes; then | ||
16 | HAVE_FPURGE=1 | ||
17 | # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune. | ||
18 | AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works], | ||
19 | [AC_RUN_IFELSE( | ||
20 | [AC_LANG_PROGRAM( | ||
21 | [[#include <stdio.h> | ||
22 | ]], | ||
23 | [[FILE *f = fopen ("conftest.txt", "w+"); | ||
24 | if (!f) | ||
25 | return 1; | ||
26 | if (fputc ('a', f) != 'a') | ||
27 | { fclose (f); return 2; } | ||
28 | rewind (f); | ||
29 | if (fgetc (f) != 'a') | ||
30 | { fclose (f); return 3; } | ||
31 | if (fgetc (f) != EOF) | ||
32 | { fclose (f); return 4; } | ||
33 | if (fpurge (f) != 0) | ||
34 | { fclose (f); return 5; } | ||
35 | if (putc ('b', f) != 'b') | ||
36 | { fclose (f); return 6; } | ||
37 | if (fclose (f) != 0) | ||
38 | return 7; | ||
39 | if ((f = fopen ("conftest.txt", "r")) == NULL) | ||
40 | return 8; | ||
41 | if (fgetc (f) != 'a') | ||
42 | { fclose (f); return 9; } | ||
43 | if (fgetc (f) != 'b') | ||
44 | { fclose (f); return 10; } | ||
45 | if (fgetc (f) != EOF) | ||
46 | { fclose (f); return 11; } | ||
47 | if (fclose (f) != 0) | ||
48 | return 12; | ||
49 | if (remove ("conftest.txt") != 0) | ||
50 | return 13; | ||
51 | return 0; | ||
52 | ]])], | ||
53 | [gl_cv_func_fpurge_works=yes], | ||
54 | [gl_cv_func_fpurge_works=no], | ||
55 | [case "$host_os" in | ||
56 | # Guess yes on musl systems. | ||
57 | *-musl*) gl_cv_func_fpurge_works="guessing yes" ;; | ||
58 | # Otherwise obey --enable-cross-guesses. | ||
59 | *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; | ||
60 | esac | ||
61 | ]) | ||
62 | ]) | ||
63 | case "$gl_cv_func_fpurge_works" in | ||
64 | *yes) ;; | ||
65 | *) REPLACE_FPURGE=1 ;; | ||
66 | esac | ||
67 | else | ||
68 | HAVE_FPURGE=0 | ||
69 | fi | ||
70 | if test "x$ac_cv_have_decl_fpurge" = xno; then | ||
71 | HAVE_DECL_FPURGE=0 | ||
72 | fi | ||
73 | ]) | ||