]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/demangle/lib/src/memcmp.c
Inital import
[l4.git] / l4 / pkg / demangle / lib / src / memcmp.c
1 /* 
2  * Mach Operating System
3  * Copyright (c) 1992,1991,1990,1989 Carnegie Mellon University
4  * All Rights Reserved.
5  * 
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  * 
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  * 
16  * Carnegie Mellon requests users of this software to return to
17  * 
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  * 
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  */
26 /*
27  * File:        limach/memcmp.c
28  * Author:      Robert V. Baron at Carnegie Mellon
29  * Date:        Oct 13, 1992
30  * Abstract:
31  *      strcmp (s1, s2) compares the strings "s1" and "s2".
32  *      It returns 0 if the strings are identical. It returns
33  *      > 0 if the first character that differs into two strings
34  *      is larger in s1 than in s2 or if s1 is longer than s2 and 
35  *      the contents  are identical up to the length of s2.
36  *      It returns < 0 if the first differing character is smaller 
37  *      in s1 than in s2 or if s1 is shorter than s2 and the
38  *      contents are identical upto the length of s1.
39  */
40
41 #include <stddef.h>
42
43 int memcmp(const void *s1v, const void *s2v, size_t size);
44
45 int
46 memcmp(const void *s1v, const void *s2v, size_t size)
47 {
48         register const char *s1 = s1v, *s2 = s2v;
49         register unsigned int a, b;
50
51         while (size-- > 0) {
52                 if ((a = *s1++) != (b = *s2++))
53                         return (a-b);
54         }
55
56         return 0;
57 }