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

Subversion Repositories or1k

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

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

Rev 39 Rev 56
Line 68... Line 68...
_DEFUN (strncpy, (dst0, src0),
_DEFUN (strncpy, (dst0, src0),
        char *dst0 _AND
        char *dst0 _AND
        _CONST char *src0 _AND
        _CONST char *src0 _AND
        size_t count)
        size_t count)
{
{
#ifdef PREFER_SIZE_OVER_SPEED
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
  char *dscan;
  char *dscan;
  _CONST char *sscan;
  _CONST char *sscan;
 
 
  dscan = dst0;
  dscan = dst0;
  sscan = src0;
  sscan = src0;
Line 90... Line 90...
  char *dst = dst0;
  char *dst = dst0;
  _CONST char *src = src0;
  _CONST char *src = src0;
  long *aligned_dst;
  long *aligned_dst;
  _CONST long *aligned_src;
  _CONST long *aligned_src;
 
 
  /* If SRC or DEST is unaligned, then copy bytes.  */
  /* If SRC and DEST is aligned and count large enough, then copy words.  */
  if (TOO_SMALL (count) || UNALIGNED (src, dst))
  if (!UNALIGNED (src, dst) && !TOO_SMALL (count))
    {
    {
      while (count > 0)
 
        {
 
          --count;
 
          if ((*dst++ = *src++) == '\0')
 
            break;
 
        }
 
 
 
      while (count -- > 0)
 
        *dst++ = '\0';
 
 
 
      return dst0;
 
    }
 
 
 
  aligned_dst = (long*)dst;
  aligned_dst = (long*)dst;
  aligned_src = (long*)src;
  aligned_src = (long*)src;
 
 
  /* SRC and DEST are both "long int" aligned, try to do "long int"
  /* SRC and DEST are both "long int" aligned, try to do "long int"
     sized copies.  */
     sized copies.  */
Line 119... Line 106...
      *aligned_dst++ = *aligned_src++;
      *aligned_dst++ = *aligned_src++;
    }
    }
 
 
  dst = (char*)aligned_dst;
  dst = (char*)aligned_dst;
  src = (char*)aligned_src;
  src = (char*)aligned_src;
 
    }
 
 
  while (count > 0)
  while (count > 0)
    {
    {
      --count;
      --count;
      if ((*dst++ = *src++) == '\0')
      if ((*dst++ = *src++) == '\0')

powered by: WebSVN 2.1.0

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