summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh11
-rw-r--r--foreign.c12
-rw-r--r--parse.c2
-rw-r--r--toc.c2
-rw-r--r--types.h6
5 files changed, 26 insertions, 7 deletions
diff --git a/build.sh b/build.sh
index 6f9b1d3..ac09183 100755
--- a/build.sh
+++ b/build.sh
@@ -7,6 +7,10 @@ if [ "$CC" = "" ]; then
fi
fi
+if uname | grep -qi bsd; then
+ CFLAGS="$CFLAGS -L/usr/local/lib -I/usr/local/include"
+fi
+
ADDITIONAL_FLAGS="$CFLAGS -Wno-unused-function"
if [ "$CC" = "clang" ]; then
@@ -22,7 +26,12 @@ else
fi
if [ "$COMPILE_TIME_FOREIGN_FN_SUPPORT" != "no" ]; then
- ADDITIONAL_FLAGS="$ADDITIONAL_FLAGS -DCOMPILE_TIME_FOREIGN_FN_SUPPORT=1 -lffcall -ldl"
+ if uname | grep -qi bsd; then
+ LIBRARIES='-lavcall'
+ else
+ LIBRARIES='-ldl -lffcall'
+ fi
+ ADDITIONAL_FLAGS="$ADDITIONAL_FLAGS -DCOMPILE_TIME_FOREIGN_FN_SUPPORT=1 $LIBRARIES -DNO_STATIC_ASSERT"
fi
diff --git a/foreign.c b/foreign.c
index 6ad9011..462195a 100644
--- a/foreign.c
+++ b/foreign.c
@@ -4,6 +4,14 @@
#if CHAR_BIT != 8
#error "Compile-time foreign functions can only be used on systems where CHAR_BIT is 8."
#endif
+
+/* avcall has some sign conversion problems on BSD */
+/* (the macros it defines cause problems too, which is why this is ignored for so long) */
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
#include <avcall.h>
#include <dlfcn.h>
@@ -272,6 +280,10 @@ static bool arg_list_add(av_alist *arg_list, Value val, Type *type, Location whe
return true;
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
static void ffmgr_create(ForeignFnManager *ffmgr, Allocator *allocr) {
str_hash_table_create(&ffmgr->libs_loaded, sizeof(Library), allocr);
}
diff --git a/parse.c b/parse.c
index 91d61e1..f735f4e 100644
--- a/parse.c
+++ b/parse.c
@@ -1130,7 +1130,7 @@ static Status ctype_to_type(Allocator *a, CType *ctype, Type *type, Location whe
break;
case CTYPE_LONGLONG:
case CTYPE_UNSIGNED_LONGLONG:
-#if HAVE_LONGLONG
+#if LONGLONG_AVAILABLE
size = sizeof(longlong);
#else
err_print(where, "long long is not supported. Did you compile toc with a pre-C99 compiler?");
diff --git a/toc.c b/toc.c
index aed9423..f7a310b 100644
--- a/toc.c
+++ b/toc.c
@@ -65,7 +65,7 @@
/* use toc_alignof only for non-structs. it may be incorrect for pre-C(++)11. */
-#if (__STDC_VERSION__ >= 201112 || __cplusplus >= 201103L) && !defined __TINYC__
+#if (__STDC_VERSION__ >= 201112 || __cplusplus >= 201103L) && !defined __TINYC__ && !defined __OpenBSD__ && !defined __FreeBSD__
#include <stdalign.h>
#define toc_alignof alignof
diff --git a/types.h b/types.h
index ceea98b..bc6a949 100644
--- a/types.h
+++ b/types.h
@@ -29,10 +29,10 @@ typedef long double Floating; /* OPTIM: Switch to double, but make sure floating
#if __STDC_VERSION__ >= 199901
-#define HAVE_LONGLONG 1
+#define LONGLONG_AVAILABLE 1
typedef long long longlong;
#else
-#define HAVE_LONGLONG 0
+#define LONGLONG_AVAILABLE 0
typedef long longlong;
#endif
@@ -42,9 +42,7 @@ typedef long longlong;
typedef union {
long double floating;
void *ptr;
- #if HAVE_LONGLONG
longlong integer;
- #endif
void (*fn_ptr)(void);
} MaxAlign;
#else