Skip to content

Commit

Permalink
For cross platform build, include diff to check simdzone.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcawijngaards committed Aug 22, 2024
1 parent 2af96c3 commit b7ad6e7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 64 deletions.
65 changes: 1 addition & 64 deletions .github/workflows/analysis_ports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,70 +71,7 @@ jobs:
if test "$CROSS_PLATFORM_OS" = "netbsd"; then sudo pkgin -y install autoconf libtool; fi
echo "::group::configure"
echo "patch up simdzone for test"
cat <<EOF | (cd simdzone; patch -p1)
diff --git a/configure.ac b/configure.ac
index 20c2e55..4c8423d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,16 @@ AC_CONFIG_FILES([Makefile])
m4_include(m4/ax_check_compile_flag.m4)
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC])

-AC_CHECK_HEADER(endian.h, AC_DEFINE(HAVE_ENDIAN_H, 1, [Define to 1 if you have the <endian.h> header file.]))
+AC_CHECK_HEADERS([endian.h sys/endian.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_DECLS([bswap16,bswap32,bswap64], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+])

AC_ARG_ENABLE(westmere, AS_HELP_STRING([--disable-westmere],[Disable Westmere (SSE4.2) kernel]))
case "$enable_westmere" in
diff --git a/src/generic/endian.h b/src/generic/endian.h
index 7c9fdb3..f14bdb7 100644
--- a/src/generic/endian.h
+++ b/src/generic/endian.h
@@ -122,6 +122,7 @@
# endif
#endif

+#if !HAVE_DECL_BSWAP16
static really_inline uint16_t bswap16(uint16_t x)
{
// Copied from src/common/lib/libc/gen/bswap16.c in NetBSD
@@ -129,7 +130,9 @@ static really_inline uint16_t bswap16(uint16_t x)
// Public domain.
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
}
+#endif

+#if !HAVE_DECL_BSWAP32
static really_inline uint32_t bswap32(uint32_t x)
{
// Copied from src/common/lib/libc/gen/bswap32.c in NetBSD
@@ -140,7 +143,9 @@ static really_inline uint32_t bswap32(uint32_t x)
( (x >> 8) & 0x0000ff00 ) |
( (x >> 24) & 0x000000ff );
}
+#endif

+#if !HAVE_DECL_BSWAP64
static really_inline uint64_t bswap64(uint64_t x)
{
// Copied from src/common/lib/libc/gen/bswap64.c in NetBSD
@@ -155,6 +160,7 @@ static really_inline uint64_t bswap64(uint64_t x)
( (x >> 40) & 0x000000000000ff00ull ) |
( (x >> 56) & 0x00000000000000ffull );
}
+#endif

# if BYTE_ORDER == LITTLE_ENDIAN
# define htobe(bits, x) bswap ## bits((x))
EOF
(cd simdzone; patch -p1 < ../simdzone_patch_endiandecl.diff)
autoconf && autoheader
(cd simdzone && autoconf && autoheader)
libtoolize -c -i || glibtoolize -c -i
Expand Down
62 changes: 62 additions & 0 deletions simdzone_patch_endiandecl.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
diff --git a/configure.ac b/configure.ac
index 20c2e55..4c8423d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,16 @@ AC_CONFIG_FILES([Makefile])
m4_include(m4/ax_check_compile_flag.m4)
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC])

-AC_CHECK_HEADER(endian.h, AC_DEFINE(HAVE_ENDIAN_H, 1, [Define to 1 if you have the <endian.h> header file.]))
+AC_CHECK_HEADERS([endian.h sys/endian.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_DECLS([bswap16,bswap32,bswap64], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+])

AC_ARG_ENABLE(westmere, AS_HELP_STRING([--disable-westmere],[Disable Westmere (SSE4.2) kernel]))
case "$enable_westmere" in
diff --git a/src/generic/endian.h b/src/generic/endian.h
index 7c9fdb3..f14bdb7 100644
--- a/src/generic/endian.h
+++ b/src/generic/endian.h
@@ -122,6 +122,7 @@
# endif
#endif

+#if !HAVE_DECL_BSWAP16
static really_inline uint16_t bswap16(uint16_t x)
{
// Copied from src/common/lib/libc/gen/bswap16.c in NetBSD
@@ -129,7 +130,9 @@ static really_inline uint16_t bswap16(uint16_t x)
// Public domain.
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
}
+#endif

+#if !HAVE_DECL_BSWAP32
static really_inline uint32_t bswap32(uint32_t x)
{
// Copied from src/common/lib/libc/gen/bswap32.c in NetBSD
@@ -140,7 +143,9 @@ static really_inline uint32_t bswap32(uint32_t x)
( (x >> 8) & 0x0000ff00 ) |
( (x >> 24) & 0x000000ff );
}
+#endif

+#if !HAVE_DECL_BSWAP64
static really_inline uint64_t bswap64(uint64_t x)
{
// Copied from src/common/lib/libc/gen/bswap64.c in NetBSD
@@ -155,6 +160,7 @@ static really_inline uint64_t bswap64(uint64_t x)
( (x >> 40) & 0x000000000000ff00ull ) |
( (x >> 56) & 0x00000000000000ffull );
}
+#endif

# if BYTE_ORDER == LITTLE_ENDIAN
# define htobe(bits, x) bswap ## bits((x))

0 comments on commit b7ad6e7

Please sign in to comment.