Home
Phabricator
Search
Log In
Paste
P330
c++11 atomics compile test
Active
Public
Actions
Authored by
hausmann
on Feb 21 2019, 2:14 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
/* Generated by configure */
#include <atomic>
#include <cstdint>
void test(volatile std::atomic<std::int64_t> &a)
{
std::int64_t v = a.load(std::memory_order_acquire);
while (!a.compare_exchange_strong(v, v + 1,
std::memory_order_acq_rel,
std::memory_order_acquire)) {
v = a.exchange(v - 1);
}
a.store(v + 1, std::memory_order_release);
}
int main(int argc, char **argv)
{
(void)argc; (void)argv;
/* BEGIN TEST: */
void *ptr = (void*)0xffffffc0; // any random pointer
test(*reinterpret_cast<std::atomic<std::int64_t> *>(ptr));
/* END TEST */
return 0;
}
hausmann
created this paste.
Feb 21 2019, 2:14 PM
hausmann
created this object in space
S1 KDE Community
.
Log In to Comment