shithub: femtolisp

Download patch

ref: 0aa1359a3e1b67081bc450dce19a7f08477a75de
parent: a76b29eee8a484df5b355b9102e4f38a639d32f0
parent: 63274538954ad3aa062290f7a349ff461adca2b4
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Sat Jun 8 15:29:46 EDT 2013

Merge branch 'master' of github.com:JeffBezanson/femtolisp

--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -1,4 +1,5 @@
-CC = gcc
+CC ?= gcc
+CARBON_HEADERS ?= "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/Developer/Headers"
 
 NAME = flisp
 SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c
@@ -9,7 +10,7 @@
 LLTDIR = llt
 LLT = $(LLTDIR)/libllt.a
 
-CONFIG = -DMACOSX -DARCH_X86_64 -DBITS64 -D__CPU__=686
+CONFIG = -DMACOSX -DARCH_X86_64 -DBITS64 -D__CPU__=686 -I$(CARBON_HEADERS)
 FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO $(CONFIG)
 LIBFILES = $(LLT)
 LIBS = $(LIBFILES) -lm -framework ApplicationServices
--- a/flisp.c
+++ b/flisp.c
@@ -2304,6 +2304,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/flmain.c
+++ b/flmain.c
@@ -27,6 +27,9 @@
     fl_init(512*1024);
 
     fname_buf[0] = '\0';
+#ifdef INITFILE
+    strcat(fname_buf, INITFILE);
+#else
     value_t str = symbol_value(symbol("*install-dir*"));
     char *exedir = (str == UNBOUND ? NULL : cvalue_data(str));
     if (exedir != NULL) {
@@ -34,6 +37,7 @@
         strcat(fname_buf, PATHSEPSTRING);
     }
     strcat(fname_buf, "flisp.boot");
+#endif
 
     value_t args[2];
     fl_gc_handle(&args[0]);
--- 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>
@@ -113,8 +119,8 @@
     return buf;
 }
 #elif defined(MACOSX)
-#include "/Developer/Headers/FlatCarbon/Processes.h"
-#include "/Developer/Headers/FlatCarbon/Files.h"
+#include <FlatCarbon/Processes.h>
+#include <FlatCarbon/Files.h>
 char *get_exename(char *buf, size_t size)
 {
     ProcessSerialNumber PSN;
--- 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,7 +29,15 @@
 #  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__
 #  error "__SIZEOF_POINTER__ undefined"
 #endif
@@ -38,6 +48,7 @@
 #else
 #  error "this is one weird machine"
 #endif
+#endif
 
 
 #if defined(WIN32)
@@ -59,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>