[BusyBox] minor dietlibc support patches

Mike Castle dalgoda at ix.netcom.com
Sun Aug 8 04:40:50 UTC 2004


A few minor, hopefully non-intrusive, patches to support dietlibc.

Not sure if the best implementation, but hopefully at least get the ideas
across.

I think this is definitely a dietlibc bug (if they're going to support
GNU_SOURCE, they should have it automatically turning on _BSD_SOURCE
as well).  Understand if rejected, but mostly documenting it for search
engines.  This will fix the caddr_t problem.  I will also submit a bug to
dietlibc, so hopefully this won't be necessary.

diff -ruN busybox-1.00-rc2.orig/Rules.mak busybox-1.00-rc2/Rules.mak
--- busybox-1.00-rc2.orig/Rules.mak     2004-07-26 05:12:06.000000000 -0700
+++ busybox-1.00-rc2/Rules.mak  2004-08-07 19:10:17.000000000 -0700
@@ -153,11 +153,11 @@
     endif
 endif
 ifeq ($(strip $(CONFIG_DEBUG)),y)
-    CFLAGS  +=$(WARNINGS) -g -D_GNU_SOURCE
+    CFLAGS  +=$(WARNINGS) -g -D_BSD_SOURCE -D_GNU_SOURCE
     LDFLAGS +=-Wl,-warn-common
     STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
 else
-    CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
+    CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_BSD_SOURCE -D_GNU_SOURCE
-DNDEBUG
     LDFLAGS += -s -Wl,-warn-common
     STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
 endif


I think this is a bit more portable over all.  Even better would probably
be to use %z, but since dietlibc doesn't support that....

diff -ruN busybox-1.00-rc2.orig/archival/libunarchive/archive_xread_all_eof.c busybox-1.00-rc2/archival/libunarchive/archive_xread_all_eof.c
--- busybox-1.00-rc2.orig/archival/libunarchive/archive_xread_all_eof.c	2003-11-21 14:24:48.000000000 -0800
+++ busybox-1.00-rc2/archival/libunarchive/archive_xread_all_eof.c	2004-08-07 19:10:17.000000000 -0700
@@ -26,7 +26,7 @@
 
 	size = bb_full_read(archive_handle->src_fd, buf, count);
 	if ((size != 0) && (size != count)) {
-		bb_perror_msg_and_die("Short read, read %d of %d", size, count);
+		bb_perror_msg_and_die("Short read, read %ld of %lu", (long) size, (unsigned long) count);
 	}
 	return(size);
 }


Turns out dietlibc DOES have something pretty similar.  And as far as I
know, dprintf is not (yet) a standard (and it appears to have been over a
year since it was bantered about on opengroup.org).  I'm just not sure if
this is what you'd like, or still prefer a support function that just
wrapped this in libbb.

diff -ruN busybox-1.00-rc2.orig/coreutils/tail.c busybox-1.00-rc2/coreutils/tail.c
--- busybox-1.00-rc2.orig/coreutils/tail.c	2004-03-15 00:28:21.000000000 -0800
+++ busybox-1.00-rc2/coreutils/tail.c	2004-08-07 19:10:17.000000000 -0700
@@ -61,6 +61,9 @@
 
 static void tail_xprint_header(const char *fmt, const char *filename)
 {
+#ifdef __dietlibc__
+#  define dprintf fdprintf
+#endif
 	/* If we get an output error, there is really no sense in continuing. */
 	if (dprintf(STDOUT_FILENO, fmt, filename) < 0) {
 		bb_perror_nomsg_and_die();


According to opengroup.org:

     Inclusion of the <netdb.h> header may also make visible all symbols
     from <netinet/in.h> and <inttypes.h>.

So it appears that you should be able to handle netinet/in.h being present,
but you should not depend on it.  So I think this patch is definitely a
portability fix, regardless of dietlibc support or not.

diff -ruN busybox-1.00-rc2.orig/include/libbb.h busybox-1.00-rc2/include/libbb.h
--- busybox-1.00-rc2.orig/include/libbb.h	2004-06-22 03:07:15.000000000 -0700
+++ busybox-1.00-rc2/include/libbb.h	2004-08-07 19:10:17.000000000 -0700
@@ -34,6 +34,7 @@
 #include <stdint.h>
 
 #include <netdb.h>
+#include <netinet/in.h>
 
 #ifdef DMALLOC
 #include <dmalloc.h>

-- 
     Mike Castle      dalgoda at ix.netcom.com      www.netcom.com/~dalgoda/
    We are all of us living in the shadow of Manhattan.  -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc



More information about the busybox mailing list