OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-or32/] [string.h] - Blame information for rev 1633

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _OR32_STRING_H_
2
#define _OR32_STRING_H_
3
 
4
#include <linux/config.h>
5
#include <asm/page.h>
6
 
7
#define  __HAVE_ARCH_MEMSET
8
extern inline void * memset(void * s,int c,__kernel_size_t count)
9
{
10
        char *xs = (char *) s;
11
 
12
        while (count--)
13
                *xs++ = c;
14
 
15
        return s;
16
}
17
#define __HAVE_ARCH_STRSTR
18
/* Return the first occurrence of NEEDLE in HAYSTACK.  */
19
extern inline char *
20
strstr(const char *haystack, const char *needle)
21
{
22
  const char *const needle_end = strchr(needle, '\0');
23
  const char *const haystack_end = strchr(haystack, '\0');
24
  const size_t needle_len = needle_end - needle;
25
  const size_t needle_last = needle_len - 1;
26
  const char *begin;
27
 
28
  if (needle_len == 0)
29
#ifdef __linux__
30
    return (char *) haystack;
31
#else
32
    return (char *) haystack_end;
33
#endif
34
  if ((size_t) (haystack_end - haystack) < needle_len)
35
    return NULL;
36
 
37
  for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
38
    {
39
      register const char *n = &needle[needle_last];
40
      register const char *h = begin;
41
 
42
      do
43
        if (*h != *n)
44
          goto loop;            /* continue for loop */
45
      while (--n >= needle && --h >= haystack);
46
 
47
      return (char *) h;
48
 
49
    loop:;
50
    }
51
 
52
  return NULL;
53
}
54
 
55
#endif /* _OR32_STRING_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.