libdl: first execute all destructors, then munmap library
[uclibc-ng.git] / libc / string / strncmp.c
blob2da61771c61e4a5516026735237a200994f55018
1 /*
2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 #include "_string.h"
10 #ifdef WANT_WIDE
11 # define Wstrncmp wcsncmp
12 #else
13 # define Wstrncmp strncmp
14 #endif
16 int Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n)
18 #ifdef WANT_WIDE
19 while (n && (*((Wuchar *)s1) == *((Wuchar *)s2))) {
20 if (!*s1++) {
21 return 0;
23 ++s2;
24 --n;
27 return (n == 0) ? 0 : (*((Wuchar *)s1) - *((Wuchar *)s2));
28 #else
29 int r = 0;
31 while (n--
32 && ((r = ((int)(*((unsigned char *)s1))) - *((unsigned char *)s2++))
33 == 0)
34 && *s1++);
36 return r;
37 #endif
39 #ifndef WANT_WIDE
40 libc_hidden_weak(strncmp)
41 #endif