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

Subversion Repositories or1k

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

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

Rev 39 Rev 56
Line 60... Line 60...
int
int
_DEFUN (strcmp, (s1, s2),
_DEFUN (strcmp, (s1, s2),
        _CONST char *s1 _AND
        _CONST char *s1 _AND
        _CONST char *s2)
        _CONST char *s2)
{
{
#ifdef PREFER_SIZE_OVER_SPEED
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
  while (*s1 != '\0' && *s1 == *s2)
  while (*s1 != '\0' && *s1 == *s2)
    {
    {
      s1++;
      s1++;
      s2++;
      s2++;
    }
    }
Line 73... Line 73...
#else
#else
  unsigned long *a1;
  unsigned long *a1;
  unsigned long *a2;
  unsigned long *a2;
 
 
  /* If s1 or s2 are unaligned, then compare bytes. */
  /* If s1 or s2 are unaligned, then compare bytes. */
  if (UNALIGNED (s1, s2))
  if (!UNALIGNED (s1, s2))
    {
    {
      while (*s1 != '\0' && *s1 == *s2)
 
        {
 
          s1++;
 
          s2++;
 
        }
 
      return (*(unsigned char *) s1) - (*(unsigned char *) s2);
 
    }
 
 
 
  /* If s1 and s2 are word-aligned, compare them a word at a time. */
  /* If s1 and s2 are word-aligned, compare them a word at a time. */
  a1 = (unsigned long*)s1;
  a1 = (unsigned long*)s1;
  a2 = (unsigned long*)s2;
  a2 = (unsigned long*)s2;
  while (*a1 == *a2)
  while (*a1 == *a2)
    {
    {
Line 100... Line 92...
    }
    }
 
 
  /* A difference was detected in last few bytes of s1, so search bytewise */
  /* A difference was detected in last few bytes of s1, so search bytewise */
  s1 = (char*)a1;
  s1 = (char*)a1;
  s2 = (char*)a2;
  s2 = (char*)a2;
 
    }
 
 
  while (*s1 != '\0' && *s1 == *s2)
  while (*s1 != '\0' && *s1 == *s2)
    {
    {
      s1++;
      s1++;
      s2++;
      s2++;

powered by: WebSVN 2.1.0

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