OSDN Git Service

Moving libc_hidden_proto's into #ifdef UCLIBC_INTERNAL block
[uclinux-h8/uClibc.git] / libc / string / memrchr.c
1 /*
2  * Copyright (C) 2002     Manuel Novoa III
3  * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4  *
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7
8 #include "_string.h"
9
10 #ifdef __USE_GNU
11
12 /* Experimentally off - libc_hidden_proto(memrchr) */
13
14 void *memrchr(const void *s, int c, size_t n)
15 {
16         register const unsigned char *r;
17 #ifdef __BCC__
18         /* bcc can optimize the counter if it thinks it is a pointer... */
19         register const char *np = (const char *) n;
20 #else
21 #define np n
22 #endif
23         
24         r = ((unsigned char *)s) + ((size_t) np);
25
26         while (np) {
27                 if (*--r == ((unsigned char)c)) {
28                         return (void *) r;      /* silence the warning */
29                 }
30                 --np;
31         }
32
33         return NULL;
34 }
35 #undef np
36
37 libc_hidden_def(memrchr)
38 #endif