Building APL with GCC 7/8 required some minor patching: src/Error.hh,
in set_error_line_X() methods, there are calls to strncpy(3), so it
needs #include <cstring> or #include <string.h>.

Also, had to change types of total_memory from unsigned to signed,
those values are compared to values of type rlim_t which is signed.
Such comparison causes error.  Since there types are 64-bit, it does
not make sense to make them unsigned, they are huge enough to hold any
reasonable values, be it positive or negative.

On FreeBSD, I've also needed to explicitly #include <sys/socket.h>
which on GNU/Linux is included implicitly via other headers.  And two
calls to ::bind() were missing global namespace specifier which broke
the builds with compilers that default to newish C++ standards.

./danfe
--- src/Common.hh.orig
+++ src/Common.hh
@@ -23,6 +23,7 @@
 
 #include "../config.h"   // for xxx_WANTED and other macros from ./configure
 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
 #include <sys/stat.h>
--- src/emacs_mode/TcpListener.cc.orig
+++ src/emacs_mode/TcpListener.cc
@@ -78,7 +78,7 @@ std::string TcpListener::start( void )
         DOMAIN_ERROR;        
     }
 
-    if( bind( server_socket, addr->ai_addr, addr->ai_addrlen ) == -1 ) {
+    if( ::bind( server_socket, addr->ai_addr, addr->ai_addrlen ) == -1 ) {
         stringstream errmsg;
         errmsg << "Unable to bind to port " << port << ": " << strerror( errno );
         close( server_socket );
--- src/emacs_mode/UnixSocketListener.cc.orig
+++ src/emacs_mode/UnixSocketListener.cc
@@ -58,7 +58,7 @@ std::string UnixSocketListener::start( void )
     struct sockaddr_un addr;
     addr.sun_family = AF_UNIX;
     strncpy( addr.sun_path, filename.c_str(), sizeof( addr.sun_path ) );
-    if( bind( server_socket, (struct sockaddr *)&addr, sizeof( addr ) ) == -1 ) {
+    if( ::bind( server_socket, (struct sockaddr *)&addr, sizeof( addr ) ) == -1 ) {
         stringstream errmsg;
         errmsg << "Error binding unix domain socket: " << strerror( errno ) << endl;
         close( server_socket );
--- src/Error.hh.orig
+++ src/Error.hh
@@ -25,6 +25,7 @@
 #include "Common.hh"
 #include "ErrorCode.hh"
 #include "UCS_string.hh"
+#include <cstring>
 
 #ifdef __GNUC__
     #define GNUC__noreturn __attribute__ ((noreturn))
--- src/Quad_WA.hh.orig
+++ src/Quad_WA.hh
@@ -38,7 +38,7 @@ class Quad_WA : public RO_SystemVariable (public)
    static void init(bool log_startup);
 
    /// the estimated (!) the amount of free memory
-   static uint64_t total_memory;
+   static int64_t total_memory;
 
    /// a safety margin causing WS FULL before complete memory starvation
    static int64_t WA_margin;
--- src/Quad_WA.cc.orig
+++ src/Quad_WA.cc
@@ -24,7 +24,7 @@
 extern uint64_t top_of_memory();
 
 rlim_t Quad_WA::initial_rlimit = RLIM_INFINITY;
-uint64_t Quad_WA::total_memory = 0x40000000;   // a little more than 1 Gig
+int64_t Quad_WA::total_memory = 0x40000000;   // a little more than 1 Gig
 int64_t  Quad_WA::WA_margin = 0;  // 100000000;
 int      Quad_WA::WA_scale = 90;   // percent
 unsigned long long Quad_WA::initial_sbrk = 0;
--- src/Value.cc.orig
+++ src/Value.cc
@@ -181,7 +181,7 @@ bool
 Value::check_WS_FULL(const char * args, ShapeItem requested_cell_count,
                      const char * loc)
 {
-const uint64_t used_memory
+const int64_t used_memory
                = (total_ravel_count + requested_cell_count) * sizeof(Cell)
                + (value_count + 1) * sizeof(Value)
                + Workspace::SI_entry_count() * sizeof(StateIndicator);
@@ -215,7 +215,7 @@ void
 Value::catch_exception(const exception & ex, const char * args,
                       const char * caller,  const char * loc)
 {
-const uint64_t used_memory
+const int64_t used_memory
                = total_ravel_count * sizeof(Cell)
                + value_count * sizeof(Value)
                + Workspace::SI_entry_count() * sizeof(StateIndicator);

Reply via email to