summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcmp.c
blob: 82284546f653551d8ae00c1e33111d5c82b8175d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extern void abort (void);
extern int inside_main;

__attribute__ ((__noinline__))
int
strcmp (const char *s1, const char *s2)
{
#ifdef __OPTIMIZE__
  if (inside_main)
    abort ();
#endif

  while (*s1 != 0 && *s1 == *s2)
    s1++, s2++;

  if (*s1 == 0 || *s2 == 0)
    return (unsigned char) *s1 - (unsigned char) *s2;
  return *s1 - *s2;
}