Fix lost wmemcmp symbol
[glibc.git] / wcsmbs / wmemcmp.c
blob73c6394f8edf3f6e44dd6f75c1bea7a8d79d63f3
1 /* Copyright (C) 1996, 1997, 2011 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <wchar.h>
22 #ifndef WMEMCMP
23 # define WMEMCMP wmemcmp
24 #endif
26 int
27 WMEMCMP (s1, s2, n)
28 const wchar_t *s1;
29 const wchar_t *s2;
30 size_t n;
32 register wint_t c1;
33 register wint_t c2;
35 while (n >= 4)
37 c1 = (wint_t) s1[0];
38 c2 = (wint_t) s2[0];
39 if (c1 - c2 != 0)
40 return c1 > c2 ? 1 : -1;
41 c1 = (wint_t) s1[1];
42 c2 = (wint_t) s2[1];
43 if (c1 - c2 != 0)
44 return c1 > c2 ? 1 : -1;
45 c1 = (wint_t) s1[2];
46 c2 = (wint_t) s2[2];
47 if (c1 - c2 != 0)
48 return c1 > c2 ? 1 : -1;
49 c1 = (wint_t) s1[3];
50 c2 = (wint_t) s2[3];
51 if (c1 - c2 != 0)
52 return c1 > c2 ? 1 : -1;
53 s1 += 4;
54 s2 += 4;
55 n -= 4;
58 if (n > 0)
60 c1 = (wint_t) s1[0];
61 c2 = (wint_t) s2[0];
62 if (c1 - c2 != 0)
63 return c1 > c2 ? 1 : -1;
64 ++s1;
65 ++s2;
66 --n;
68 if (n > 0)
70 c1 = (wint_t) s1[0];
71 c2 = (wint_t) s2[0];
72 if (c1 - c2 != 0)
73 return c1 > c2 ? 1 : -1;
74 ++s1;
75 ++s2;
76 --n;
78 if (n > 0)
80 c1 = (wint_t) s1[0];
81 c2 = (wint_t) s2[0];
82 if (c1 - c2 != 0)
83 return c1 > c2 ? 1 : -1;
86 return 0;