FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / stfle.c
blob5926964c6a32fdeb8f53a0a6faf45ee82c3447a0
1 #include <stdio.h>
3 /* Number of double words needed to store all facility bits. */
4 #define S390_NUM_FACILITY_DW 4
7 unsigned long long stfle(unsigned long dw, unsigned bit_to_test)
9 unsigned long long hoststfle[S390_NUM_FACILITY_DW];
10 register unsigned long long __nr asm("0") = dw - 1;
11 int cc;
13 asm volatile(" .insn s,0xb2b00000,%0 \n" /* stfle */
14 "ipm %2\n"
15 "srl %2,28\n"
16 : "=Q" (*hoststfle), "+d" (__nr), "=d" (cc) : : "cc", "memory");
18 printf("the value of cc is %d and #double words is %llu\n", cc, __nr + 1);
19 if (bit_to_test < 64)
20 return (hoststfle[0] & (1ULL << (63 - bit_to_test)));
21 else if (bit_to_test < 128)
22 return (hoststfle[1] & (1ULL << (63 - bit_to_test)));
23 else if (bit_to_test < 192)
24 return (hoststfle[2] & (1ULL << (63 - bit_to_test)));
26 printf("code needs to be updated\n");
27 return 0;
30 int main()
32 int dw = S390_NUM_FACILITY_DW;
34 /* Test #1: Make sure STFLE returns sensible values. z/Arch facilities
35 must be present. */
36 if ((stfle(dw, 1)) && stfle(dw, 2))
37 printf("The z/Architecture architectural mode is installed and active\n");
38 else
39 printf("The z/Architecture architectural mode is not installed\n");
41 /* Test #2: Make sure the STFLE is supported. */
42 if (stfle(dw, 7))
43 printf("STFLE facility is installed\n");
44 else
45 printf("STFLE facility is not installed\n");
47 /* Test #3: Tell STFLE to only write 1 DW of facility bits. Expected condition
48 code should be 3 because this test is run on those machines only
49 that need 3 do double words to store facility bits. */
50 dw = 1;
51 if ((stfle(dw, 1)) && stfle(dw, 2))
52 printf("The z/Architecture architectural mode is installed and active\n");
53 else
54 printf("The z/Architecture architectural mode is not installed\n");
56 /* Test #4: Constrained transactional-execution */
57 if (stfle(dw, 50)) {
58 printf("Constrained transactional-execution is supported\n");
59 } else {
60 printf("No constrained transactional-execution facility available\n");
62 return 0;