Discussion:
memory barrier/fence function in Watcom?
(too old to reply)
Jens Staal
2014-12-02 13:53:12 UTC
Permalink
Hi

I have tried to build an application that depends on the GCC-style

__asm__ __volatile__ ("": : :"memory")

memory barrier. My preliminary thing was basically just to comment it out,
but there are some crashes that might have to do with this barrier... so I
would like to get that thing properly fixed.

What is the corresponding way of doing it in Watcom?

http://en.wikipedia.org/wiki/Memory_ordering#Compiler_memory_barrier
Jiri Malak
2014-12-04 09:50:31 UTC
Permalink
OW doesn't have similar support.
But you can create code fragments which use appropriate fence instruction.
By example for sfence

extern void asm_sfence( void );
#pragma aux asm_sfence = 0x0F 0xAE 0xF8;

then you can call it in program as
asm_sfence();
Post by Jens Staal
Hi
I have tried to build an application that depends on the GCC-style
__asm__ __volatile__ ("": : :"memory")
memory barrier. My preliminary thing was basically just to comment it out,
but there are some crashes that might have to do with this barrier... so I
would like to get that thing properly fixed.
What is the corresponding way of doing it in Watcom?
http://en.wikipedia.org/wiki/Memory_ordering#Compiler_memory_barrier
Jens Staal
2014-12-04 11:25:55 UTC
Permalink
Post by Jiri Malak
OW doesn't have similar support.
But you can create code fragments which use appropriate fence instruction.
By example for sfence
extern void asm_sfence( void );
#pragma aux asm_sfence = 0x0F 0xAE 0xF8;
then you can call it in program as
asm_sfence();
awesome! thanks I will try this.

By the way... I found that wasm should have the "mfence" function... is this
an appropriate approximation?

I could not find any example syntaxes with it by googling though...
Jiri Malak
2014-12-04 13:27:31 UTC
Permalink
Post by Jens Staal
Post by Jiri Malak
OW doesn't have similar support.
But you can create code fragments which use appropriate fence
instruction.
By example for sfence
extern void asm_sfence( void );
#pragma aux asm_sfence = 0x0F 0xAE 0xF8;
then you can call it in program as
asm_sfence();
awesome! thanks I will try this.
By the way... I found that wasm should have the "mfence" function... is this
an appropriate approximation?
You are right, wasm support all fence instructions that you can change
sample code to

extern void asm_sfence( void );
#pragma aux asm_sfence = "sfence";

or you can use

__asm sfence;

etc.

Loading...