Add NetBSD support

$ make test
cd tests && ../flisp unittest.lsp
all tests pass
This commit is contained in:
Kamil Rytarowski 2019-07-12 16:00:36 +02:00 committed by Lassi Kortela
parent 956fd32a06
commit 48ff4764a4
6 changed files with 21 additions and 8 deletions

View File

@ -2320,6 +2320,8 @@ static void lisp_init(size_t initial_heapsize)
set(symbol("*os-name*"), symbol("openbsd"));
#elif defined(FREEBSD)
set(symbol("*os-name*"), symbol("freebsd"));
#elif defined(NETBSD)
set(symbol("*os-name*"), symbol("netbsd"));
#else
set(symbol("*os-name*"), symbol("unknown"));
#endif

View File

@ -191,7 +191,7 @@ char *get_exename(char *buf, size_t size)
return buf;
}
#elif defined(FREEBSD)
#elif defined(FREEBSD) || defined(NETBSD)
#include <sys/types.h>
#include <sys/sysctl.h>
@ -199,9 +199,15 @@ char *get_exename(char *buf, size_t size)
{
int mib[4];
mib[0] = CTL_KERN;
#if defined(FREEBSD)
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME;
mib[3] = -1;
#else
mib[1] = KERN_PROC_ARGS;
mib[2] = -1;
mib[3] = KERN_PROC_PATHNAME;
#endif
sysctl(mib, 4, buf, &size, NULL, 0);
return buf;

View File

@ -25,13 +25,15 @@
# define OPENBSD
#elif defined(__FreeBSD__)
# define FREEBSD
#elif defined(__NetBSD__)
# define NETBSD
#elif defined(_WIN32)
# define WIN32
#else
# error "unknown platform"
#endif
#if defined(OPENBSD) || defined(FREEBSD)
#if defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
#if defined(__x86_64__)
# define __SIZEOF_POINTER__ 8
#else
@ -72,7 +74,7 @@
# define BIG_ENDIAN __BIG_ENDIAN
# define PDP_ENDIAN __PDP_ENDIAN
# define BYTE_ORDER __BYTE_ORDER
#elif defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
#elif defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
# include <machine/endian.h>
# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __BIG_ENDIAN BIG_ENDIAN
@ -193,10 +195,12 @@ typedef u_ptrint_t uptrint_t;
#define DBL_EPSILON 2.2204460492503131e-16
#define FLT_EPSILON 1.192092896e-7
#if !defined(NETBSD)
#define DBL_MAX 1.7976931348623157e+308
#define DBL_MIN 2.2250738585072014e-308
#define FLT_MAX 3.402823466e+38
#define FLT_MIN 1.175494351e-38
#endif
#define LOG2_10 3.3219280948873626
#define rel_zero(a, b) (fabs((a)/(b)) < DBL_EPSILON)
#define sign_bit(r) ((*(int64_t*)&(r)) & BIT63)

View File

@ -7,7 +7,7 @@
#include "dtypes.h"
#if defined(MACOSX)
#if defined(MACOSX) || defined(NETBSD)
#include <sys/time.h>
#include <sys/select.h>
#include <sys/types.h>

View File

@ -82,7 +82,7 @@ void timestring(double seconds, char *buffer, size_t len)
{
time_t tme = (time_t)seconds;
#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
char *fmt = "%c"; /* needed to suppress GCC warning */
struct tm tm;
@ -106,7 +106,7 @@ void timestring(double seconds, char *buffer, size_t len)
#endif
}
#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD)
extern char *strptime(const char *s, const char *format, struct tm *tm);
double parsetime(const char *str)
{

View File

@ -15,6 +15,7 @@
#define _XOPEN_SOURCE 700
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <wchar.h>
@ -26,9 +27,9 @@
#include <malloc.h>
#define snprintf _snprintf
#else
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
#include <alloca.h>
#endif /* __FreeBSD__ && __OpenBSD__ */
#endif /* __FreeBSD__ && __OpenBSD__ && __NetBSD__ */
#endif
#include <assert.h>