فهرست منبع

* Update from Maciej Izak, bug ID #33921

git-svn-id: trunk@39345 -
michael 7 سال پیش
والد
کامیت
d4f2a593d4
30فایلهای تغییر یافته به همراه259 افزوده شده و 115 حذف شده
  1. 1 0
      .gitattributes
  2. 1 1
      packages/rtl-generics/examples/tarraydouble/tarrayprojectdouble.lpr
  3. 1 1
      packages/rtl-generics/examples/tarraysingle/tarrayprojectsingle.lpr
  4. 1 1
      packages/rtl-generics/examples/tcomparer/tcomparerproject.lpr
  5. 1 1
      packages/rtl-generics/examples/thashmap/thashmapproject.lpr
  6. 1 1
      packages/rtl-generics/examples/thashmapcaseinsensitive/thashmapcaseinsensitive.lpr
  7. 1 1
      packages/rtl-generics/examples/thashmapextendedequalitycomparer/thashmapextendedequalitycomparer.lpr
  8. 4 0
      packages/rtl-generics/examples/thashset/thashset_exceptwith.lpr
  9. 4 0
      packages/rtl-generics/examples/thashset/thashset_intersectwith.lpr
  10. 4 0
      packages/rtl-generics/examples/thashset/thashset_symmetricexceptwith.lpr
  11. 4 0
      packages/rtl-generics/examples/thashset/thashset_unionwith.lpr
  12. 1 1
      packages/rtl-generics/examples/tobjectlist/tobjectlistproject.lpr
  13. 1 1
      packages/rtl-generics/examples/tqueue/tqueueproject.lpr
  14. 2 1
      packages/rtl-generics/examples/tstack/tstackproject.lpr
  15. 15 0
      packages/rtl-generics/readme.txt
  16. 4 23
      packages/rtl-generics/src/generics.collections.pas
  17. 55 10
      packages/rtl-generics/src/generics.defaults.pas
  18. 52 41
      packages/rtl-generics/src/generics.hashes.pas
  19. 4 4
      packages/rtl-generics/src/generics.helpers.pas
  20. 4 4
      packages/rtl-generics/src/generics.memoryexpanders.pas
  21. 4 4
      packages/rtl-generics/src/generics.strings.pas
  22. 4 4
      packages/rtl-generics/src/inc/generics.dictionaries.inc
  23. 4 4
      packages/rtl-generics/src/inc/generics.dictionariesh.inc
  24. 4 2
      packages/rtl-generics/tests/tests.generics.arrayhelper.pas
  25. 5 2
      packages/rtl-generics/tests/tests.generics.bugs.pas
  26. 46 2
      packages/rtl-generics/tests/tests.generics.hashmaps.pas
  27. 5 2
      packages/rtl-generics/tests/tests.generics.sets.pas
  28. 4 2
      packages/rtl-generics/tests/tests.generics.stdcollections.pas
  29. 4 2
      packages/rtl-generics/tests/tests.generics.trees.pas
  30. 18 0
      packages/rtl-generics/tests/tests.generics.utils.pas

+ 1 - 0
.gitattributes

@@ -7428,6 +7428,7 @@ packages/rtl-generics/examples/tqueue/tqueueproject.lpr svneol=native#text/pasca
 packages/rtl-generics/examples/tstack/tstackproject.lpi svneol=native#text/xml
 packages/rtl-generics/examples/tstack/tstackproject.lpi svneol=native#text/xml
 packages/rtl-generics/examples/tstack/tstackproject.lpr svneol=native#text/pascal
 packages/rtl-generics/examples/tstack/tstackproject.lpr svneol=native#text/pascal
 packages/rtl-generics/fpmake.pp svneol=native#text/pascal
 packages/rtl-generics/fpmake.pp svneol=native#text/pascal
+packages/rtl-generics/readme.txt svneol=native#text/plain
 packages/rtl-generics/src/generics.collections.pas svneol=native#text/pascal
 packages/rtl-generics/src/generics.collections.pas svneol=native#text/pascal
 packages/rtl-generics/src/generics.defaults.pas svneol=native#text/pascal
 packages/rtl-generics/src/generics.defaults.pas svneol=native#text/pascal
 packages/rtl-generics/src/generics.hashes.pas svneol=native#text/pascal
 packages/rtl-generics/src/generics.hashes.pas svneol=native#text/pascal

+ 1 - 1
packages/rtl-generics/examples/tarraydouble/tarrayprojectdouble.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
 
 

+ 1 - 1
packages/rtl-generics/examples/tarraysingle/tarrayprojectsingle.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
 
 

+ 1 - 1
packages/rtl-generics/examples/tcomparer/tcomparerproject.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // by Maciej Izak (hnb), 2014
 // by Maciej Izak (hnb), 2014
 
 
 program TComparerProject;
 program TComparerProject;

+ 1 - 1
packages/rtl-generics/examples/thashmap/thashmapproject.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
 
 

+ 1 - 1
packages/rtl-generics/examples/thashmapcaseinsensitive/thashmapcaseinsensitive.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // by Maciej Izak (hnb), 2014
 // by Maciej Izak (hnb), 2014
 
 
 program THashMapCaseInsensitive;
 program THashMapCaseInsensitive;

+ 1 - 1
packages/rtl-generics/examples/thashmapextendedequalitycomparer/thashmapextendedequalitycomparer.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // by Maciej Izak (hnb), 2014
 // by Maciej Izak (hnb), 2014
 
 
 program THashMapExtendedEqualityComparer;
 program THashMapExtendedEqualityComparer;

+ 4 - 0
packages/rtl-generics/examples/thashset/thashset_exceptwith.lpr

@@ -1,3 +1,7 @@
+// Generic types for NewPascal.org and FPC!
+// by Maciej Izak (hnb), 2018
+// sponsored by Sphere 10 Software (http://sphere10.com)
+
 program thashset_exceptwith;
 program thashset_exceptwith;
 
 
 {$MODE DELPHI}
 {$MODE DELPHI}

+ 4 - 0
packages/rtl-generics/examples/thashset/thashset_intersectwith.lpr

@@ -1,3 +1,7 @@
+// Generic types for NewPascal.org and FPC!
+// by Maciej Izak (hnb), 2018
+// sponsored by Sphere 10 Software (http://sphere10.com)
+
 program thashset_intersectwith;
 program thashset_intersectwith;
 
 
 {$MODE DELPHI}
 {$MODE DELPHI}

+ 4 - 0
packages/rtl-generics/examples/thashset/thashset_symmetricexceptwith.lpr

@@ -1,3 +1,7 @@
+// Generic types for NewPascal.org and FPC!
+// by Maciej Izak (hnb), 2018
+// sponsored by Sphere 10 Software (http://sphere10.com)
+
 program thashset_symmetricexceptwith;
 program thashset_symmetricexceptwith;
 
 
 {$MODE DELPHI}
 {$MODE DELPHI}

+ 4 - 0
packages/rtl-generics/examples/thashset/thashset_unionwith.lpr

@@ -1,3 +1,7 @@
+// Generic types for NewPascal.org and FPC!
+// by Maciej Izak (hnb), 2018
+// sponsored by Sphere 10 Software (http://sphere10.com)
+
 program thashset_unionwith;
 program thashset_unionwith;
 
 
 {$MODE DELPHI}
 {$MODE DELPHI}

+ 1 - 1
packages/rtl-generics/examples/tobjectlist/tobjectlistproject.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
 
 

+ 1 - 1
packages/rtl-generics/examples/tqueue/tqueueproject.lpr

@@ -1,4 +1,4 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
 
 

+ 2 - 1
packages/rtl-generics/examples/tstack/tstackproject.lpr

@@ -1,6 +1,7 @@
-// Generic types for FreeSparta.com and FreePascal!
+// Generic types for NewPascal.org and FPC!
 // Original version by keeper89.blogspot.com, 2011
 // Original version by keeper89.blogspot.com, 2011
 // FPC version by Maciej Izak (hnb), 2014
 // FPC version by Maciej Izak (hnb), 2014
+
 program TStackProject;
 program TStackProject;
 
 
 {$MODE DELPHI}
 {$MODE DELPHI}

+ 15 - 0
packages/rtl-generics/readme.txt

@@ -0,0 +1,15 @@
+
+This directory contains the rtl-generics units. These units are created 
+outside the FPC source tree by Macie Izak, see:
+
+https://github.com/maciej-izak/generics.collections
+
+The FPC team will maintain the copy you find here, the FPC bugtracker can be
+used for reporting bugs.
+
+Open FPC bugs related to Generics.* :
+
+CRITICAL:  26030 25918, 25620, 24283
+IMPORTANT: 24097, 24285, 24286 (Similar to? 24285), 24098,  24534, 25614, 26195
+OTHER: 26484, 25593, 26181 
+

+ 4 - 23
packages/rtl-generics/src/generics.collections.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -44,25 +44,6 @@ uses
     RtlConsts, Classes, SysUtils, Generics.MemoryExpanders, Generics.Defaults,
     RtlConsts, Classes, SysUtils, Generics.MemoryExpanders, Generics.Defaults,
     Generics.Helpers, Generics.Strings;
     Generics.Helpers, Generics.Strings;
 
 
-{ FPC BUGS related to Generics.* (54 bugs, 19 fixed)
-  REGRESSION: 26483, 26481
-  FIXED REGRESSION: 26480, 26482
-
-  CRITICAL: 24848(!!!), 24872(!), 25607(!), 26030, 25917, 25918, 25620, 24283, 24254, 24287 (Related to? 24872)
-  IMPORTANT: 23862(!), 24097, 24285, 24286 (Similar to? 24285), 24098, 24609 (RTL inconsistency), 24534,
-             25606, 25614, 26177, 26195
-  OTHER: 26484, 24073, 24463, 25593, 25596, 25597, 25602, 26181 (or MYBAD?)
-  CLOSED BUT IMO STILL TO FIX: 25601(!), 25594
-  FIXED: 25610(!), 24064, 24071, 24282, 24458, 24867, 24871, 25604, 25600, 25605, 25598, 25603, 25929, 26176, 26180,
-         26193, 24072
-  MYBAD: 24963, 25599
-}
-
-{ LAZARUS BUGS related to Generics.* (7 bugs, 0 fixed)
-  CRITICAL: 25613
-  OTHER: 25595, 25612, 25615, 25617, 25618, 25619
-}
-
 {.$define EXTRA_WARNINGS}
 {.$define EXTRA_WARNINGS}
 {.$define ENABLE_METHODS_WITH_TEnumerableWithPointers}
 {.$define ENABLE_METHODS_WITH_TEnumerableWithPointers}
 
 

+ 55 - 10
packages/rtl-generics/src/generics.defaults.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -302,6 +302,7 @@ type
     class procedure UInt8        (constref AValue: UInt8        ; AHashList: PUInt32); overload;
     class procedure UInt8        (constref AValue: UInt8        ; AHashList: PUInt32); overload;
     class procedure UInt16       (constref AValue: UInt16       ; AHashList: PUInt32); overload;
     class procedure UInt16       (constref AValue: UInt16       ; AHashList: PUInt32); overload;
     class procedure UInt32       (constref AValue: UInt32       ; AHashList: PUInt32); overload;
     class procedure UInt32       (constref AValue: UInt32       ; AHashList: PUInt32); overload;
+
     class procedure UInt64       (constref AValue: UInt64       ; AHashList: PUInt32); overload;
     class procedure UInt64       (constref AValue: UInt64       ; AHashList: PUInt32); overload;
     class procedure Single       (constref AValue: Single       ; AHashList: PUInt32); overload;
     class procedure Single       (constref AValue: Single       ; AHashList: PUInt32); overload;
     class procedure Double       (constref AValue: Double       ; AHashList: PUInt32); overload;
     class procedure Double       (constref AValue: Double       ; AHashList: PUInt32); overload;
@@ -865,7 +866,25 @@ type
     class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
     class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
   end;
   end;
 
 
-  TmORMotHashFactory = class(THashFactory)
+  { TGenericsHashFactory }
+
+  TGenericsHashFactory = class(THashFactory)
+  public
+    class function GetHashService: THashServiceClass; override;
+    class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
+  end;
+
+  { TxxHash32HashFactory }
+
+  TxxHash32HashFactory = class(THashFactory)
+  public
+    class function GetHashService: THashServiceClass; override;
+    class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
+  end;
+
+  { TxxHash32PascalHashFactory }
+
+  TxxHash32PascalHashFactory = class(THashFactory)
   public
   public
     class function GetHashService: THashServiceClass; override;
     class function GetHashService: THashServiceClass; override;
     class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
     class function GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32 = 0): UInt32; override;
@@ -936,7 +955,7 @@ type
     class procedure GetHashList(AKey: Pointer; ASize: SizeInt; AHashList: PUInt32; AOptions: TGetHashListOptions = []); override;
     class procedure GetHashList(AKey: Pointer; ASize: SizeInt; AHashList: PUInt32; AOptions: TGetHashListOptions = []); override;
   end;
   end;
 
 
-  TDefaultHashFactory = TmORMotHashFactory;
+  TDefaultHashFactory = TDelphiQuadrupleHashFactory;
 
 
   TDefaultGenericInterface = (giComparer, giEqualityComparer, giExtendedEqualityComparer);
   TDefaultGenericInterface = (giComparer, giEqualityComparer, giExtendedEqualityComparer);
 
 
@@ -2796,18 +2815,44 @@ begin
   Result := DelphiHashLittle(AKey, ASize, AInitVal);
   Result := DelphiHashLittle(AKey, ASize, AInitVal);
 end;
 end;
 
 
-{ TmORMotHashFactory }
+{ TGenericsHashFactory }
 
 
-class function TmORMotHashFactory.GetHashService: THashServiceClass;
+class function TGenericsHashFactory.GetHashService: THashServiceClass;
 begin
 begin
-  Result := THashService<TmORMotHashFactory>;
+  Result := THashService<TGenericsHashFactory>;
 end;
 end;
 
 
-class function TmORMotHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32): UInt32;
+class function TGenericsHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt; AInitVal: UInt32): UInt32;
 begin
 begin
   Result := mORMotHasher(AInitVal, AKey, ASize);
   Result := mORMotHasher(AInitVal, AKey, ASize);
 end;
 end;
 
 
+{ TxxHash32HashFactory }
+
+class function TxxHash32HashFactory.GetHashService: THashServiceClass;
+begin
+  Result := THashService<TxxHash32HashFactory>;
+end;
+
+class function TxxHash32HashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt;
+  AInitVal: UInt32): UInt32;
+begin
+  Result := xxHash32(AInitVal, AKey, ASize);
+end;
+
+{ TxxHash32PascalHashFactory }
+
+class function TxxHash32PascalHashFactory.GetHashService: THashServiceClass;
+begin
+  Result := THashService<TxxHash32PascalHashFactory>;
+end;
+
+class function TxxHash32PascalHashFactory.GetHashCode(AKey: Pointer; ASize: SizeInt;
+  AInitVal: UInt32): UInt32;
+begin
+  Result := xxHash32Pascal(AInitVal, AKey, ASize);
+end;
+
 { TAdler32HashFactory }
 { TAdler32HashFactory }
 
 
 class function TAdler32HashFactory.GetHashService: THashServiceClass;
 class function TAdler32HashFactory.GetHashService: THashServiceClass;

+ 52 - 41
packages/rtl-generics/src/generics.hashes.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -33,6 +33,37 @@ unit Generics.Hashes;
 {$OVERFLOWCHECKS OFF}
 {$OVERFLOWCHECKS OFF}
 {$RANGECHECKS OFF}
 {$RANGECHECKS OFF}
 
 
+{$ifdef FPC_PIC}
+  {$define DISABLE_X86_CPUINTEL}
+{$endif FPC_PIC}
+
+{$if defined(OPENBSD) or defined(EMX) or defined(OS2)}
+  { These targets have old GNU assemblers that }
+  { do not support all instructions used in assembler code below }
+  {$define DISABLE_X86_CPUINTEL}
+{$endif}
+
+{$ifdef CPU64}
+  {$define PUREPASCAL}
+  {$ifdef CPUX64}
+    {$define CPUINTEL}
+    {$ASMMODE INTEL}
+  {$endif CPUX64}
+{$else}
+  {$ifdef CPUX86}
+    {$ifndef DISABLE_X86_CPUINTEL}
+      {$define CPUINTEL}
+      {$ASMMODE INTEL}
+    {$else}
+      { Assembler code uses references to static
+        variables with are not PIC ready }
+      {$define PUREPASCAL}
+    {$endif}
+  {$else CPUX86}
+  {$define PUREPASCAL}
+  {$endif}
+{$endif CPU64}
+
 interface
 interface
 
 
 uses
 uses
@@ -72,7 +103,9 @@ function SimpleChecksumHash(AKey: Pointer; ALength: SizeInt): UInt32;
 // https://code.google.com/p/hedgewars/source/browse/hedgewars/adler32.pas
 // https://code.google.com/p/hedgewars/source/browse/hedgewars/adler32.pas
 function Adler32(AKey: Pointer; ALength: SizeInt): UInt32;
 function Adler32(AKey: Pointer; ALength: SizeInt): UInt32;
 function sdbm(AKey: Pointer; ALength: SizeInt): UInt32;
 function sdbm(AKey: Pointer; ALength: SizeInt): UInt32;
-function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal;
+function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal;{$IFNDEF CPUINTEL}inline;{$ENDIF}
+// pure pascal implementation of xxHash32
+function xxHash32Pascal(crc: cardinal; P: Pointer; len: integer): cardinal;
 
 
 type
 type
   THasher = function(crc: cardinal; buf: Pointer; len: cardinal): cardinal;
   THasher = function(crc: cardinal; buf: Pointer; len: cardinal): cardinal;
@@ -927,37 +960,6 @@ begin
   Result := Int32(c);
   Result := Int32(c);
 end;
 end;
 
 
-{$ifdef FPC_PIC}
-  {$define DISABLE_X86_CPUINTEL}
-{$endif FPC_PIC}
-
-{$if defined(OPENBSD) or defined(EMX) or defined(OS2)}
-  { These targets have old GNU assemblers that }
-  { do not support all instructions used in assembler code below }
-  {$define DISABLE_X86_CPUINTEL}
-{$endif}
-
-{$ifdef CPU64}
-  {$define PUREPASCAL}
-  {$ifdef CPUX64}
-    {$define CPUINTEL}
-    {$ASMMODE INTEL}
-  {$endif CPUX64}
-{$else}
-  {$ifdef CPUX86}
-    {$ifndef DISABLE_X86_CPUINTEL}
-      {$define CPUINTEL}
-      {$ASMMODE INTEL}
-    {$else}
-      { Assembler code uses references to static
-        variables with are not PIC ready }
-      {$define PUREPASCAL}
-    {$endif}
-  {$else CPUX86}
-  {$define PUREPASCAL}
-  {$endif}
-{$endif CPU64}
-
 {$ifdef CPUARM} // circumvent FPC issue on ARM
 {$ifdef CPUARM} // circumvent FPC issue on ARM
 function ToByte(value: cardinal): cardinal; inline;
 function ToByte(value: cardinal): cardinal; inline;
 begin
 begin
@@ -1166,8 +1168,13 @@ asm
         {$endif}
         {$endif}
 end;
 end;
 {$endif CPUX64}
 {$endif CPUX64}
-
 {$else not CPUINTEL}
 {$else not CPUINTEL}
+function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal;
+begin
+  result := xxHash32Pascal(crc, P, len);
+end;
+{$endif CPUINTEL}
+
 const
 const
   PRIME32_1 = 2654435761;
   PRIME32_1 = 2654435761;
   PRIME32_2 = 2246822519;
   PRIME32_2 = 2246822519;
@@ -1181,7 +1188,7 @@ begin
   result := RolDWord(value, 13);
   result := RolDWord(value, 13);
 end;
 end;
 
 
-function xxHash32(crc: cardinal; P: Pointer; len: integer): cardinal;
+function xxHash32Pascal(crc: cardinal; P: Pointer; len: integer): cardinal;
 var c1, c2, c3, c4: cardinal;
 var c1, c2, c3, c4: cardinal;
     PLimit, PEnd: PAnsiChar;
     PLimit, PEnd: PAnsiChar;
 begin
 begin
@@ -1203,7 +1210,12 @@ begin
   end else
   end else
     result := crc + PRIME32_5;
     result := crc + PRIME32_5;
   inc(result, len);
   inc(result, len);
-  while P <= PEnd - 4 do begin
+  { Use "P + 4 <= PEnd" instead of "P <= PEnd - 4" to avoid crashes in case P = nil.
+    When P = nil,
+    then "PtrUInt(PEnd - 4)" is 4294967292,
+    so the condition "P <= PEnd - 4" would be satisfied,
+    and the code would try to access PCardinal(nil)^ causing a SEGFAULT. }
+  while P + 4 <= PEnd do begin
     inc(result, PCardinal(P)^ * PRIME32_3);
     inc(result, PCardinal(P)^ * PRIME32_3);
     result := RolDWord(result, 17) * PRIME32_4;
     result := RolDWord(result, 17) * PRIME32_4;
     inc(P, 4);
     inc(P, 4);
@@ -1219,7 +1231,6 @@ begin
   result := result * PRIME32_3;
   result := result * PRIME32_3;
   result := result xor (result shr 16);
   result := result xor (result shr 16);
 end;
 end;
-{$endif CPUINTEL}
 
 
 {$ifdef CPUINTEL}
 {$ifdef CPUINTEL}
 
 
@@ -1593,7 +1604,7 @@ begin
   begin
   begin
     InitializeCrc32ctab;
     InitializeCrc32ctab;
     crc32c := @crc32cfast;
     crc32c := @crc32cfast;
-    mORMotHasher := @xxHash32;
+    mORMotHasher := @{$IFDEF CPUINTEL}xxHash32{$ELSE}xxHash32Pascal{$ENDIF};
   end;
   end;
 end.
 end.
 
 

+ 4 - 4
packages/rtl-generics/src/generics.helpers.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.

+ 4 - 4
packages/rtl-generics/src/generics.memoryexpanders.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.

+ 4 - 4
packages/rtl-generics/src/generics.strings.pas

@@ -1,11 +1,11 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.

+ 4 - 4
packages/rtl-generics/src/inc/generics.dictionaries.inc

@@ -1,13 +1,13 @@
 {%MainUnit generics.collections.pas}
 {%MainUnit generics.collections.pas}
 
 
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.

+ 4 - 4
packages/rtl-generics/src/inc/generics.dictionariesh.inc

@@ -1,13 +1,13 @@
 {%MainUnit generics.collections.pas}
 {%MainUnit generics.collections.pas}
 
 
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2014 by Maciej Izak (hnb)
     Copyright (c) 2014 by Maciej Izak (hnb)
-    member of the Free Sparta development team (http://freesparta.com)
+    member of the NewPascal development team (http://newpascal.org)
 
 
-    Copyright(c) 2004-2014 DaThoX
+    Copyright(c) 2004-2018 DaThoX
 
 
-    It contains the Free Pascal generics library
+    It contains the generics collections library
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.

+ 4 - 2
packages/rtl-generics/tests/tests.generics.arrayhelper.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 

+ 5 - 2
packages/rtl-generics/tests/tests.generics.bugs.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 
@@ -18,6 +20,7 @@
     many new types, tests and major refactoring of entire library
     many new types, tests and major refactoring of entire library
 
 
  **********************************************************************}
  **********************************************************************}
+
 unit tests.generics.bugs;
 unit tests.generics.bugs;
 
 
 {$mode delphi}
 {$mode delphi}

+ 46 - 2
packages/rtl-generics/tests/tests.generics.hashmaps.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 
@@ -17,6 +19,9 @@
     Thanks to Sphere 10 Software (http://sphere10.com) for sponsoring
     Thanks to Sphere 10 Software (http://sphere10.com) for sponsoring
     many new types, tests and major refactoring of entire library
     many new types, tests and major refactoring of entire library
 
 
+    Thanks to Castle Game Engine (https://castle-engine.sourceforge.io)
+    Part of tests for this module was copied from Castle Game Engine tests
+
  **********************************************************************}
  **********************************************************************}
 
 
 unit tests.generics.hashmaps;
 unit tests.generics.hashmaps;
@@ -65,6 +70,8 @@ type
     procedure Test_ObjectDictionary;
     procedure Test_ObjectDictionary;
 
 
     procedure Test_TryAddOrSetOrGetValue;
     procedure Test_TryAddOrSetOrGetValue;
+    procedure Test_TryGetValueEmpty_xxHash32;
+    procedure Test_TryGetValueEmpty_xxHash32Pascal;
   end;
   end;
 
 
 implementation
 implementation
@@ -360,6 +367,43 @@ begin
   end;
   end;
 end;
 end;
 
 
+// modified test from Castle Game Engine (https://castle-engine.io/)
+{$DEFINE TEST_TRYGETEMPTYVALUE :=
+  try
+    Map.AddOrSetValue('some key', 'some value');
+
+    B := Map.TryGetValue('some key', V);
+    AssertTrue(B);
+    AssertEquals('some value', V);
+
+    B := Map.TryGetValue('some other key', V);
+    AssertFalse(B);
+
+    B := Map.TryGetValue('', V);
+    AssertFalse(B);
+  finally
+    FreeAndNil(Map)
+  end;
+}
+
+procedure TTestHashMaps.Test_TryGetValueEmpty_xxHash32;
+var
+  Map: TOpenAddressingLP<string, string, TxxHash32HashFactory>;
+  V: String; B: Boolean;
+begin
+  Map := TOpenAddressingLP<string, string, TxxHash32HashFactory>.Create;
+  TEST_TRYGETEMPTYVALUE;
+end;
+
+procedure TTestHashMaps.Test_TryGetValueEmpty_xxHash32Pascal;
+var
+  Map: TOpenAddressingLP<string, string, TxxHash32PascalHashFactory>;
+  V: String; B: Boolean;
+begin
+  Map := TOpenAddressingLP<string, string, TxxHash32PascalHashFactory>.Create;
+  TEST_TRYGETEMPTYVALUE;
+end;
+
 begin
 begin
   RegisterTest(TTestHashMaps);
   RegisterTest(TTestHashMaps);
 end.
 end.

+ 5 - 2
packages/rtl-generics/tests/tests.generics.sets.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 
@@ -18,6 +20,7 @@
     many new types, tests and major refactoring of entire library
     many new types, tests and major refactoring of entire library
 
 
  **********************************************************************}
  **********************************************************************}
+
 unit tests.generics.sets;
 unit tests.generics.sets;
 
 
 {$mode delphi}
 {$mode delphi}

+ 4 - 2
packages/rtl-generics/tests/tests.generics.stdcollections.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 

+ 4 - 2
packages/rtl-generics/tests/tests.generics.trees.pas

@@ -1,7 +1,9 @@
 {
 {
-    This file is part of the Free Pascal run time library.
+    This file is part of the Free Pascal/NewPascal run time library.
     Copyright (c) 2018 by Maciej Izak (hnb),
     Copyright (c) 2018 by Maciej Izak (hnb),
-    member of the Free Pascal development team
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
 
 
     It contains tests for the Free Pascal generics library
     It contains tests for the Free Pascal generics library
 
 

+ 18 - 0
packages/rtl-generics/tests/tests.generics.utils.pas

@@ -1,3 +1,21 @@
+{
+    This file is part of the Free Pascal/NewPascal run time library.
+    Copyright (c) 2014 by Maciej Izak (hnb)
+    member of the NewPascal development team (http://newpascal.org)
+
+    Copyright(c) 2004-2018 DaThoX
+
+    It contains tests for the Free Pascal generics library
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
 unit tests.generics.utils;
 unit tests.generics.utils;
 
 
 {$mode delphi}
 {$mode delphi}