From ac467ea31427f2e91fab9a3f2c2ae5fa3a1c05df Mon Sep 17 00:00:00 2001 From: Andrew Gwozdziewycz <apg@jason.sigusr2.net> Date: Fri, 2 Aug 2019 01:56:51 -0700 Subject: [PATCH 1/2] Add features for the various BSDs. This could and should be done cleaner. Works as a proof of concept at this point in time. --- sexp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sexp.c b/sexp.c index cc9c6fc2..ed8bdb68 100644 --- a/sexp.c +++ b/sexp.c @@ -464,6 +464,18 @@ static const char* sexp_initial_features[] = { #if SEXP_BSD "bsd", #endif +#if defined(__OpenBSD__) + "openbsd", +#endif +#if defined(__FreeBSD__) + "freebsd", +#endif +#if defined(__NetBSD__) + "netbsd", +#endif +#if defined(__DragonFly__) + "dragonfly", +#endif #if defined(_WIN32) "windows", #endif From e5ae89c9c6bf88bc180f8bcfa00253807a0e38ac Mon Sep 17 00:00:00 2001 From: Andrew Gwozdziewycz <apg@jason.sigusr2.net> Date: Fri, 2 Aug 2019 11:33:07 -0700 Subject: [PATCH 2/2] Define / detect explicit features for BSD platforms --- include/chibi/features.h | 37 +++++++++++++++++++++++++++++++++++++ sexp.c | 11 +++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/chibi/features.h b/include/chibi/features.h index ccf27b04..09926179 100644 --- a/include/chibi/features.h +++ b/include/chibi/features.h @@ -303,6 +303,43 @@ #endif #endif +/* Detect specific BSD */ +#if SEXP_BSD +#if defined(__APPLE__) +#define SEXP_DARWIN 1 +#define SEXP_FREEBSD 0 +#define SEXP_NETBSD 0 +#define SEXP_DRAGONFLY 0 +#define SEXP_OPENBSD 0 +#elif defined(__FreeBSD__) +#define SEXP_DARWIN 0 +#define SEXP_FREEBSD 1 +#define SEXP_NETBSD 0 +#define SEXP_DRAGONFLY 0 +#define SEXP_OPENBSD 0 +#elif defined(__NetBSD__) +#define SEXP_DARWIN 0 +#define SEXP_FREEBSD 0 +#define SEXP_NETBSD 1 +#define SEXP_DRAGONFLY 0 +#define SEXP_OPENBSD 0 +#define SEXP_NETBSD 0 +#elif defined(__DragonFly__) +#define SEXP_DARWIN 1 +#define SEXP_FREEBSD 0 +#define SEXP_NETBSD 0 +#define SEXP_DRAGONFLY 1 +#define SEXP_OPENBSD 0 +#define SEXP_DRAGONFLY 0 +#elif defined(__OpenBSD__) +#define SEXP_DARWIN 0 +#define SEXP_FREEBSD 0 +#define SEXP_NETBSD 0 +#define SEXP_DRAGONFLY 0 +#define SEXP_OPENBSD 1 +#endif +#endif + /* for bignum support, need a double long to store long*long */ /* gcc supports uint128_t, otherwise we need a custom struct */ #ifndef SEXP_USE_CUSTOM_LONG_LONGS diff --git a/sexp.c b/sexp.c index ed8bdb68..8ceef0e1 100644 --- a/sexp.c +++ b/sexp.c @@ -464,16 +464,19 @@ static const char* sexp_initial_features[] = { #if SEXP_BSD "bsd", #endif -#if defined(__OpenBSD__) +#if SEXP_DARWIN + "darwin", +#endif +#if SEXP_OPENBSD "openbsd", #endif -#if defined(__FreeBSD__) +#if SEXP_FREEBSD "freebsd", #endif -#if defined(__NetBSD__) +#if SEXP_NETBSD "netbsd", #endif -#if defined(__DragonFly__) +#if SEXP_DRAGONFLY "dragonfly", #endif #if defined(_WIN32)