From 3707cc21abf5ee271f76f712c9be6609fd542e0b Mon Sep 17 00:00:00 2001 From: Jon Distad Date: Wed, 8 May 2013 19:41:21 -0400 Subject: [PATCH 1/3] Updated carbon path and pointer size check --- Makefile.macosx | 5 +++-- llt/dirpath.c | 4 ++-- llt/dtypes.h | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile.macosx b/Makefile.macosx index 67d4aa3..502fa10 100644 --- 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 @@ LIBTARGET = lib$(NAME) 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 diff --git a/llt/dirpath.c b/llt/dirpath.c index f448ac0..ca86b27 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -113,8 +113,8 @@ char *get_exename(char *buf, size_t size) return buf; } #elif defined(MACOSX) -#include "/Developer/Headers/FlatCarbon/Processes.h" -#include "/Developer/Headers/FlatCarbon/Files.h" +#include +#include char *get_exename(char *buf, size_t size) { ProcessSerialNumber PSN; diff --git a/llt/dtypes.h b/llt/dtypes.h index b0784cd..9a5995c 100644 --- a/llt/dtypes.h +++ b/llt/dtypes.h @@ -28,6 +28,7 @@ #endif +#if !defined (BITS32) && !defined (BITS64) #ifndef __SIZEOF_POINTER__ # error "__SIZEOF_POINTER__ undefined" #endif @@ -38,6 +39,7 @@ #else # error "this is one weird machine" #endif +#endif #if defined(WIN32) From 19a835847c826572f6cff45852d496276b772056 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 3 Jun 2013 21:40:14 -0400 Subject: [PATCH 2/3] Add support for OpenBSD --- flisp.c | 2 ++ llt/dirpath.c | 6 ++++++ llt/dtypes.h | 11 ++++++++++- llt/timefuncs.c | 2 +- llt/utf8.c | 4 ++-- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/flisp.c b/flisp.c index ca2a2b7..75acd9b 100644 --- a/flisp.c +++ b/flisp.c @@ -2303,6 +2303,8 @@ static void lisp_init(size_t initial_heapsize) 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 diff --git a/llt/dirpath.c b/llt/dirpath.c index ca86b27..b68b8ca 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -89,6 +89,12 @@ char *get_exename(char *buf, size_t size) 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 #include diff --git a/llt/dtypes.h b/llt/dtypes.h index 9a5995c..9fec2a3 100644 --- a/llt/dtypes.h +++ b/llt/dtypes.h @@ -21,12 +21,21 @@ # define LINUX #elif defined(__APPLE__) && defined(__MACH__) # define MACOSX +#elif defined(__OpenBSD__) +# define OPENBSD #elif defined(_WIN32) # define WIN32 #else # 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 # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN diff --git a/llt/timefuncs.c b/llt/timefuncs.c index d2986c8..86639a0 100644 --- a/llt/timefuncs.c +++ b/llt/timefuncs.c @@ -106,7 +106,7 @@ void timestring(double seconds, char *buffer, size_t len) #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) { diff --git a/llt/utf8.c b/llt/utf8.c index 9d554ca..fee04ba 100644 --- a/llt/utf8.c +++ b/llt/utf8.c @@ -25,9 +25,9 @@ #include #define snprintf _snprintf #else -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) #include -#endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ && __OpenBSD__ */ #endif #include From 56b46ba923c2aa4d150bbb28de29fa57c3adbef6 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 3 Jun 2013 21:40:51 -0400 Subject: [PATCH 3/3] Allow the defining of an init file at build time Since OpenBSD is unable to determine the pathname of a running process, this allows us to specify the full path to flisp.boot. This will also come in handy for system wide installs where you want flisp to live in bin and flisp.boot to live in share or a similar location. --- flmain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flmain.c b/flmain.c index 5e26b04..1ff5b07 100644 --- a/flmain.c +++ b/flmain.c @@ -38,6 +38,9 @@ int main(int argc, char *argv[]) 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) { @@ -45,6 +48,7 @@ int main(int argc, char *argv[]) strcat(fname_buf, PATHSEPSTRING); } strcat(fname_buf, "flisp.boot"); +#endif value_t args[2]; fl_gc_handle(&args[0]);