diff src/win32/7zip/7z/C/LzFindMt.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/C/LzFindMt.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,97 @@
     1.4 +/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
     1.5 +2008-10-04 : Igor Pavlov : Public domain */
     1.6 +
     1.7 +#ifndef __LZFINDMT_H
     1.8 +#define __LZFINDMT_H
     1.9 +
    1.10 +#include "Threads.h"
    1.11 +#include "LzFind.h"
    1.12 +
    1.13 +#define kMtHashBlockSize (1 << 13)
    1.14 +#define kMtHashNumBlocks (1 << 3)
    1.15 +#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
    1.16 +
    1.17 +#define kMtBtBlockSize (1 << 14)
    1.18 +#define kMtBtNumBlocks (1 << 6)
    1.19 +#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)
    1.20 +
    1.21 +typedef struct _CMtSync
    1.22 +{
    1.23 +  Bool wasCreated;
    1.24 +  Bool needStart;
    1.25 +  Bool exit;
    1.26 +  Bool stopWriting;
    1.27 +
    1.28 +  CThread thread;
    1.29 +  CAutoResetEvent canStart;
    1.30 +  CAutoResetEvent wasStarted;
    1.31 +  CAutoResetEvent wasStopped;
    1.32 +  CSemaphore freeSemaphore;
    1.33 +  CSemaphore filledSemaphore;
    1.34 +  Bool csWasInitialized;
    1.35 +  Bool csWasEntered;
    1.36 +  CCriticalSection cs;
    1.37 +  UInt32 numProcessedBlocks;
    1.38 +} CMtSync;
    1.39 +
    1.40 +typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
    1.41 +
    1.42 +/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
    1.43 +#define kMtCacheLineDummy 128
    1.44 +
    1.45 +typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
    1.46 +  UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
    1.47 +
    1.48 +typedef struct _CMatchFinderMt
    1.49 +{
    1.50 +  /* LZ */
    1.51 +  const Byte *pointerToCurPos;
    1.52 +  UInt32 *btBuf;
    1.53 +  UInt32 btBufPos;
    1.54 +  UInt32 btBufPosLimit;
    1.55 +  UInt32 lzPos;
    1.56 +  UInt32 btNumAvailBytes;
    1.57 +
    1.58 +  UInt32 *hash;
    1.59 +  UInt32 fixedHashSize;
    1.60 +  UInt32 historySize;
    1.61 +  const UInt32 *crc;
    1.62 +
    1.63 +  Mf_Mix_Matches MixMatchesFunc;
    1.64 +  
    1.65 +  /* LZ + BT */
    1.66 +  CMtSync btSync;
    1.67 +  Byte btDummy[kMtCacheLineDummy];
    1.68 +
    1.69 +  /* BT */
    1.70 +  UInt32 *hashBuf;
    1.71 +  UInt32 hashBufPos;
    1.72 +  UInt32 hashBufPosLimit;
    1.73 +  UInt32 hashNumAvail;
    1.74 +
    1.75 +  CLzRef *son;
    1.76 +  UInt32 matchMaxLen;
    1.77 +  UInt32 numHashBytes;
    1.78 +  UInt32 pos;
    1.79 +  Byte *buffer;
    1.80 +  UInt32 cyclicBufferPos;
    1.81 +  UInt32 cyclicBufferSize; /* it must be historySize + 1 */
    1.82 +  UInt32 cutValue;
    1.83 +
    1.84 +  /* BT + Hash */
    1.85 +  CMtSync hashSync;
    1.86 +  /* Byte hashDummy[kMtCacheLineDummy]; */
    1.87 +  
    1.88 +  /* Hash */
    1.89 +  Mf_GetHeads GetHeadsFunc;
    1.90 +  CMatchFinder *MatchFinder;
    1.91 +} CMatchFinderMt;
    1.92 +
    1.93 +void MatchFinderMt_Construct(CMatchFinderMt *p);
    1.94 +void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);
    1.95 +SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
    1.96 +    UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);
    1.97 +void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
    1.98 +void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
    1.99 +
   1.100 +#endif