| 1 | #include <stdint.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | alignas(16) uint8_t buf[32]; |
| 5 | // This uses inline assembly to generate an instruction that writes to a large |
| 6 | // block of memory. If it fails on your compiler/architecture, please add |
| 7 | // appropriate code to generate a large write to "buf". If you cannot write at |
| 8 | // least 2*sizeof(void*) bytes with a single instruction, you will have to skip |
| 9 | // this test. |
| 10 | |
| 11 | int main() { |
| 12 | memset(s: buf, UINT32_MAX, n: 8); |
| 13 | #if defined(__i386__) || defined(__x86_64__) |
| 14 | asm volatile ("movdqa %%xmm0, %0" : : "m" (buf)); |
| 15 | #elif defined(__arm__) |
| 16 | asm volatile ("stm %0, { r0, r1, r2, r3 }" : : "r" (buf)); |
| 17 | #elif defined(__aarch64__) |
| 18 | asm volatile ("stp x0, x1, %0" : : "m" (buf)); |
| 19 | #elif defined(__mips__) |
| 20 | asm volatile ("lw $2, %0" : : "m" (buf)); |
| 21 | #endif |
| 22 | return 0; |
| 23 | } |
| 24 | |