sparc: refactor sparc64 __mpn_addmul_1 selector to C
[glibc.git] / wcsmbs / wmemcmp.c
blobee0724cf2b4c795c41c62b789d867019fcdda495
1 /* Copyright (C) 1996-2017 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, see
17 <http://www.gnu.org/licenses/>. */
19 #include <wchar.h>
21 #ifndef WMEMCMP
22 # define WMEMCMP wmemcmp
23 #endif
25 int
26 WMEMCMP (const wchar_t *s1, const wchar_t *s2, size_t n)
28 wchar_t c1;
29 wchar_t c2;
31 while (n >= 4)
33 c1 = s1[0];
34 c2 = s2[0];
35 if (c1 - c2 != 0)
36 return c1 > c2 ? 1 : -1;
37 c1 = s1[1];
38 c2 = s2[1];
39 if (c1 - c2 != 0)
40 return c1 > c2 ? 1 : -1;
41 c1 = s1[2];
42 c2 = s2[2];
43 if (c1 - c2 != 0)
44 return c1 > c2 ? 1 : -1;
45 c1 = s1[3];
46 c2 = s2[3];
47 if (c1 - c2 != 0)
48 return c1 > c2 ? 1 : -1;
49 s1 += 4;
50 s2 += 4;
51 n -= 4;
54 if (n > 0)
56 c1 = s1[0];
57 c2 = s2[0];
58 if (c1 - c2 != 0)
59 return c1 > c2 ? 1 : -1;
60 ++s1;
61 ++s2;
62 --n;
64 if (n > 0)
66 c1 = s1[0];
67 c2 = s2[0];
68 if (c1 - c2 != 0)
69 return c1 > c2 ? 1 : -1;
70 ++s1;
71 ++s2;
72 --n;
74 if (n > 0)
76 c1 = s1[0];
77 c2 = s2[0];
78 if (c1 - c2 != 0)
79 return c1 > c2 ? 1 : -1;
82 return 0;