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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [mempcpy-2.c] - Blame information for rev 825

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

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Ensure that builtin mempcpy and stpcpy perform correctly.
4
 
5
   Written by Jakub Jelinek, 21/05/2003.  */
6
 
7
extern void abort (void);
8
typedef __SIZE_TYPE__ size_t;
9
extern void *mempcpy (void *, const void *, size_t);
10
extern int memcmp (const void *, const void *, size_t);
11
extern int inside_main;
12
 
13
long buf1[64];
14
char *buf2 = (char *) (buf1 + 32);
15
long buf5[20];
16
char buf7[20];
17
 
18
void
19
__attribute__((noinline))
20
test (long *buf3, char *buf4, char *buf6, int n)
21
{
22
  int i = 0;
23
 
24
  /* These should probably be handled by store_by_pieces on most arches.  */
25
  if (mempcpy (buf1, "ABCDEFGHI", 9) != (char *) buf1 + 9
26
      || memcmp (buf1, "ABCDEFGHI\0", 11))
27
    abort ();
28
 
29
  if (mempcpy (buf1, "abcdefghijklmnopq", 17) != (char *) buf1 + 17
30
      || memcmp (buf1, "abcdefghijklmnopq\0", 19))
31
    abort ();
32
 
33
  if (__builtin_mempcpy (buf3, "ABCDEF", 6) != (char *) buf1 + 6
34
      || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
35
    abort ();
36
 
37
  if (__builtin_mempcpy (buf3, "a", 1) != (char *) buf1 + 1
38
      || memcmp (buf1, "aBCDEFghijklmnopq\0", 19))
39
    abort ();
40
 
41
  if (mempcpy ((char *) buf3 + 2, "bcd" + ++i, 2) != (char *) buf1 + 4
42
      || memcmp (buf1, "aBcdEFghijklmnopq\0", 19)
43
      || i != 1)
44
    abort ();
45
 
46
  /* These should probably be handled by move_by_pieces on most arches.  */
47
  if (mempcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 10
48
      || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
49
    abort ();
50
 
51
  if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)
52
      != (char *) buf1 + 11
53
      || memcmp (buf1, "aBcdRSTUVWSlmnopq\0", 19)
54
      || i != 2)
55
    abort ();
56
 
57
  if (mempcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 16
58
      || memcmp (buf1, "aBcdRSTUVWSlmnrsq\0", 19))
59
    abort ();
60
 
61
  if (mempcpy (buf3, buf5, 8) != (char *) buf1 + 8
62
      || memcmp (buf1, "RSTUVWXYVWSlmnrsq\0", 19))
63
    abort ();
64
 
65
  if (mempcpy (buf3, buf5, 17) != (char *) buf1 + 17
66
      || memcmp (buf1, "RSTUVWXYZ01234567\0", 19))
67
    abort ();
68
 
69
  __builtin_memcpy (buf3, "aBcdEFghijklmnopq\0", 19);
70
 
71
  /* These should be handled either by movmemendM or mempcpy
72
     call.  */
73
  if (mempcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 10
74
      || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
75
    abort ();
76
 
77
  if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, n + 1)
78
      != (char *) buf1 + 12
79
      || memcmp (buf1, "aBcdRSTUVWkSmnopq\0", 19)
80
      || i != 3)
81
    abort ();
82
 
83
  if (mempcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 16
84
      || memcmp (buf1, "aBcdRSTUVWkSmnrsq\0", 19))
85
    abort ();
86
 
87
  i = 1;
88
 
89
  /* These might be handled by store_by_pieces.  */
90
  if (mempcpy (buf2, "ABCDEFGHI", 9) != buf2 + 9
91
      || memcmp (buf2, "ABCDEFGHI\0", 11))
92
    abort ();
93
 
94
  if (mempcpy (buf2, "abcdefghijklmnopq", 17) != buf2 + 17
95
      || memcmp (buf2, "abcdefghijklmnopq\0", 19))
96
    abort ();
97
 
98
  if (__builtin_mempcpy (buf4, "ABCDEF", 6) != buf2 + 6
99
      || memcmp (buf2, "ABCDEFghijklmnopq\0", 19))
100
    abort ();
101
 
102
  if (__builtin_mempcpy (buf4, "a", 1) != buf2 + 1
103
      || memcmp (buf2, "aBCDEFghijklmnopq\0", 19))
104
    abort ();
105
 
106
  if (mempcpy (buf4 + 2, "bcd" + i++, 2) != buf2 + 4
107
      || memcmp (buf2, "aBcdEFghijklmnopq\0", 19)
108
      || i != 2)
109
    abort ();
110
 
111
  /* These might be handled by move_by_pieces.  */
112
  if (mempcpy (buf4 + 4, buf7, 6) != buf2 + 10
113
      || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
114
    abort ();
115
 
116
  if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, 1)
117
      != buf2 + 11
118
      || memcmp (buf2, "aBcdRSTUVWSlmnopq\0", 19)
119
      || i != 3)
120
    abort ();
121
 
122
  if (mempcpy (buf4 + 14, buf6, 2) != buf2 + 16
123
      || memcmp (buf2, "aBcdRSTUVWSlmnrsq\0", 19))
124
    abort ();
125
 
126
  __builtin_memcpy (buf4, "aBcdEFghijklmnopq\0", 19);
127
 
128
  /* These should be handled either by movmemendM or mempcpy
129
     call.  */
130
  if (mempcpy (buf4 + 4, buf7, n + 6) != buf2 + 10
131
      || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
132
    abort ();
133
 
134
  if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, n + 1)
135
      != buf2 + 12
136
      || memcmp (buf2, "aBcdRSTUVWkSmnopq\0", 19)
137
      || i != 4)
138
    abort ();
139
 
140
  if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16
141
      || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19))
142
    abort ();
143
}
144
 
145
void
146
main_test (void)
147
{
148
  /* All these tests are allowed to call mempcpy/stpcpy.  */
149
  inside_main = 0;
150
  __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
151
  __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
152
  test (buf1, buf2, "rstuvwxyz", 0);
153
}

powered by: WebSVN 2.1.0

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