summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-lib.c
blob: 44032357405618e9f7c9c3e9954ba8575e3b1788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern void abort (void);

void *
memcpy (void *dst, const void *src, __SIZE_TYPE__ n)
{
  const char *srcp;
  char *dstp;

  srcp = src;
  dstp = dst;

  if (dst < src)
    {
      if (dst + n > src)
	abort ();
    }
  else
    {
      if (src + n > dst)
	abort ();
    }

  while (n-- != 0)
    *dstp++ = *srcp++;

  return dst;
}