summaryrefslogtreecommitdiffstats
path: root/newlib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/string/local.h15
-rw-r--r--newlib/libc/string/memmove.c2
-rw-r--r--newlib/libc/string/memset.c2
3 files changed, 19 insertions, 0 deletions
diff --git a/newlib/libc/string/local.h b/newlib/libc/string/local.h
index 5d17dccc4..dfe01d70b 100644
--- a/newlib/libc/string/local.h
+++ b/newlib/libc/string/local.h
@@ -7,3 +7,18 @@ int _EXFUN (__wcwidth, (wint_t));
/* Defined in locale/locale.c. Returns a value != 0 if the current
language is assumed to use CJK fonts. */
int __locale_cjk_lang ();
+
+/*
+ Taken from glibc:
+ Add the compiler optimization to inhibit loop transformation to library
+ calls. This is used to avoid recursive calls in memset and memmove
+ default implementations.
+*/
+#ifdef _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
+# define __inhibit_loop_to_libcall \
+ __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
+#else
+# define __inhibit_loop_to_libcall
+#endif
+
+
diff --git a/newlib/libc/string/memmove.c b/newlib/libc/string/memmove.c
index b03bb3821..a037c7c2f 100644
--- a/newlib/libc/string/memmove.c
+++ b/newlib/libc/string/memmove.c
@@ -39,6 +39,7 @@ QUICKREF
#include <_ansi.h>
#include <stddef.h>
#include <limits.h>
+#include "local.h"
/* Nonzero if either X or Y is not aligned on a "long" boundary. */
#define UNALIGNED(X, Y) \
@@ -55,6 +56,7 @@ QUICKREF
/*SUPPRESS 20*/
_PTR
+__inhibit_loop_to_libcall
_DEFUN (memmove, (dst_void, src_void, length),
_PTR dst_void _AND
_CONST _PTR src_void _AND
diff --git a/newlib/libc/string/memset.c b/newlib/libc/string/memset.c
index 55d2ce180..ee91b056e 100644
--- a/newlib/libc/string/memset.c
+++ b/newlib/libc/string/memset.c
@@ -34,12 +34,14 @@ QUICKREF
*/
#include <string.h>
+#include "local.h"
#define LBLOCKSIZE (sizeof(long))
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
_PTR
+__inhibit_loop_to_libcall
_DEFUN (memset, (m, c, n),
_PTR m _AND
int c _AND