diff options
author | Jason Earl <jearl@notengoamigos.org> | 2013-03-10 23:40:13 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-03-10 23:40:13 +0100 |
commit | 428f9e95fccb7105f00d22e80312e9f5a7a263a4 (patch) | |
tree | 3c7ffd3951f5fd6f430c964f7e246f25724f27f3 /m4 | |
parent | ccd0ae1fbb1c8c942a89bf84272377b341739e0f (diff) |
import `poll' from gnulib
* lib/Makefile.am:
* lib/poll.c:
* lib/poll.in.h:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4:
* m4/poll.m4:
* m4/poll_h.m4: Add poll gnulib module.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | m4/gnulib-comp.m4 | 13 | ||||
-rw-r--r-- | m4/poll.m4 | 103 | ||||
-rw-r--r-- | m4/poll_h.m4 | 47 |
4 files changed, 165 insertions, 1 deletions
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 99ace9aed..02c8bcbea 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -27,7 +27,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil clock-time close connect dirfd duplocale environ extensions flock floor fpieee frexp fstat full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe-posix pipe2 putenv recv recvfrom regex rename select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat times trunc verify vsnprintf warnings wchar +# gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil clock-time close connect dirfd duplocale environ extensions flock floor fpieee frexp fstat full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe-posix pipe2 poll putenv recv recvfrom regex rename select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat times trunc verify vsnprintf warnings wchar # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gnulib-local]) @@ -88,6 +88,7 @@ gl_MODULES([ open pipe-posix pipe2 + poll putenv recv recvfrom diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 0d0aa7b79..55c003a58 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -149,6 +149,8 @@ AC_DEFUN([gl_EARLY], # Code from module pathmax: # Code from module pipe-posix: # Code from module pipe2: + # Code from module poll: + # Code from module poll-h: # Code from module putenv: # Code from module raise: # Code from module read: @@ -559,6 +561,13 @@ AC_SUBST([LTALLOCA]) gl_UNISTD_MODULE_INDICATOR([pipe]) gl_FUNC_PIPE2 gl_UNISTD_MODULE_INDICATOR([pipe2]) + gl_FUNC_POLL + if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then + AC_LIBOBJ([poll]) + gl_PREREQ_POLL + fi + gl_POLL_MODULE_INDICATOR([poll]) + gl_POLL_H gl_FUNC_PUTENV if test $REPLACE_PUTENV = 1; then AC_LIBOBJ([putenv]) @@ -1009,6 +1018,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/pathmax.h lib/pipe.c lib/pipe2.c + lib/poll.c + lib/poll.in.h lib/printf-args.c lib/printf-args.h lib/printf-parse.c @@ -1200,6 +1211,8 @@ AC_DEFUN([gl_FILE_LIST], [ m4/pathmax.m4 m4/pipe.m4 m4/pipe2.m4 + m4/poll.m4 + m4/poll_h.m4 m4/printf.m4 m4/putenv.m4 m4/raise.m4 diff --git a/m4/poll.m4 b/m4/poll.m4 new file mode 100644 index 000000000..f0f0b80e2 --- /dev/null +++ b/m4/poll.m4 @@ -0,0 +1,103 @@ +# poll.m4 serial 17 +dnl Copyright (c) 2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_POLL], +[ + AC_REQUIRE([gl_POLL_H]) + AC_REQUIRE([gl_SOCKETS]) + if test $ac_cv_header_poll_h = no; then + ac_cv_func_poll=no + gl_cv_func_poll=no + else + AC_CHECK_FUNC([poll], + [# Check whether poll() works on special files (like /dev/null) and + # and ttys (like /dev/tty). On Mac OS X 10.4.0 and AIX 5.3, it doesn't. + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include <fcntl.h> +#include <poll.h> + int main() + { + int result = 0; + struct pollfd ufd; + /* Try /dev/null for reading. */ + ufd.fd = open ("/dev/null", O_RDONLY); + /* If /dev/null does not exist, it's not Mac OS X nor AIX. */ + if (ufd.fd >= 0) + { + ufd.events = POLLIN; + ufd.revents = 0; + if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLIN)) + result |= 1; + } + /* Try /dev/null for writing. */ + ufd.fd = open ("/dev/null", O_WRONLY); + /* If /dev/null does not exist, it's not Mac OS X nor AIX. */ + if (ufd.fd >= 0) + { + ufd.events = POLLOUT; + ufd.revents = 0; + if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLOUT)) + result |= 2; + } + /* Trying /dev/tty may be too environment dependent. */ + return result; + }]])], + [gl_cv_func_poll=yes], + [gl_cv_func_poll=no], + [# When cross-compiling, assume that poll() works everywhere except on + # Mac OS X or AIX, regardless of its version. + AC_EGREP_CPP([MacOSX], [ +#if (defined(__APPLE__) && defined(__MACH__)) || defined(_AIX) +This is MacOSX or AIX +#endif +], [gl_cv_func_poll=no], [gl_cv_func_poll=yes])])]) + fi + if test $gl_cv_func_poll != yes; then + AC_CHECK_FUNC([poll], [ac_cv_func_poll=yes], [ac_cv_func_poll=no]) + if test $ac_cv_func_poll = no; then + HAVE_POLL=0 + else + REPLACE_POLL=1 + fi + fi + if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then + : + else + AC_DEFINE([HAVE_POLL], [1], + [Define to 1 if you have the 'poll' function and it works.]) + fi + + dnl Determine the needed libraries. + LIB_POLL="$LIBSOCKET" + if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then + case "$host_os" in + mingw*) + dnl On the MSVC platform, the function MsgWaitForMultipleObjects + dnl (used in lib/poll.c) requires linking with -luser32. On mingw, + dnl it is implicit. + AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +int +main () +{ + MsgWaitForMultipleObjects (0, NULL, 0, 0, 0); + return 0; +}]])], + [], + [LIB_POLL="$LIB_POLL -luser32"]) + ;; + esac + fi + AC_SUBST([LIB_POLL]) +]) + +# Prerequisites of lib/poll.c. +AC_DEFUN([gl_PREREQ_POLL], +[ + AC_CHECK_HEADERS_ONCE([sys/ioctl.h sys/filio.h]) +]) diff --git a/m4/poll_h.m4 b/m4/poll_h.m4 new file mode 100644 index 000000000..49306746c --- /dev/null +++ b/m4/poll_h.m4 @@ -0,0 +1,47 @@ +# poll_h.m4 serial 2 +dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Bruno Haible. + +AC_DEFUN([gl_POLL_H], +[ + dnl Use AC_REQUIRE here, so that the default behavior below is expanded + dnl once only, before all statements that occur in other macros. + AC_REQUIRE([gl_POLL_H_DEFAULTS]) + + AC_CHECK_HEADERS_ONCE([poll.h]) + if test $ac_cv_header_poll_h = yes; then + HAVE_POLL_H=1 + else + HAVE_POLL_H=0 + fi + AC_SUBST([HAVE_POLL_H]) + + dnl <poll.h> is always overridden, because of GNULIB_POSIXCHECK. + gl_CHECK_NEXT_HEADERS([poll.h]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <poll.h>]], + [poll]) +]) + +AC_DEFUN([gl_POLL_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_POLL_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_POLL_H_DEFAULTS], +[ + GNULIB_POLL=0; AC_SUBST([GNULIB_POLL]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_POLL=1; AC_SUBST([HAVE_POLL]) + REPLACE_POLL=0; AC_SUBST([REPLACE_POLL]) +]) |