build BUGFIX fix build and utest on *BSD
Signed-off-by: Christian Hopps <chopps@labn.net>
diff --git a/compat/compat.h.in b/compat/compat.h.in
index 8566ed0..6d2e3a1 100644
--- a/compat/compat.h.in
+++ b/compat/compat.h.in
@@ -16,6 +16,7 @@
#define _COMPAT_H_
#include <limits.h>
+#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
@@ -53,11 +54,13 @@
#cmakedefine HAVE_GETLINE
#cmakedefine HAVE_GET_CURRENT_DIR_NAME
+#ifndef bswap64
#define bswap64(val) \
( (((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \
(((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \
(((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \
(((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000) )
+#endif
#undef le64toh
#undef htole64
diff --git a/src/context.c b/src/context.c
index 491e33e..c1a88df 100644
--- a/src/context.c
+++ b/src/context.c
@@ -14,6 +14,11 @@
#define _GNU_SOURCE /* asprintf */
#define _POSIX_C_SOURCE 200809L /* strdup */
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED /* realpath */
+#endif
+
#include "context.h"
#include <errno.h>
diff --git a/src/in.c b/src/in.c
index 92003ff..7b48c38 100644
--- a/src/in.c
+++ b/src/in.c
@@ -19,6 +19,12 @@
#define _DARWIN_C_SOURCE /* F_GETPATH */
#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+/* realpath */
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED /* realpath */
+#endif
+
#include "in.h"
#include "in_internal.h"
diff --git a/tests/style/check_includes.sh b/tests/style/check_includes.sh
index 81d83ba..1a26c36 100755
--- a/tests/style/check_includes.sh
+++ b/tests/style/check_includes.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
RETVAL=0
@@ -6,7 +6,7 @@
SRC="$*"
# param FUNC - name of the function in compat to check
-function check_compat_func {
+check_compat_func () {
FILES=`grep -rE "([^[:alnum:]]|^)$1\([^\)]+\)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq`
for f in $FILES; do
grep -q "#include \"compat.h\"" $f
@@ -17,7 +17,7 @@
done
}
-function check_compat_macro {
+check_compat_macro () {
FILES=`grep -rE "([^[:alnum:]]|^)$1([^[:alnum:]]|$)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq`
for f in $FILES; do
grep -q "#include \"compat.h\"" $f