Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit c2ab5fa

Browse files
committed
#get/#set have 'volatile' semantics when compiled with MS Visual C++
1 parent 793012e commit c2ab5fa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ext/atomic_reference.c

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static VALUE ir_initialize(int argc, VALUE* argv, VALUE self) {
3939
static VALUE ir_get(VALUE self) {
4040
#if HAVE_GCC_SYNC
4141
__sync_synchronize();
42+
#elif defined _MSC_VER
43+
MemoryBarrier();
4244
#endif
4345
return (VALUE) DATA_PTR(self);
4446
}
@@ -47,6 +49,8 @@ static VALUE ir_set(VALUE self, VALUE new_value) {
4749
DATA_PTR(self) = (void *) new_value;
4850
#if HAVE_GCC_SYNC
4951
__sync_synchronize();
52+
#elif defined _MSC_VER
53+
MemoryBarrier();
5054
#endif
5155
return new_value;
5256
}

0 commit comments

Comments
 (0)