This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ColdFire 60/63] Tweak the memset() builtin tests
Some ColdFire start-up routines use memset() to clear bss. This caused
a failure in the builtins testsuite because the memset() replacement
checks the bss inside_main variable before doing anything (i.e. when
inside_main is still uninitialised).
The simplest fix is to do the memset() regardless of whether
inside_main is set, then abort afterwards if appropriate.
The memops-asm-lib.c part makes the same change in the
copying code for consistency.
Richard
200x-xx-xx Nathan Sidwell <nathan@codesourcery.com>
gcc/testsuite/
* gcc.c-torture/execute/builtins/memops-asm-lib.c: Do the copy or
set before checking whether it was allowed.
* gcc.c-torture/execute/builtins/lib/memset.c: Do the memset
before checking inside_main.
Index: gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c 2007-01-09 13:18:10.000000000 +0000
+++ gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c 2007-01-09 15:02:32.000000000 +0000
@@ -51,27 +51,29 @@ my_bzero (void *d, size_t n)
void *
memcpy (void *d, const void *s, size_t n)
{
+ void *result = my_memcpy (d, s, n);
TEST_ABORT;
- return my_memcpy (d, s, n);
+ return result;
}
void
bcopy (const void *s, void *d, size_t n)
{
- TEST_ABORT;
my_bcopy (s, d, n);
+ TEST_ABORT;
}
void *
memset (void *d, int c, size_t n)
{
+ void *result = my_memset (d, c, n);
TEST_ABORT;
- return my_memset (d, c, n);
+ return result;
}
void
bzero (void *d, size_t n)
{
- TEST_ABORT;
my_bzero (d, n);
+ TEST_ABORT;
}
Index: gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c 2007-01-09 13:18:10.000000000 +0000
+++ gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c 2007-01-09 15:02:32.000000000 +0000
@@ -4,15 +4,16 @@ extern void abort (void);
void *
memset (void *dst, int c, __SIZE_TYPE__ n)
{
+ while (n-- != 0)
+ n[(char *) dst] = c;
+
/* Single-byte memsets should be done inline when optimisation
- is enabled. */
+ is enabled. Do this after the copy in case we're being called to
+ initialize bss. */
#ifdef __OPTIMIZE__
if (inside_main && n < 2)
abort ();
#endif
- while (n-- != 0)
- n[(char *) dst] = c;
-
return dst;
}