portability improvements
This commit is contained in:
parent
a7c0396a2f
commit
c019b3bf2d
4
Makefile
4
Makefile
|
@ -29,8 +29,8 @@ test:
|
||||||
%.do: %.c
|
%.do: %.c
|
||||||
$(CC) $(DEBUGFLAGS) -c $< -o $@
|
$(CC) $(DEBUGFLAGS) -c $< -o $@
|
||||||
|
|
||||||
flisp.o: 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 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.o: flmain.c flisp.h
|
||||||
flmain.do: flmain.c flisp.h
|
flmain.do: flmain.c flisp.h
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,21 @@ char *get_exename(char *buf, size_t size)
|
||||||
|
|
||||||
return buf;
|
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)
|
#elif defined(WIN32)
|
||||||
char *get_exename(char *buf, size_t size)
|
char *get_exename(char *buf, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#else
|
#else
|
||||||
|
#ifndef __FreeBSD__
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
#endif /* __FreeBSD__ */
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
|
@ -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 cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag,
|
||||||
int equalnans)
|
int equalnans)
|
||||||
{
|
{
|
||||||
|
union { double d; int64_t i64; } u, v;
|
||||||
if (atag==btag && (!equalnans || atag < T_FLOAT))
|
if (atag==btag && (!equalnans || atag < T_FLOAT))
|
||||||
return cmp_same_eq(a, b, atag);
|
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 ((int)atag >= T_FLOAT && (int)btag >= T_FLOAT) {
|
||||||
if (equalnans) {
|
if (equalnans) {
|
||||||
return *(uint64_t*)&da == *(uint64_t*)&db;
|
u.d = da; v.d = db;
|
||||||
|
return u.i64 == v.i64;
|
||||||
}
|
}
|
||||||
return (da == db);
|
return (da == db);
|
||||||
}
|
}
|
||||||
|
|
2
string.c
2
string.c
|
@ -378,7 +378,7 @@ value_t fl_stringtonumber(value_t *args, uint32_t nargs)
|
||||||
argcount("string->number", nargs, 2);
|
argcount("string->number", nargs, 2);
|
||||||
char *str = tostring(args[0], "string->number");
|
char *str = tostring(args[0], "string->number");
|
||||||
value_t n;
|
value_t n;
|
||||||
ulong radix = 0;
|
unsigned long radix = 0;
|
||||||
if (nargs == 2)
|
if (nargs == 2)
|
||||||
radix = get_radix_arg(args[1], "string->number");
|
radix = get_radix_arg(args[1], "string->number");
|
||||||
if (!isnumtok_base(str, &n, (int)radix))
|
if (!isnumtok_base(str, &n, (int)radix))
|
||||||
|
|
Loading…
Reference in New Issue