aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2014-03-05 09:37:01 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2014-03-05 09:37:01 +0000
commite645f9b1863414d34474131bd64d5c9d97145851 (patch)
treea0b59006af165ec5020f515e13c7d2a8fb7a0f34 /m4
parent30943d715aa02271e274aa622cf4587c060e139f (diff)
downloadlibmicrohttpd-e645f9b1863414d34474131bd64d5c9d97145851.tar.gz
libmicrohttpd-e645f9b1863414d34474131bd64d5c9d97145851.zip
configure.ac: properly check for epoll support by macro from autoconf archive
Diffstat (limited to 'm4')
-rw-r--r--m4/ax_have_epoll.m4104
1 files changed, 104 insertions, 0 deletions
diff --git a/m4/ax_have_epoll.m4 b/m4/ax_have_epoll.m4
new file mode 100644
index 00000000..07ceb49f
--- /dev/null
+++ b/m4/ax_have_epoll.m4
@@ -0,0 +1,104 @@
1# ===========================================================================
2# http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7# AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
8# AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
9#
10# DESCRIPTION
11#
12# This macro determines whether the system supports the epoll I/O event
13# interface. A neat usage example would be:
14#
15# AX_HAVE_EPOLL(
16# [AX_CONFIG_FEATURE_ENABLE(epoll)],
17# [AX_CONFIG_FEATURE_DISABLE(epoll)])
18# AX_CONFIG_FEATURE(
19# [epoll], [This platform supports epoll(7)],
20# [HAVE_EPOLL], [This platform supports epoll(7).])
21#
22# The epoll interface was added to the Linux kernel in version 2.5.45, and
23# the macro verifies that a kernel newer than this is installed. This
24# check is somewhat unreliable if <linux/version.h> doesn't match the
25# running kernel, but it is necessary regardless, because glibc comes with
26# stubs for the epoll_create(), epoll_wait(), etc. that allow programs to
27# compile and link even if the kernel is too old; the problem would then
28# be detected only at runtime.
29#
30# Linux kernel version 2.6.19 adds the epoll_pwait() call in addition to
31# epoll_wait(). The availability of that function can be tested with the
32# second macro. Generally speaking, it is safe to assume that
33# AX_HAVE_EPOLL would succeed if AX_HAVE_EPOLL_PWAIT has, but not the
34# other way round.
35#
36# LICENSE
37#
38# Copyright (c) 2008 Peter Simons <simons@cryp.to>
39#
40# Copying and distribution of this file, with or without modification, are
41# permitted in any medium without royalty provided the copyright notice
42# and this notice are preserved. This file is offered as-is, without any
43# warranty.
44
45#serial 10
46
47AC_DEFUN([AX_HAVE_EPOLL], [dnl
48 ax_have_epoll_cppflags="${CPPFLAGS}"
49 AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
50 AC_MSG_CHECKING([for Linux epoll(7) interface])
51 AC_CACHE_VAL([ax_cv_have_epoll], [dnl
52 AC_LINK_IFELSE([dnl
53 AC_LANG_PROGRAM([dnl
54#include <sys/epoll.h>
55#ifdef HAVE_LINUX_VERSION_H
56# include <linux/version.h>
57# if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
58# error linux kernel version is too old to have epoll
59# endif
60#endif
61], [dnl
62int fd, rc;
63struct epoll_event ev;
64fd = epoll_create(128);
65rc = epoll_wait(fd, &ev, 1, 0);])],
66 [ax_cv_have_epoll=yes],
67 [ax_cv_have_epoll=no])])
68 CPPFLAGS="${ax_have_epoll_cppflags}"
69 AS_IF([test "${ax_cv_have_epoll}" = "yes"],
70 [AC_MSG_RESULT([yes])
71$1],[AC_MSG_RESULT([no])
72$2])
73])dnl
74
75AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
76 ax_have_epoll_cppflags="${CPPFLAGS}"
77 AC_CHECK_HEADER([linux/version.h],
78 [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
79 AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
80 AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
81 AC_LINK_IFELSE([dnl
82 AC_LANG_PROGRAM([dnl
83#ifdef HAVE_LINUX_VERSION_H
84# include <linux/version.h>
85# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
86# error linux kernel version is too old to have epoll_pwait
87# endif
88#endif
89#include <sys/epoll.h>
90#include <signal.h>
91], [dnl
92int fd, rc;
93struct epoll_event ev;
94fd = epoll_create(128);
95rc = epoll_wait(fd, &ev, 1, 0);
96rc = epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
97 [ax_cv_have_epoll_pwait=yes],
98 [ax_cv_have_epoll_pwait=no])])
99 CPPFLAGS="${ax_have_epoll_cppflags}"
100 AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
101 [AC_MSG_RESULT([yes])
102$1],[AC_MSG_RESULT([no])
103$2])
104])dnl