diff -Naur newlib-2.0.0.orig/newlib/libc/string/memmove.c newlib-2.0.0/newlib/libc/string/memmove.c --- newlib-2.0.0.orig/newlib/libc/string/memmove.c 2010-09-22 05:15:07.000000000 +0200 +++ newlib-2.0.0/newlib/libc/string/memmove.c 2013-12-08 05:17:00.450248311 +0100 @@ -40,6 +40,22 @@ #include #include +/* hack because currently I don't want to fiddle with autoconf */ +#define HAVE_CC_INHIBIT_LOOP_TO_LIBCALL + +/* + 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 + /* Nonzero if either X or Y is not aligned on a "long" boundary. */ #define UNALIGNED(X, Y) \ (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) @@ -55,6 +71,7 @@ /*SUPPRESS 20*/ _PTR +inhibit_loop_to_libcall _DEFUN (memmove, (dst_void, src_void, length), _PTR dst_void _AND _CONST _PTR src_void _AND diff -Naur newlib-2.0.0.orig/newlib/libc/string/memset.c newlib-2.0.0/newlib/libc/string/memset.c --- newlib-2.0.0.orig/newlib/libc/string/memset.c 2008-05-27 20:44:40.000000000 +0200 +++ newlib-2.0.0/newlib/libc/string/memset.c 2013-12-08 05:16:27.830247253 +0100 @@ -35,11 +35,28 @@ #include +/* hack because currently I don't want to fiddle with autoconf */ +#define HAVE_CC_INHIBIT_LOOP_TO_LIBCALL + +/* + 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 + #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