memcpy performance

Joel Sherrill
Tue Dec 9 08:57:00 GMT 1997

On Tue, 9 Dec 1997, Jonathan Larmour wrote:

> Joel Sherrill wrote:
> > 
> > An RTEMS user has noticed that the performance of the RTEMS message
> > queue routines is bound by our use of newlib's memcpy routine.  The
> > current implementation uses a byte-by-byte copy.
> > 
> > What would it take to get a better generic implementation?  Is there one
> > laying around which could be used instead?  I remember the old GNU/960
> > version did some alignment and then copied 16-bytes at a time.
> The current newlib implementation has this already in
> libc/string/memcpy.c
> et al. There is a #define PREFER_SIZE_OVER_SPEED which will use the
> byte-by-byte copy if it is defined, otherwise it will use the 16-byte at
> a time one.
> Perhaps he has PREFER_SIZE_OVER_SPEED set?

I do not have this implementation.  I see this simple body. :)

_DEFUN (memcpy, (out, in, length),
        _PTR out _AND
        _CONST _PTR in _AND
        size_t length)
  char *dst = (char *) out;
  char *src = (char *) in;

  _PTR save = out;

  while (length--)
      *dst++ = *src++;

  return save;

Perhaps this is different in current newlib snapshots but I do not have
access to them.


More information about the Newlib mailing list