1dnl
2dnl Automated Testing Framework (atf)
3dnl
4dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
5dnl All rights reserved.
6dnl
7dnl Redistribution and use in source and binary forms, with or without
8dnl modification, are permitted provided that the following conditions
9dnl are met:
10dnl 1. Redistributions of source code must retain the above copyright
11dnl    notice, this list of conditions and the following disclaimer.
12dnl 2. Redistributions in binary form must reproduce the above copyright
13dnl    notice, this list of conditions and the following disclaimer in the
14dnl    documentation and/or other materials provided with the distribution.
15dnl
16dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28dnl
29
30AC_DEFUN([ATF_CHECK_IN_STD], [
31    AC_MSG_CHECKING(whether $1 is in std)
32    AC_COMPILE_IFELSE(
33        [AC_LANG_PROGRAM([$2], [$3 return 0;])],
34        AC_MSG_RESULT(yes)
35        AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_IN_STD], [1],
36                  [Define to 1 if $1 is in std]),
37        AC_MSG_RESULT(no)
38    )
39])
40
41AC_DEFUN([ATF_CHECK_STD_PUTENV], [
42    ATF_CHECK_IN_STD([putenv],
43                     [#include <cstdio>],
44                     [std::putenv("a=b");]
45                    )
46])
47
48AC_DEFUN([ATF_CHECK_STD_SETENV], [
49    ATF_CHECK_IN_STD([setenv],
50                     [#include <cstdio>],
51                     [std::setenv("a", "b");]
52                    )
53])
54
55AC_DEFUN([ATF_CHECK_STD_SNPRINTF], [
56    ATF_CHECK_IN_STD([snprintf],
57                     [#include <cstdio>],
58                     [char buf;
59                      std::snprintf(&buf, 1, "");]
60                    )
61])
62
63AC_DEFUN([ATF_CHECK_STD_UNSETENV], [
64    ATF_CHECK_IN_STD([unsetenv],
65                     [#include <cstdio>],
66                     [std::unsetenv("a");]
67                    )
68])
69
70AC_DEFUN([ATF_CHECK_STD_VSNPRINTF], [
71    ATF_CHECK_IN_STD([vsnprintf],
72                     [#include <cstdarg>
73                      #include <cstdio>],
74                     [va_list ap;
75                      char* buf = NULL;
76                      const char* fmt = NULL;
77                      std::vsnprintf(buf, 0, fmt, ap);]
78                    )
79])
80