source: doc/theses/thierry_delisle_PhD/code/bts_test.cpp @ 5569a31

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 5569a31 was 9421f3d8, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Adding some of the implemented code. Current state: relaxed list is achieves at least 6M ops/sec total

  • Property mode set to 100644
File size: 671 bytes
Line 
1#include <cassert>
2#include <iostream>
3
4bool 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
14bool 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
24int 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.