This is the mail archive of the
pthreads-win32@sources.redhat.com
mailing list for the pthreas-win32 project.
Re: PThreads under win95 linked to missing export
- To: "'martin at gadgets dot co dot nz'" <martin at gadgets dot co dot nz>, "'pthreads-win32 at sources dot redhat dot com'" <pthreads-win32 at sources dot redhat dot com>
- Subject: Re: PThreads under win95 linked to missing export
- From: "van Lieshout, Fred" <Fred dot vanLieshout at atosorigin dot com>
- Date: Wed, 15 Aug 2001 22:20:18 +0200
The source of the problem appears to be that InterlockedCompareExchange()
"Requires Windows 98 or later" (according to MSDN).Dave---
Martin van den Nieuwelaar <martin@gadgets.co.nz> wrote:
> The PTHREADVCE.DLL file is linked to missing export
KERNEL32.DLL:InterlockedCompareExchange
Martin,
Just in case you really need the latest pthread lib, here's a work around
that may do the trick: create your 'own' InterlockedCompareExchange function
using some assembly code (not the best optimised, I know) and the Intel
CMPXCHG instruction:
extern PVOID InterlockedCompareExchange(PVOID *shared, PVOID v, PVOID c)
{
PVOID result;
_asm {
PUSH ecx
PUSH edx
MOV ecx,dword ptr [shared] ; Load ECX with plTarget
MOV edx,dword ptr [v] ; Load EDX with lValue
MOV eax,dword ptr [c]
LOCK CMPXCHG dword ptr [ecx],edx ; if (EAX == [ECX]),
; [ECX] = EDX
; else
; EAX = [ECX]
MOV dword ptr [result], eax
POP edx
POP ecx
}
return result;
}
With thanks to an article on MSDN (search on the function's name).
Cheers,
Fred