This is the mail archive of the mailing list for the pthreas-win32 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PThreads under win95 linked to missing export

The source of the problem appears to be that InterlockedCompareExchange()
"Requires Windows 98 or later" (according to MSDN).Dave--- 
Martin van den Nieuwelaar <> wrote:
> The PTHREADVCE.DLL file is linked to missing export


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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]