Permalink
Browse files

lizard.dpr FPC project

to have working Lizard1-32.dll/Lizard1-64.dll for Delphi
- also uploaded to https://synopse.info/files/SynLizardLibs.7z
  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Nov 27, 2017
1 parent a4fceba commit 267b98c9a8cc3f3416500e944393d22e106e4c6b
Showing with 52 additions and 13 deletions.
  1. +17 −9 SynLizard.pas
  2. +17 −3 SynSelfTests.pas
  3. +1 −1 SynopseCommit.inc
  4. +17 −0 lizard.dpr
@@ -1,4 +1,4 @@
/// fast Lizard (LZ5) Compression routines (FPC only yet)
/// fast Lizard (LZ5) Compression routines (static for FPC only yet)
// - licensed under a MPL/GPL/LGPL tri-license; original Lizard is BSD 2-Clause
unit SynLizard;
@@ -115,9 +115,6 @@
external Lizard1-32.dll/Lizard1-64.dll/liblizard.so.1
from https://synopse.info/files/SynLizardLibs.7z
WARNING: Lizard1-32.dll/Lizard1-64.dll files currently DON'T WORK :(
-> use FPC for proper static linking
}
interface
@@ -220,7 +217,7 @@ TSynLizard = class
end;
var
/// direct access to the low-level Lizard (LZ5) library
/// direct access to the low-level Lizard (LZ5) library
// - is defined by default if Lizard was statically linked (under FPC)
// - otherwise, you should execute explictly:
// ! if Lizard = nil then
@@ -230,8 +227,10 @@ TSynLizard = class
type
/// try to load a LIZARD_LIB_NAME external library
// - static linking is currently available only on FPC Win32/64 and Linux32/64
// - this class is expected to access .dll files for Delphi - but it is NOT
// WORKING YET, due to not good support of the Windows platform for Lizard :(
// - this class is expected to access Lizard1-32.dll/Lizard1-64.dll files for
// Delphi, as such:
// ! if Lizard = nil then
// ! Lizard := TSynLizardDynamic.Create;
TSynLizardDynamic = class(TSynLizard)
protected
{$ifdef FPC}
@@ -257,7 +256,16 @@ TSynLizardStatic = class(TSynLizard)
end;
{$endif LIZARD_EXTERNALONLY}
{$ifndef LIZARD_STANDALONE}
{$ifdef LIZARD_STANDALONE}
function Lizard_versionNumber: integer; cdecl;
function Lizard_compressBound(inputSize: integer): integer; cdecl;
function Lizard_compress(src, dst: pointer; srcSize, maxDstSize, compressionLevel: integer): integer; cdecl;
function Lizard_sizeofState(compressionLevel: integer): integer; cdecl;
function Lizard_compress_extState(state: pointer;
src, dst: pointer; srcSize, maxDstSize, compressionLevel: integer): integer; cdecl;
function Lizard_decompress_safe(src, dst: pointer; srcSize, maxDstSize: integer): integer; cdecl;
function Lizard_decompress_safe_partial(src, dst: pointer; srcSize, targetDstSize: integer): integer; cdecl;
{$else}
var
/// implement Lizard compression in level 17 (LIZARD_DEFAULT_CLEVEL) as AlgoID=4
// - is set by TSynLizard.Create, so available e.g. if library is statically linked
@@ -462,7 +470,7 @@ constructor TSynLizard.Create;
const
LIZARD_ENTRIES: array[0..6] of TFileName =
('versionNumber', 'compressbound', 'compress', 'sizeofState',
('versionNumber', 'compressBound', 'compress', 'sizeofState',
'compress_extState', 'decompress_safe', 'decompress_safe_partial');
constructor TSynLizardDynamic.Create(const aLibraryFile: TFileName);
@@ -9394,15 +9394,22 @@ procedure TTestCompression._TAlgoCompress;
if log<>'' then
break;
end;
AddConsole(format('%s %s->%s: comp %s/s decomp %s/s', [algo.ClassName,
KB(plain), KB(comp), KB((plain*Int64(1000*1000)) div timecomp),
KB((plain*Int64(1000*1000)) div timedecomp)]));
AddConsole(format('%s %s->%s: comp %d:%dMB/s decomp %d:%dMB/s',
[algo.ClassName, KB(plain), KB(comp),
((plain*Int64(1000*1000)) div timecomp)shr 20,
((comp*Int64(1000*1000)) div timecomp)shr 20,
((comp*Int64(1000*1000)) div timedecomp)shr 20,
((plain*Int64(1000*1000)) div timedecomp)shr 20]));
s2 := algo.Decompress(algo.Compress(s),false);
Check(s2=s, algo.ClassName);
if (log<>'') and (s2<>s) then FileFromString(s2,'bigTestPartial'+algo.ClassName+'.log');
end;
begin
TestAlgo(AlgoSynLZ);
{$ifdef MSWINDOWS}
if (Lizard=nil) and FileExists(ExeVersion.ProgramFilePath+LIZARD_LIB_NAME) then
Lizard := TSynLizardDynamic.Create;
{$endif}
TestAlgo(AlgoLizard);
TestAlgo(AlgoLizardFast);
{$ifndef DELPHI5OROLDER}
@@ -9411,6 +9418,13 @@ procedure TTestCompression._TAlgoCompress;
{$endif}
end;
{ FPC Linux x86-64 for a 53MB log file:
TAlgoSynLz 53 MB->5 MB: comp 650:62MB/s decomp 90:945MB/s
TAlgoLizard 53 MB->3.9 MB: comp 55:4MB/s decomp 139:1881MB/s
TAlgoLizardFast 53 MB->6.8 MB: comp 695:89MB/s decomp 196:1522MB/s
TAlgoDeflate 53 MB->4.8 MB: comp 71:6MB/s decomp 48:540MB/s
TAlgoDeflateFast 53 MB->7 MB: comp 142:18MB/s decomp 56:428MB/s
}
{ TTestCryptographicRoutines }
@@ -1 +1 @@
'1.18.4009'
'1.18.4010'
@@ -0,0 +1,17 @@
/// compiled under FPC to have working lizard1-32.dll/lizard1-64.dll files for Delphi
library lizard;
uses
SynLizard; // LIZARD_STANDALONE should be defined in the Lazarus Projects Options
{$ifndef FPC}
FPC-only library - not compilable under Delphi
{$endif}
exports
Lizard_versionNumber, Lizard_compressBound, Lizard_compress,
Lizard_sizeofState, Lizard_compress_extState,
Lizard_decompress_safe, Lizard_decompress_safe_partial;
begin
end.

0 comments on commit 267b98c

Please sign in to comment.