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

Subversion Repositories or1k

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

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

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

powered by: WebSVN 2.1.0

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