svn commit: branches/busybox_1_1_stable: include libbb
aldot at busybox.net
aldot at busybox.net
Fri May 19 10:43:33 UTC 2006
Author: aldot
Date: 2006-05-19 03:43:32 -0700 (Fri, 19 May 2006)
New Revision: 15111
Log:
- make sure not to trip enless loops when using strlen in IMA mode.
(r15000 from trunk plus preprocessor fixes plus
repair of commit message)
Modified:
branches/busybox_1_1_stable/include/libbb.h
branches/busybox_1_1_stable/include/platform.h
branches/busybox_1_1_stable/libbb/xfuncs.c
Changeset:
Modified: branches/busybox_1_1_stable/include/libbb.h
===================================================================
--- branches/busybox_1_1_stable/include/libbb.h 2006-05-19 10:15:47 UTC (rev 15110)
+++ branches/busybox_1_1_stable/include/libbb.h 2006-05-19 10:43:32 UTC (rev 15111)
@@ -387,12 +387,6 @@
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
-/* Stupid gcc always includes its own builtin strlen()... */
-extern size_t bb_strlen(const char *string);
-#ifndef BB_STRLEN_IMPLEMENTATION
-#define strlen(x) bb_strlen(x)
-#endif
-
char *bb_xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
#define FAIL_DELAY 3
Modified: branches/busybox_1_1_stable/include/platform.h
===================================================================
--- branches/busybox_1_1_stable/include/platform.h 2006-05-19 10:15:47 UTC (rev 15110)
+++ branches/busybox_1_1_stable/include/platform.h 2006-05-19 10:43:32 UTC (rev 15111)
@@ -32,17 +32,6 @@
# endif
#endif
-#if 0
-/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
-#ifndef ATTRIBUTE_MALLOC
-# if __GNUC_PREREQ (2,96)
-# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-# else
-# define ATTRIBUTE_MALLOC
-# endif /* GNUC >= 2.96 */
-#endif /* ATTRIBUTE_MALLOC */
-#endif
-
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif /* ATTRIBUTE_UNUSED */
@@ -78,25 +67,30 @@
# 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>
- #include <endian.h>
+# include <byteswap.h>
+# include <endian.h>
#endif
#ifdef __BIG_ENDIAN__
- #define BB_BIG_ENDIAN 1
+# define BB_BIG_ENDIAN 1
#elif __BYTE_ORDER == __BIG_ENDIAN
- #define BB_BIG_ENDIAN 1
+# define BB_BIG_ENDIAN 1
#else
- #define BB_BIG_ENDIAN 0
+# define BB_BIG_ENDIAN 0
#endif
/* ---- Networking ------------------------------------------ */
#ifndef __APPLE__
-#include <arpa/inet.h>
+# include <arpa/inet.h>
#else
-#include <netinet/in.h>
+# include <netinet/in.h>
#endif
/* ---- miscellaneous --------------------------------------- */
Modified: branches/busybox_1_1_stable/libbb/xfuncs.c
===================================================================
--- branches/busybox_1_1_stable/libbb/xfuncs.c 2006-05-19 10:15:47 UTC (rev 15110)
+++ branches/busybox_1_1_stable/libbb/xfuncs.c 2006-05-19 10:43:32 UTC (rev 15111)
@@ -14,16 +14,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
-
-/* Since gcc always inlines strlen(), this saves a byte or two, but we need
- * the #undef here to avoid endless loop from #define strlen bb_strlen */
-#ifdef L_strlen
-#define BB_STRLEN_IMPLEMENTATION
-#endif
-
#include "libbb.h"
-
#ifndef DMALLOC
#ifdef L_xmalloc
void *xmalloc(size_t size)
@@ -175,10 +167,13 @@
}
#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(strlen(string));
+ return(__builtin_strlen(string));
}
#endif
More information about the busybox-cvs
mailing list