Add DragonFly BSD port

  • From: Robin Hahling <robin.hahling@xxxxxxxxxxxxxxxx>
  • Date: Sun, 5 Oct 2014 20:59:33 +0200

Thanks to Alex Hornung and Joris Giovannangeli from the
DragonFly BSD project for their help figuring this out.
---
 src/jit/bcsave.lua | 6 +++---
 src/lj_alloc.c     | 6 +++---
 src/lj_arch.h      | 3 ++-
 src/lj_gdbjit.c    | 2 ++
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua
index f55bda9..3cbf0fb 100644
--- a/src/jit/bcsave.lua
+++ b/src/jit/bcsave.lua
@@ -68,8 +68,8 @@ local map_arch = {
 }
 
 local map_os = {
-  linux = true, windows = true, osx = true, freebsd = true, netbsd = true,
-  openbsd = true, solaris = true,
+  linux = true, windows = true, osx = true, dragonfly = true, freebsd = true,
+  netbsd = true, openbsd = true, solaris = true,
 }
 
 local function checkarg(str, map, err)
@@ -231,7 +231,7 @@ typedef struct {
     check(hdr.emagic[0] == 127, "no support for writing native object files")
   else
     hdr.emagic = "\127ELF"
-    hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0
+    hdr.eosabi = ({ dragonfly=0, freebsd=9, netbsd=2, openbsd=12, solaris=6 
})[ctx.os] or 0
   end
   hdr.eclass = is64 and 2 or 1
   hdr.eendian = isbe and 2 or 1
diff --git a/src/lj_alloc.c b/src/lj_alloc.c
index facccee..fb6675e 100644
--- a/src/lj_alloc.c
+++ b/src/lj_alloc.c
@@ -194,14 +194,14 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
   return ptr;
 }
 
-#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || 
defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || 
defined(__sun__)
+#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__DragonFly__) || 
defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || 
defined(__OpenBSD__) || defined(__sun__)
 
 /* OSX and FreeBSD mmap() use a naive first-fit linear search.
 ** That's perfect for us. Except that -pagezero_size must be set for OSX,
 ** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
 ** to be reduced to 250MB on FreeBSD.
 */
-#if LJ_TARGET_OSX
+#if LJ_TARGET_OSX || defined(__DragonFly__)
 #define MMAP_REGION_START      ((uintptr_t)0x10000)
 #elif LJ_TARGET_PS4
 #define MMAP_REGION_START      ((uintptr_t)0x4000)
@@ -238,7 +238,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
       return p;
     }
     if (p != CMFAIL) munmap(p, size);
-#ifdef __sun__
+#ifdef __sun__ || defined(__DragonFly__)
     alloc_hint += 0x1000000;  /* Need near-exhaustive linear scan. */
     if (alloc_hint + size < MMAP_REGION_END) continue;
 #endif
diff --git a/src/lj_arch.h b/src/lj_arch.h
index f04da3b..7d9c103 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -67,7 +67,8 @@
 #elif defined(__MACH__) && defined(__APPLE__)
 #define LUAJIT_OS      LUAJIT_OS_OSX
 #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
-       defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__)
+       defined(__DragonFly__) || defined(__NetBSD__) || \
+       defined(__OpenBSD__)) && !defined(__ORBIS__)
 #define LUAJIT_OS      LUAJIT_OS_BSD
 #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
 #define LUAJIT_OS      LUAJIT_OS_POSIX
diff --git a/src/lj_gdbjit.c b/src/lj_gdbjit.c
index 5e7fca1..f882428 100644
--- a/src/lj_gdbjit.c
+++ b/src/lj_gdbjit.c
@@ -350,6 +350,8 @@ static const ELFheader elfhdr_template = {
   .eversion = 1,
 #if LJ_TARGET_LINUX
   .eosabi = 0,  /* Nope, it's not 3. */
+#elif defined(__DragonFly__)
+  .eosabi = 0,
 #elif defined(__FreeBSD__)
   .eosabi = 9,
 #elif defined(__NetBSD__)
-- 
2.1.0


--nextPart1533871.h3deQxmQDO--


Other related posts: