THRIFT-3788 Compatibility improvements and Win64 support
Client: Delphi
Patch: Jens Geyer
Revised previous patch.
diff --git a/lib/delphi/src/Thrift.Transport.Pipes.pas b/lib/delphi/src/Thrift.Transport.Pipes.pas
index 9e62341..a11bdc1 100644
--- a/lib/delphi/src/Thrift.Transport.Pipes.pas
+++ b/lib/delphi/src/Thrift.Transport.Pipes.pas
@@ -19,18 +19,16 @@
unit Thrift.Transport.Pipes;
{$WARN SYMBOL_PLATFORM OFF}
-{$IF CompilerVersion >= 23.0}
- {$LEGACYIFEND ON}
-{$IFEND}
+{$I Thrift.Defines.inc}
interface
uses
-{$IF CompilerVersion < 23.0}
+ {$IFDEF OLD_UNIT_NAMES}
Windows, SysUtils, Math, AccCtrl, AclAPI, SyncObjs,
-{$ELSE}
+ {$ELSE}
Winapi.Windows, System.SysUtils, System.Math, Winapi.AccCtrl, Winapi.AclAPI, System.SyncObjs,
-{$IFEND}
+ {$ENDIF}
Thrift.Transport,
Thrift.Utils,
Thrift.Stream;
@@ -903,14 +901,9 @@
function TNamedPipeServerTransportImpl.Handle : THandle;
-{$IFDEF WIN64}
-var
- Hndl: Integer;
-{$ENDIF}
begin
{$IFDEF WIN64}
- Hndl := Integer(FHandle);
- result := THandle( InterlockedExchangeAdd( Hndl, 0));
+ result := THandle( InterlockedExchangeAdd64( Int64(FHandle), 0));
{$ELSE}
result := THandle( InterlockedExchangeAdd( Integer(FHandle), 0));
{$ENDIF}
@@ -958,29 +951,22 @@
sa.bInheritHandle := FALSE;
// Create an instance of the named pipe
-{$IF CompilerVersion < 23.0}
- result := Windows.CreateNamedPipe( PChar( FPipeName), // pipe name
- PIPE_ACCESS_DUPLEX or // read/write access
- FILE_FLAG_OVERLAPPED, // async mode
- PIPE_TYPE_BYTE or // byte type pipe
- PIPE_READMODE_BYTE, // byte read mode
- FMaxConns, // max. instances
- FBufSize, // output buffer size
- FBufSize, // input buffer size
- FTimeout, // time-out, see MSDN
- @sa); // default security attribute
-{$ELSE}
- result := Winapi.Windows.CreateNamedPipe( PChar( FPipeName), // pipe name
- PIPE_ACCESS_DUPLEX or // read/write access
- FILE_FLAG_OVERLAPPED, // async mode
- PIPE_TYPE_BYTE or // byte type pipe
- PIPE_READMODE_BYTE, // byte read mode
- FMaxConns, // max. instances
- FBufSize, // output buffer size
- FBufSize, // input buffer size
- FTimeout, // time-out, see MSDN
- @sa); // default security attribute
-{$IFEND}
+ {$IFDEF OLD_UNIT_NAMES}
+ result := Windows.CreateNamedPipe(
+ {$ELSE}
+ result := Winapi.Windows.CreateNamedPipe(
+ {$ENDIF}
+ PChar( FPipeName), // pipe name
+ PIPE_ACCESS_DUPLEX or // read/write access
+ FILE_FLAG_OVERLAPPED, // async mode
+ PIPE_TYPE_BYTE or // byte type pipe
+ PIPE_READMODE_BYTE, // byte read mode
+ FMaxConns, // max. instances
+ FBufSize, // output buffer size
+ FBufSize, // input buffer size
+ FTimeout, // time-out, see MSDN
+ @sa // default security attribute
+ );
if( result <> INVALID_HANDLE_VALUE)
then InterlockedExchangePointer( Pointer(FHandle), Pointer(result))