2012 06 05 10 43 [c] 自製InterlockedExchange64, 讓gcc 4.xx 32bits 以前的環境可以使用.

#include <stdio.h>
#include <stdint.h>

asm(".text\n"
  ".globl _test\n"
  "_test:\n"
  "push %ebx\n"
  "push %esi\n"
  "movl 12(%esp),%esi\n"
  "movl 16(%esp),%ebx\n"
  "movl 20(%esp),%ecx\n"
  "movl 24(%esp),%eax\n"
  "movl 28(%esp),%edx\n"
  "lock cmpxchg8b (%esi)\n"
  "pop  %esi\n"
  "pop  %ebx\n"
  "ret"
);