shithub: femtolisp

Download patch

ref: 19a835847c826572f6cff45852d496276b772056
parent: 2c2c145fbb538b7fc8080bf69fb56ff5c9adc098
author: James Turner <james@calminferno.net>
date: Mon Jun 3 17:40:14 EDT 2013

Add support for OpenBSD

--- a/flisp.c
+++ b/flisp.c
@@ -2303,6 +2303,8 @@
     set(symbol("*os-name*"), symbol("win32"));
 #elif defined(MACOSX)
     set(symbol("*os-name*"), symbol("macos"));
+#elif defined(OPENBSD)
+    set(symbol("*os-name*"), symbol("openbsd"));
 #else
     set(symbol("*os-name*"), symbol("unknown"));
 #endif
--- a/llt/dirpath.c
+++ b/llt/dirpath.c
@@ -89,6 +89,12 @@
 
     return buf;
 }
+#elif defined(OPENBSD)
+char *get_exename(char *buf, size_t size)
+{
+  /* OpenBSD currently has no way of determining a processes pathname */
+  return NULL;
+}
 #elif defined(__FreeBSD__)
 #include <sys/types.h>
 #include <sys/sysctl.h>
--- a/llt/dtypes.h
+++ b/llt/dtypes.h
@@ -21,6 +21,8 @@
 #  define LINUX
 #elif defined(__APPLE__) && defined(__MACH__)
 #  define MACOSX
+#elif defined(__OpenBSD__)
+#  define OPENBSD
 #elif defined(_WIN32)
 #  define WIN32
 #else
@@ -27,6 +29,13 @@
 #  error "unknown platform"
 #endif
 
+#if defined(OPENBSD)
+#if defined(__x86_64__)
+#  define __SIZEOF_POINTER__ 8
+#else
+#  define __SIZEOF_POINTER__ 4
+#endif
+#endif
 
 #if !defined (BITS32) && !defined (BITS64)
 #ifndef __SIZEOF_POINTER__
@@ -61,7 +70,7 @@
 #  define BIG_ENDIAN     __BIG_ENDIAN
 #  define PDP_ENDIAN     __PDP_ENDIAN
 #  define BYTE_ORDER     __BYTE_ORDER
-#elif defined(MACOSX)
+#elif defined(MACOSX) || defined(OPENBSD)
 #  include <machine/endian.h>
 #  define __LITTLE_ENDIAN  LITTLE_ENDIAN
 #  define __BIG_ENDIAN     BIG_ENDIAN
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -106,7 +106,7 @@
 #endif
 }
 
-#if defined(LINUX) || defined(MACOSX)
+#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD)
 extern char *strptime(const char *s, const char *format, struct tm *tm);
 double parsetime(const char *str)
 {
--- a/llt/utf8.c
+++ b/llt/utf8.c
@@ -25,9 +25,9 @@
 #include <malloc.h>
 #define snprintf _snprintf
 #else
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
 #include <alloca.h>
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ && __OpenBSD__ */
 #endif
 #include <assert.h>