Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetBSD support #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion llt/dirpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,23 @@ 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>

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;
Expand Down
8 changes: 6 additions & 2 deletions llt/dtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion llt/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions llt/timefuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions llt/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

Expand Down