ADTast-experimental
Last change
on this file since 9feb34b was
f9f3775,
checked in by Thierry Delisle <tdelisle@…>, 4 years ago
|
Moved phd code for the readQ prototype to it's own folder
|
-
Property mode set to
100644
|
File size:
671 bytes
|
Line | |
---|
1 | #include <cassert> |
---|
2 | #include <iostream> |
---|
3 | |
---|
4 | bool bts(volatile size_t & target, size_t bit ) { |
---|
5 | bool result = false; |
---|
6 | asm volatile( |
---|
7 | "LOCK btsq %[bit], %[target]\n\t" |
---|
8 | :"=c" (result) |
---|
9 | : [target] "m" (target), [bit] "r" (bit) |
---|
10 | ); |
---|
11 | return result; |
---|
12 | } |
---|
13 | |
---|
14 | bool btr(volatile size_t & target, size_t bit ) { |
---|
15 | bool result = false; |
---|
16 | asm volatile( |
---|
17 | "LOCK btrq %[bit], %[target]\n\t" |
---|
18 | :"=c" (result) |
---|
19 | : [target] "m" (target), [bit] "r" (bit) |
---|
20 | ); |
---|
21 | return result; |
---|
22 | } |
---|
23 | |
---|
24 | int main() { |
---|
25 | volatile size_t i = 0; |
---|
26 | std::cout << std::hex << i << std::endl; |
---|
27 | assert(bts(i, 31)); |
---|
28 | std::cout << std::hex << i << std::endl; |
---|
29 | assert(btr(i, 31)); |
---|
30 | std::cout << std::hex << i << std::endl; |
---|
31 | return 0; |
---|
32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.