OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [string/] [memset.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 43... Line 43...
_DEFUN (memset, (m, c, n),
_DEFUN (memset, (m, c, n),
        _PTR m _AND
        _PTR m _AND
        int c _AND
        int c _AND
        size_t n)
        size_t n)
{
{
#ifdef PREFER_SIZE_OVER_SPEED
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
  char *s = (char *) m;
  char *s = (char *) m;
 
 
  while (n-- != 0)
  while (n-- != 0)
    {
    {
      *s++ = (char) c;
      *s++ = (char) c;
Line 59... Line 59...
  int count, i;
  int count, i;
  unsigned long buffer;
  unsigned long buffer;
  unsigned long *aligned_addr;
  unsigned long *aligned_addr;
  unsigned char *unaligned_addr;
  unsigned char *unaligned_addr;
 
 
  if (TOO_SMALL (n) || UNALIGNED (m))
  if (!TOO_SMALL (n) && !UNALIGNED (m))
    {
    {
      while (n-- != 0)
 
        {
 
          *s++ = (char) c;
 
        }
 
      return m;
 
    }
 
 
 
  /* If we get this far, we know that n is large and m is word-aligned. */
  /* If we get this far, we know that n is large and m is word-aligned. */
 
 
  aligned_addr = (unsigned long*)m;
  aligned_addr = (unsigned long*)m;
 
 
  /* Store C into each char sized location in BUFFER so that
  /* Store C into each char sized location in BUFFER so that
Line 101... Line 94...
  while (n >= LBLOCKSIZE)
  while (n >= LBLOCKSIZE)
    {
    {
      *aligned_addr++ = buffer;
      *aligned_addr++ = buffer;
      n -= LBLOCKSIZE;
      n -= LBLOCKSIZE;
    }
    }
 
 
  /* Pick up the remainder with a bytewise loop.  */
  /* Pick up the remainder with a bytewise loop.  */
  unaligned_addr = (unsigned char*)aligned_addr;
      s = (char*)aligned_addr;
  while (n)
    }
 
 
 
  while (n--)
    {
    {
      *unaligned_addr++ = (char)c;
      *s++ = (char)c;
      n--;
 
    }
    }
 
 
  return m;
  return m;
#endif /* not PREFER_SIZE_OVER_SPEED */
#endif /* not PREFER_SIZE_OVER_SPEED */
}
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.