Browse Source

Merge branch 'master' of https://github.com/Sphere10/PascalCoin

Herman Schoenfeld 7 years ago
parent
commit
cab7b8798f

+ 8 - 6
PasOpenCL/DelphiCL.pas

@@ -26,7 +26,9 @@ interface
 uses
   CL,
   CL_GL,
+  {$IFDEF WINDOWS}
   Windows,
+  {$ENDIF}
   SysUtils,
   dglOpenGL,
   CL_Platform;
@@ -2182,10 +2184,10 @@ end;
 
 constructor TDCLContext.CreateGL(Device_id: PCL_device_id);
 var
-  props: array [0..4] of TCL_uint;
+  props: array [0..4] of Pointer;
 begin
   inherited Create();
-  props[0] := CL_GL_CONTEXT_KHR;
+  props[0] := Pointer(CL_GL_CONTEXT_KHR);
 
   //MacOsX not yet (Andoid hm....)
   //MacOSX, Linux, Windows: http://www.dyn-lab.com/articles/cl-gl.html
@@ -2196,8 +2198,8 @@ begin
   {$ENDIF}
   {$IFDEF LINUX}
     props[1] := glXGetCurrentContext();
-    props[2] := CL_GLX_DISPLAY_KHR;
-    props[3] := glXGetCurrentDisplay();
+    props[2] := Pointer(CL_GLX_DISPLAY_KHR);
+    props[3] := Pointer(glXGetCurrentDisplayEXT());
   {$ENDIF}
   props[4] := 0;
 
@@ -2572,7 +2574,7 @@ var
   EndTime: TCL_ulong;
 {$ENDIF}
 begin
-  ZeroMemory(@origin, SizeOf(origin));
+  FillChar(origin, SizeOf(origin), #0);
   region[0] := Image.Width;
   region[1] := Image.Height;
   region[2] := 1;// Image 2D
@@ -2611,7 +2613,7 @@ var
   EndTime: TCL_ulong;
 {$ENDIF}
 begin
-  ZeroMemory(@origin, SizeOf(origin));
+  FillChar(origin, SizeOf(origin), #0);
   region[0] := Width;
   region[1] := Height;
   region[2] := 1;// Image 2D

+ 0 - 8
PascalCoinMiner.lpi

@@ -17,9 +17,6 @@
     <i18n>
       <EnableI18N LFM="False"/>
     </i18n>
-    <VersionInfo>
-      <StringTable ProductVersion=""/>
-    </VersionInfo>
     <BuildModes Count="1">
       <Item1 Name="Default" Default="True"/>
     </BuildModes>
@@ -60,11 +57,6 @@
         <OptimizationLevel Value="3"/>
       </Optimizations>
     </CodeGeneration>
-    <Linking>
-      <Debugging>
-        <GenerateDebugInfo Value="False"/>
-      </Debugging>
-    </Linking>
   </CompilerOptions>
   <Debugging>
     <Exceptions Count="3">

+ 11 - 11
PascalCoinMiner.pp

@@ -1,6 +1,6 @@
 program PascalCoinMiner;
 
-{$mode objfpc}{$H+}
+{$mode delphi}{$H+}
 {$DEFINE UseCThreads}
 {$I ./Units/PascalCoin/config.inc}
 
@@ -160,7 +160,7 @@ begin
       txt := copy(txt,1,FWindow32X2-FWindow32X1+1);
     end;
     if (nline<=(FWindow32Y2-FWindow32Y1)) then begin
-      GotoXY32(FWindow32X1,nline);
+      GotoXY(FWindow32X1,nline);
       write(txt);
     end;
   finally
@@ -180,7 +180,7 @@ begin
     // TODO - test logtype is properly casted/stored/retrieved/accessed.
     // Confirm casting doesn't lose bits in 32/64 bit archs
     // OLD: FLastLogs.AddObject(msg,TObject(PtrInt(logtype)));
-    FLastLogs.AddObject(msg,TObject(Int(QWord(logtype))));
+    FLastLogs.AddObject(msg,Pointer(logtype));
     i := FLastLogs.Count-CT_MaxLogs;
     if (i<0) then i:=0;
     nline := CT_Line_Logs+FDeviceThreads.Count;
@@ -222,9 +222,9 @@ var
         exit;
       end;
       devt:= TCPUDeviceThread.Create(FPoolMinerThread,CT_TMinerValuesForWork_NULL);
-      devt.OnStateChanged:=@OnDeviceStateChanged;
-      devt.OnMinerValuesChanged:=@OnMinerValuesChanged;
-      devt.OnFoundNOnce:=@OnFoundNOnce;
+      devt.OnStateChanged:=OnDeviceStateChanged;
+      devt.OnMinerValuesChanged:=OnMinerValuesChanged;
+      devt.OnFoundNOnce:=OnFoundNOnce;
       TCPUDeviceThread(devt).CPUs:=c;
       devt.Paused:=true;
       FDeviceThreads.Add(devt);
@@ -252,9 +252,9 @@ var
           end;
           //
           devt := TGPUDeviceThread.Create(FPoolMinerThread,CT_TMinerValuesForWork_NULL);
-          devt.OnStateChanged:=@OnDeviceStateChanged;
-          devt.OnMinerValuesChanged:=@OnMinerValuesChanged;
-          devt.OnFoundNOnce:=@OnFoundNOnce;
+          devt.OnStateChanged:=OnDeviceStateChanged;
+          devt.OnMinerValuesChanged:=OnMinerValuesChanged;
+          devt.OnFoundNOnce:=OnFoundNOnce;
           TGPUDeviceThread(devt).Platform:=p;
           TGPUDeviceThread(devt).Device:=d;
           TGPUDeviceThread(devt).ProgramFileName:=ExtractFileDir(ExeName)+PathDelim+CT_OpenCL_FileName;
@@ -362,7 +362,7 @@ var
         FPoolMinerThread.MinerAddName:=minerName;
         WriteLine(CT_Line_MinerValues-1,'MINER VALUES: (My miner name="'+minerName+'")');
 
-        FPoolMinerThread.OnConnectionStateChanged:=@OnConnectionStateChanged;
+        FPoolMinerThread.OnConnectionStateChanged:=OnConnectionStateChanged;
         OnConnectionStateChanged(FPoolMinerThread);
 
         If (FDeviceThreads.Count)=1 then begin
@@ -373,7 +373,7 @@ var
         end;
         Flog := TLog.Create(Nil);
         try
-          Flog.OnInThreadNewLog:=@OnInThreadNewLog;
+          Flog.OnInThreadNewLog:=OnInThreadNewLog;
           DoWaitAndLog;
         finally
           FLog.free;

+ 1 - 1
Units/Forms/UFRMMainForm.lfm

@@ -22,7 +22,7 @@ object FRMMainForm: TFRMMainForm
   OnResize = FormResize
   Position = poScreenCenter
   ShowHint = True
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.0.6'
   object paLogoPanel: TPanel
     Left = 0
     Height = 80

+ 1 - 1
Units/Forms/UFRMMainForm.pas

@@ -17,7 +17,7 @@ interface
 
 uses
   Messages, SysUtils, Classes, Graphics, Controls, Forms,
-  Dialogs, ExtCtrls, ComCtrls, UWallet,
+  Dialogs, ExtCtrls, ComCtrls, LMessages, UWallet,
   ULog,
   UBlockChain, UNode, UGridUtils, UAccounts, Menus,
   UNetProtocol, UCrypto, Buttons, ActnList, UPoolMining,

+ 2 - 2
Units/Forms/UFRMNodes.lfm

@@ -7,8 +7,8 @@ object FRMNodes: TFRMNodes
   ClientHeight = 444
   ClientWidth = 861
   OnCreate = FormCreate
-  Position = poOwnerFormCenter  
-  LCLVersion = '1.6.4.0'
+  Position = poOwnerFormCenter
+  LCLVersion = '1.8.0.6'
   object Label3: TLabel
     Left = 15
     Height = 15

+ 1 - 1
Units/Forms/UFRMNodes.pas

@@ -18,7 +18,7 @@ interface
 uses
   LCLIntf, LCLType,
   Messages, SysUtils, Classes, Graphics, Controls, Forms,
-  Dialogs, ExtCtrls, StdCtrls, UCommonUI,
+  Dialogs, ExtCtrls, StdCtrls, LMessages, UCommonUI,
   ULog,  UBlockChain, UNode, Menus,  UNetProtocol;
 
 Const

+ 1 - 1
Units/Forms/UFRMWalletKeys.lfm

@@ -9,7 +9,7 @@ object FRMWalletKeys: TFRMWalletKeys
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.0.6'
   object lbWalletKeys: TListBox
     Left = 24
     Height = 210

+ 1 - 1
Units/Forms/UFRMWalletKeys.pas

@@ -15,7 +15,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Messages,
-  Buttons, Menus, UCommonUI, UWallet;
+  Buttons, Menus, LMessages, UCommonUI, UWallet;
 
 const
   CM_PC_WalletChanged = WM_USER + 1;

+ 1 - 1
Units/Forms/UUserInterface.pas

@@ -16,7 +16,7 @@ interface
 {$I ./../PascalCoin/config.inc}
 
 uses
-  SysUtils, Classes, Forms, Controls, Windows, ExtCtrls, Dialogs,
+  SysUtils, Classes, Forms, Controls, {$IFDEF WINDOWS}Windows,{$ENDIF} ExtCtrls, Dialogs, LCLType,
   UCommonUI, UBlockChain, UAccounts, UNode, UWallet, UConst, UFolderHelper, UGridUtils, URPC, UPoolMining,
   ULog, UThread, UNetProtocol, UCrypto,
   UFRMMainForm, UCTRLSyncronization, UFRMAccountExplorer, UFRMOperationExplorer, UFRMPendingOperations, UFRMOperation,

+ 5 - 5
Units/Utils/UVisualGrid.pas

@@ -1355,7 +1355,7 @@ end;
 
 procedure TCustomVisualGrid.MultiSearchCheckComboBoxChange(Sender: TObject; AIndex: Integer);
 var
-  LState: PTCheckComboItemState;
+  LState: TCheckComboItemState;
   LOldHasEdit, LNewHasEdit: boolean;
 
   function HasOneOrMoreEdit: boolean;
@@ -1370,11 +1370,11 @@ var
 
 begin
   LOldHasEdit := HasOneOrMoreEdit;
-  LState := PTCheckComboItemState(FMultiSearchCheckComboBox.Items.Objects[AIndex]);
-  if Assigned(LState^.Data) then
-    TSearchEdit(LState^.Data).EditVisible:=LState^.State=cbChecked
+  LState := TCheckComboItemState(FMultiSearchCheckComboBox.Items.Objects[AIndex]);
+  if Assigned(LState.Data) then
+    TSearchEdit(LState.Data).EditVisible:=LState.State=cbChecked
   else
-    FSearchEdit.Visible:=LState^.State=cbChecked;
+    FSearchEdit.Visible:=LState.State=cbChecked;
 
   LNewHasEdit := HasOneOrMoreEdit;
   FTopPanelMultiSearch.Visible := LNewHasEdit;

+ 19 - 4
Units/Utils/generics.collections.pas

@@ -54,7 +54,13 @@ uses
   OTHER: 25595, 25612, 25615, 25617, 25618, 25619
 }
 
+{.$define EXTRA_WARNINGS}
+
 type
+  {$ifdef VER3_0_0}
+  TArray<T> = array of T;
+  {$endif}
+
   // bug #24254 workaround
   // should be TArray = record class procedure Sort<T>(...) etc.
   TCustomArrayHelper<T> = class abstract
@@ -80,7 +86,7 @@ type
       out AFoundIndex: SizeInt; const AComparer: IComparer<T>): Boolean; overload;
     class function BinarySearch(constref AValues: array of T; constref AItem: T;
       out AFoundIndex: SizeInt): Boolean; overload;
-  end experimental; // will be renamed to TCustomArray (bug #24254)
+  end {$ifdef EXTRA_WARNINGS}experimental{$endif}; // will be renamed to TCustomArray (bug #24254)
 
   TArrayHelper<T> = class(TCustomArrayHelper<T>)
   protected
@@ -90,7 +96,7 @@ type
     class function BinarySearch(constref AValues: array of T; constref AItem: T;
       out AFoundIndex: SizeInt; const AComparer: IComparer<T>;
       AIndex, ACount: SizeInt): Boolean; override; overload;
-  end experimental; // will be renamed to TArray (bug #24254)
+  end {$ifdef EXTRA_WARNINGS}experimental{$endif}; // will be renamed to TArray (bug #24254)
 
   TCollectionNotification = (cnAdded, cnRemoved, cnExtracted);
   TCollectionNotifyEvent<T> = procedure(ASender: TObject; constref AItem: T; AAction: TCollectionNotification)
@@ -706,9 +712,10 @@ end;
 procedure TList<T>.SetItem(AIndex: SizeInt; const AValue: T);
 begin
   if (AIndex < 0) or (AIndex >= Count) then
-    raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
-
+    raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);   
+  Notify(FItems[AIndex], cnRemoved);
   FItems[AIndex] := AValue;
+  Notify(AValue, cnAdded);
 end;
 
 function TList<T>.GetEnumerator: TEnumerator;
@@ -1003,7 +1010,9 @@ constructor TThreadList<T>.Create;
 begin
   inherited Create;
   FDuplicates:=dupIgnore;
+{$ifdef FPC_HAS_FEATURE_THREADING}
   InitCriticalSection(FLock);
+{$endif}
   FList := TList<T>.Create;
 end;
 
@@ -1015,7 +1024,9 @@ begin
     inherited Destroy;
   finally
     UnlockList;
+{$ifdef FPC_HAS_FEATURE_THREADING}
     DoneCriticalSection(FLock);
+{$endif}
   end;
 end;
 
@@ -1055,12 +1066,16 @@ end;
 function TThreadList<T>.LockList: TList<T>;
 begin
   Result:=FList;
+{$ifdef FPC_HAS_FEATURE_THREADING}
   System.EnterCriticalSection(FLock);
+{$endif}
 end;
 
 procedure TThreadList<T>.UnlockList;
 begin
+{$ifdef FPC_HAS_FEATURE_THREADING}
   System.LeaveCriticalSection(FLock);
+{$endif}
 end;
 
 { TQueue<T>.TEnumerator }

+ 3 - 3
Units/Utils/generics.defaults.pas

@@ -554,7 +554,7 @@ type
     EqualityComparer_Method_VMT : THashFactory.TEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Method ; GetHashCode: @THashFactory.Method );
     EqualityComparer_Variant_VMT: THashFactory.TEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Variant; GetHashCode: @THashFactory.Variant);
     EqualityComparer_Pointer_VMT: THashFactory.TEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Pointer; GetHashCode: @THashFactory.Pointer);
-{$WARNINGS ON}
+{.$WARNINGS ON} // do not enable warnings ever in this unit, or you will get many warnings about uninitialized TEqualityComparerVMT fields
   private class var
     // IEqualityComparer VMT
     FEqualityComparer_Int8_VMT  : THashFactory.TEqualityComparerVMT;
@@ -673,7 +673,7 @@ type
     ExtendedEqualityComparer_Method_VMT : TExtendedHashFactory.TExtendedEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Method ; GetHashCode: @THashFactory.Method ; GetHashList: @TExtendedHashFactory.Method );
     ExtendedEqualityComparer_Variant_VMT: TExtendedHashFactory.TExtendedEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Variant; GetHashCode: @THashFactory.Variant; GetHashList: @TExtendedHashFactory.Variant);
     ExtendedEqualityComparer_Pointer_VMT: TExtendedHashFactory.TExtendedEqualityComparerVMT = (STD_RAW_INTERFACE_METHODS; Equals: @TEquals.Pointer; GetHashCode: @THashFactory.Pointer; GetHashList: @TExtendedHashFactory.Pointer);
-{$WARNINGS ON}
+{.$WARNINGS ON} // do not enable warnings ever in this unit, or you will get many warnings about uninitialized TEqualityComparerVMT fields
   private class var
     // IExtendedEqualityComparer VMT
     FExtendedEqualityComparer_Int8_VMT  : TExtendedHashFactory.TExtendedEqualityComparerVMT;
@@ -2879,7 +2879,7 @@ begin
   else
     raise EArgumentOutOfRangeException.CreateRes(@SArgumentOutOfRange);
   end;
-{$WARNINGS ON}
+{.$WARNINGS ON} // do not enable warnings ever in this unit, or you will get many warnings about uninitialized TEqualityComparerVMT fields
 end;
 
 { TDelphiQuadrupleHashFactory }

+ 1 - 12
Units/Utils/generics.memoryexpanders.pas

@@ -47,12 +47,7 @@ type
   { TQuadraticProbing }
 
   TQuadraticProbing = class(TProbeSequence)
-  private
-    class constructor Create;
   public
-    class var C1: UInt32;
-    class var C2: UInt32;
-
     class function Probe(I, Hash: UInt32): UInt32; static; inline;
 
     const MAX_LOAD_FACTOR = 0.5;
@@ -214,15 +209,9 @@ end;
 
 { TQuadraticProbing }
 
-class constructor TQuadraticProbing.Create;
-begin
-  C1 := 1;
-  C2 := 1;
-end;
-
 class function TQuadraticProbing.Probe(I, Hash: UInt32): UInt32;
 begin
-  Result := (Hash + C1 * I {%H-}+ C2 * Sqr(I));
+  Result := (Hash + Sqr(I));
 end;
 
 { TDoubleHashingNoMod }

+ 6 - 4
pascalcoin_daemon.lpi

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="9"/>
+    <Version Value="10"/>
     <PathDelim Value="\"/>
     <General>
       <Flags>
@@ -17,9 +17,6 @@
     <i18n>
       <EnableI18N LFM="False"/>
     </i18n>
-    <VersionInfo>
-      <StringTable ProductVersion=""/>
-    </VersionInfo>
     <BuildModes Count="1">
       <Item1 Name="Default" Default="True"/>
     </BuildModes>
@@ -33,6 +30,11 @@
         <Display Use="True" Value=""/>
       </local>
     </RunParams>
+    <RequiredPackages Count="1">
+      <Item1>
+        <PackageName Value="LCL"/>
+      </Item1>
+    </RequiredPackages>
     <Units Count="1">
       <Unit0>
         <Filename Value="pascalcoin_daemon.pp"/>

+ 1 - 0
pascalcoin_daemon.pp

@@ -8,6 +8,7 @@ uses
   {$IFDEF UNIX}{$IFDEF UseCThreads}
   cthreads,
   {$ENDIF}{$ENDIF}
+  Interfaces,
   sysutils,
   Classes, daemonapp,
   UCrypto, upcdaemon;