THRIFT-4262 Invalid binding to InterlockedCompareExchange64() with 64-bit targets Client: Delphi Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Utils.pas b/lib/delphi/src/Thrift.Utils.pas
index a0bf144..89d0211 100644
--- a/lib/delphi/src/Thrift.Utils.pas
+++ b/lib/delphi/src/Thrift.Utils.pas
@@ -69,8 +69,9 @@
   end;
 
 
-function InterlockedCompareExchange64( var Target : Int64; Exchange, Comparand : Int64) : Int64; stdcall;
-function InterlockedExchangeAdd64( var Addend : Int64; Value : Int64) : Int64; stdcall;
+{$IFDEF Win64}
+function InterlockedExchangeAdd64( var Addend : Int64; Value : Int64) : Int64;  
+{$ENDIF}
 
 
 implementation
@@ -223,14 +224,19 @@
 end;
 
 
-// natively available since stone age
-function InterlockedCompareExchange64;
-external KERNEL32 name 'InterlockedCompareExchange64';
+{$IFDEF Win64}
+
+function InterlockedCompareExchange64( var Target : Int64; Exchange, Comparand : Int64) : Int64;  inline;
+begin
+  {$IFDEF OLD_UNIT_NAMES}
+  result := Windows.InterlockedCompareExchange64( Target, Exchange, Comparand);
+  {$ELSE}
+  result := WinApi.Windows.InterlockedCompareExchange64( Target, Exchange, Comparand);
+  {$ENDIF}
+end;
 
 
-// natively available >= Vista
-// implemented this way since there are still some people running Windows XP :-(
-function InterlockedExchangeAdd64( var Addend : Int64; Value : Int64) : Int64; stdcall;
+function InterlockedExchangeAdd64( var Addend : Int64; Value : Int64) : Int64;
 var old : Int64;
 begin
   repeat
@@ -239,6 +245,7 @@
   result := Old;
 end;
 
+{$ENDIF}
 
 
 end.