This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add builtin memmove and bcopy


Two more nits:

+  /* New argument list transforming bcopy(ptr x, ptr y, int z) to
+     memmove(ptr y, ptr x, size_t z).   This is done this way
+     so that if it isn't expanded inline, we fallback to
+     calling bzero instead of memset.  */

Cut & paste error, the comment should not reference bzero or memset.



And in the testcase:

+#ifdef __OPTIMIZE__
+__attribute__ ((noinline))
+static void *
+memmove (void *d, const void *s, size_t n)
+{
+  abort ();
+}
+
+__attribute__ ((noinline))
+static void
+bcopy (const void *s, void *d, size_t n)
+{
+  abort ();
+}
+#endif


Although most platforms have bcopy and especially memmove if they're
ISO C, some don't have them and will spuriously fail this testcase at
-O0 when they don't expand the builtins and instead expect to call the
functions.

Since you're testing behavior when src and dst don't overlap, I
suggest you instead make both functions have a body which calls memcpy
or abort.  E.g.:


__attribute__ ((noinline))
static void *
memmove (void *d, const void *s, size_t n)
{
#ifdef __OPTIMIZE__
  abort ();
#else
  return memcpy (d, s, n);
#endif
}


and similarly for bcopy.

		--Kaveh
--
Kaveh R. Ghazi			ghazi at caip dot rutgers dot edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]