This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: Improve x86-64 bcopy/bzero


> +#define TEST_BCOPY
> +#define TEST_MAIN
> +#include "test-string.h"
> +
> +typedef void (*proto_t) (const char *, char *, size_t);
> +void simple_bcopy (const char *, char *, size_t);
> +
> +IMPL (simple_bcopy, 0)
> +IMPL (bcopy, 1)
> +
> +void
> +simple_bcopy (const char *src, char *dst, size_t n)
> +{
> +  if (src < dst)
> +    {
> +      dst += n;
> +      src += n;
> +      while (n--)
> +	*--dst = *--src;
> +    }
> +  else
> +    while (n--)
> +      *dst++ = *src++;
> +}
> +
> +#include "test-memmove.c"

Since test-memmove.c has #ifdef TEST_BCOPY logic in it anyway,
I think it's better to just make test-bcopy.c be:

	#define TEST_BCOPY
	#include "test-memmove.c"

Then it also becomes straightforward for test-memmove.c to do:

	void
	simple_bcopy (const char *src, char *dst, size_t n)
	{
	  simple_memmove (dst, src, n);
	}

and not repeat the actual implementation.

Likewise for test-bzero.c and simple_bzero/simple_memset.

The rest looks OK.


Thanks,
Roland


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