aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/xfuncs.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 8ec1a24c0..9f0c85b03 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -387,7 +387,9 @@ 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)));
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 69eaf79e0..6d54c1a79 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -14,6 +14,13 @@
#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"
@@ -167,9 +174,6 @@ extern void bb_xfflush_stdout(void)
#endif
#ifdef L_strlen
-/* 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 */
-#undef strlen
size_t bb_strlen(const char *string)
{
return(strlen(string));