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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-or32/] [string.h] - Rev 1777

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

#ifndef _OR32_STRING_H_
#define _OR32_STRING_H_
 
#include <linux/config.h>
#include <asm/page.h>
 
#define  __HAVE_ARCH_MEMSET
extern inline void * memset(void * s,int c,__kernel_size_t count)
{
	char *xs = (char *) s;
 
	while (count--)
		*xs++ = c;
 
	return s;
}
#define __HAVE_ARCH_STRSTR
/* Return the first occurrence of NEEDLE in HAYSTACK.  */
extern inline char *
strstr(const char *haystack, const char *needle)
{
  const char *const needle_end = strchr(needle, '\0');
  const char *const haystack_end = strchr(haystack, '\0');
  const size_t needle_len = needle_end - needle;
  const size_t needle_last = needle_len - 1;
  const char *begin;
 
  if (needle_len == 0)
#ifdef __linux__
    return (char *) haystack;
#else
    return (char *) haystack_end;
#endif
  if ((size_t) (haystack_end - haystack) < needle_len)
    return NULL;
 
  for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
    {
      register const char *n = &needle[needle_last];
      register const char *h = begin;
 
      do
	if (*h != *n)
	  goto loop;		/* continue for loop */
      while (--n >= needle && --h >= haystack);
 
      return (char *) h;
 
    loop:;
    }
 
  return NULL;
}
 
#endif /* _OR32_STRING_H_ */
 

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

powered by: WebSVN 2.1.0

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