Skip to content

Commit

Permalink
Releaxing memory barriers on x86 arch. (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and mjansson committed Apr 3, 2019
1 parent 4122fc1 commit a66360f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/thread.c
Expand Up @@ -7,6 +7,11 @@
# define ATTRIBUTE_NORETURN __attribute__((noreturn))
#endif

#if !defined(__x86_64__) && !defined(_AMD64_) && !defined(_M_AMD64) && !defined(__i386__)
# define MEMORY_BARRIER __sync_synchronize()
#else
# define MEMORY_BARRIER __asm__ __volatile__("":::"memory")
#endif
#ifdef _WIN32
# include <Windows.h>
# include <process.h>
Expand Down Expand Up @@ -92,7 +97,7 @@ thread_yield(void) {
_ReadWriteBarrier();
#else
sched_yield();
__sync_synchronize();
MEMORY_BARRIER;
#endif
}

Expand All @@ -101,6 +106,6 @@ thread_fence(void) {
#ifdef _WIN32
_ReadWriteBarrier();
#else
__sync_synchronize();
MEMORY_BARRIER;
#endif
}

0 comments on commit a66360f

Please sign in to comment.