chiggsy wrote:

Hello all,
    I am having a problem building apr on darwin.

I am using :
darwin 7.0.0
gcc 3.3
 and here is the error i get :

poll.c: In function `apr_poll':
poll.c:126: error: storage size of `pollset' isn't known

problem was caused by finding poll() but no header file with definitions necessary for poll


attached is one possible patch to play with that causes apr to refuse to use poll unless we have the required definitions

it would be better to make sure we have the appropriate definitions first, and only then check for poll()... that way HAVE_POLL is set properly

so this patch is just to incite someone to reaffirm that they have enough pride (not to mention time) to do it the right way :)

Index: acconfig.h
===================================================================
RCS file: /home/cvs/apr/acconfig.h,v
retrieving revision 1.64
diff -u -r1.64 acconfig.h
--- acconfig.h  16 Feb 2003 21:59:09 -0000      1.64
+++ acconfig.h  29 Sep 2003 12:35:01 -0000
@@ -24,6 +24,8 @@
 
 #undef HAVE_INT64_C
 
+#undef USE_POLL
+
 @BOTTOM@
 
 /* Make sure we have ssize_t defined to be something */
Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.535
diff -u -r1.535 configure.in
--- configure.in        2 Sep 2003 08:42:54 -0000       1.535
+++ configure.in        29 Sep 2003 12:35:03 -0000
@@ -1448,6 +1448,20 @@
 # any POLL definitions.
 APR_CHECK_DEFINE_FILES(POLLIN, poll.h sys/poll.h)
 
+# Can we really use poll()?  We must have the function as
+# well as POLLIN defined in the system headers.  Otherwise,
+# we'll implement APR poll functions using select().
+if test "$ac_cv_func_poll" = "yes"; then
+  APR_IFALLYES(define:POLLIN func:poll, hasusablepoll="1", hasusablepoll="0")
+  AC_MSG_CHECKING(if poll function can be used)
+  if test "$hasusablepoll" = "1"; then
+    AC_MSG_RESULT(yes)
+    AC_DEFINE(USE_POLL)
+  else
+    AC_MSG_RESULT(no)
+  fi
+fi
+
 if test "$threads" = "1"; then
     APR_CHECK_DEFINE(PTHREAD_PROCESS_SHARED, pthread.h)
     AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
Index: include/arch/unix/apr_arch_networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/apr_arch_networkio.h,v
retrieving revision 1.2
diff -u -r1.2 apr_arch_networkio.h
--- include/arch/unix/apr_arch_networkio.h      8 Jul 2003 12:53:10 -0000       
1.2
+++ include/arch/unix/apr_arch_networkio.h      29 Sep 2003 12:35:03 -0000
@@ -137,7 +137,7 @@
     apr_sockaddr_t *local_addr;
     apr_sockaddr_t *remote_addr;
     apr_interval_time_t timeout; 
-#ifndef HAVE_POLL
+#ifndef USE_POLL
     int connected;
 #endif
     int local_port_unknown;
Index: network_io/unix/sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
retrieving revision 1.111
diff -u -r1.111 sockets.c
--- network_io/unix/sockets.c   3 Sep 2003 14:43:52 -0000       1.111
+++ network_io/unix/sockets.c   29 Sep 2003 12:35:03 -0000
@@ -188,7 +188,7 @@
     alloc_socket(new, connection_context);
     set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, 
sock->protocol);
 
-#ifndef HAVE_POLL
+#ifndef USE_POLL
     (*new)->connected = 1;
 #endif
     (*new)->timeout = -1;
@@ -305,7 +305,7 @@
          */
         sock->local_interface_unknown = 1;
     }
-#ifndef HAVE_POLL
+#ifndef USE_POLL
     sock->connected=1;
 #endif
     return APR_SUCCESS;
@@ -374,7 +374,7 @@
         (*apr_sock)->local_port_unknown = (*apr_sock)->local_interface_unknown 
= 1;
     }
     if (os_sock_info->remote) {
-#ifndef HAVE_POLL
+#ifndef USE_POLL
         (*apr_sock)->connected = 1;
 #endif
         memcpy(&(*apr_sock)->remote_addr->sa.sin, 
Index: poll/unix/poll.c
===================================================================
RCS file: /home/cvs/apr/poll/unix/poll.c,v
retrieving revision 1.38
diff -u -r1.38 poll.c
--- poll/unix/poll.c    7 Jan 2003 00:52:56 -0000       1.38
+++ poll/unix/poll.c    29 Sep 2003 12:35:04 -0000
@@ -73,7 +73,7 @@
 #define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0
 #endif
 
-#ifdef HAVE_POLL    /* We can just use poll to do our socket polling. */
+#ifdef USE_POLL    /* We can just use poll to do our socket polling. */
 
 static apr_int16_t get_event(apr_int16_t event)
 {
@@ -321,7 +321,7 @@
 struct apr_pollset_t {
     apr_uint32_t nelts;
     apr_uint32_t nalloc;
-#ifdef HAVE_POLL
+#ifdef USE_POLL
     struct pollfd *pollset;
 #else
     fd_set readset, writeset, exceptset;
@@ -340,7 +340,7 @@
                                              apr_pool_t *p,
                                              apr_uint32_t flags)
 {
-#if !defined(HAVE_POLL) && defined(FD_SETSIZE)
+#if !defined(USE_POLL) && defined(FD_SETSIZE)
     if (size > FD_SETSIZE) {
         *pollset = NULL;
         return APR_EINVAL;
@@ -349,7 +349,7 @@
     *pollset = apr_palloc(p, sizeof(**pollset));
     (*pollset)->nelts = 0;
     (*pollset)->nalloc = size;
-#ifdef HAVE_POLL
+#ifdef USE_POLL
     (*pollset)->pollset = apr_palloc(p, size * sizeof(struct pollfd));
 #else
     FD_ZERO(&((*pollset)->readset));
@@ -377,7 +377,7 @@
 APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
                                           const apr_pollfd_t *descriptor)
 {
-#ifndef HAVE_POLL
+#ifndef USE_POLL
     apr_os_sock_t fd;
 #endif
 
@@ -386,7 +386,7 @@
     }
 
     pollset->query_set[pollset->nelts] = *descriptor;
-#ifdef HAVE_POLL
+#ifdef USE_POLL
 
     if (descriptor->desc_type == APR_POLL_SOCKET) {
         pollset->pollset[pollset->nelts].fd = descriptor->desc.s->socketdes;
@@ -449,11 +449,11 @@
                                              const apr_pollfd_t *descriptor)
 {
     apr_uint32_t i;
-#ifndef HAVE_POLL
+#ifndef USE_POLL
     apr_os_sock_t fd;
 #endif
 
-#ifdef HAVE_POLL
+#ifdef USE_POLL
     for (i = 0; i < pollset->nelts; i++) {
         if (descriptor->desc.s == pollset->query_set[i].desc.s) {
             /* Found an instance of the fd: remove this and any other copies */
@@ -515,7 +515,7 @@
     return APR_NOTFOUND;
 }
 
-#ifdef HAVE_POLL
+#ifdef USE_POLL
 APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
                                            apr_interval_time_t timeout,
                                            apr_int32_t *num,

Reply via email to