From 505499588b17ed5397688ed10ea52c92318a8a59 Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Sat, 17 Nov 2007 06:33:07 +0000
Subject: [PATCH] Update the configure script check for sys/poll.h to also
 provide the result in include/asterisk/autoconfig.h.  Also, move the
 conditional include of sys/poll.h or asterisk/poll-compat.h into
 asterisk/config.h instead of the two headers it existed in before.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89361 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 configure                        | 19 ++++++++++++++-----
 configure.ac                     |  5 ++++-
 include/asterisk/autoconfig.h.in |  3 +++
 include/asterisk/channel.h       |  2 +-
 include/asterisk/compat.h        |  6 ++++++
 include/asterisk/io.h            |  2 +-
 6 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 863b79bd5d..a38e6d629b 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 89354 .
+# From configure.ac Revision: 89357 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61.
 #
@@ -12403,11 +12403,13 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <stdio.h>
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
 int
 main ()
 {
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
   ;
   return 0;
 }
@@ -12447,11 +12449,13 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <stdio.h>
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
 int
 main ()
 {
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
   ;
   return 0;
 }
@@ -15503,6 +15507,11 @@ echo "${ECHO_T}$ac_cv_header_sys_poll_h" >&6; }
 fi
 if test $ac_cv_header_sys_poll_h = yes; then
   HAS_POLL=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYS_POLL_H 1
+_ACEOF
+
 fi
 
 
diff --git a/configure.ac b/configure.ac
index 3a56fbecc5..aa8966802b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -288,7 +288,10 @@ AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent ftruncate getcwd gethostbyna
 
 AC_CHECK_FUNCS([glob])
 AC_CHECK_FUNCS([timersub])
-AC_CHECK_HEADER([sys/poll.h], [HAS_POLL=1],)
+AC_CHECK_HEADER([sys/poll.h], 
+   [HAS_POLL=1]
+   AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]),
+   )
 AC_SUBST(HAS_POLL)
 
 # https support (in main/http.c) uses funopen on BSD systems,
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index b3b5001906..d07749d0b1 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -840,6 +840,9 @@
 /* Define to 1 if you have the <sys/param.h> header file. */
 #undef HAVE_SYS_PARAM_H
 
+/* Define to 1 if your system has working sys/poll.h */
+#undef HAVE_SYS_POLL_H
+
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 4e61668c54..8a7f2f83f5 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -125,7 +125,7 @@ References:
 
 #include "asterisk/abstract_jb.h"
 
-#ifdef HAVE_POLL 
+#ifdef HAVE_SYS_POLL_H
 #include <sys/poll.h>
 #else
 #include "asterisk/poll-compat.h"
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
index f70dcea163..819ac46759 100644
--- a/include/asterisk/compat.h
+++ b/include/asterisk/compat.h
@@ -56,6 +56,12 @@
 #include <string.h>
 #endif
 
+#ifdef HAVE_SYS_POLL_H
+#include <sys/poll.h>
+#else
+#include "asterisk/poll-compat.h"
+#endif
+
 #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
 int asprintf(char **str, const char *fmt, ...);
 #endif
diff --git a/include/asterisk/io.h b/include/asterisk/io.h
index 247d0de72a..6f227dc2c7 100644
--- a/include/asterisk/io.h
+++ b/include/asterisk/io.h
@@ -23,7 +23,7 @@
 #ifndef _ASTERISK_IO_H
 #define _ASTERISK_IO_H
 
-#ifdef HAVE_POLL
+#ifdef HAVE_SYS_POLL_H
 #include <sys/poll.h>		/* For POLL* constants */
 #else
 #include "asterisk/poll-compat.h"
-- 
GitLab