diff options
-rwxr-xr-x | build.sh | 11 | ||||
-rw-r--r-- | foreign.c | 12 | ||||
-rw-r--r-- | parse.c | 2 | ||||
-rw-r--r-- | toc.c | 2 | ||||
-rw-r--r-- | types.h | 6 |
5 files changed, 26 insertions, 7 deletions
@@ -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 @@ -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); } @@ -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?"); @@ -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 @@ -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 |