Mercurial > repos > rhope
view vis_threading.c @ 96:5a08705f7610
Semi-broken cleanup of Array implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Aug 2010 05:12:19 -0400 |
parents | 76568becd6d6 |
children |
line wrap: on
line source
#ifdef WIN32 #include "windows.h" void VIS_EnterCriticalSectionImpl(short * cs) { int tmp = (int)cs; __asm { mov ebx, tmp CriticalLoop: bts [ebx], 0 jnc End } Sleep(0); __asm { jmp CriticalLoop } End: return; } #else #include <unistd.h> volatile /*inline*/ void VIS_EnterCriticalSectionImpl(short * cs) { int code; VIS_EnterStart: asm( "movw $1, %%ax\n\t" "xchg %%ax, (%1)\n\t" "test %%ax, %%ax\n\t" "jz VIS_EnterEnd\n\t" "movl $1, %0\n\t" "jmp VIS_EnterCont\n" "VIS_EnterEnd:\n\t" "movl $0, %0\n" "VIS_EnterCont:": "=r"(code): "r"(cs): "%ax"); if(!code) return; sleep(0); goto VIS_EnterStart; } volatile /*inline*/ void VIS_LeaveCriticalSectionImpl(short * cs) { asm( "movw $0, %%ax\n\t" "mfence\n\t" "xchg %%ax, (%0)":: "r"(cs): "%ax"); } #endif