EDuke32

  • Status Unconfirmed
  • Percent Complete
    0%
  • Task Type Bug Report
  • Category Backend / Core
  • Assigned To No-one
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version Development
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: EDuke32
Opened by Ph. Engel - 2019-11-01

FS#91 - Adding FreeBSD support

Please consider adding support for FreeBSD by updating “source/build/include/zpl.h” to the latest ZPL version (GitHub commit 26753e04e9ed08dff55a5998a085ca2996d1775f) and applying the following patch. EDuke32 then compiles on FreeBSD as well with:

$ gmake -f GNUmakefile L=/usr/local/lib/ I=/usr/local/include/ BUILD32_ON_64=1 CLANG=1
--- zpl.h	2019-11-01 05:35:57.095504000 +0100
+++ zpl_new.h	2019-11-01 05:50:39.201436000 +0100
@@ -520,10 +520,16 @@
 #include <stdlib.h> // NOTE: malloc on linux
 #include <sys/mman.h>
 
-#if !defined(ZPL_SYSTEM_OSX)
+#if !defined(ZPL_SYSTEM_OSX) && !defined(ZPL_SYSTEM_FREEBSD)
     #include <sys/sendfile.h>
 #endif
 
+#if defined(ZPL_SYSTEM_FREEBSD)
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <sys/uio.h>
+#endif
+
 #include <dirent.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -767,6 +773,11 @@
     #endif
 #endif
 
+#if defined(ZPL_SYSTEM_FREEBSD)
+    #define ZPL_EXTERN extern
+    #define zpl_inline inline
+#endif
+
 #if !defined(zpl_no_inline)
     #if defined(_MSC_VER)
         #define zpl_no_inline __declspec(noinline)
@@ -1557,7 +1568,7 @@
     zpl_isize threads_per_core;
 } zpl_affinity;
 
-#elif defined(ZPL_SYSTEM_LINUX) || defined(ZPL_SYSTEM_EMSCRIPTEN)
+#elif defined(ZPL_SYSTEM_LINUX) || defined(ZPL_SYSTEM_FREEBSD) || defined(ZPL_SYSTEM_EMSCRIPTEN)
 
 typedef struct zpl_affinity {
     zpl_b32   is_accurate;
@@ -6967,7 +6978,7 @@
 
 #else
 
-#if defined(ZPL_SYSTEM_LINUX)
+#if defined(ZPL_SYSTEM_LINUX) || defined(ZPL_SYSTEM_FREEBSD)
 zpl_inline zpl_f64 zpl__unix_getime(void) {
     struct timespec t;
     zpl_f64 result;
@@ -8152,7 +8163,7 @@
     return a->threads_per_core;
 }
 
-#elif defined(ZPL_SYSTEM_LINUX)
+#elif defined(ZPL_SYSTEM_LINUX) || defined(ZPL_SYSTEM_FREEBSD)
 // IMPORTANT TODO: This zpl_affinity stuff for linux needs be improved a lot!
 // NOTE(zangent): I have to read /proc/cpuinfo to get the number of threads per core.
 
@@ -10816,7 +10827,11 @@
     struct stat stat_existing;
     fstat(existing_fd, &stat_existing);
 
+#if defined(ZPL_SYSTEM_FREEBSD)
+    size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size, NULL, 0, 0);
+#else
     size = sendfile(new_fd, existing_fd, 0, stat_existing.st_size);
+#endif
 
     close(new_fd);
     close(existing_fd);
Admin
Evan Ramos commented on 2019-11-01 16:28

Please update your copy of the EDuke32 SVN, because I have already restored FreeBSD compatibility by removing almost all of ZPL. The library presents a host of portability issues and I have already identified several correctness issues in the few parts we do use, leading me to remove those as well.

Please submit this patch upstream to ZPL.

Ph. Engel commented on 2019-11-01 16:31

Thank you for your comment. Patch has been added to ZPL upstream.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing