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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [strstr-asm-lib.c] - Blame information for rev 297

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

Line No. Rev Author Line
1 297 jeremybenn
extern void abort (void);
2
typedef __SIZE_TYPE__ size_t;
3
extern size_t strlen(const char *);
4
extern char *strchr(const char *, int);
5
extern int strcmp(const char *, const char *);
6
extern int strncmp(const char *, const char *, size_t);
7
extern int inside_main;
8
extern const char *p;
9
 
10
char *
11
my_strstr (const char *s1, const char *s2)
12
{
13
  const size_t len = strlen (s2);
14
 
15
#ifdef __OPTIMIZE__
16
  /* If optimizing, we should be called only in the strstr (foo + 2, p)
17
     case.  All other cases should be optimized.  */
18
  if (inside_main)
19
    if (s2 != p || strcmp (s1, "hello world" + 2) != 0)
20
      abort ();
21
#endif
22
  if (len == 0)
23
    return (char *) s1;
24
  for (s1 = strchr (s1, *s2); s1; s1 = strchr (s1 + 1, *s2))
25
    if (strncmp (s1, s2, len) == 0)
26
      return (char *) s1;
27
  return (char *) 0;
28
}
29
 
30
char *
31
strstr (const char *s1, const char *s2)
32
{
33
  if (inside_main)
34
    abort ();
35
 
36
  return my_strstr (s1, s2);
37
}

powered by: WebSVN 2.1.0

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