Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F3872849
atomic_* test, fails to link on i386
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
mmokhi
Oct 14 2018, 2:04 PM
2018-10-14 14:04:07 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
atomic_* test, fails to link on i386
View Options
#include <stdint.h>
#include <stdatomic.h>
struct test {
volatile uint16_t a;
volatile uint64_t b;
volatile uint64_t c;
};
volatile struct test test = {
.a = 0,
.b = 0,
.c = 1
};
void compare_and_add(uint64_t dt, uint64_t argb) {
uint64_t oldb = test.b;
while(dt > oldb)
__atomic_compare_exchange(&test.b, &oldb, &dt, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&test.b, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&test.b, dt, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&test.b, argb, __ATOMIC_SEQ_CST);
}
void compare_and_add2(uint64_t dt, uint64_t argb) {
volatile struct test test2 = {0, 0, 1};
__atomic_fetch_add(&test2.b, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&test2.b, dt, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&test2.b, argb, __ATOMIC_SEQ_CST);
}
int main (int argc, char **argv)
{
uint64_t ull1 = 1, ull2 = 0, ull3 = 2;
__atomic_load_n(&ull1, __ATOMIC_SEQ_CST);
__atomic_compare_exchange(&ull1, &ull2, &ull3, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
__atomic_fetch_add(&ull1, 1, __ATOMIC_SEQ_CST);
__atomic_fetch_sub(&test.b, 1, __ATOMIC_SEQ_CST);
__atomic_or_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
__atomic_and_fetch(&ull1, ull2, __ATOMIC_SEQ_CST);
return 0;
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1599842
Default Alt Text
atomic_* test, fails to link on i386 (1 KB)
Attached To
Mode
P229 atomic_* test, fails to link on i386
Attached
Detach File
Event Timeline
Log In to Comment