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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [memmove.c] - Blame information for rev 774

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

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2003, 2004  Free Software Foundation.
2
 
3
   Ensure builtin memmove and bcopy perform correctly.
4
 
5
   Written by Jakub Jelinek, 4/26/2003.  */
6
 
7
extern void abort (void);
8
typedef __SIZE_TYPE__ size_t;
9
extern void *memmove (void *, const void *, size_t);
10
extern void bcopy (const void *, void *, size_t);
11
extern int memcmp (const void *, const void *, size_t);
12
 
13
const char s1[] = "123";
14
char p[32] = "";
15
 
16
static const struct foo
17
{
18
  char *s;
19
  double d;
20
  long l;
21
} foo[] =
22
{
23
  { "hello world1", 3.14159, 101L },
24
  { "hello world2", 3.14159, 102L },
25
  { "hello world3", 3.14159, 103L },
26
  { "hello world4", 3.14159, 104L },
27
  { "hello world5", 3.14159, 105L },
28
  { "hello world6", 3.14159, 106L }
29
};
30
 
31
static const struct bar
32
{
33
  char *s;
34
  const struct foo f[3];
35
} bar[] =
36
{
37
  {
38
    "hello world10",
39
    {
40
      { "hello1", 3.14159, 201L },
41
      { "hello2", 3.14159, 202L },
42
      { "hello3", 3.14159, 203L },
43
    }
44
  },
45
  {
46
    "hello world11",
47
    {
48
      { "hello4", 3.14159, 204L },
49
      { "hello5", 3.14159, 205L },
50
      { "hello6", 3.14159, 206L },
51
    }
52
  }
53
};
54
 
55
static const int baz[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
56
 
57
void
58
main_test (void)
59
{
60
  const char *s;
61
  struct foo f1[sizeof foo/sizeof*foo];
62
  struct bar b1[sizeof bar/sizeof*bar];
63
  int bz[sizeof baz/sizeof*baz];
64
 
65
  if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))
66
    abort ();
67
  if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))
68
    abort ();
69
  bcopy (baz, bz, sizeof (baz));
70
  if (memcmp (bz, baz, sizeof (baz)))
71
    abort ();
72
 
73
  if (memmove (p, "abcde", 6) != p || memcmp (p, "abcde", 6))
74
    abort ();
75
  s = s1;
76
  if (memmove (p + 2, ++s, 0) != p + 2 || memcmp (p, "abcde", 6) || s != s1 + 1)
77
    abort ();
78
  if (__builtin_memmove (p + 3, "", 1) != p + 3 || memcmp (p, "abc\0e", 6))
79
    abort ();
80
  bcopy ("fghijk", p + 2, 4);
81
  if (memcmp (p, "abfghi", 7))
82
    abort ();
83
  s = s1 + 1;
84
  bcopy (s++, p + 1, 0);
85
  if (memcmp (p, "abfghi", 7) || s != s1 + 2)
86
    abort ();
87
  __builtin_bcopy ("ABCDE", p + 4, 1);
88
  if (memcmp (p, "abfgAi", 7))
89
    abort ();
90
}

powered by: WebSVN 2.1.0

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