File: atomic_is_lock_free.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (98 lines) | stat: -rw-r--r-- 2,433 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// RUN: %clang_cc1 -triple s390x-linux-gnu -O1 -emit-llvm %s -o - | FileCheck %s
//
// Test __atomic_is_lock_free() and friends.

#include <stdatomic.h>
#include <stdint.h>

typedef __attribute__((aligned(16))) __int128 __int128_Al16;

_Atomic __int128 Int128_Atomic;
__int128_Al16    Int128_Al16;
__int128         Int128;
struct { int I[3]; } _Atomic AtomicStruct;
_Atomic long double Atomic_fp128; // Also check the alignment of this.

// Check alignments of the variables. @AtomicStruct gets padded and its size
// and alignment becomes 16. Only a power-of-2 size is considered, so 16 (not
// 12) needs to be specified with the intrinsics below.
//
// CHECK: %struct.anon = type { [3 x i32] }
// CHECK: @Int128 = {{.*}} i128 0, align 8
// CHECK: @Int128_Atomic = {{.*}} i128 0, align 16
// CHECK: @Int128_Al16 = {{.*}} i128 0, align 16
// CHECK: @AtomicStruct = {{.*}} { %struct.anon, [4 x i8] } zeroinitializer, align 16
// CHECK: @Atomic_fp128 = {{.*}} fp128 0xL00000000000000000000000000000000, align 16


// CHECK-LABEL: @fun0
// CHECK:       ret i1 true
_Bool fun0() {
  return __atomic_is_lock_free(16, &Int128_Atomic);
}

// CHECK-LABEL: @fun1
// CHECK:       ret i1 true
_Bool fun1() {
  return __atomic_always_lock_free(16, &Int128_Atomic);
}

// CHECK-LABEL: @fun2
// CHECK:       ret i1 true
_Bool fun2() {
  return __atomic_is_lock_free(16, &Int128_Al16);
}

// CHECK-LABEL: @fun3
// CHECK:       ret i1 true
_Bool fun3() {
  return __atomic_always_lock_free(16, &Int128_Al16);
}

// CHECK-LABEL: @fun4
// CHECK:    call zeroext i1 @__atomic_is_lock_free
_Bool fun4() {
  return __atomic_is_lock_free(16, &Int128);
}

// CHECK-LABEL: @fun5
// CHECK:    ret i1 false
_Bool fun5() {
  return __atomic_always_lock_free(16, &Int128);
}

// CHECK-LABEL: @fun6
// CHECK:       ret i1 true
_Bool fun6() {
  return __atomic_is_lock_free(16, 0);
}

// CHECK-LABEL: @fun7
// CHECK:       ret i1 true
_Bool fun7() {
  return __atomic_always_lock_free(16, 0);
}

// CHECK-LABEL: @fun8
// CHECK:       ret i1 true
_Bool fun8() {
  return __atomic_is_lock_free(16, &AtomicStruct);
}

// CHECK-LABEL: @fun9
// CHECK:       ret i1 true
_Bool fun9() {
  return __atomic_always_lock_free(16, &AtomicStruct);
}

// CHECK-LABEL: @fun10
// CHECK:       ret i1 true
_Bool fun10() {
  return atomic_is_lock_free(&Int128_Atomic);
}

// CHECK-LABEL: @fun11
// CHECK:       ret i1 true
_Bool fun11() {
  return __c11_atomic_is_lock_free(16);
}