2 memset-3.c from the execute part of the gcc torture tests.
9 /* Copyright (C) 2002 Free Software Foundation.
11 Test memset with various combinations of constant pointer alignments and
12 lengths to make sure any optimizations in the compiler are correct.
14 Written by Roger Sayle, July 22, 2002. */
17 #define MAX_OFFSET (sizeof (long long))
25 #define MAX_EXTRA (sizeof (long long))
28 #define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
30 #if 0 // TODO: Enable when SDC supports long double!
43 for (i
= 0; i
< MAX_LENGTH
; i
++)
47 void check (int off
, int len
, int ch
)
53 for (i
= 0; i
< off
; i
++, q
++)
57 for (i
= 0; i
< len
; i
++, q
++)
61 for (i
= 0; i
< MAX_EXTRA
; i
++, q
++)
67 testTortureExecute (void)
74 for (len
= 0; len
< MAX_COPY
; len
++)
78 p
= memset (u
.buf
, '\0', len
);
79 if (p
!= u
.buf
) ASSERT (0);
82 p
= memset (u
.buf
, A
, len
);
83 if (p
!= u
.buf
) ASSERT (0);
86 p
= memset (u
.buf
, 'B', len
);
87 if (p
!= u
.buf
) ASSERT (0);
92 for (len
= 0; len
< MAX_COPY
; len
++)
96 p
= memset (u
.buf
+1, '\0', len
);
97 if (p
!= u
.buf
+1) ASSERT (0);
100 p
= memset (u
.buf
+1, A
, len
);
101 if (p
!= u
.buf
+1) ASSERT (0);
104 p
= memset (u
.buf
+1, 'B', len
);
105 if (p
!= u
.buf
+1) ASSERT (0);
110 for (len
= 0; len
< MAX_COPY
; len
++)
114 p
= memset (u
.buf
+2, '\0', len
);
115 if (p
!= u
.buf
+2) ASSERT (0);
116 check (2, len
, '\0');
118 p
= memset (u
.buf
+2, A
, len
);
119 if (p
!= u
.buf
+2) ASSERT (0);
122 p
= memset (u
.buf
+2, 'B', len
);
123 if (p
!= u
.buf
+2) ASSERT (0);
128 for (len
= 0; len
< MAX_COPY
; len
++)
132 p
= memset (u
.buf
+3, '\0', len
);
133 if (p
!= u
.buf
+3) ASSERT (0);
134 check (3, len
, '\0');
136 p
= memset (u
.buf
+3, A
, len
);
137 if (p
!= u
.buf
+3) ASSERT (0);
140 p
= memset (u
.buf
+3, 'B', len
);
141 if (p
!= u
.buf
+3) ASSERT (0);
146 for (len
= 0; len
< MAX_COPY
; len
++)
150 p
= memset (u
.buf
+4, '\0', len
);
151 if (p
!= u
.buf
+4) ASSERT (0);
152 check (4, len
, '\0');
154 p
= memset (u
.buf
+4, A
, len
);
155 if (p
!= u
.buf
+4) ASSERT (0);
158 p
= memset (u
.buf
+4, 'B', len
);
159 if (p
!= u
.buf
+4) ASSERT (0);
164 for (len
= 0; len
< MAX_COPY
; len
++)
168 p
= memset (u
.buf
+5, '\0', len
);
169 if (p
!= u
.buf
+5) ASSERT (0);
170 check (5, len
, '\0');
172 p
= memset (u
.buf
+5, A
, len
);
173 if (p
!= u
.buf
+5) ASSERT (0);
176 p
= memset (u
.buf
+5, 'B', len
);
177 if (p
!= u
.buf
+5) ASSERT (0);
182 for (len
= 0; len
< MAX_COPY
; len
++)
186 p
= memset (u
.buf
+6, '\0', len
);
187 if (p
!= u
.buf
+6) ASSERT (0);
188 check (6, len
, '\0');
190 p
= memset (u
.buf
+6, A
, len
);
191 if (p
!= u
.buf
+6) ASSERT (0);
194 p
= memset (u
.buf
+6, 'B', len
);
195 if (p
!= u
.buf
+6) ASSERT (0);
200 for (len
= 0; len
< MAX_COPY
; len
++)
204 p
= memset (u
.buf
+7, '\0', len
);
205 if (p
!= u
.buf
+7) ASSERT (0);
206 check (7, len
, '\0');
208 p
= memset (u
.buf
+7, A
, len
);
209 if (p
!= u
.buf
+7) ASSERT (0);
212 p
= memset (u
.buf
+7, 'B', len
);
213 if (p
!= u
.buf
+7) ASSERT (0);