[BusyBox-cvs] svn commit: trunk/busybox: include networking

landley at busybox.net landley at busybox.net
Wed Jul 27 06:55:38 UTC 2005


Author: landley
Date: 2005-07-27 00:55:36 -0600 (Wed, 27 Jul 2005)
New Revision: 10929

Log:
#ifdef reduction infrastructure, based on an argument between Shaun Jackman,
Rob Landley, and others.

Currently CONFIG options are defined or undefined, so we chop out code with
#ifdefs, ala:
#ifdef CONFIG_THING
  stuff();
#endif

This creates a new header file, bb_config.h, which sets the CONFIG entry to 1
or 0, and lets us do:

  if(CONFIG_THING) stuff();

And let the compiler do dead code elimination to get rid of it.  (Note: #ifdef
will still work because for the 1 case it's a static const int, not a #define.)



Modified:
   trunk/busybox/Makefile
   trunk/busybox/include/busybox.h
   trunk/busybox/include/libbb.h
   trunk/busybox/networking/ifconfig.c


Changeset:
Modified: trunk/busybox/Makefile
===================================================================
--- trunk/busybox/Makefile	2005-07-27 06:05:38 UTC (rev 10928)
+++ trunk/busybox/Makefile	2005-07-27 06:55:36 UTC (rev 10929)
@@ -122,7 +122,7 @@
 include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
 -include $(top_builddir)/.depend
 
-busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
+busybox: $(ALL_MAKEFILES) .depend include/bb_config.h $(libraries-y)
 	$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
 	$(STRIPCMD) $@
 
@@ -212,6 +212,11 @@
 	fi;
 	@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
 
+include/bb_config.h: include/config.h
+	echo "#ifndef AUTOCONF_INCLUDED" > $@
+	sed -e 's/#undef \(.*\)/static const int \1 = 0;/' < $< >> $@
+	echo "#endif" >> $@
+
 finished2:
 	@echo
 	@echo Finished installing...
@@ -279,7 +284,7 @@
 
 distclean: clean
 	- rm -f scripts/split-include scripts/mkdep
-	- rm -rf include/config include/config.h
+	- rm -rf include/config include/config.h include/bb_config.h
 	- find . -name .depend -exec rm -f {} \;
 	rm -f .config .config.old .config.cmd
 	- $(MAKE) -C scripts/config clean

Modified: trunk/busybox/include/busybox.h
===================================================================
--- trunk/busybox/include/busybox.h	2005-07-27 06:05:38 UTC (rev 10928)
+++ trunk/busybox/include/busybox.h	2005-07-27 06:55:36 UTC (rev 10929)
@@ -24,7 +24,7 @@
 #ifndef	_BB_INTERNAL_H_
 #define	_BB_INTERNAL_H_    1
 
-#include "config.h"
+#include "bb_config.h"
 
 #include <stdio.h>
 #include <stdlib.h>

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2005-07-27 06:05:38 UTC (rev 10928)
+++ trunk/busybox/include/libbb.h	2005-07-27 06:55:36 UTC (rev 10929)
@@ -41,7 +41,7 @@
 
 #include <features.h>
 
-#include "config.h"
+#include "bb_config.h"
 #ifdef CONFIG_SELINUX
 #include <selinux/selinux.h>  
 #endif

Modified: trunk/busybox/networking/ifconfig.c
===================================================================
--- trunk/busybox/networking/ifconfig.c	2005-07-27 06:05:38 UTC (rev 10928)
+++ trunk/busybox/networking/ifconfig.c	2005-07-27 06:55:36 UTC (rev 10929)
@@ -37,6 +37,7 @@
 #include <string.h>		/* strcmp and friends */
 #include <ctype.h>		/* isdigit and friends */
 #include <stddef.h>		/* offsetof */
+#include <unistd.h>
 #include <netdb.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
@@ -558,6 +559,7 @@
 		continue;
 	}					/* end of while-loop */
 
+	if (CONFIG_FEATURE_CLEAN_UP) close(sockfd);
 	return goterr;
 }
 




More information about the busybox-cvs mailing list