Debian Codegraph @

m4/memset_explicit.m4

raw
1 # memset_explicit.m4
2 # serial 4
3 dnl Copyright 2022-2026 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_FUNC_MEMSET_EXPLICIT],
10 [
11 AC_REQUIRE([gl_STRING_H_DEFAULTS])
12 dnl Persuade OpenSolaris derivatives' <string.h> to declare memset_s().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15 gl_CHECK_FUNCS_ANDROID([memset_explicit], [[#include <string.h>]])
16 if test $ac_cv_func_memset_explicit = no; then
17 HAVE_MEMSET_EXPLICIT=0
18 case "$gl_cv_onwards_func_memset_explicit" in
19 future*) REPLACE_MEMSET_EXPLICIT=1 ;;
20 esac
21 fi
22 ])
23
24 AC_DEFUN([gl_PREREQ_MEMSET_EXPLICIT],
25 [
26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
27 AC_CHECK_FUNCS([explicit_memset])
28 AC_CHECK_FUNCS_ONCE([memset_s])
29 if test $ac_cv_func_memset_s = yes; then
30 AC_CACHE_CHECK([for working memset_s],
31 [gl_cv_func_memset_s_works],
32 [AC_RUN_IFELSE(
33 [AC_LANG_PROGRAM(
34 [[#include <string.h>
35 #include <stddef.h>
36 ]], [[
37 (void) memset_s (NULL, 0, '?', 0);
38 ]])
39 ],
40 [gl_cv_func_memset_s_works=yes],
41 [gl_cv_func_memset_s_works=no],
42 [case "$host_os" in
43 # Guess no on Solaris.
44 solaris*)
45 gl_cv_func_memset_s_works="guessing no" ;;
46 *)
47 gl_cv_func_memset_s_works="guessing yes" ;;
48 esac
49 ])
50 ])
51 case "$gl_cv_func_memset_s_works" in
52 *yes)
53 AC_DEFINE([HAVE_MEMSET_S_SUPPORTS_ZERO], [1],
54 [Define to 1 if memset_s support zero-length operations.])
55 ;;
56 esac
57 fi
58 ])