1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # 1. Redistributions of source code must retain the above copyright notice, this
8 # list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 # Check the availability of the POSIX AIO API, and of the aio_init(3) extension
28 # provided by glibc. See for the latter:
30 # http://www.gnu.org/software/libc/manual/html_node/Configuration-of-AIO.html
32 # If the POSIX AIO API is available, we set $nsca_lib_posix_aio to "yes" and
33 # define HAVE_POSIX_AIO to 1. We also set the output variable AIOLIBS. Apart
34 # from that, we define symbols which describe the aio_init(3) extension, if
37 # We check whether POSIX AIO programs can actually be executed because at least
38 # on AIX 5.3, POSIX AIO is not enabled by default even though the header
39 # declarations and library functions are available. When cross-compiling, we
40 # assume that POSIX AIO isn't available on the target system. AC_CACHE_CHECK
41 # allows the user to override this assumption.
42 AC_DEFUN([NSCA_LIB_AIO],
44 AC_CHECK_FUNC([aio_return],
45 [nsca_lib_posix_aio=yes],
46 [AC_CHECK_LIB([rt], [aio_return],
48 nsca_lib_posix_aio=yes],
49 [AC_CHECK_LIB([pthread], [aio_return],
50 [AIOLIBS='-lrt -lpthread'
51 nsca_lib_posix_aio=yes],
52 [nsca_lib_posix_aio=no],
54 AS_IF([test "x$nsca_lib_posix_aio" = xyes],
55 [AC_CACHE_CHECK([whether POSIX AIO works],
56 [nsca_cv_lib_aio_enabled],
61 [[#include <sys/types.h>
68 static void signal_handler(int sig, siginfo_t *info, void *ctx) {
69 if (sig != SIGUSR1 || info->si_code != SI_ASYNCIO || ctx == NULL)
72 (void)close(info->si_value.sival_int);
76 [[struct sigaction action;
78 char msg[] = "Hello, world!\n";
80 action.sa_sigaction = signal_handler;
81 action.sa_flags = SA_SIGINFO;
82 (void)sigemptyset(&action.sa_mask);
83 (void)sigaction(SIGUSR1, &action, NULL);
84 if ((fd = open("/dev/null", O_WRONLY)) == -1)
86 (void)memset(&cb, 0, sizeof(cb));
88 cb.aio_nbytes = sizeof(msg);
91 cb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
92 cb.aio_sigevent.sigev_signo = SIGUSR1;
93 cb.aio_sigevent.sigev_value.sival_int = fd;
98 [nsca_cv_lib_aio_enabled=yes],
99 [nsca_cv_lib_aio_enabled=no],
100 [nsca_cv_lib_aio_enabled=no])
101 LIBS=$nsca_save_LIBS])])
102 AS_IF([test "x$nsca_cv_lib_aio_enabled" = xyes],
103 [AC_DEFINE([HAVE_POSIX_AIO], [1],
104 [Define to 1 if you have the POSIX AIO API.])
107 AC_CHECK_FUNCS([aio_init],
108 [AC_CHECK_MEMBERS([struct aioinit.aio_threads,
109 struct aioinit.aio_num,
110 struct aioinit.aio_locks,
111 struct aioinit.aio_usedba,
112 struct aioinit.aio_debug,
113 struct aioinit.aio_numusers,
114 struct aioinit.aio_idle_time], [], [],
115 [[#include <aio.h>]])])
116 LIBS=$nsca_save_LIBS],
117 [nsca_lib_posix_aio=no])
121 dnl vim:set joinspaces textwidth=80: