blob: 2864ab69d2ab9b447250d7137dca8cc86fc758b6 (
plain)
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
|
/* { dg-do compile { target x86_64-*-* } } */
/* { dg-require-effective-target lp64 } */
/* Adapted from Linux x86: page_ref_dec_and_test.c (GPL-2.0). */
typedef _Bool bool;
typedef struct {
int counter;
} atomic_t;
bool
arch_atomic_dec_and_test(atomic_t *v) {
return ({
bool c;
asm volatile(".pushsection .smp_locks,\"a\"\n"
".balign 4\n"
".long 671f - .\n"
".popsection\n"
"671:"
"\n\tlock; "
"decl"
" "
"%[var]"
"\n\t/* output condition code "
"e"
"*/\n"
: [ var ] "+m"(v->counter), "=@cc"
"e"(c)
:
: "memory");
c;
});
}
|