[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] BSD portability patch
From:       Waldemar Brodkorb <wbx () openadk ! org>
Date:       2010-07-30 16:08:09
Message-ID: 20100730160809.GA8705 () waldemar-brodkorb ! de
[Download RAW message or body]

Hi,

When cross-compiling busybox from BSD, there are some
minor glitches, which can be resolved by this patch.
Verfied to work on NetBSD, FreeBSD, OpenBSD and MacOS X.

Thanks in advance for comments or inclusion.

best regards
 Waldemar

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 include/libbb.h            |    2 ++
 include/platform.h         |   20 +++++++++++++++++---
 scripts/gen_build_files.sh |    2 +-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/include/libbb.h b/include/libbb.h
index c043506..e30cb19 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -40,6 +40,7 @@
 /* Try to pull in PATH_MAX */
 #include <limits.h>
 #include <sys/param.h>
+#if !(defined __APPLE__ || defined BSD )
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
 #endif
@@ -52,6 +53,7 @@
 #include <selinux/flask.h>
 #include <selinux/av_permissions.h>
 #endif
+#endif
 #if ENABLE_LOCALE_SUPPORT
 # include <locale.h>
 #else
diff --git a/include/platform.h b/include/platform.h
index 0dadf42..4496e8b 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -150,18 +150,19 @@
 
 /* ---- Endian Detection ------------------------------------ */
 
+# include <sys/param.h>
 #if defined(__digital__) && defined(__unix__)
 # include <sex.h>
 # define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
 # define __BYTE_ORDER BYTE_ORDER
-#elif defined __FreeBSD__
+#elif defined __FreeBSD__ || defined __APPLE__
 # include <sys/resource.h>	/* rlimit */
 # include <machine/endian.h>
 # define bswap_64 __bswap64
 # define bswap_32 __bswap32
 # define bswap_16 __bswap16
 # define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
-#elif !defined __APPLE__
+#elif !defined BSD
 # include <byteswap.h>
 # include <endian.h>
 #endif
@@ -172,9 +173,15 @@
 #elif defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
 # define BB_BIG_ENDIAN 1
 # define BB_LITTLE_ENDIAN 0
+#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN
+# define BB_BIG_ENDIAN 1
+# define BB_LITTLE_ENDIAN 0
 #elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__386__)
 # define BB_BIG_ENDIAN 0
 # define BB_LITTLE_ENDIAN 1
+#elif (defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN) || defined(__386__)
+# define BB_BIG_ENDIAN 0
+# define BB_LITTLE_ENDIAN 1
 #else
 # error "Can't determine endianness"
 #endif
@@ -230,7 +237,7 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
 /* ---- Compiler dependent settings ------------------------- */
 
 #if (defined __digital__ && defined __unix__) \
- || defined __APPLE__ || defined __FreeBSD__
+ || defined __APPLE__ || defined __FreeBSD__ || defined BSD
 # undef HAVE_MNTENT_H
 # undef HAVE_SYS_STATFS_H
 #else
@@ -238,6 +245,13 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
 # define HAVE_SYS_STATFS_H 1
 #endif
 
+/* ---- Networking ------------------------------------------ */
+
+#if defined __OpenBSD__
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
 /*----- Kernel versioning ------------------------------------*/
 
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 18c172d..09a95b5 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -48,7 +48,7 @@ if test x"$new" != x"$old"; then
 fi
 
 # (Re)generate */Kbuild and */Config.in
-{ cd -- "$srctree" && find -type d; } | while read -r d; do
+{ cd -- "$srctree" && find . -type d; } | while read -r d; do
 	d="${d#./}"
 
 	src="$srctree/$d/Kbuild.src"
-- 
1.7.0.4

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic