portability improvements

This commit is contained in:
Jeff Bezanson 2012-02-26 23:00:47 -05:00
parent a7c0396a2f
commit c019b3bf2d
5 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -89,6 +89,21 @@ char *get_exename(char *buf, size_t size)
return buf;
}
#elif defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
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)
{

View File

@ -25,7 +25,9 @@
#include <malloc.h>
#define snprintf _snprintf
#else
#ifndef __FreeBSD__
#include <alloca.h>
#endif /* __FreeBSD__ */
#endif
#include <assert.h>

View File

@ -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);
}

View File

@ -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))