2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / string-asm-1-lib.c
bloba0318212e6714d072466b58c2e34a191034b3776
1 extern int inside_main;
2 extern const char *p;
4 char *
5 my_strstr (const char *s1, const char *s2)
7 __SIZE_TYPE__ len = strlen (s2);
9 #ifdef __OPTIMIZE__
10 /* If optimizing, we should be called only in the strstr (foo + 2, p)
11 case. All other cases should be optimized. */
12 if (inside_main)
13 if (s2 != p || strcmp (s1, "hello world" + 2) != 0)
14 abort ();
15 #endif
16 if (len == 0)
17 return (char *) s1;
18 for (s1 = strchr (s1, *s2); s1; s1 = strchr (s1 + 1, *s2))
19 if (strncmp (s1, s2, len) == 0)
20 return (char *) s1;
21 return (char *) 0;
24 char *
25 strstr (const char *s1, const char *s2)
27 if (inside_main)
28 abort ();
30 return my_strstr (s1, s2);