zstdlib 0.1.2-x86-mingw32 → 0.2.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/CHANGES.md +7 -0
  4. data/README.md +4 -3
  5. data/ext/zstdlib/extconf.rb +1 -1
  6. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/bitstream.h +0 -0
  7. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/compiler.h +1 -1
  8. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/cpu.h +0 -0
  9. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/debug.c +0 -0
  10. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/debug.h +0 -0
  11. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/entropy_common.c +0 -0
  12. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/error_private.c +0 -0
  13. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/error_private.h +0 -0
  14. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/fse.h +1 -1
  15. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/fse_decompress.c +0 -0
  16. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/huf.h +0 -0
  17. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/mem.h +0 -0
  18. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/pool.c +0 -0
  19. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/pool.h +0 -0
  20. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/threading.c +2 -2
  21. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/threading.h +0 -0
  22. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/xxhash.c +2 -2
  23. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/xxhash.h +0 -0
  24. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/zstd_common.c +0 -0
  25. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/zstd_errors.h +0 -0
  26. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/common/zstd_internal.h +55 -2
  27. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/fse_compress.c +2 -2
  28. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/hist.c +0 -0
  29. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/hist.h +0 -0
  30. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/huf_compress.c +0 -0
  31. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_compress.c +423 -296
  32. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_compress_internal.h +14 -11
  33. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_double_fast.c +0 -0
  34. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_double_fast.h +0 -0
  35. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_fast.c +203 -124
  36. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_fast.h +0 -0
  37. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_lazy.c +0 -0
  38. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_lazy.h +1 -1
  39. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_ldm.c +1 -1
  40. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_ldm.h +0 -0
  41. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_opt.c +27 -11
  42. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstd_opt.h +0 -0
  43. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstdmt_compress.c +41 -49
  44. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/compress/zstdmt_compress.h +43 -26
  45. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/huf_decompress.c +0 -0
  46. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_ddict.c +4 -4
  47. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_ddict.h +0 -0
  48. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_decompress.c +257 -164
  49. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_decompress_block.c +51 -47
  50. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_decompress_block.h +0 -0
  51. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/decompress/zstd_decompress_internal.h +7 -0
  52. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/lib/zstd.h +689 -542
  53. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzclose.c +0 -0
  54. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzcompatibility.h +0 -0
  55. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzguts.h +2 -0
  56. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzlib.c +0 -0
  57. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzread.c +0 -0
  58. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/gzwrite.c +0 -0
  59. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/zstd_zlibwrapper.c +0 -0
  60. data/ext/zstdlib/{zstd-1.3.8 → zstd-1.4.0}/zlibWrapper/zstd_zlibwrapper.h +0 -0
  61. data/lib/2.2/zstdlib.so +0 -0
  62. data/lib/2.3/zstdlib.so +0 -0
  63. data/lib/2.4/zstdlib.so +0 -0
  64. data/lib/2.5/zstdlib.so +0 -0
  65. data/lib/2.6/zstdlib.so +0 -0
  66. metadata +58 -57
@@ -22,6 +22,7 @@
22
22
  /* ====== Dependencies ====== */
23
23
  #include <string.h> /* memcpy, memset */
24
24
  #include <limits.h> /* INT_MAX, UINT_MAX */
25
+ #include "mem.h" /* MEM_STATIC */
25
26
  #include "pool.h" /* threadpool */
26
27
  #include "threading.h" /* mutex */
27
28
  #include "zstd_compress_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */
@@ -456,7 +457,7 @@ typedef struct {
456
457
  * Must be acquired after the main mutex when acquiring both.
457
458
  */
458
459
  ZSTD_pthread_mutex_t ldmWindowMutex;
459
- ZSTD_pthread_cond_t ldmWindowCond; /* Signaled when ldmWindow is udpated */
460
+ ZSTD_pthread_cond_t ldmWindowCond; /* Signaled when ldmWindow is updated */
460
461
  ZSTD_window_t ldmWindow; /* A thread-safe copy of ldmState.window */
461
462
  } serialState_t;
462
463
 
@@ -647,7 +648,7 @@ static void ZSTDMT_compressionJob(void* jobDescription)
647
648
  buffer_t dstBuff = job->dstBuff;
648
649
  size_t lastCBlockSize = 0;
649
650
 
650
- /* ressources */
651
+ /* resources */
651
652
  if (cctx==NULL) JOB_ERROR(ERROR(memory_allocation));
652
653
  if (dstBuff.start == NULL) { /* streaming job : doesn't provide a dstBuffer */
653
654
  dstBuff = ZSTDMT_getBuffer(job->bufPool);
@@ -672,7 +673,7 @@ static void ZSTDMT_compressionJob(void* jobDescription)
672
673
  if (ZSTD_isError(initError)) JOB_ERROR(initError);
673
674
  } else { /* srcStart points at reloaded section */
674
675
  U64 const pledgedSrcSize = job->firstJob ? job->fullFrameSize : job->src.size;
675
- { size_t const forceWindowError = ZSTD_CCtxParam_setParameter(&jobParams, ZSTD_c_forceMaxWindow, !job->firstJob);
676
+ { size_t const forceWindowError = ZSTD_CCtxParams_setParameter(&jobParams, ZSTD_c_forceMaxWindow, !job->firstJob);
676
677
  if (ZSTD_isError(forceWindowError)) JOB_ERROR(forceWindowError);
677
678
  }
678
679
  { size_t const initError = ZSTD_compressBegin_advanced_internal(cctx,
@@ -864,14 +865,10 @@ static size_t ZSTDMT_expandJobsTable (ZSTDMT_CCtx* mtctx, U32 nbWorkers) {
864
865
  * Internal use only */
865
866
  size_t ZSTDMT_CCtxParam_setNbWorkers(ZSTD_CCtx_params* params, unsigned nbWorkers)
866
867
  {
867
- if (nbWorkers > ZSTDMT_NBWORKERS_MAX) nbWorkers = ZSTDMT_NBWORKERS_MAX;
868
- params->nbWorkers = nbWorkers;
869
- params->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT;
870
- params->jobSize = 0;
871
- return nbWorkers;
868
+ return ZSTD_CCtxParams_setParameter(params, ZSTD_c_nbWorkers, (int)nbWorkers);
872
869
  }
873
870
 
874
- ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers, ZSTD_customMem cMem)
871
+ MEM_STATIC ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced_internal(unsigned nbWorkers, ZSTD_customMem cMem)
875
872
  {
876
873
  ZSTDMT_CCtx* mtctx;
877
874
  U32 nbJobs = nbWorkers + 2;
@@ -906,6 +903,17 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers, ZSTD_customMem cMem)
906
903
  return mtctx;
907
904
  }
908
905
 
906
+ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers, ZSTD_customMem cMem)
907
+ {
908
+ #ifdef ZSTD_MULTITHREAD
909
+ return ZSTDMT_createCCtx_advanced_internal(nbWorkers, cMem);
910
+ #else
911
+ (void)nbWorkers;
912
+ (void)cMem;
913
+ return NULL;
914
+ #endif
915
+ }
916
+
909
917
  ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbWorkers)
910
918
  {
911
919
  return ZSTDMT_createCCtx_advanced(nbWorkers, ZSTD_defaultCMem);
@@ -986,26 +994,13 @@ ZSTDMT_CCtxParam_setMTCtxParameter(ZSTD_CCtx_params* params,
986
994
  {
987
995
  case ZSTDMT_p_jobSize :
988
996
  DEBUGLOG(4, "ZSTDMT_CCtxParam_setMTCtxParameter : set jobSize to %i", value);
989
- if ( value != 0 /* default */
990
- && value < ZSTDMT_JOBSIZE_MIN)
991
- value = ZSTDMT_JOBSIZE_MIN;
992
- assert(value >= 0);
993
- if (value > ZSTDMT_JOBSIZE_MAX) value = ZSTDMT_JOBSIZE_MAX;
994
- params->jobSize = value;
995
- return value;
996
-
997
+ return ZSTD_CCtxParams_setParameter(params, ZSTD_c_jobSize, value);
997
998
  case ZSTDMT_p_overlapLog :
998
999
  DEBUGLOG(4, "ZSTDMT_p_overlapLog : %i", value);
999
- if (value < ZSTD_OVERLAPLOG_MIN) value = ZSTD_OVERLAPLOG_MIN;
1000
- if (value > ZSTD_OVERLAPLOG_MAX) value = ZSTD_OVERLAPLOG_MAX;
1001
- params->overlapLog = value;
1002
- return value;
1003
-
1000
+ return ZSTD_CCtxParams_setParameter(params, ZSTD_c_overlapLog, value);
1004
1001
  case ZSTDMT_p_rsyncable :
1005
- value = (value != 0);
1006
- params->rsyncable = value;
1007
- return value;
1008
-
1002
+ DEBUGLOG(4, "ZSTD_p_rsyncable : %i", value);
1003
+ return ZSTD_CCtxParams_setParameter(params, ZSTD_c_rsyncable, value);
1009
1004
  default :
1010
1005
  return ERROR(parameter_unsupported);
1011
1006
  }
@@ -1021,32 +1016,29 @@ size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter,
1021
1016
  {
1022
1017
  switch (parameter) {
1023
1018
  case ZSTDMT_p_jobSize:
1024
- assert(mtctx->params.jobSize <= INT_MAX);
1025
- *value = (int)(mtctx->params.jobSize);
1026
- break;
1019
+ return ZSTD_CCtxParams_getParameter(&mtctx->params, ZSTD_c_jobSize, value);
1027
1020
  case ZSTDMT_p_overlapLog:
1028
- *value = mtctx->params.overlapLog;
1029
- break;
1021
+ return ZSTD_CCtxParams_getParameter(&mtctx->params, ZSTD_c_overlapLog, value);
1030
1022
  case ZSTDMT_p_rsyncable:
1031
- *value = mtctx->params.rsyncable;
1032
- break;
1023
+ return ZSTD_CCtxParams_getParameter(&mtctx->params, ZSTD_c_rsyncable, value);
1033
1024
  default:
1034
1025
  return ERROR(parameter_unsupported);
1035
1026
  }
1036
- return 0;
1037
1027
  }
1038
1028
 
1039
1029
  /* Sets parameters relevant to the compression job,
1040
1030
  * initializing others to default values. */
1041
1031
  static ZSTD_CCtx_params ZSTDMT_initJobCCtxParams(ZSTD_CCtx_params const params)
1042
1032
  {
1043
- ZSTD_CCtx_params jobParams;
1044
- memset(&jobParams, 0, sizeof(jobParams));
1045
-
1046
- jobParams.cParams = params.cParams;
1047
- jobParams.fParams = params.fParams;
1048
- jobParams.compressionLevel = params.compressionLevel;
1049
-
1033
+ ZSTD_CCtx_params jobParams = params;
1034
+ /* Clear parameters related to multithreading */
1035
+ jobParams.forceWindow = 0;
1036
+ jobParams.nbWorkers = 0;
1037
+ jobParams.jobSize = 0;
1038
+ jobParams.overlapLog = 0;
1039
+ jobParams.rsyncable = 0;
1040
+ memset(&jobParams.ldmParams, 0, sizeof(ldmParams_t));
1041
+ memset(&jobParams.customMem, 0, sizeof(ZSTD_customMem));
1050
1042
  return jobParams;
1051
1043
  }
1052
1044
 
@@ -1056,7 +1048,7 @@ static ZSTD_CCtx_params ZSTDMT_initJobCCtxParams(ZSTD_CCtx_params const params)
1056
1048
  static size_t ZSTDMT_resize(ZSTDMT_CCtx* mtctx, unsigned nbWorkers)
1057
1049
  {
1058
1050
  if (POOL_resize(mtctx->factory, nbWorkers)) return ERROR(memory_allocation);
1059
- CHECK_F( ZSTDMT_expandJobsTable(mtctx, nbWorkers) );
1051
+ FORWARD_IF_ERROR( ZSTDMT_expandJobsTable(mtctx, nbWorkers) );
1060
1052
  mtctx->bufPool = ZSTDMT_expandBufferPool(mtctx->bufPool, nbWorkers);
1061
1053
  if (mtctx->bufPool == NULL) return ERROR(memory_allocation);
1062
1054
  mtctx->cctxPool = ZSTDMT_expandCCtxPool(mtctx->cctxPool, nbWorkers);
@@ -1263,7 +1255,7 @@ static size_t ZSTDMT_compress_advanced_internal(
1263
1255
  if (ZSTDMT_serialState_reset(&mtctx->serial, mtctx->seqPool, params, avgJobSize))
1264
1256
  return ERROR(memory_allocation);
1265
1257
 
1266
- CHECK_F( ZSTDMT_expandJobsTable(mtctx, nbJobs) ); /* only expands if necessary */
1258
+ FORWARD_IF_ERROR( ZSTDMT_expandJobsTable(mtctx, nbJobs) ); /* only expands if necessary */
1267
1259
 
1268
1260
  { unsigned u;
1269
1261
  for (u=0; u<nbJobs; u++) {
@@ -1396,7 +1388,7 @@ size_t ZSTDMT_initCStream_internal(
1396
1388
 
1397
1389
  /* init */
1398
1390
  if (params.nbWorkers != mtctx->params.nbWorkers)
1399
- CHECK_F( ZSTDMT_resize(mtctx, params.nbWorkers) );
1391
+ FORWARD_IF_ERROR( ZSTDMT_resize(mtctx, params.nbWorkers) );
1400
1392
 
1401
1393
  if (params.jobSize != 0 && params.jobSize < ZSTDMT_JOBSIZE_MIN) params.jobSize = ZSTDMT_JOBSIZE_MIN;
1402
1394
  if (params.jobSize > (size_t)ZSTDMT_JOBSIZE_MAX) params.jobSize = ZSTDMT_JOBSIZE_MAX;
@@ -1547,7 +1539,7 @@ size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel) {
1547
1539
  /* ZSTDMT_writeLastEmptyBlock()
1548
1540
  * Write a single empty block with an end-of-frame to finish a frame.
1549
1541
  * Job must be created from streaming variant.
1550
- * This function is always successfull if expected conditions are fulfilled.
1542
+ * This function is always successful if expected conditions are fulfilled.
1551
1543
  */
1552
1544
  static void ZSTDMT_writeLastEmptyBlock(ZSTDMT_jobDescription* job)
1553
1545
  {
@@ -1987,7 +1979,7 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
1987
1979
  assert(input->pos <= input->size);
1988
1980
 
1989
1981
  if (mtctx->singleBlockingThread) { /* delegate to single-thread (synchronous) */
1990
- return ZSTD_compressStream_generic(mtctx->cctxPool->cctx[0], output, input, endOp);
1982
+ return ZSTD_compressStream2(mtctx->cctxPool->cctx[0], output, input, endOp);
1991
1983
  }
1992
1984
 
1993
1985
  if ((mtctx->frameEnded) && (endOp==ZSTD_e_continue)) {
@@ -2051,7 +2043,7 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
2051
2043
  || ((endOp == ZSTD_e_end) && (!mtctx->frameEnded)) ) { /* must finish the frame with a zero-size block */
2052
2044
  size_t const jobSize = mtctx->inBuff.filled;
2053
2045
  assert(mtctx->inBuff.filled <= mtctx->targetSectionSize);
2054
- CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp) );
2046
+ FORWARD_IF_ERROR( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp) );
2055
2047
  }
2056
2048
 
2057
2049
  /* check for potential compressed data ready to be flushed */
@@ -2065,7 +2057,7 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
2065
2057
 
2066
2058
  size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
2067
2059
  {
2068
- CHECK_F( ZSTDMT_compressStream_generic(mtctx, output, input, ZSTD_e_continue) );
2060
+ FORWARD_IF_ERROR( ZSTDMT_compressStream_generic(mtctx, output, input, ZSTD_e_continue) );
2069
2061
 
2070
2062
  /* recommended next input size : fill current input buffer */
2071
2063
  return mtctx->targetSectionSize - mtctx->inBuff.filled; /* note : could be zero when input buffer is fully filled and no more availability to create new job */
@@ -2082,7 +2074,7 @@ static size_t ZSTDMT_flushStream_internal(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* ou
2082
2074
  || ((endFrame==ZSTD_e_end) && !mtctx->frameEnded)) { /* need a last 0-size block to end frame */
2083
2075
  DEBUGLOG(5, "ZSTDMT_flushStream_internal : create a new job (%u bytes, end:%u)",
2084
2076
  (U32)srcSize, (U32)endFrame);
2085
- CHECK_F( ZSTDMT_createCompressionJob(mtctx, srcSize, endFrame) );
2077
+ FORWARD_IF_ERROR( ZSTDMT_createCompressionJob(mtctx, srcSize, endFrame) );
2086
2078
  }
2087
2079
 
2088
2080
  /* check if there is any data available to flush */
@@ -17,10 +17,25 @@
17
17
 
18
18
 
19
19
  /* Note : This is an internal API.
20
- * Some methods are still exposed (ZSTDLIB_API),
20
+ * These APIs used to be exposed with ZSTDLIB_API,
21
21
  * because it used to be the only way to invoke MT compression.
22
- * Now, it's recommended to use ZSTD_compress_generic() instead.
23
- * These methods will stop being exposed in a future version */
22
+ * Now, it's recommended to use ZSTD_compress2 and ZSTD_compressStream2()
23
+ * instead.
24
+ *
25
+ * If you depend on these APIs and can't switch, then define
26
+ * ZSTD_LEGACY_MULTITHREADED_API when making the dynamic library.
27
+ * However, we may completely remove these functions in a future
28
+ * release, so please switch soon.
29
+ *
30
+ * This API requires ZSTD_MULTITHREAD to be defined during compilation,
31
+ * otherwise ZSTDMT_createCCtx*() will fail.
32
+ */
33
+
34
+ #ifdef ZSTD_LEGACY_MULTITHREADED_API
35
+ # define ZSTDMT_API ZSTDLIB_API
36
+ #else
37
+ # define ZSTDMT_API
38
+ #endif
24
39
 
25
40
  /* === Dependencies === */
26
41
  #include <stddef.h> /* size_t */
@@ -40,17 +55,19 @@
40
55
 
41
56
  /* === Memory management === */
42
57
  typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
43
- ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbWorkers);
44
- ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers,
58
+ /* Requires ZSTD_MULTITHREAD to be defined during compilation, otherwise it will return NULL. */
59
+ ZSTDMT_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbWorkers);
60
+ /* Requires ZSTD_MULTITHREAD to be defined during compilation, otherwise it will return NULL. */
61
+ ZSTDMT_API ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers,
45
62
  ZSTD_customMem cMem);
46
- ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx);
63
+ ZSTDMT_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx);
47
64
 
48
- ZSTDLIB_API size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx);
65
+ ZSTDMT_API size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx);
49
66
 
50
67
 
51
68
  /* === Simple one-pass compression function === */
52
69
 
53
- ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
70
+ ZSTDMT_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
54
71
  void* dst, size_t dstCapacity,
55
72
  const void* src, size_t srcSize,
56
73
  int compressionLevel);
@@ -59,31 +76,31 @@ ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
59
76
 
60
77
  /* === Streaming functions === */
61
78
 
62
- ZSTDLIB_API size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel);
63
- ZSTDLIB_API size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* mtctx, unsigned long long pledgedSrcSize); /**< if srcSize is not known at reset time, use ZSTD_CONTENTSIZE_UNKNOWN. Note: for compatibility with older programs, 0 means the same as ZSTD_CONTENTSIZE_UNKNOWN, but it will change in the future to mean "empty" */
79
+ ZSTDMT_API size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel);
80
+ ZSTDMT_API size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* mtctx, unsigned long long pledgedSrcSize); /**< if srcSize is not known at reset time, use ZSTD_CONTENTSIZE_UNKNOWN. Note: for compatibility with older programs, 0 means the same as ZSTD_CONTENTSIZE_UNKNOWN, but it will change in the future to mean "empty" */
64
81
 
65
- ZSTDLIB_API size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx);
66
- ZSTDLIB_API size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
82
+ ZSTDMT_API size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx);
83
+ ZSTDMT_API size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
67
84
 
68
- ZSTDLIB_API size_t ZSTDMT_flushStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
69
- ZSTDLIB_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
85
+ ZSTDMT_API size_t ZSTDMT_flushStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
86
+ ZSTDMT_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
70
87
 
71
88
 
72
89
  /* === Advanced functions and parameters === */
73
90
 
74
- ZSTDLIB_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
75
- void* dst, size_t dstCapacity,
76
- const void* src, size_t srcSize,
77
- const ZSTD_CDict* cdict,
78
- ZSTD_parameters params,
79
- int overlapLog);
91
+ ZSTDMT_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
92
+ void* dst, size_t dstCapacity,
93
+ const void* src, size_t srcSize,
94
+ const ZSTD_CDict* cdict,
95
+ ZSTD_parameters params,
96
+ int overlapLog);
80
97
 
81
- ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
98
+ ZSTDMT_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
82
99
  const void* dict, size_t dictSize, /* dict can be released after init, a local copy is preserved within zcs */
83
100
  ZSTD_parameters params,
84
101
  unsigned long long pledgedSrcSize); /* pledgedSrcSize is optional and can be zero == unknown */
85
102
 
86
- ZSTDLIB_API size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
103
+ ZSTDMT_API size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
87
104
  const ZSTD_CDict* cdict,
88
105
  ZSTD_frameParameters fparams,
89
106
  unsigned long long pledgedSrcSize); /* note : zero means empty */
@@ -92,7 +109,7 @@ ZSTDLIB_API size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
92
109
  * List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
93
110
  typedef enum {
94
111
  ZSTDMT_p_jobSize, /* Each job is compressed in parallel. By default, this value is dynamically determined depending on compression parameters. Can be set explicitly here. */
95
- ZSTDMT_p_overlapLog, /* Each job may reload a part of previous job to enhance compressionr ratio; 0 == no overlap, 6(default) == use 1/8th of window, >=9 == use full window. This is a "sticky" parameter : its value will be re-used on next compression job */
112
+ ZSTDMT_p_overlapLog, /* Each job may reload a part of previous job to enhance compression ratio; 0 == no overlap, 6(default) == use 1/8th of window, >=9 == use full window. This is a "sticky" parameter : its value will be re-used on next compression job */
96
113
  ZSTDMT_p_rsyncable /* Enables rsyncable mode. */
97
114
  } ZSTDMT_parameter;
98
115
 
@@ -101,12 +118,12 @@ typedef enum {
101
118
  * The function must be called typically after ZSTD_createCCtx() but __before ZSTDMT_init*() !__
102
119
  * Parameters not explicitly reset by ZSTDMT_init*() remain the same in consecutive compression sessions.
103
120
  * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
104
- ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int value);
121
+ ZSTDMT_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int value);
105
122
 
106
123
  /* ZSTDMT_getMTCtxParameter() :
107
124
  * Query the ZSTDMT_CCtx for a parameter value.
108
125
  * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
109
- ZSTDLIB_API size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int* value);
126
+ ZSTDMT_API size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int* value);
110
127
 
111
128
 
112
129
  /*! ZSTDMT_compressStream_generic() :
@@ -116,7 +133,7 @@ ZSTDLIB_API size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter
116
133
  * 0 if fully flushed
117
134
  * or an error code
118
135
  * note : needs to be init using any ZSTD_initCStream*() variant */
119
- ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
136
+ ZSTDMT_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
120
137
  ZSTD_outBuffer* output,
121
138
  ZSTD_inBuffer* input,
122
139
  ZSTD_EndDirective endOp);
@@ -105,9 +105,9 @@ ZSTD_loadEntropy_intoDDict(ZSTD_DDict* ddict,
105
105
  ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
106
106
 
107
107
  /* load entropy tables */
108
- CHECK_E( ZSTD_loadDEntropy(&ddict->entropy,
109
- ddict->dictContent, ddict->dictSize),
110
- dictionary_corrupted );
108
+ RETURN_ERROR_IF(ZSTD_isError(ZSTD_loadDEntropy(
109
+ &ddict->entropy, ddict->dictContent, ddict->dictSize)),
110
+ dictionary_corrupted);
111
111
  ddict->entropyPresent = 1;
112
112
  return 0;
113
113
  }
@@ -133,7 +133,7 @@ static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict,
133
133
  ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
134
134
 
135
135
  /* parse dictionary content */
136
- CHECK_F( ZSTD_loadEntropy_intoDDict(ddict, dictContentType) );
136
+ FORWARD_IF_ERROR( ZSTD_loadEntropy_intoDDict(ddict, dictContentType) );
137
137
 
138
138
  return 0;
139
139
  }