view gcc/testsuite/gcc.c-torture/execute/builtins/lib/memcmp.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

extern void abort(void);
extern int inside_main;

__attribute__ ((__noinline__))
int
memcmp (const void *s1, const void *s2, __SIZE_TYPE__ len)
{
  const unsigned char *sp1, *sp2;

#ifdef __OPTIMIZE__
  if (inside_main)
    abort ();
#endif

  sp1 = s1;
  sp2 = s2;
  while (len != 0 && *sp1 == *sp2)
    sp1++, sp2++, len--;

  if (len == 0)
    return 0;
  return *sp1 - *sp2;
}