none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc
[valgrind.git] / none / tests / arm64 / ldxp_stxp.c
blobb5f6ea121d5168304e0e87809c9f5d7adc7cd876
2 /* Note, this is only a basic smoke test of LD{A}XP and ST{L}XP. Their
3 atomicity properties are tested by memcheck/tests/atomic_incs.c. */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <malloc.h>
8 #include <assert.h>
10 typedef unsigned int UInt;
11 typedef unsigned long long int ULong;
14 void initBlock ( ULong* block )
16 block[0] = 0x0001020304050607ULL;
17 block[1] = 0x1011121314151617ULL;
18 block[2] = 0x2021222324252627ULL;
19 block[3] = 0x3031323334353637ULL;
20 block[4] = 0x4041424344454647ULL;
21 block[5] = 0x5051525354555657ULL;
24 void printBlock ( const char* who,
25 ULong* block, ULong rt1contents, ULong rt2contents,
26 UInt zeroIfSuccess )
28 printf("Block %s (%s)\n", who, zeroIfSuccess == 0 ? "success" : "FAILURE" );
29 for (int i = 0; i < 6; i++) {
30 printf("0x%016llx\n", block[i]);
32 printf("0x%016llx rt1contents\n", rt1contents);
33 printf("0x%016llx rt2contents\n", rt2contents);
34 printf("\n");
37 int main ( void )
39 ULong* block = memalign(16, 6 * sizeof(ULong));
40 assert(block);
42 ULong rt1in, rt2in, rt1out, rt2out;
43 UInt scRes;
45 // Do ldxp then stxp with x-registers
46 initBlock(block);
47 rt1in = 0x5555666677778888ULL;
48 rt2in = 0xAAAA9999BBBB0000ULL;
49 rt1out = 0x1111222233334444ULL;
50 rt2out = 0xFFFFEEEEDDDDCCCCULL;
51 scRes = 0x55555555;
52 __asm__ __volatile__(
53 "ldxp %1, %2, [%5]" "\n\t"
54 "stxp %w0, %3, %4, [%5]" "\n\t"
55 : /*OUT*/
56 "=&r"(scRes), // %0
57 "=&r"(rt1out), // %1
58 "=&r"(rt2out) // %2
59 : /*IN*/
60 "r"(rt1in), // %3
61 "r"(rt2in), // %4
62 "r"(&block[2]) // %5
63 : /*TRASH*/
64 "memory","cc"
66 printBlock("after ldxp/stxp 2x64-bit", block, rt1out, rt2out, scRes);
68 // Do ldxp then stxp with w-registers
69 initBlock(block);
70 rt1in = 0x5555666677778888ULL;
71 rt2in = 0xAAAA9999BBBB0000ULL;
72 rt1out = 0x1111222233334444ULL;
73 rt2out = 0xFFFFEEEEDDDDCCCCULL;
74 scRes = 0x55555555;
75 __asm__ __volatile__(
76 "ldxp %w1, %w2, [%5]" "\n\t"
77 "stxp %w0, %w3, %w4, [%5]" "\n\t"
78 : /*OUT*/
79 "=&r"(scRes), // %0
80 "=&r"(rt1out), // %1
81 "=&r"(rt2out) // %2
82 : /*IN*/
83 "r"(rt1in), // %3
84 "r"(rt2in), // %4
85 "r"(&block[2]) // %5
86 : /*TRASH*/
87 "memory","cc"
89 printBlock("after ldxp/stxp 2x32-bit", block, rt1out, rt2out, scRes);
91 free(block);
92 return 0;