svn commit: trunk/busybox: archival debianutils editors include li etc...

landley at busybox.net landley at busybox.net
Sun May 7 20:20:39 UTC 2006


Author: landley
Date: 2006-05-07 13:20:34 -0700 (Sun, 07 May 2006)
New Revision: 15023

Log:
Remove bb_strlen() in favor of -fno-builtin-strlen.  Saves as many bytes
as the old optimization did (actually does slightly better under gcc 4.0), and
simplifies the code.


Modified:
   trunk/busybox/Rules.mak
   trunk/busybox/archival/dpkg.c
   trunk/busybox/debianutils/which.c
   trunk/busybox/editors/awk.c
   trunk/busybox/include/platform.h
   trunk/busybox/libbb/Makefile.in
   trunk/busybox/libbb/correct_password.c
   trunk/busybox/libbb/xfuncs.c
   trunk/busybox/loginutils/login.c
   trunk/busybox/modutils/modprobe.c
   trunk/busybox/networking/arping.c
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/procps/sysctl.c
   trunk/busybox/util-linux/hwclock.c


Changeset:
Modified: trunk/busybox/Rules.mak
===================================================================
--- trunk/busybox/Rules.mak	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/Rules.mak	2006-05-07 20:20:34 UTC (rev 15023)
@@ -125,6 +125,7 @@
 # Pin CHECKED_CFLAGS with := so it's only evaluated once.
 CHECKED_CFLAGS:=$(call check_gcc,-funsigned-char,)
 CHECKED_CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
+CHECKED_CFLAGS+=$(call check_gcc,-fno-builtin-strlen)
 
 # Preemptively pin this too.
 PROG_CFLAGS:=

Modified: trunk/busybox/archival/dpkg.c
===================================================================
--- trunk/busybox/archival/dpkg.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/archival/dpkg.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -1573,7 +1573,7 @@
 	init_archive_deb_control(archive_handle);
 
 	while(all_control_files[i]) {
-		char *c = (char *) xmalloc(3 + bb_strlen(all_control_files[i]));
+		char *c = (char *) xmalloc(3 + strlen(all_control_files[i]));
 		sprintf(c, "./%s", all_control_files[i]);
 		accept_list= llist_add_to(accept_list, c);
 		i++;

Modified: trunk/busybox/debianutils/which.c
===================================================================
--- trunk/busybox/debianutils/which.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/debianutils/which.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -29,7 +29,7 @@
 
 	path_list = getenv("PATH");
 	if (path_list != NULL) {
-		size_t path_len = bb_strlen(path_list);
+		size_t path_len = strlen(path_list);
 		char *new_list = NULL;
 		count = 1;
 
@@ -88,7 +88,7 @@
 					break;
 				}
 				free(buf);
-				path_n += (bb_strlen(path_n) + 1);
+				path_n += (strlen(path_n) + 1);
 			}
 		}
 		if (found) {

Modified: trunk/busybox/editors/awk.c
===================================================================
--- trunk/busybox/editors/awk.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/editors/awk.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -534,7 +534,7 @@
 		if (++hash->nel / hash->csize > 10)
 			hash_rebuild(hash);
 
-		l = bb_strlen(name) + 1;
+		l = strlen(name) + 1;
 		hi = xcalloc(sizeof(hash_item) + l, 1);
 		memcpy(hi->name, name, l);
 
@@ -559,7 +559,7 @@
 	while (*phi) {
 		hi = *phi;
 		if (strcmp(hi->name, name) == 0) {
-			hash->glen -= (bb_strlen(name) + 1);
+			hash->glen -= (strlen(name) + 1);
 			hash->nel--;
 			*phi = hi->next;
 			free(hi);
@@ -1364,7 +1364,7 @@
 		regfree(re);
 		regfree(ire);
 	}
-	if (bb_strlen(s) > 1) {
+	if (strlen(s) > 1) {
 		mk_re_node(s, n, re);
 	} else {
 		n->info = (uint32_t) *s;
@@ -1432,7 +1432,7 @@
 	regmatch_t pmatch[2];
 
 	/* in worst case, each char would be a separate field */
-	*slist = s1 = bb_xstrndup(s, bb_strlen(s) * 2 + 3);
+	*slist = s1 = bb_xstrndup(s, strlen(s) * 2 + 3);
 
 	c[0] = c[1] = (char)spl->info;
 	c[2] = c[3] = '\0';
@@ -1527,12 +1527,12 @@
 
 		/* recalculate $0 */
 		sep = getvar_s(V[OFS]);
-		sl = bb_strlen(sep);
+		sl = strlen(sep);
 		b = NULL;
 		len = 0;
 		for (i=0; i<n; i++) {
 			s = getvar_s(&Fields[i]);
-			l = bb_strlen(s);
+			l = strlen(s);
 			if (b) {
 				memcpy(b+len, sep, sl);
 				len += sl;
@@ -1769,7 +1769,7 @@
 
 		} else if (c == 's') {
 		    s1 = getvar_s(arg);
-			qrealloc(&b, incr+i+bb_strlen(s1), &bsize);
+			qrealloc(&b, incr+i+strlen(s1), &bsize);
 			i += sprintf(b+i, s, s1);
 
 		} else {
@@ -1809,7 +1809,7 @@
 
 	i = di = 0;
 	sp = getvar_s(src);
-	rl = bb_strlen(repl);
+	rl = strlen(repl);
 	while (regexec(re, sp, 10, pmatch, sp==getvar_s(src) ? 0:REG_NOTBOL) == 0) {
 		so = pmatch[0].rm_so;
 		eo = pmatch[0].rm_eo;
@@ -1922,7 +1922,7 @@
 		break;
 
 	  case B_ss:
-		l = bb_strlen(as[0]);
+		l = strlen(as[0]);
 		i = getvar_i(av[1]) - 1;
 		if (i>l) i=l; if (i<0) i=0;
 		n = (nargs > 2) ? getvar_i(av[2]) : l-i;
@@ -1950,8 +1950,8 @@
 
 	  case B_ix:
 		n = 0;
-		ll = bb_strlen(as[1]);
-		l = bb_strlen(as[0]) - ll;
+		ll = strlen(as[1]);
+		l = strlen(as[0]) - ll;
 		if (ll > 0 && l >= 0) {
 			if (! icase) {
 				s = strstr(as[0], as[1]);
@@ -2353,7 +2353,7 @@
 			  case F_le:
 				if (! op1)
 					L.s = getvar_s(V[F0]);
-				R.d = bb_strlen(L.s);
+				R.d = strlen(L.s);
 				break;
 
 			  case F_sy:
@@ -2441,12 +2441,12 @@
 		  /* concatenation (" ") and index joining (",") */
 		  case XC( OC_CONCAT ):
 		  case XC( OC_COMMA ):
-			opn = bb_strlen(L.s) + bb_strlen(R.s) + 2;
+			opn = strlen(L.s) + strlen(R.s) + 2;
 			X.s = (char *)xmalloc(opn);
 			strcpy(X.s, L.s);
 			if ((opinfo & OPCLSMASK) == OC_COMMA) {
 				L.s = getvar_s(V[SUBSEP]);
-				X.s = (char *)xrealloc(X.s, opn + bb_strlen(L.s));
+				X.s = (char *)xrealloc(X.s, opn + strlen(L.s));
 				strcat(X.s, L.s);
 			}
 			strcat(X.s, R.s);

Modified: trunk/busybox/include/platform.h
===================================================================
--- trunk/busybox/include/platform.h	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/include/platform.h	2006-05-07 20:20:34 UTC (rev 15023)
@@ -67,11 +67,6 @@
 # endif
 #endif
 
-#ifdef __GNUC__
-#define strlen(x) bb_strlen(x)
-extern size_t bb_strlen(const char *string);
-#endif
-
 /* ---- Endian Detection ------------------------------------ */
 #ifndef __APPLE__
 # include <byteswap.h>

Modified: trunk/busybox/libbb/Makefile.in
===================================================================
--- trunk/busybox/libbb/Makefile.in	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/libbb/Makefile.in	2006-05-07 20:20:34 UTC (rev 15023)
@@ -69,7 +69,7 @@
 LIBBB_MSRC1:=$(srcdir)/xfuncs.c
 LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \
 	xfopen.o xopen.o xopen3.o xread.o xread_all.o xread_char.o \
-	xferror.o xferror_stdout.o xfflush_stdout.o strlen.o
+	xferror.o xferror_stdout.o xfflush_stdout.o
 LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
 $(LIBBB_MOBJ1):$(LIBBB_MSRC1)
 	$(compile.c) -DL_$(notdir $*)
@@ -101,7 +101,7 @@
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC6:=$(srcdir)/llist.c
-LIBBB_MOBJ6:=llist_add_to.o llist_add_to_end.o llist_free_one.o llist_free.o
+LIBBB_MOBJ6:=llist_add_to.o llist_add_to_end.o llist_pop.o llist_free.o
 LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
 $(LIBBB_MOBJ6):$(LIBBB_MSRC6)
 	$(compile.c) -DL_$(notdir $*)

Modified: trunk/busybox/libbb/correct_password.c
===================================================================
--- trunk/busybox/libbb/correct_password.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/libbb/correct_password.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -72,6 +72,6 @@
 		return 0;
 	}
 	encrypted = crypt ( unencrypted, correct );
-	memset ( unencrypted, 0, bb_strlen ( unencrypted ));
+	memset ( unencrypted, 0, strlen ( unencrypted ));
 	return ( strcmp ( encrypted, correct ) == 0 ) ? 1 : 0;
 }

Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/libbb/xfuncs.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -174,15 +174,6 @@
 }
 #endif
 
-// GCC forces inlining of strlen everywhere, which is generally a byte
-// larger than calling a function, and it's called a lot so it adds up.
-#ifdef L_strlen
-size_t bb_strlen(const char *string)
-{
-	    return(__builtin_strlen(string));
-}
-#endif
-
 /* END CODE */
 /*
 Local Variables:

Modified: trunk/busybox/loginutils/login.c
===================================================================
--- trunk/busybox/loginutils/login.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/loginutils/login.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -338,7 +338,7 @@
 
 	if (( fp = fopen ( bb_path_securetty_file, "r" ))) {
 		while ( fgets ( buf, sizeof( buf ) - 1, fp )) {
-			for ( i = bb_strlen( buf ) - 1; i >= 0; --i ) {
+			for ( i = strlen( buf ) - 1; i >= 0; --i ) {
 				if ( !isspace ( buf[i] ))
 					break;
 			}

Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/modutils/modprobe.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -283,7 +283,7 @@
 		if ( p )
 			*p = 0;
 
-		l = bb_strlen ( buffer );
+		l = strlen ( buffer );
 
 		while ( l && isspace ( buffer [l-1] )) {
 			buffer [l-1] = 0;
@@ -399,7 +399,7 @@
 	free(filename);
 
 	while ( reads ( fd, buffer, sizeof( buffer ))) {
-		int l = bb_strlen ( buffer );
+		int l = strlen ( buffer );
 		char *p = 0;
 
 		while ( l > 0 && isspace ( buffer [l-1] )) {

Modified: trunk/busybox/networking/arping.c
===================================================================
--- trunk/busybox/networking/arping.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/networking/arping.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -293,7 +293,7 @@
 		if (opt & 128) /* timeout */
 			timeout = atoi(_timeout);
 		if (opt & 256) { /* interface */
-			if (bb_strlen(_device) > IF_NAMESIZE) {
+			if (strlen(_device) > IF_NAMESIZE) {
 				bb_error_msg_and_die("Interface name `%s' must be less than %d",
 								_device, IF_NAMESIZE);
 			}

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/networking/ifupdown.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -256,7 +256,7 @@
 					varvalue = get_var(command, nextpercent - command, ifd);
 
 					if (varvalue) {
-						addstr(&result, &len, &pos, varvalue, bb_strlen(varvalue));
+						addstr(&result, &len, &pos, varvalue, strlen(varvalue));
 					} else {
 #ifdef CONFIG_FEATURE_IFUPDOWN_IP
 						/* Sigh...  Add a special case for 'ip' to convert from
@@ -267,7 +267,7 @@
 							if (varvalue && (res=count_netmask_bits(varvalue)) > 0) {
 								char argument[255];
 								sprintf(argument, "%d", res);
-								addstr(&result, &len, &pos, argument, bb_strlen(argument));
+								addstr(&result, &len, &pos, argument, strlen(argument));
 								command = nextpercent + 1;
 								break;
 							}
@@ -763,7 +763,7 @@
 					{
 						int i;
 
-						if (bb_strlen(buf_ptr) == 0) {
+						if (strlen(buf_ptr) == 0) {
 							bb_error_msg("option with empty value \"%s\"", buf);
 							return NULL;
 						}
@@ -845,7 +845,7 @@
 	char *here;
 	char *there;
 
-	result = xmalloc(bb_strlen(format) + bb_strlen(name) + bb_strlen(value) + 1);
+	result = xmalloc(strlen(format) + strlen(name) + strlen(value) + 1);
 
 	sprintf(result, format, name, value);
 
@@ -860,7 +860,7 @@
 			here++;
 		}
 	}
-	memmove(here, there, bb_strlen(there) + 1);
+	memmove(here, there, strlen(there) + 1);
 
 	return result;
 }
@@ -1061,7 +1061,7 @@
 			/* If we are able to read a line of output from the script,
 			 * remove any trailing whitespace and use this value
 			 * as the name of the logical interface. */
-			char *pch = new_logical + bb_strlen(new_logical) - 1;
+			char *pch = new_logical + strlen(new_logical) - 1;
 
 			while (pch >= new_logical && isspace(*pch))
 				*(pch--) = '\0';
@@ -1083,7 +1083,7 @@
 
 static llist_t *find_iface_state(llist_t *state_list, const char *iface)
 {
-	unsigned short iface_len = bb_strlen(iface);
+	unsigned short iface_len = strlen(iface);
 	llist_t *search = state_list;
 
 	while (search) {
@@ -1308,7 +1308,7 @@
 			llist_t *iface_state = find_iface_state(state_list, iface);
 
 			if (cmds == iface_up) {
-				char *newiface = xmalloc(bb_strlen(iface) + 1 + bb_strlen(liface) + 1);
+				char *newiface = xmalloc(strlen(iface) + 1 + strlen(liface) + 1);
 				sprintf(newiface, "%s=%s", iface, liface);
 				if (iface_state == NULL) {
 					state_list = llist_add_to_end(state_list, newiface);

Modified: trunk/busybox/procps/sysctl.c
===================================================================
--- trunk/busybox/procps/sysctl.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/procps/sysctl.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -146,7 +146,7 @@
 		if (*ptr == '#' || *ptr == ';')
 			continue;
 
-		if (bb_strlen(ptr) < 2)
+		if (strlen(ptr) < 2)
 			continue;
 
 		name = strtok(ptr, "=");
@@ -323,7 +323,7 @@
 					sysctl_display_all(tmpdir, output, show_table);
 				} else
 					retval |=
-						sysctl_read_setting(tmpdir + bb_strlen(PROC_PATH),
+						sysctl_read_setting(tmpdir + strlen(PROC_PATH),
 											output);
 
 			}

Modified: trunk/busybox/util-linux/hwclock.c
===================================================================
--- trunk/busybox/util-linux/hwclock.c	2006-05-07 19:26:53 UTC (rev 15022)
+++ trunk/busybox/util-linux/hwclock.c	2006-05-07 20:20:34 UTC (rev 15023)
@@ -109,7 +109,7 @@
 
 	safe_strncpy ( buffer, ctime ( &t ), 64);
 	if ( buffer [0] )
-		buffer [bb_strlen ( buffer ) - 1] = 0;
+		buffer [strlen ( buffer ) - 1] = 0;
 
 	//printf ( "%s  %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] ));
 	printf ( "%s  %.6f seconds\n", buffer, 0.0 );
@@ -157,7 +157,7 @@
 		RESERVE_CONFIG_BUFFER(buffer, 128);
 
 		while ( fgets ( buffer, sizeof( buffer ), f )) {
-			int len = bb_strlen ( buffer );
+			int len = strlen ( buffer );
 
 			while ( len && isspace ( buffer [len - 1] ))
 				len--;




More information about the busybox-cvs mailing list