Linux/ARM implementation of pread.
[glibc.git] / wcsmbs / wmemcmp.c
blobd8d7e3952a7ec72de528a4f5621e756f062a3ad0
1 /* Copyright (C) 1996, 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <wchar.h>
23 int
24 wmemcmp (s1, s2, n)
25 const wchar_t *s1;
26 const wchar_t *s2;
27 size_t n;
29 register wint_t c1;
30 register wint_t c2;
32 while (n >= 4)
34 c1 = (wint_t) s1[0];
35 c2 = (wint_t) s2[0];
36 if (c1 - c2 != 0)
37 return c1 - c2;
38 c1 = (wint_t) s1[1];
39 c2 = (wint_t) s2[1];
40 if (c1 - c2 != 0)
41 return c1 - c2;
42 c1 = (wint_t) s1[2];
43 c2 = (wint_t) s2[2];
44 if (c1 - c2 != 0)
45 return c1 - c2;
46 c1 = (wint_t) s1[3];
47 c2 = (wint_t) s2[3];
48 if (c1 - c2 != 0)
49 return c1 - c2;
50 s1 += 4;
51 s2 += 4;
52 n -= 4;
55 if (n > 0)
57 c1 = (wint_t) s1[0];
58 c2 = (wint_t) s2[0];
59 if (c1 - c2 != 0)
60 return c1 - c2;
61 ++s1;
62 ++s2;
63 --n;
65 if (n > 0)
67 c1 = (wint_t) s1[0];
68 c2 = (wint_t) s2[0];
69 if (c1 - c2 != 0)
70 return c1 - c2;
71 ++s1;
72 ++s2;
73 --n;
75 if (n > 0)
77 c1 = (wint_t) s1[0];
78 c2 = (wint_t) s2[0];
79 if (c1 - c2 != 0)
80 return c1 - c2;
83 return 0;