From 12b90137449917cc543e307d9d90db5235e29176 Mon Sep 17 00:00:00 2001 From: JeffBezanson Date: Mon, 24 Aug 2009 01:11:36 +0000 Subject: [PATCH] changes to support mac compilation better. patches from Stefan. --- femtolisp/Makefile | 7 ++++--- femtolisp/Makefile.macosx | 44 +++++++++++++++++++++++++++++++++++++++ llt/dblprint.c | 2 +- llt/ios.c | 14 +++++++++++++ llt/timefuncs.c | 2 +- llt/utf8.h | 2 +- 6 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 femtolisp/Makefile.macosx diff --git a/femtolisp/Makefile b/femtolisp/Makefile index 1c85176..8fea5b9 100644 --- a/femtolisp/Makefile +++ b/femtolisp/Makefile @@ -9,7 +9,8 @@ LLTDIR = ../llt LLT = $(LLTDIR)/libllt.a FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO -LIBS = $(LLT) -lm +LIBFILES = $(LLT) +LIBS = $(LIBFILES) -lm DEBUGFLAGS = -g -DDEBUG $(FLAGS) SHIPFLAGS = -O2 -DNDEBUG $(FLAGS) @@ -30,11 +31,11 @@ flisp.do: flisp.c cvalues.c types.c flisp.h print.c read.c $(LLT): cd $(LLTDIR) && make -debug: $(DOBJS) $(LIBS) +debug: $(DOBJS) $(LIBFILES) $(CC) $(DEBUGFLAGS) $(DOBJS) -o $(EXENAME) $(LIBS) make test -release: $(OBJS) $(LIBS) +release: $(OBJS) $(LIBFILES) $(CC) $(SHIPFLAGS) $(OBJS) -o $(EXENAME) $(LIBS) clean: diff --git a/femtolisp/Makefile.macosx b/femtolisp/Makefile.macosx new file mode 100644 index 0000000..5c5b3bf --- /dev/null +++ b/femtolisp/Makefile.macosx @@ -0,0 +1,44 @@ +CC = gcc + +NAME = flisp +SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c +OBJS = $(SRCS:%.c=%.o) +DOBJS = $(SRCS:%.c=%.do) +EXENAME = $(NAME) +LLTDIR = ../llt +LLT = $(LLTDIR)/libllt.a + +FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO +LIBFILES = $(LLT) +LIBS = $(LIBFILES) -lm -framework ApplicationServices + +DEBUGFLAGS = -g -DDEBUG $(FLAGS) +SHIPFLAGS = -O2 -DNDEBUG $(FLAGS) + +default: release test + +test: + ./flisp unittest.lsp + +%.o: %.c + $(CC) $(SHIPFLAGS) -c $< -o $@ +%.do: %.c + $(CC) $(DEBUGFLAGS) -c $< -o $@ + +flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c +flisp.do: flisp.c cvalues.c types.c flisp.h print.c read.c + +$(LLT): + cd $(LLTDIR) && make + +debug: $(DOBJS) $(LIBFILES) + $(CC) $(DEBUGFLAGS) $(DOBJS) -o $(EXENAME) $(LIBS) + make test + +release: $(OBJS) $(LIBFILES) + $(CC) $(SHIPFLAGS) $(OBJS) -o $(EXENAME) $(LIBS) + +clean: + rm -f *.o + rm -f *.do + rm -f $(EXENAME) diff --git a/llt/dblprint.c b/llt/dblprint.c index 8d49f92..5279c17 100644 --- a/llt/dblprint.c +++ b/llt/dblprint.c @@ -2,8 +2,8 @@ #include #include #include -#include "ieee754.h" #include "dtypes.h" +#include "ieee754.h" int double_exponent(double d) { diff --git a/llt/ios.c b/llt/ios.c index 4a02015..3fd7e33 100644 --- a/llt/ios.c +++ b/llt/ios.c @@ -31,6 +31,20 @@ /* OS-level primitive wrappers */ +#if defined(MACOSX) || defined(MACINTEL) +void *memrchr(const void *s, int c, size_t n) +{ + const unsigned char *src = s + n; + unsigned char uc = c; + while (--src >= (unsigned char *) s) + if (*src == uc) + return (void *) src; + return NULL; +} +#else +extern void *memrchr(const void *s, int c, size_t n); +#endif + static int _fd_available(long fd) { #ifndef WIN32 diff --git a/llt/timefuncs.c b/llt/timefuncs.c index 8cf0d0b..efb8db7 100644 --- a/llt/timefuncs.c +++ b/llt/timefuncs.c @@ -105,7 +105,7 @@ void timestring(double seconds, char *buffer, size_t len) #endif } -#ifdef LINUX +#if defined(LINUX) || defined(MACOSX) || defined(MACINTEL) extern char *strptime(const char *s, const char *format, struct tm *tm); double parsetime(char *str) { diff --git a/llt/utf8.h b/llt/utf8.h index 39b7fc6..41505e6 100644 --- a/llt/utf8.h +++ b/llt/utf8.h @@ -1,7 +1,7 @@ #ifndef __UTF8_H_ #define __UTF8_H_ -#ifndef MACOSX +#if !defined(MACOSX) && !defined(MACINTEL) #if !defined(__DTYPES_H_) && !defined(_SYS_TYPES_H) typedef char int8_t; typedef short int16_t;