#pragma once #ifndef x55791370_E395_11d2_A2F0_00A0CC248AA8 #define x55791370_E395_11d2_A2F0_00A0CC248AA8 /* * Copyright (c) 1999 Spokane Software Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in any supporting * documentation. Spokane Software Systems makes no representations about * the suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * */ #ifndef _MSC_VER #error Compiler specific adaptation required #endif #if _MSC_VER <= 1200 #pragma warning(disable:4097) // typedef used as synonym #endif #ifndef _WIN32 #error Platform specific adaptation required #endif #ifndef _M_IX86 #error CPU specific adaptation required #endif #ifdef _MT extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); extern "C" __declspec(dllimport) void __stdcall Sleep(unsigned long); #pragma warning(push) #pragma warning(disable:4035) // no return value (asm) #pragma warning(disable:4100) // unreferenced parameter #ifndef TRACE1 #define TRACE1(s, x) ((void)0) #define x56CB52D0_E6C2_11d2_A2F0_00A0CC248AA8 #endif namespace sss { namespace i { inline unsigned long Xthreadid() { return GetCurrentThreadId(); } inline void __declspec(naked) __fastcall Xlock(volatile unsigned char* bLock) { top: __asm lock bts word ptr[ecx], 0 __asm jc short repeat __asm ret repeat: __asm push ecx TRACE1("Spinning %08x\n", bLock); Sleep(1); __asm pop ecx __asm jmp short top } template T __fastcall Xadd(volatile T* t, int x); template<> inline __declspec(naked) char __fastcall Xadd(volatile char* t, int x) { __asm mov eax, edx __asm lock xadd byte ptr [ecx], al __asm ret } template<> inline __declspec(naked) signed char __fastcall Xadd(volatile signed char* t, int x) { __asm mov eax, edx __asm lock xadd byte ptr [ecx], al __asm ret } template<> inline __declspec(naked) unsigned char __fastcall Xadd(volatile unsigned char* t, int x) { __asm mov eax, edx __asm lock xadd byte ptr [ecx], al __asm ret } template<> inline __declspec(naked) short __fastcall Xadd(volatile short* t, int x) { __asm mov eax, edx __asm lock xadd word ptr [ecx], ax __asm ret } template<> inline __declspec(naked) unsigned short __fastcall Xadd(volatile unsigned short* t, int x) { __asm mov eax, edx __asm lock xadd word ptr [ecx], ax __asm ret } template<> inline __declspec(naked) int __fastcall Xadd(volatile int* t, int x) { __asm mov eax, edx __asm lock xadd dword ptr [ecx], eax __asm ret } template<> inline __declspec(naked) unsigned __fastcall Xadd(volatile unsigned* t, int x) throw() { __asm mov eax, edx __asm lock xadd dword ptr [ecx], eax __asm ret } template<> inline __declspec(naked) long __fastcall Xadd(volatile long* t, int x) { __asm mov eax, edx __asm lock xadd dword ptr [ecx], eax __asm ret } template<> inline __declspec(naked) unsigned long __fastcall Xadd(volatile unsigned long* t, int x) { __asm mov eax, edx __asm lock xadd dword ptr [ecx], eax __asm ret } } // namespace i } // namespace sss #ifdef x56CB52D0_E6C2_11d2_A2F0_00A0CC248AA8 #undef x56CB52D0_E6C2_11d2_A2F0_00A0CC248AA8 #undef TRACE1 #endif #pragma warning(pop) #endif // _MT #endif // x55791370_E395_11d2_A2F0_00A0CC248AA8