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

Subversion Repositories or1k_old

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

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

Rev 39 Rev 56
Line 55... Line 55...
 
 
size_t
size_t
_DEFUN (strlen, (str),
_DEFUN (strlen, (str),
        _CONST char *str)
        _CONST char *str)
{
{
#ifdef PREFER_SIZE_OVER_SPEED
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
  _CONST char *start = str;
  _CONST char *start = str;
 
 
  while (*str)
  while (*str)
    str++;
    str++;
 
 
  return str - start;
  return str - start;
#else
#else
  _CONST char *start = str;
  _CONST char *start = str;
  unsigned long *aligned_addr;
  unsigned long *aligned_addr;
 
 
  if (UNALIGNED (str))
  if (!UNALIGNED (str))
    {
    {
      while (*str)
 
        str++;
 
      return str - start;
 
    }
 
 
 
  /* If the string is word-aligned, we can check for the presence of
  /* If the string is word-aligned, we can check for the presence of
     a null in each word-sized block.  */
     a null in each word-sized block.  */
  aligned_addr = (unsigned long*)str;
  aligned_addr = (unsigned long*)str;
  while (!DETECTNULL (*aligned_addr))
  while (!DETECTNULL (*aligned_addr))
    aligned_addr++;
    aligned_addr++;
 
 
  /* Once a null is detected, we check each byte in that block for a
  /* Once a null is detected, we check each byte in that block for a
     precise position of the null.  */
     precise position of the null.  */
  str = (char*)aligned_addr;
  str = (char*)aligned_addr;
 
    }
 
 
  while (*str)
  while (*str)
    str++;
    str++;
  return str - start;
  return str - start;
#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.