diff --git a/Makefile b/Makefile index 59439a5..61b2024 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ test: %.do: %.c $(CC) $(DEBUGFLAGS) -c $< -o $@ -flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c -flisp.do: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c +flisp.o: flisp.c cvalues.c operators.c types.c flisp.h print.c read.c equal.c +flisp.do: flisp.c cvalues.c operators.c types.c flisp.h print.c read.c equal.c flmain.o: flmain.c flisp.h flmain.do: flmain.c flisp.h diff --git a/llt/dirpath.c b/llt/dirpath.c index cba9201..f448ac0 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -89,6 +89,21 @@ char *get_exename(char *buf, size_t size) return buf; } +#elif defined(__FreeBSD__) +#include +#include + +char *get_exename(char *buf, size_t size) +{ + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + sysctl(mib, 4, buf, &size, NULL, 0); + + return buf; +} #elif defined(WIN32) char *get_exename(char *buf, size_t size) { diff --git a/llt/utf8.c b/llt/utf8.c index 082f78f..c95b905 100644 --- a/llt/utf8.c +++ b/llt/utf8.c @@ -25,7 +25,9 @@ #include #define snprintf _snprintf #else +#ifndef __FreeBSD__ #include +#endif /* __FreeBSD__ */ #endif #include diff --git a/operators.c b/operators.c index f9f9c9e..d10ebc0 100644 --- a/operators.c +++ b/operators.c @@ -249,6 +249,7 @@ int cmp_lt(void *a, numerictype_t atag, void *b, numerictype_t btag) int cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag, int equalnans) { + union { double d; int64_t i64; } u, v; if (atag==btag && (!equalnans || atag < T_FLOAT)) return cmp_same_eq(a, b, atag); @@ -257,7 +258,8 @@ int cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag, if ((int)atag >= T_FLOAT && (int)btag >= T_FLOAT) { if (equalnans) { - return *(uint64_t*)&da == *(uint64_t*)&db; + u.d = da; v.d = db; + return u.i64 == v.i64; } return (da == db); } diff --git a/string.c b/string.c index a3e674c..7859d95 100644 --- a/string.c +++ b/string.c @@ -378,7 +378,7 @@ value_t fl_stringtonumber(value_t *args, uint32_t nargs) argcount("string->number", nargs, 2); char *str = tostring(args[0], "string->number"); value_t n; - ulong radix = 0; + unsigned long radix = 0; if (nargs == 2) radix = get_radix_arg(args[1], "string->number"); if (!isnumtok_base(str, &n, (int)radix))