[git commit] platform: use KERNEL_VERSION to simplify uClibc version checking

Mike Frysinger vapier at gentoo.org
Tue Mar 12 15:13:22 UTC 2013


commit: http://git.busybox.net/busybox/commit/?id=445e7543e80d629173d96a77fbfe228fe795cb88
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

This makes reading the logic (as well as adding new code) a lot simpler,
and fixes one or two cases that were broken due to incorrect sub-version
tests.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 coreutils/id.c          |    4 +---
 include/platform.h      |   20 +++++++++++---------
 networking/ether-wake.c |    5 +----
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/coreutils/id.c b/coreutils/id.c
index 1f20b75..1f3e1c4 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -64,12 +64,10 @@
 /* This is a NOEXEC applet. Be very careful! */
 
 #if !ENABLE_USE_BB_PWD_GRP
-#if defined(__UCLIBC_MAJOR__) && (__UCLIBC_MAJOR__ == 0)
-#if (__UCLIBC_MINOR__ < 9) || (__UCLIBC_MINOR__ == 9 &&  __UCLIBC_SUBLEVEL__ < 30)
+#if defined(__UCLIBC__) && UCLIBC_VERSION < KERNEL_VERSION(0, 9, 30)
 #error "Sorry, you need at least uClibc version 0.9.30 for id applet to build"
 #endif
 #endif
-#endif
 
 enum {
 	PRINT_REAL      = (1 << 0),
diff --git a/include/platform.h b/include/platform.h
index f4deb30..917d87d 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -263,6 +263,12 @@ typedef unsigned smalluint;
 
 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
 
+#ifdef __UCLIBC__
+# define UCLIBC_VERSION KERNEL_VERSION(__UCLIBC_MAJOR__, __UCLIBC_MINOR__, __UCLIBC_SUBLEVEL__)
+#else
+# define UCLIBC_VERSION 0
+#endif
+
 
 /* ---- Miscellaneous --------------------------------------- */
 
@@ -305,8 +311,9 @@ typedef unsigned smalluint;
  * for a mmu-less system.
  */
 #if ENABLE_NOMMU || \
-    (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \
-    __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__)
+    (defined __UCLIBC__ && \
+     UCLIBC_VERSION > KERNEL_VERSION(0, 9, 28) && \
+     !defined __ARCH_USE_MMU__)
 # define BB_MMU 0
 # define USE_FOR_NOMMU(...) __VA_ARGS__
 # define USE_FOR_MMU(...)
@@ -373,13 +380,8 @@ typedef unsigned smalluint;
 #define HAVE_NET_ETHERNET_H 1
 #define HAVE_SYS_STATFS_H 1
 
-#if defined(__UCLIBC_MAJOR__)
-# if __UCLIBC_MAJOR__ == 0 \
-  && (   __UCLIBC_MINOR__ < 9 \
-     || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 32) \
-     )
-#  undef HAVE_STRVERSCMP
-# endif
+#if defined(__UCLIBC__) && UCLIBC_VERSION < KERNEL_VERSION(0, 9, 32)
+# undef HAVE_STRVERSCMP
 #endif
 
 #if defined(__dietlibc__)
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
index bf09cd5..2d389ea 100644
--- a/networking/ether-wake.c
+++ b/networking/ether-wake.c
@@ -121,10 +121,7 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
 	eap = ether_aton_r(hostid, eaddr);
 	if (eap) {
 		bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap));
-#if !defined(__UCLIBC_MAJOR__) \
- || __UCLIBC_MAJOR__ > 0 \
- || __UCLIBC_MINOR__ > 9 \
- || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ >= 30)
+#if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
 	} else if (ether_hostton(hostid, eaddr) == 0) {
 		bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr));
 #endif


More information about the busybox-cvs mailing list