drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / gdbserver_tests / self_invalidate.c
blob52b3d2bef18b69784efdd10459ded56926163a74
1 /* Based on reproducer done by Dejan Jevtic */
2 int main (void)
4 #if defined(VGA_amd64)
5 /* Note that small changes in the code below
6 caused the bug not to be triggered anymore.
7 E.g. removing the dec %%eax avoids the assert
8 while this removal causes one more loop to be
9 executed. */
10 __asm__ __volatile__
11 ("mov $30, %%eax\n\t"
12 "top:\n\t"
13 "mov $-4, %%ebx\n\t"
14 "add %%ebx, %%eax\n\t"
15 "dec %%eax\n\t"
16 "cmp $0x0,%%eax\n\t"
17 "jne top\n\t"
18 "mov $60, %%eax\n\t"
19 "mov $0, %%rdi\n\t"
20 "syscall\n\t"
21 : : : "eax", "ebx", "rdi"
23 #elif defined(VGA_mips32) || defined(VGA_mips64)
24 __asm__ __volatile__
25 ("li $t0, 42\n\t"
26 "top:\n\t"
27 "li $t1, -4\n\t"
28 "addu $t0, $t0, $t1\n\t"
29 "li $t2, -2\n\t"
30 "addu $t0, $t0, $t2\n\t"
31 "addiu $t0, $t0, -1\n\t"
32 "bnez $t0, top\n\t"
33 "nop\n\t"
34 : : : "t0", "t1"
36 #endif
37 return 0;