]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/bcopytest.c
xnu-344.21.74.tar.gz
[apple/xnu.git] / osfmk / ppc / bcopytest.c
CommitLineData
d7e50217
A
1#include <cpus.h>
2#include <debug.h>
3#include <mach_kgdb.h>
4#include <mach_vm_debug.h>
5#include <db_machine_commands.h>
6
7#include <kern/thread.h>
8#include <kern/thread_act.h>
9#include <mach/vm_attributes.h>
10#include <mach/vm_param.h>
11#include <vm/vm_kern.h>
12#include <vm/vm_map.h>
13#include <vm/vm_page.h>
14#include <kern/spl.h>
15
16#include <kern/misc_protos.h>
17#include <ppc/exception.h>
18#include <ppc/misc_protos.h>
19#include <ppc/proc_reg.h>
20
21#include <vm/pmap.h>
22#include <ppc/pmap.h>
23#include <ppc/mem.h>
24
25#include <ppc/new_screen.h>
26#include <ppc/Firmware.h>
27#include <ppc/mappings.h>
28#include <ddb/db_output.h>
29
30#include <ppc/POWERMAC/video_console.h> /* (TEST/DEBUG) */
31
32#define patper 253
33
34
35int main(void);
36void clrarea(unsigned int *source, unsigned int *sink);
37int tstcopy(void *src, void *snk, unsigned int lgn);
38void clrarea2(unsigned int *source, unsigned int *sink);
39int tstcopy2(void *src, void *snk, unsigned int lgn);
40int tstcopy3(void *src, void *snk, unsigned int lgn);
41int tstcopy4(void *src, void *snk, unsigned int lgn);
42int tstcopy5(void *src, void *snk, unsigned int lgn);
43int dumbcopy(void *src, void *snk, unsigned int lgn);
44
45
46unsigned int gtick(void);
47
48
49void bcopytest(void);
50void bcopytest(void) {
51
52 void *srcptr, *snkptr, *asrc, *asnk;
53 int bsrc, bsnk, size, iterations, i, ret, n;
54 unsigned int makerand, timein, timeout, ticks;
55 volatile int dbg = 0;
56 unsigned int *sink, *source;
57
58 long long tottime, totbytes;
59 long long tottime2, totbytes2;
60
61 kern_return_t retr;
62
63 db_printf("bcopy test\n");
64
65 retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&sink, (1024*1024)+4096); /* Get sink area */
66 if(retr != KERN_SUCCESS) { /* Did we find any memory at all? */
67 panic("bcopytest: Whoops... no memory for sink\n");
68 }
69
70 retr = kmem_alloc_wired(kernel_map, (vm_offset_t *)&source, (1024*1024)+4096); /* Get source area */
71 if(retr != KERN_SUCCESS) { /* Did we find any memory at all? */
72 panic("bcopytest: Whoops... no memory for source\n");
73 }
74
75 db_printf("Source at %08X; Sink at %08X\n", source, sink);
76
77 srcptr = (void *)&source[0];
78 snkptr = (void *)&sink[0];
79
80#if 1
81 db_printf("Testing non-overlap case; source bndry = 0 to 7F; sink bndry = 0 - 7F; lgn = 1 to 256\n");
82 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step the source by 1 */
83 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step the sink by 1 */
84 for(size = 1; size <= 256; size++) { /* Step the size by 1 */
85
86 clrarea(source, sink); /* Reset source and clear sink */
87 if(size == 255) {
88 dbg = 99;
89 }
90 if(tstcopy((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)snkptr + bsnk), size)) {
91 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
92 db_printf("failed\n");
93 }
94 }
95 }
96 }
97 db_printf("Non-overlap test complete\n");
98#endif
99
100
101#if 1
102 db_printf("Testing overlap\n");
103 for(bsrc = 1; bsrc < 128; bsrc++) { /* Step the source by 1 */
104 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step the sink by 1 */
105 for(size = 1; size <= 256; size++) { /* Step the size by 1 */
106
107 clrarea2(source, sink); /* Reset source and clear sink */
108 if(bsrc < bsnk) {
109 dbg = 88;
110 }
111 else {
112 dbg = 99;
113 }
114 if(tstcopy2((void *)((unsigned int)srcptr + bsrc), (void *)((unsigned int)srcptr + bsnk), size)) {
115 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
116 db_printf("failed\n");
117 }
118 }
119 }
120 }
121 db_printf("Overlap test complete\n");
122#endif
123
124#if 1
125 db_printf("Starting exhaustive tests\n");
126 for(i = 0; i < 262144 * 4; i++) { /* Set all 1MB of source and dest to known pattern */
127 ((unsigned char *)srcptr)[i] = i % patper; /* Make a non-power-of-two length pattern */
128 ((unsigned char *)snkptr)[i] = i % patper; /* Make a non-power-of-two length pattern */
129 }
130
131 db_printf("No overlap; source < sink, length = 0 to 1023\nSource =");
132
133#if 1
134 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
135 db_printf(" %3d", bsrc); /* Show where we're at */
136 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
137 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
138 asrc = (void *)((unsigned int)srcptr + bsrc); /* Start byte address */
139 asnk = (void *)((unsigned int)srcptr + bsnk + 2048); /* End byte address */
140 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
141 if(ret) {
142 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
143 db_printf("failed\n");
144 }
145 }
146 }
147 }
148#endif
149
150 db_printf("\n");
151 db_printf("No overlap; source > sink, length = 0 to 1023\nSource =");
152
153#if 1
154 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
155 db_printf(" %3d", bsrc); /* Show where we're at */
156 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
157 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
158 asrc = (void *)((unsigned int)srcptr + bsrc + 2048); /* Start byte address */
159 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
160 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
161 if(ret) {
162 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
163 db_printf("failed\n");
164 }
165 }
166 }
167 }
168#endif
169
170 db_printf("\n");
171 db_printf("Overlap; source = sink + N (N = 0 to 127), length = 0 to 1023\nN =");
172
173#if 1
174 for(n = 0; n < 128; n++) { /* Step n by 1 */
175 db_printf(" %3d", n); /* Show where we're at */
176 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
177 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
178 asrc = (void *)((unsigned int)srcptr + bsnk + n); /* Start byte address */
179 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
180 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
181 if(ret) {
182 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
183 db_printf("failed\n");
184 }
185 }
186 }
187 }
188#endif
189
190 db_printf("\n");
191 db_printf("Overlap; source + N = sink (N = 0 to 127), length = 0 to 1023\nSource =");
192
193#if 1
194 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
195 db_printf(" %3d", bsrc); /* Show where we're at */
196 for(n = 0; n < 128; n++) { /* Step N by 1 */
197 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
198 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
199 asnk = (void *)((unsigned int)srcptr + bsnk + n); /* End byte address */
200 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
201 if(ret) {
202 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
203 db_printf("failed\n");
204 }
205 }
206 }
207 }
208#endif
209
210
211 db_printf("\n");
212 db_printf("Overlap; source = sink + N + 128 (N = 0 to 127), length = 0 to 1023\nN =");
213
214#if 1
215 for(n = 0; n < 128; n++) { /* Step n by 1 */
216 db_printf(" %3d", n); /* Show where we're at */
217 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
218 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
219 asrc = (void *)((unsigned int)srcptr + bsnk + n + 128); /* Start byte address */
220 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
221 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
222 if(ret) {
223 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
224 db_printf("failed\n");
225 }
226 }
227 }
228 }
229#endif
230
231 db_printf("\n");
232 db_printf("Overlap; source + N + 128 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
233
234#if 1
235 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
236 db_printf(" %3d", bsrc); /* Show where we're at */
237 for(n = 0; n < 128; n++) { /* Step N by 1 */
238 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
239 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
240 asnk = (void *)((unsigned int)srcptr + bsnk + n + 128); /* End byte address */
241 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
242 if(ret) {
243 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
244 db_printf("failed\n");
245 }
246 }
247 }
248 }
249#endif
250
251 db_printf("\n");
252 db_printf("Overlap; source = sink + N + 256 (N = 0 to 127), length = 0 to 1023\nSource =");
253
254#if 1
255 for(n = 0; n < 128; n++) { /* Step n by 1 */
256 db_printf(" %3d", n); /* Show where we're at */
257 for(bsnk = 0; bsnk < 128; bsnk++) { /* Step sink by 1 */
258 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
259 asrc = (void *)((unsigned int)srcptr + bsnk + n + 256); /* Start byte address */
260 asnk = (void *)((unsigned int)srcptr + bsnk); /* End byte address */
261 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
262 if(ret) {
263 db_printf("\nTest failed - source = %3d, sink = %3d size = %d\n", bsrc, bsnk, size);
264 db_printf("failed\n");
265 }
266 }
267 }
268 }
269#endif
270
271 db_printf("\n");
272 db_printf("Overlap; source + N + 256 = sink (N = 0 to 127), length = 0 to 1023\nSource =");
273#if 1
274 for(bsrc = 0; bsrc < 128; bsrc++) { /* Step source by 1 */
275 db_printf(" %3d", bsrc); /* Show where we're at */
276 for(n = 0; n < 128; n++) { /* Step N by 1 */
277 for(size = 0; size < 1025; size++) { /* Step size from 0 to 1023 */
278 asrc = (void *)((unsigned int)srcptr + bsnk); /* Start byte address */
279 asnk = (void *)((unsigned int)srcptr + bsnk + n + 256); /* End byte address */
280 ret = tstcopy5(asrc, asnk, size); /* Copy and validate */
281 if(ret) {
282 db_printf("\nTest failed - source = %3d, n = %3d size = %d\n", bsrc, n, size);
283 db_printf("failed\n");
284 }
285 }
286 }
287 }
288#endif
289
290
291
292
293
294
295#endif
296
297#if 0
298 iterations = 1000;
299 tottime = 0;
300 totbytes = 0;
301
302 db_printf("Random test starting; iterations = %d\n", iterations);
303 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
304 ((unsigned char *)srcptr)[i] = i & 255;
305 }
306
307 for(i = 0; i < iterations; i++) { /* Test until we are done */
308 makerand = rand() << 16 | (rand() & 0x0000FFFF);
309 bsrc = makerand & 0x0007FFFF; /* Generate source */
310 makerand = rand() << 16 | (rand() & 0x0000FFFF);
311 bsnk = makerand & 0x0007FFFF; /* Generate sink */
312 makerand = rand() << 16 | (rand() & 0x0000FFFF);
313 size = makerand & 0x0007FFFF; /* Generate length */
314#if 1
315 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
316 ((unsigned int)srcptr + bsnk), size);
317#endif
318
319 asrc = (void *)((unsigned int)srcptr + bsrc);
320 asnk = (void *)((unsigned int)srcptr + bsnk);
321 timein = gtick();
322 ret = tstcopy3(asrc, asnk, size);
323 timeout = gtick();
324 if(ret) {
325 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
326 db_printf("failed\n");
327
328 }
329 ticks = timeout - timein; /* Get time in ticks for copy */
330 tottime += ticks;
331 totbytes += size;
332
333 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
334// rate = rate * (double)11250000.0; /* Bytes per second */
335// rate = rate * (double)16500000.0; /* Bytes per second */
336 rate = rate * (double)tbfreq; /* Bytes per second */
337 rate = rate / (double)1000000.0; /* Get number of MBs */
338
339 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
340
341 }
342#endif
343
344
345
346#if 0
347 iterations = 100;
348 tottime = 0;
349 totbytes = 0;
350
351 db_printf("Random test starting; iterations = %d\n", iterations);
352 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
353 ((unsigned char *)srcptr)[i] = i & 255;
354 }
355
356 for(i = 0; i < iterations; i++) { /* Test until we are done */
357 makerand = rand() << 16 | (rand() & 0x0000FFFF);
358 bsrc = makerand & 0x0007FFFF; /* Generate source */
359 makerand = rand() << 16 | (rand() & 0x0000FFFF);
360 bsnk = makerand & 0x0007FFFF; /* Generate sink */
361 makerand = rand() << 16 | (rand() & 0x0000FFFF);
362 size = makerand & 0x0007FFFF; /* Generate length */
363#if 1
364 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
365 ((unsigned int)srcptr + bsnk), size);
366#endif
367
368 asrc = (void *)((unsigned int)srcptr + bsrc);
369 asnk = (void *)((unsigned int)srcptr + bsnk);
370 timein = gtick();
371 ret = tstcopy4(asrc, asnk, size);
372 timeout = gtick();
373 if(ret) {
374 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
375 db_printf("failed\n");
376
377 }
378 ticks = timeout - timein; /* Get time in ticks for copy */
379 tottime += ticks;
380 totbytes += size;
381
382 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
383// rate = rate * (double)11250000.0; /* Bytes per second */
384// rate = rate * (double)16500000.0; /* Bytes per second */
385 rate = rate * (double)tbfreq; /* Bytes per second */
386 rate = rate / (double)1000000.0; /* Get number of MBs */
387
388 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
389
390 }
391#endif
392
393#if 0
394 iterations = 100;
395 tottime = 0;
396 totbytes = 0;
397
398 db_printf("Random test starting; iterations = %d\n", iterations);
399 for(i = 0; i < 262144 * 4; i++) { /* Clear all 2MB of source (and dest for this test) */
400 ((unsigned char *)srcptr)[i] = i & 255;
401 }
402
403 for(i = 0; i < iterations; i++) { /* Test until we are done */
404 makerand = rand() << 16 | (rand() & 0x0000FFFF);
405 bsrc = makerand & 0x0007FFFF; /* Generate source */
406 makerand = rand() << 16 | (rand() & 0x0000FFFF);
407 bsnk = makerand & 0x0007FFFF; /* Generate sink */
408 makerand = rand() << 16 | (rand() & 0x0000FFFF);
409 size = makerand & 0x0007FFFF; /* Generate length */
410#if 1
411 db_printf("rt %7d: src = %08X; sink = %08X; length = %7d\n", i, ((unsigned int)srcptr + bsrc),
412 ((unsigned int)srcptr + bsnk), size);
413#endif
414
415 asrc = (void *)((unsigned int)srcptr + bsrc);
416 asnk = (void *)((unsigned int)srcptr + bsnk);
417 timein = gtick();
418 ret = dumbcopy(asrc, asnk, size);
419 timeout = gtick();
420 if(ret) {
421 db_printf("Test failed; source = %02X; sink = %02X; length = %d\n", bsrc, bsnk, size);
422 db_printf("failed\n");
423
424 }
425 ticks = timeout - timein; /* Get time in ticks for copy */
426 tottime += ticks;
427 totbytes += size;
428
429 rate = (double) totbytes / (double)tottime; /* Get bytes per tick */
430 rate = rate * (double)tbfreq; /* Bytes per second */
431 rate = rate / (double)1000000.0; /* Get number of MBs */
432
433 db_printf("Total bytes = %lld; total time = %lld; rate = %f10\n", totbytes, tottime, rate);
434
435 }
436#endif
437
438 kmem_free(kernel_map, (vm_offset_t) sink, (1024*1024)+4096); /* Release this mapping block */
439 kmem_free(kernel_map, (vm_offset_t) source, (1024*1024)+4096); /* Release this mapping block */
440
441 if(dbg == 22) db_printf("Gabbagoogoo\n");
442 return;
443}
444
445void clrarea(unsigned int *source, unsigned int *sink) {
446
447 unsigned int i;
448
449 for(i=0; i < 1024; i++) { /* Init source & sink */
450 source[i] = 0x55555555; /* Known pattern */
451 sink[i] = 0xAAAAAAAA; /* Known pattern */
452 }
453 return;
454}
455
456void clrarea2(unsigned int *source, unsigned int *sink) {
457
458 unsigned int i;
459 unsigned char *ss;
460
461 ss = (unsigned char *)&source[0];
462
463 for(i=0; i < 1024 * 4; i++) { /* Init source/sink */
464 ss[i] = i & 0xFF; /* Known pattern */
465 }
466 return;
467}
468
469int tstcopy(void *src, void *snk, unsigned int lgn) {
470
471 unsigned int i, crap;
472
473 bcopy(src, snk, lgn);
474
475 for(i = 0; i < lgn; i++) {
476 if(((unsigned char *)snk)[i] != 0x55) {
477 crap = (unsigned int)&((unsigned char *)snk)[i];
478 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
479 return 1;
480 }
481 }
482 if(((unsigned char *)snk)[lgn] != 0xAA) { /* Is it right? */
483 crap = (unsigned int)&((unsigned char *)snk)[i];
484 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
485 return 1;
486 }
487 return 0;
488
489}
490
491int tstcopy2(void *src, void *snk, unsigned int lgn) {
492
493 unsigned int i, crap;
494 unsigned char ic, ec;
495
496 ic = ((unsigned char *)src)[0];
497 ec = ((unsigned char *)snk)[lgn];
498
499 bcopy(src, snk, lgn);
500
501 for(i = 0; i < lgn; i++) {
502 if(((unsigned char *)snk)[i] != ic) {
503 crap = (unsigned int)&((unsigned char *)snk)[i];
504 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i,crap, ((unsigned char *)snk)[i]);
505 return 1;
506 }
507 ic = (ic + 1) & 0xFF;
508 }
509
510 if(((unsigned char *)snk)[lgn] != ec) { /* Is it right? */
511 crap = (unsigned int)&((unsigned char *)snk)[i];
512 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
513 return 1;
514 }
515 return 0;
516
517}
518
519int tstcopy3(void *src, void *snk, unsigned int lgn) {
520
521 unsigned int i, crap;
522 unsigned char ic, ec, oic;
523
524 oic = ((unsigned char *)snk)[0];
525 ic = ((unsigned char *)src)[0];
526 ec = ((unsigned char *)snk)[lgn];
527
528 bcopy(src, snk, lgn);
529
530 for(i = 0; i < lgn; i++) {
531 if(((unsigned char *)snk)[i] != ic) {
532 crap = (unsigned int)&((unsigned char *)snk)[i];
533 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
534 return 1;
535 }
536 ic = (ic + 1) & 0xFF;
537 }
538
539 if(((unsigned char *)snk)[lgn] != ec) { /* Is it right? */
540 crap = (unsigned int)&((unsigned char *)snk)[i];
541 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
542 return 1;
543 }
544
545 for(i=0; i < lgn; i++) { /* Restore pattern */
546 ((unsigned char *)snk)[i] = oic;
547 oic = (oic + 1) & 0xFF;
548 }
549
550 return 0;
551
552}
553
554int tstcopy4(void *src, void *snk, unsigned int lgn) {
555
556 bcopy(src, snk, lgn);
557 return 0;
558
559}
560
561int tstcopy5(void *src, void *snk, unsigned int lgn) {
562
563 unsigned int i, crap;
564 unsigned char ic, ec, oic, pc;
565
566 oic = ((unsigned char *)snk)[0]; /* Original first sink character */
567 ic = ((unsigned char *)src)[0]; /* Original first source character */
568 ec = ((unsigned char *)snk)[lgn]; /* Original character just after last sink character */
569 pc = ((unsigned char *)snk)[-1]; /* Original character just before sink */
570
571 bcopy(src, snk, lgn);
572
573 if(((unsigned char *)snk)[lgn] != ec) { /* Did we copy too far forward? */
574 crap = (unsigned int)&((unsigned char *)snk)[i];
575 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
576 return 1;
577 }
578
579 if(((unsigned char *)snk)[-1] != pc) { /* Did we copy too far backward? */
580 crap = (unsigned int)&((unsigned char *)snk)[i];
581 db_printf("Copied too far at sink[%d] (%08X) it is %02X\n", i, crap, ((unsigned char *)snk)[lgn]);
582 return 1;
583 }
584
585 for(i = 0; i < lgn; i++) { /* Check sink byte sequence */
586 if(((unsigned char *)snk)[i] != ic) {
587 crap = (unsigned int)&((unsigned char *)snk)[i];
588 db_printf("bad copy at sink[%d] (%08X) it is %02X\n", i ,crap, ((unsigned char *)snk)[i]);
589 return 1;
590 }
591 ic = (ic + 1) % patper;
592 }
593
594 for(i=0; i < lgn; i++) { /* Restore pattern */
595 ((unsigned char *)snk)[i] = oic;
596 oic = (oic + 1) % patper;
597 }
598
599 return 0;
600
601}
602
603int dumbcopy(void *src, void *snk, unsigned int lgn) {
604 int i;
605 char *p = (char *)snk;
606 char *q = (char *)src;
607
608 for(i = 0; i < lgn; i++) {
609 *p++ = *q++;
610 }
611 return 0;
612
613}
614
615
616
617
618
619
620
621
622
623
624
625
626