On Mon, Aug 9, 2010 at 9:55 AM, Lutger <<a href="mailto:lutger.blijdestijn@gmail.com" target="_blank">lutger.blijdestijn@gmail.com</a>> wrote:<br>><br>> I'm not an expert on this, but if I am not mistaken the shared type qualifier<br>
> will handle the barriers, require atomic ops and prevent reordering compiler<br>> optimizations so it looks like this one will take care of what volatile used to<br>> do, right?<br>><br>><br><br>Seems the latest dmd in svn hasn't implemented shared atomics yet anyway. If it had, we'd see a lock prefix in use.<br>
<br><span style="font-family: courier new,monospace;">$ cat main.d</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">shared int x = 1;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">int main()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> x = x + 1;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ++x;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">$ dmd -O -w -wi main.d</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$ objdump -d main.o</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">main.o: file format elf32-i386</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Disassembly of section .text:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">00000000 <.text>:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 0: c3 ret </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 1: 60 pusha </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 2: b8 14 00 00 00 mov $0x14,%eax</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 7: b9 00 00 00 00 mov $0x0,%ecx</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> c: 8b 11 mov (%ecx),%edx</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> e: 89 10 mov %edx,(%eax)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 10: 89 01 mov %eax,(%ecx)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 12: 61 popa </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 13: c3 ret </span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Disassembly of section .text._Dmain:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">00000000 <_Dmain>:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 0: 55 push %ebp</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 1: a1 00 00 00 00 mov 0x0,%eax</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 6: 40 inc %eax</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 7: a3 00 00 00 00 mov %eax,0x0</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> c: 8b ec mov %esp,%ebp</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> e: 31 c0 xor %eax,%eax</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 10: 83 05 00 00 00 00 01 addl $0x1,0x0</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 17: 5d pop %ebp</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 18: c3 ret</span><br>