~ubuntu-branches/ubuntu/dapper/gnats/dapper

« back to all changes in this revision

Viewing changes to libiberty/memcmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Chad Walstrom
  • Date: 2005-03-07 17:56:31 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050307175631-agtm10dvjbemuc64
Tags: 4.1.0-0
* New upstream version
* debian/rules: now uses '--with-lispdir' option instead of environment
  variable overloading. Re-enabled optimization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* memcmp -- compare two memory regions.
2
 
   This function is in the public domain.  */
3
 
 
4
 
/*
5
 
NAME
6
 
        memcmp -- compare two memory regions
7
 
 
8
 
SYNOPSIS
9
 
        int memcmp (const void *from, const void *to, size_t count)
10
 
 
11
 
DESCRIPTION
12
 
        Compare two memory regions and return less than,
13
 
        equal to, or greater than zero, according to lexicographical
14
 
        ordering of the compared regions.
15
 
*/
16
 
 
17
 
#include <ansidecl.h>
18
 
#ifdef __STDC__
19
 
#include <stddef.h>
20
 
#else
21
 
#define size_t unsigned long
22
 
#endif
23
 
 
24
 
int
25
 
DEFUN(memcmp, (str1, str2, count),
26
 
      const PTR str1 AND const PTR str2 AND size_t count)
27
 
{
28
 
  register const unsigned char *s1 = (const unsigned char*)str1;
29
 
  register const unsigned char *s2 = (const unsigned char*)str2;
30
 
 
31
 
  while (count-- > 0)
32
 
    {
33
 
      if (*s1++ != *s2++)
34
 
          return s1[-1] < s2[-1] ? -1 : 1;
35
 
    }
36
 
  return 0;
37
 
}
38