[Box Backup-dev] COMMIT r362 - in box/trunk: . infrastructure infrastructure/m4 lib/common
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Fri Feb 3 00:44:14 GMT 2006
Author: martin
Date: 2006-02-03 00:44:12 +0000 (Fri, 03 Feb 2006)
New Revision: 362
Added:
box/trunk/infrastructure/m4/ax_bswap64.m4
Modified:
box/trunk/configure.ac
box/trunk/infrastructure/makebuildenv.pl
box/trunk/lib/common/Box.h
Log:
Beef up configure checks for 64 bit endian swapping function.
NOTE: Needs testing on other platforms, especially BSD.
Modified: box/trunk/configure.ac
===================================================================
--- box/trunk/configure.ac 2006-02-02 20:39:36 UTC (rev 361)
+++ box/trunk/configure.ac 2006-02-03 00:44:12 UTC (rev 362)
@@ -77,9 +77,8 @@
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([execinfo.h regex.h signal.h syslog.h time.h])
-AC_CHECK_HEADERS([asm/byteorder.h])
AC_CHECK_HEADERS([netinet/in.h])
-AC_CHECK_HEADERS([sys/endian.h sys/param.h sys/types.h sys/wait.h sys/xattr.h sys/time.h])
+AC_CHECK_HEADERS([sys/param.h sys/types.h sys/wait.h sys/xattr.h sys/time.h])
### Checks for typedefs, structures, and compiler characteristics.
@@ -109,6 +108,9 @@
AC_SYS_LARGEFILE
AX_CHECK_LLONG_MINMAX
AX_CHECK_DEFINE_PRAGMA
+if test "x$ac_cv_c_bigendian" != "xyes"; then
+ AX_BSWAP64
+fi
if test "$target_os" != "mingw32"; then
AX_RANDOM_DEVICE
fi
Added: box/trunk/infrastructure/m4/ax_bswap64.m4
===================================================================
--- box/trunk/infrastructure/m4/ax_bswap64.m4 2006-02-02 20:39:36 UTC (rev 361)
+++ box/trunk/infrastructure/m4/ax_bswap64.m4 2006-02-03 00:44:12 UTC (rev 362)
@@ -0,0 +1,52 @@
+dnl @synopsis AX_BSWAP64
+dnl
+dnl This macro will check for a built in way of endian reversing an int64_t.
+dnl If one is found then HAVE_BSWAP64 is set to 1 and BSWAP64 will be defined
+dnl to the name of the endian swap function.
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2006/02/02
+dnl @license AllPermissive
+
+AC_DEFUN([AX_BSWAP64], [
+ bswap64_function=""
+ AC_CHECK_HEADERS([sys/endian.h asm/byteorder.h])
+ if test "x$ac_cv_header_sys_endian_h" = "xyes"; then
+ AC_CACHE_CHECK([for htobe64], [have_htobe64],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #include <sys/endian.h>
+ ]], [[
+ htobe64(0);
+ return 1;
+ ]])],
+ [have_htobe64=yes], [have_htobe64=no]
+ )])
+ if test "x$have_htobe64" = "xyes"; then
+ bswap64_function=htobe64
+ fi
+ fi
+ if test "x$bswap64_function" = "x" && \
+ test "x$ac_cv_header_asm_byteorder_h" = "xyes"; then
+ AC_CACHE_CHECK([for __cpu_to_be64], [have___cpu_to_be64],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #include <asm/byteorder.h>
+ ]], [[
+ __cpu_to_be64(0);
+ return 1;
+ ]])],
+ [have___cpu_to_be64=yes], [have___cpu_to_be64=no]
+ )])
+ if test "x$have___cpu_to_be64" = "xyes"; then
+ bswap64_function=__cpu_to_be64
+ fi
+ fi
+
+ if test "x$bswap64_function" != "x"; then
+ AC_DEFINE([HAVE_BSWAP64], 1,
+ [Define to 1 if BSWAP64 is defined to the name of a valid 64 bit endian swapping function])
+ AC_DEFINE_UNQUOTED([BSWAP64], [$bswap64_function], [Name of the 64 bit endian swapping function])
+ fi
+ ])dnl
Modified: box/trunk/infrastructure/makebuildenv.pl
===================================================================
--- box/trunk/infrastructure/makebuildenv.pl 2006-02-02 20:39:36 UTC (rev 361)
+++ box/trunk/infrastructure/makebuildenv.pl 2006-02-03 00:44:12 UTC (rev 362)
@@ -350,8 +350,8 @@
{
opendir DIR,$mod;
for my $h (grep /\.h\Z/i, readdir DIR)
- {
- next if /\A\._/; # Temp Mac OS Resource hack
+ {
+ next if $h =~ /\A\./; # Ignore Mac resource forks, autosaves, etc
open FL,"$mod/$h" or die "can't open $mod/$h";
my $f;
Modified: box/trunk/lib/common/Box.h
===================================================================
--- box/trunk/lib/common/Box.h 2006-02-02 20:39:36 UTC (rev 361)
+++ box/trunk/lib/common/Box.h 2006-02-03 00:44:12 UTC (rev 362)
@@ -134,21 +134,19 @@
#ifdef WORDS_BIGENDIAN
#define box_hton64(x) (x)
#define box_ntoh64(x) (x)
-#else
+#elif defined(HAVE_BSWAP64)
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
- // betoh64 (OpenBSD) is sometimes called be64toh (FreeBSD, NetBSD).
- // Rather than check for it just reuse htobe64 since they are symmetrical
- #define box_hton64(x) htobe64(x)
- #define box_ntoh64(x) htobe64(x)
- #elif HAVE_ASM_BYTEORDER_H
+ #endif
+ #ifdef HAVE_ASM_BYTEORDER_H
#include <asm/byteorder.h>
- #define box_hton64(x) __cpu_to_be64(x)
- #define box_ntoh64(x) __be64_to_cpu(x)
- #else
- #define box_hton64(x) box_swap64(x)
- #define box_ntoh64(x) box_swap64(x)
#endif
+
+ #define box_hton64(x) BSWAP64(x)
+ #define box_ntoh64(x) BSWAP64(x)
+#else
+ #define box_hton64(x) box_swap64(x)
+ #define box_ntoh64(x) box_swap64(x)
#endif
#endif // BOX__H
More information about the Boxbackup-dev
mailing list