I'm encountering the following error when trying to compile SVN 1974 on the 
latest macOS release:

g++ -DHAVE_CONFIG_H -I. -I../..     -I ./.. -g -O2  -O2 -Wno-narrowing 
-I/opt/local/include -std=gnu++17 -I /Users/paulrockwell/Documents/apl/trunk 
-MT APserver-Svar_DB_server.o -MD -MP -MF .deps/APserver-Svar_DB_server.Tpo -c 
-o APserver-Svar_DB_server.o `test -f 'Svar_DB_server.cc' || echo 
'./'`Svar_DB_server.cc
APserver.cc:1159:60: error: use of undeclared identifier 'POLLRDHUP'
 1159 |                    fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
      |                                                            ^
APserver.cc:1167:60: error: use of undeclared identifier 'POLLRDHUP'
 1167 |                    fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
      |                                                            ^
2 errors generated.
make[3]: *** [APserver-APserver.o] Error 1

POLLRDHUP is not available on macOS (it appears to be a Linux-ism). 

Things appeared to work in prior SVNs. I found a change starting in SVN 1973 
that looks to be the cause of this failure.

paulrockwell@Upstairs trunk % svn diff -r 1972 src/APs/APserver.cc
Index: src/APs/APserver.cc
===================================================================
--- src/APs/APserver.cc (revision 1972)
+++ src/APs/APserver.cc (working copy)
@@ -2,7 +2,7 @@
     This file is part of GNU APL, a free implementation of the
     ISO/IEC Standard 13751, "Programming Language APL, Extended"
 
-    Copyright (C) 2008-2014  Dr. Jürgen Sauermann
+    Copyright (C) 2008-2026  Dr. Jürgen Sauermann
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -741,6 +741,10 @@
              }
              return;
 
+        case sid_DISCONNECT:     // APL closes the connection
+             close_fd(fd);
+             return;
+
         case sid_ASSIGN_VALUE:     // Svar←X for APs
              {
                const SV_key key = request->get__ASSIGN_VALUE__key();
@@ -1142,25 +1146,25 @@
 
 #ifdef USE_POLL // use poll()
 
-        pollfd fds[2*connected_procs.size() + 1];
+        pollfd fds[2*connected_procs.size() + 1];   // more than needed
         fds[0].fd = listen_sock;
         fds[0].events = POLLIN | POLLPRI;
         int fd_idx = 1;
         for (size_t j = 0; j < connected_procs.size(); ++j)
             {
-              TCP_socket fd = connected_procs[j].fd;
+              const TCP_socket fd = connected_procs[j].fd;
               if (fd != NO_TCP_SOCKET)
                  {
                    fds[fd_idx].fd = fd;
-                   fds[fd_idx].events = POLLIN | POLLPRI;
+                   fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
                    ++fd_idx;
                  }
 
-              fd = connected_procs[j].fd2;
-              if (fd != NO_TCP_SOCKET)
+              const TCP_socket fd2 = connected_procs[j].fd2;
+              if (fd2 != NO_TCP_SOCKET)
                  {
-                   fds[fd_idx].fd = fd;
-                   fds[fd_idx].events = POLLIN | POLLPRI;
+                   fds[fd_idx].fd = fd2;
+                   fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
                    ++fd_idx;
                  }
             }
@@ -1180,7 +1184,9 @@
          for (int i = 0; i < fd_idx; ++i)
              {
                if (fds[i].revents & (POLLIN | POLLPRI | POLLERR | POLLHUP))
-                  FD_SET(fds[i].fd, &read_fds);
+                  {
+                    FD_SET(fds[i].fd, &read_fds);
+                  }
              }
 
 #else // use select()

Conditionalizing on the existence of POLLRDHUP like is done in src/Quad_GTK3.cc 
(essentially reverting the change made in SVN 1973 for systems that don't have 
POLLRDHUP) seems to allow compilation to succeed. I don't know for sure what 
impact this will have on functionality, though, since I don't typically start 
the AP services.

paulrockwell@Upstairs trunk % svn diff src/APs/APserver.cc        
Index: src/APs/APserver.cc
===================================================================
--- src/APs/APserver.cc (revision 1974)
+++ src/APs/APserver.cc (working copy)
@@ -1156,7 +1156,11 @@
               if (fd != NO_TCP_SOCKET)
                  {
                    fds[fd_idx].fd = fd;
+#ifdef POLLRDHUP
                    fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
+#else
+                   fds[fd_idx].events = POLLIN | POLLPRI;
+#endif
                    ++fd_idx;
                  }
 
@@ -1164,10 +1168,14 @@
               if (fd2 != NO_TCP_SOCKET)
                  {
                    fds[fd_idx].fd = fd2;
+#ifdef POLLRDHUP
                    fds[fd_idx].events = POLLIN | POLLPRI | POLLRDHUP;
+#else
+                   fds[fd_idx].events = POLLIN | POLLPRI;
+#endif
                    ++fd_idx;
                  }
-            }
+            } 
 
          int ret = poll(fds, fd_idx, -1);
          if (ret <= 0)

             }

- Paul Rockwell

  • SVN 1974 compl... Paul Rockwell
    • Re: SVN 1... Dr . Jürgen Sauermann via Bugs and suggestions for GNU APL

Reply via email to