1 | #include <boost/thread/win32/thread_primitives.hpp>
|
---|
2 | #include <cstdio>
|
---|
3 |
|
---|
4 | int main()
|
---|
5 | {
|
---|
6 | {
|
---|
7 | long x = 3;
|
---|
8 | long bit = 0;
|
---|
9 | printf("Testing bit %ld of x=%ld\n", bit, x);
|
---|
10 | bool ret = boost::detail::win32::interlocked_bit_test_and_set(&x, bit);
|
---|
11 | printf("result: %d (expected: 1)\n", ret ? 1 : 0);
|
---|
12 | printf("x: %ld (expected: 3)\n", x);
|
---|
13 | }
|
---|
14 |
|
---|
15 | {
|
---|
16 | long x = 3;
|
---|
17 | long bit = 2;
|
---|
18 | printf("Testing bit %ld of x=%ld\n", bit, x);
|
---|
19 | bool ret = boost::detail::win32::interlocked_bit_test_and_set(&x, bit);
|
---|
20 | printf("result: %d (expected: 0)\n", ret ? 1 : 0);
|
---|
21 | printf("x: %ld (expected: 7)\n", x);
|
---|
22 | }
|
---|
23 |
|
---|
24 | return 0;
|
---|
25 | }
|
---|