1 // Derived from test case from the memory model study group of SC22 WG14
2 // For this test, behaviour is defined in the PNVI-ae-udi memory model.
5 Original test copyright (c) 2012-2016 David Chisnall, Kayvan Memarian, and Peter Sewell.
7 Permission to use, copy, modify, and/or distribute this software for
8 any purpose with or without fee is hereby granted, provided that the
9 above copyright notice and this permission notice appear in all
12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
22 // Adapted for SDCC by Philipp Klaus Krause in 2020.
30 unsigned char control_flow_copy(unsigned char c
) {
132 case 100: return(100);
133 case 101: return(101);
134 case 102: return(102);
135 case 103: return(103);
136 case 104: return(104);
137 case 105: return(105);
138 case 106: return(106);
139 case 107: return(107);
140 case 108: return(108);
141 case 109: return(109);
142 case 110: return(110);
143 case 111: return(111);
144 case 112: return(112);
145 case 113: return(113);
146 case 114: return(114);
147 case 115: return(115);
148 case 116: return(116);
149 case 117: return(117);
150 case 118: return(118);
151 case 119: return(119);
152 case 120: return(120);
153 case 121: return(121);
154 case 122: return(122);
155 case 123: return(123);
156 case 124: return(124);
157 case 125: return(125);
158 case 126: return(126);
159 case 127: return(127);
160 case 128: return(128);
161 case 129: return(129);
162 case 130: return(130);
163 case 131: return(131);
164 case 132: return(132);
165 case 133: return(133);
166 case 134: return(134);
167 case 135: return(135);
168 case 136: return(136);
169 case 137: return(137);
170 case 138: return(138);
171 case 139: return(139);
172 case 140: return(140);
173 case 141: return(141);
174 case 142: return(142);
175 case 143: return(143);
176 case 144: return(144);
177 case 145: return(145);
178 case 146: return(146);
179 case 147: return(147);
180 case 148: return(148);
181 case 149: return(149);
182 case 150: return(150);
183 case 151: return(151);
184 case 152: return(152);
185 case 153: return(153);
186 case 154: return(154);
187 case 155: return(155);
188 case 156: return(156);
189 case 157: return(157);
190 case 158: return(158);
191 case 159: return(159);
192 case 160: return(160);
193 case 161: return(161);
194 case 162: return(162);
195 case 163: return(163);
196 case 164: return(164);
197 case 165: return(165);
198 case 166: return(166);
199 case 167: return(167);
200 case 168: return(168);
201 case 169: return(169);
202 case 170: return(170);
203 case 171: return(171);
204 case 172: return(172);
205 case 173: return(173);
206 case 174: return(174);
207 case 175: return(175);
208 case 176: return(176);
209 case 177: return(177);
210 case 178: return(178);
211 case 179: return(179);
212 case 180: return(180);
213 case 181: return(181);
214 case 182: return(182);
215 case 183: return(183);
216 case 184: return(184);
217 case 185: return(185);
218 case 186: return(186);
219 case 187: return(187);
220 case 188: return(188);
221 case 189: return(189);
222 case 190: return(190);
223 case 191: return(191);
224 case 192: return(192);
225 case 193: return(193);
226 case 194: return(194);
227 case 195: return(195);
228 case 196: return(196);
229 case 197: return(197);
230 case 198: return(198);
231 case 199: return(199);
232 case 200: return(200);
233 case 201: return(201);
234 case 202: return(202);
235 case 203: return(203);
236 case 204: return(204);
237 case 205: return(205);
238 case 206: return(206);
239 case 207: return(207);
240 case 208: return(208);
241 case 209: return(209);
242 case 210: return(210);
243 case 211: return(211);
244 case 212: return(212);
245 case 213: return(213);
246 case 214: return(214);
247 case 215: return(215);
248 case 216: return(216);
249 case 217: return(217);
250 case 218: return(218);
251 case 219: return(219);
252 case 220: return(220);
253 case 221: return(221);
254 case 222: return(222);
255 case 223: return(223);
256 case 224: return(224);
257 case 225: return(225);
258 case 226: return(226);
259 case 227: return(227);
260 case 228: return(228);
261 case 229: return(229);
262 case 230: return(230);
263 case 231: return(231);
264 case 232: return(232);
265 case 233: return(233);
266 case 234: return(234);
267 case 235: return(235);
268 case 236: return(236);
269 case 237: return(237);
270 case 238: return(238);
271 case 239: return(239);
272 case 240: return(240);
273 case 241: return(241);
274 case 242: return(242);
275 case 243: return(243);
276 case 244: return(244);
277 case 245: return(245);
278 case 246: return(246);
279 case 247: return(247);
280 case 248: return(248);
281 case 249: return(249);
282 case 250: return(250);
283 case 251: return(251);
284 case 252: return(252);
285 case 253: return(253);
286 case 254: return(254);
287 case 255: return(255);
291 void user_memcpy2(unsigned char* dest
,
292 unsigned char *src
, size_t n
) {
294 *dest
= control_flow_copy(*src
);
306 user_memcpy2((unsigned char*)&q
, (unsigned char*)&p
,
308 if (UCHAR_MAX
==255) {
309 *q
= 11; // does this have undefined behaviour?