Commit d434fccf authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

These CPUs have very slow division - count and compare instead.

parent 27e4d722
......@@ -19,7 +19,8 @@ void memcheck()
unsigned primes[] = { 3, 7, 31, 127 };
size_t space = 512*1024; // Allocated test memory space starts at 512K
void *p = malloc(space);
int i;
int i = 0;
unsigned cnt = 0;
printf("[MEMCHECK] Detecting memory available");
while(p) {
......@@ -45,24 +46,30 @@ void memcheck()
uint8_t *pc = p;
unsigned prime = primes[i];
unsigned bytes = space;
unsigned idx = 0;
printf("%s%d", i?", ":"", prime);
fflush(stdout);
cnt = 0;
while (bytes--) {
*pc++ = (idx % prime);
idx++;
*pc++ = cnt;
cnt++;
if (cnt == prime) {
cnt = 0;
}
}
pc = p;
bytes = space;
idx = 0;
cnt = 0;
while (bytes--) {
if (*pc != (idx % prime)) {
if (*pc != cnt) {
printf("[MEMCHECK] Address space wrapped around at 0x%x!\n", (unsigned)pc);
fflush(stdout);
exit(1);
}
pc++;
idx++;
cnt++;
if (cnt == prime) {
cnt = 0;
}
}
}
puts("");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment