pyxcp 0.21.9__cp39-cp39-win_amd64.whl → 0.22.23__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyxcp might be problematic. Click here for more details.

Files changed (173) hide show
  1. pyxcp/__init__.py +12 -20
  2. pyxcp/aml/EtasCANMonitoring.a2l +82 -83
  3. pyxcp/aml/XCP_Common.aml +0 -1
  4. pyxcp/aml/XCPonUSB.aml +1 -1
  5. pyxcp/aml/ifdata_CAN.a2l +0 -1
  6. pyxcp/aml/ifdata_Eth.a2l +0 -1
  7. pyxcp/aml/ifdata_Flx.a2l +0 -1
  8. pyxcp/aml/ifdata_SxI.a2l +0 -1
  9. pyxcp/aml/ifdata_USB.a2l +0 -1
  10. pyxcp/asam/types.py +4 -4
  11. pyxcp/asamkeydll.c +0 -1
  12. pyxcp/checksum.py +0 -1
  13. pyxcp/cmdline.py +32 -50
  14. pyxcp/config/__init__.py +1100 -0
  15. pyxcp/config/legacy.py +120 -0
  16. pyxcp/constants.py +12 -13
  17. pyxcp/cpp_ext/__init__.py +0 -0
  18. pyxcp/cpp_ext/bin.hpp +104 -0
  19. pyxcp/cpp_ext/blockmem.hpp +58 -0
  20. pyxcp/cpp_ext/cpp_ext.cp38-win_amd64.pyd +0 -0
  21. pyxcp/cpp_ext/cpp_ext.cp39-win_amd64.pyd +0 -0
  22. pyxcp/cpp_ext/daqlist.hpp +200 -0
  23. pyxcp/cpp_ext/event.hpp +67 -0
  24. pyxcp/cpp_ext/extension_wrapper.cpp +96 -0
  25. pyxcp/cpp_ext/helper.hpp +280 -0
  26. pyxcp/cpp_ext/mcobject.hpp +246 -0
  27. pyxcp/cpp_ext/tsqueue.hpp +46 -0
  28. pyxcp/daq_stim/__init__.py +228 -0
  29. pyxcp/daq_stim/optimize/__init__.py +67 -0
  30. pyxcp/daq_stim/optimize/binpacking.py +41 -0
  31. pyxcp/daq_stim/scheduler.cpp +28 -0
  32. pyxcp/daq_stim/scheduler.hpp +75 -0
  33. pyxcp/daq_stim/stim.cp38-win_amd64.pyd +0 -0
  34. pyxcp/daq_stim/stim.cp39-win_amd64.pyd +0 -0
  35. pyxcp/daq_stim/stim.cpp +13 -0
  36. pyxcp/daq_stim/stim.hpp +604 -0
  37. pyxcp/daq_stim/stim_wrapper.cpp +48 -0
  38. pyxcp/dllif.py +21 -18
  39. pyxcp/errormatrix.py +5 -3
  40. pyxcp/examples/conf_can.toml +4 -2
  41. pyxcp/examples/conf_can_vector.json +9 -9
  42. pyxcp/examples/conf_can_vector.toml +4 -2
  43. pyxcp/examples/conf_eth.toml +5 -2
  44. pyxcp/examples/conf_nixnet.json +18 -18
  45. pyxcp/examples/conf_sxi.json +7 -7
  46. pyxcp/examples/ex_arrow.py +109 -0
  47. pyxcp/examples/ex_csv.py +85 -0
  48. pyxcp/examples/ex_excel.py +95 -0
  49. pyxcp/examples/ex_mdf.py +124 -0
  50. pyxcp/examples/ex_sqlite.py +128 -0
  51. pyxcp/examples/run_daq.py +148 -0
  52. pyxcp/examples/xcp_policy.py +6 -7
  53. pyxcp/examples/xcp_read_benchmark.py +8 -6
  54. pyxcp/examples/xcp_skel.py +0 -2
  55. pyxcp/examples/xcp_unlock.py +1 -1
  56. pyxcp/examples/xcp_user_supplied_driver.py +1 -2
  57. pyxcp/examples/xcphello.py +6 -3
  58. pyxcp/examples/xcphello_recorder.py +4 -4
  59. pyxcp/master/__init__.py +1 -2
  60. pyxcp/master/errorhandler.py +107 -74
  61. pyxcp/master/master.py +196 -114
  62. pyxcp/py.typed +0 -0
  63. pyxcp/recorder/__init__.py +27 -6
  64. pyxcp/recorder/converter/__init__.py +37 -0
  65. pyxcp/recorder/lz4.c +129 -51
  66. pyxcp/recorder/lz4.h +45 -28
  67. pyxcp/recorder/lz4hc.c +560 -156
  68. pyxcp/recorder/lz4hc.h +1 -1
  69. pyxcp/recorder/mio.hpp +721 -767
  70. pyxcp/recorder/reader.hpp +139 -0
  71. pyxcp/recorder/reco.py +5 -8
  72. pyxcp/recorder/rekorder.cp38-win_amd64.pyd +0 -0
  73. pyxcp/recorder/rekorder.cp39-win_amd64.pyd +0 -0
  74. pyxcp/recorder/rekorder.cpp +18 -22
  75. pyxcp/recorder/rekorder.hpp +200 -587
  76. pyxcp/recorder/setup.py +11 -10
  77. pyxcp/recorder/test_reko.py +2 -3
  78. pyxcp/recorder/unfolder.hpp +1332 -0
  79. pyxcp/recorder/wrap.cpp +171 -9
  80. pyxcp/recorder/writer.hpp +302 -0
  81. pyxcp/scripts/pyxcp_probe_can_drivers.py +0 -2
  82. pyxcp/scripts/xcp_examples.py +64 -0
  83. pyxcp/scripts/xcp_fetch_a2l.py +15 -10
  84. pyxcp/scripts/xcp_id_scanner.py +2 -6
  85. pyxcp/scripts/xcp_info.py +101 -63
  86. pyxcp/scripts/xcp_profile.py +27 -0
  87. pyxcp/stim/__init__.py +0 -0
  88. pyxcp/tests/test_asam_types.py +2 -2
  89. pyxcp/tests/test_binpacking.py +186 -0
  90. pyxcp/tests/test_can.py +1132 -38
  91. pyxcp/tests/test_checksum.py +2 -1
  92. pyxcp/tests/test_daq.py +193 -0
  93. pyxcp/tests/test_frame_padding.py +6 -3
  94. pyxcp/tests/test_master.py +42 -31
  95. pyxcp/tests/test_transport.py +12 -12
  96. pyxcp/tests/test_utils.py +2 -5
  97. pyxcp/timing.py +0 -2
  98. pyxcp/transport/__init__.py +9 -9
  99. pyxcp/transport/base.py +149 -127
  100. pyxcp/transport/base_transport.hpp +0 -0
  101. pyxcp/transport/can.py +194 -167
  102. pyxcp/transport/eth.py +80 -82
  103. pyxcp/transport/sxi.py +106 -60
  104. pyxcp/transport/transport_wrapper.cpp +0 -0
  105. pyxcp/transport/usb_transport.py +65 -83
  106. pyxcp/types.py +69 -20
  107. pyxcp/utils.py +47 -16
  108. pyxcp/vector/map.py +1 -3
  109. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/METADATA +28 -23
  110. pyxcp-0.22.23.dist-info/RECORD +131 -0
  111. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/WHEEL +1 -1
  112. {pyxcp-0.21.9.dist-info → pyxcp-0.22.23.dist-info}/entry_points.txt +2 -0
  113. pyxcp/config.py +0 -57
  114. pyxcp/cxx/asynchiofactory.hpp +0 -24
  115. pyxcp/cxx/blocking_client.cpp +0 -44
  116. pyxcp/cxx/blocking_socket.cpp +0 -43
  117. pyxcp/cxx/blocking_socket.hpp +0 -558
  118. pyxcp/cxx/concurrent_queue.hpp +0 -60
  119. pyxcp/cxx/eth.hpp +0 -57
  120. pyxcp/cxx/exceptions.hpp +0 -30
  121. pyxcp/cxx/iasyncioservice.hpp +0 -31
  122. pyxcp/cxx/iresource.hpp +0 -17
  123. pyxcp/cxx/isocket.hpp +0 -22
  124. pyxcp/cxx/linux/epoll.cpp +0 -51
  125. pyxcp/cxx/linux/epoll.hpp +0 -87
  126. pyxcp/cxx/linux/lit_tester.cpp +0 -19
  127. pyxcp/cxx/linux/socket.hpp +0 -234
  128. pyxcp/cxx/linux/timeout.hpp +0 -81
  129. pyxcp/cxx/memoryblock.hpp +0 -42
  130. pyxcp/cxx/pool.hpp +0 -81
  131. pyxcp/cxx/poolmgr.cpp +0 -6
  132. pyxcp/cxx/poolmgr.hpp +0 -31
  133. pyxcp/cxx/test_queue.cpp +0 -69
  134. pyxcp/cxx/timestamp.hpp +0 -84
  135. pyxcp/cxx/utils.cpp +0 -38
  136. pyxcp/cxx/utils.hpp +0 -29
  137. pyxcp/cxx/win/iocp.cpp +0 -242
  138. pyxcp/cxx/win/iocp.hpp +0 -42
  139. pyxcp/cxx/win/perhandledata.hpp +0 -24
  140. pyxcp/cxx/win/periodata.hpp +0 -97
  141. pyxcp/cxx/win/socket.hpp +0 -185
  142. pyxcp/cxx/win/timeout.hpp +0 -83
  143. pyxcp/examples/conf_can.json +0 -20
  144. pyxcp/examples/conf_eth.json +0 -8
  145. pyxcp/logger.py +0 -67
  146. pyxcp/tests/test_config.py +0 -62
  147. pyxcp/transport/candriver/__init__.py +0 -2
  148. pyxcp/transport/candriver/pc_canalystii.py +0 -27
  149. pyxcp/transport/candriver/pc_etas.py +0 -25
  150. pyxcp/transport/candriver/pc_gsusb.py +0 -23
  151. pyxcp/transport/candriver/pc_iscan.py +0 -23
  152. pyxcp/transport/candriver/pc_ixxat.py +0 -27
  153. pyxcp/transport/candriver/pc_kvaser.py +0 -39
  154. pyxcp/transport/candriver/pc_neovi.py +0 -31
  155. pyxcp/transport/candriver/pc_nican.py +0 -23
  156. pyxcp/transport/candriver/pc_nixnet.py +0 -23
  157. pyxcp/transport/candriver/pc_pcan.py +0 -25
  158. pyxcp/transport/candriver/pc_seeed.py +0 -28
  159. pyxcp/transport/candriver/pc_serial.py +0 -27
  160. pyxcp/transport/candriver/pc_slcan.py +0 -29
  161. pyxcp/transport/candriver/pc_socketcan.py +0 -23
  162. pyxcp/transport/candriver/pc_systec.py +0 -29
  163. pyxcp/transport/candriver/pc_usb2can.py +0 -30
  164. pyxcp/transport/candriver/pc_vector.py +0 -34
  165. pyxcp/transport/candriver/python_can.py +0 -101
  166. pyxcp/transport/cxx_ext/CMakeLists.txt +0 -51
  167. pyxcp/transport/cxx_ext/setup.py +0 -49
  168. pyxcp/transport/cxx_ext/tests/test_basic_socket.cpp +0 -39
  169. pyxcp/transport/cxx_ext/tests/test_pool.cpp +0 -39
  170. pyxcp/transport/cxx_ext/tests/test_timestamp.cpp +0 -27
  171. pyxcp-0.21.9.dist-info/RECORD +0 -147
  172. rekorder.cp39-win_amd64.pyd +0 -0
  173. {pyxcp-0.21.9.dist-info/licenses → pyxcp-0.22.23.dist-info}/LICENSE +0 -0
pyxcp/recorder/lz4.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  LZ4 - Fast LZ compression algorithm
3
- Copyright (C) 2011-2020, Yann Collet.
3
+ Copyright (C) 2011-2023, Yann Collet.
4
4
 
5
5
  BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
6
 
@@ -79,7 +79,7 @@
79
79
  ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) \
80
80
  || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
81
81
  # define LZ4_FORCE_MEMORY_ACCESS 2
82
- # elif (defined(__INTEL_COMPILER) && !defined(_WIN32)) || defined(__GNUC__)
82
+ # elif (defined(__INTEL_COMPILER) && !defined(_WIN32)) || defined(__GNUC__) || defined(_MSC_VER)
83
83
  # define LZ4_FORCE_MEMORY_ACCESS 1
84
84
  # endif
85
85
  #endif
@@ -106,15 +106,13 @@
106
106
  # define LZ4_SRC_INCLUDED 1
107
107
  #endif
108
108
 
109
- #ifndef LZ4_STATIC_LINKING_ONLY
110
- #define LZ4_STATIC_LINKING_ONLY
111
- #endif
112
-
113
109
  #ifndef LZ4_DISABLE_DEPRECATE_WARNINGS
114
- #define LZ4_DISABLE_DEPRECATE_WARNINGS /* due to LZ4_decompress_safe_withPrefix64k */
110
+ # define LZ4_DISABLE_DEPRECATE_WARNINGS /* due to LZ4_decompress_safe_withPrefix64k */
115
111
  #endif
116
112
 
117
- #define LZ4_STATIC_LINKING_ONLY /* LZ4_DISTANCE_MAX */
113
+ #ifndef LZ4_STATIC_LINKING_ONLY
114
+ # define LZ4_STATIC_LINKING_ONLY
115
+ #endif
118
116
  #include "lz4.h"
119
117
  /* see also "memory routines" below */
120
118
 
@@ -126,14 +124,17 @@
126
124
  # include <intrin.h> /* only present in VS2005+ */
127
125
  # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
128
126
  # pragma warning(disable : 6237) /* disable: C6237: conditional expression is always 0 */
127
+ # pragma warning(disable : 6239) /* disable: C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression> */
128
+ # pragma warning(disable : 6240) /* disable: C6240: (<expression> && <non-zero constant>) always evaluates to the result of <expression> */
129
+ # pragma warning(disable : 6326) /* disable: C6326: Potential comparison of a constant with another constant */
129
130
  #endif /* _MSC_VER */
130
131
 
131
132
  #ifndef LZ4_FORCE_INLINE
132
- # ifdef _MSC_VER /* Visual Studio */
133
+ # if defined (_MSC_VER) && !defined (__clang__) /* MSVC */
133
134
  # define LZ4_FORCE_INLINE static __forceinline
134
135
  # else
135
136
  # if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
136
- # ifdef __GNUC__
137
+ # if defined (__GNUC__) || defined (__clang__)
137
138
  # define LZ4_FORCE_INLINE static inline __attribute__((always_inline))
138
139
  # else
139
140
  # define LZ4_FORCE_INLINE static inline
@@ -365,6 +366,11 @@ static unsigned LZ4_isLittleEndian(void)
365
366
  return one.c[0];
366
367
  }
367
368
 
369
+ #if defined(__GNUC__) || defined(__INTEL_COMPILER)
370
+ #define LZ4_PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
371
+ #elif defined(_MSC_VER)
372
+ #define LZ4_PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
373
+ #endif
368
374
 
369
375
  #if defined(LZ4_FORCE_MEMORY_ACCESS) && (LZ4_FORCE_MEMORY_ACCESS==2)
370
376
  /* lie to the compiler about data alignment; use with caution */
@@ -380,9 +386,9 @@ static void LZ4_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
380
386
 
381
387
  /* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
382
388
  /* currently only defined for gcc and icc */
383
- typedef struct { U16 u16; } __attribute__((packed)) LZ4_unalign16;
384
- typedef struct { U32 u32; } __attribute__((packed)) LZ4_unalign32;
385
- typedef struct { reg_t uArch; } __attribute__((packed)) LZ4_unalignST;
389
+ LZ4_PACK(typedef struct { U16 u16; }) LZ4_unalign16;
390
+ LZ4_PACK(typedef struct { U32 u32; }) LZ4_unalign32;
391
+ LZ4_PACK(typedef struct { reg_t uArch; }) LZ4_unalignST;
386
392
 
387
393
  static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
388
394
  static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign32*)ptr)->u32; }
@@ -427,10 +433,22 @@ static U16 LZ4_readLE16(const void* memPtr)
427
433
  return LZ4_read16(memPtr);
428
434
  } else {
429
435
  const BYTE* p = (const BYTE*)memPtr;
430
- return (U16)((U16)p[0] + (p[1]<<8));
436
+ return (U16)((U16)p[0] | (p[1]<<8));
431
437
  }
432
438
  }
433
439
 
440
+ #ifdef LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT
441
+ static U32 LZ4_readLE32(const void* memPtr)
442
+ {
443
+ if (LZ4_isLittleEndian()) {
444
+ return LZ4_read32(memPtr);
445
+ } else {
446
+ const BYTE* p = (const BYTE*)memPtr;
447
+ return (U32)p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
448
+ }
449
+ }
450
+ #endif
451
+
434
452
  static void LZ4_writeLE16(void* memPtr, U16 value)
435
453
  {
436
454
  if (LZ4_isLittleEndian()) {
@@ -512,7 +530,7 @@ LZ4_wildCopy32(void* dstPtr, const void* srcPtr, void* dstEnd)
512
530
 
513
531
  /* LZ4_memcpy_using_offset() presumes :
514
532
  * - dstEnd >= dstPtr + MINMATCH
515
- * - there is at least 8 bytes available to write after dstEnd */
533
+ * - there is at least 12 bytes available to write after dstEnd */
516
534
  LZ4_FORCE_INLINE void
517
535
  LZ4_memcpy_using_offset(BYTE* dstPtr, const BYTE* srcPtr, BYTE* dstEnd, const size_t offset)
518
536
  {
@@ -527,12 +545,12 @@ LZ4_memcpy_using_offset(BYTE* dstPtr, const BYTE* srcPtr, BYTE* dstEnd, const si
527
545
  case 2:
528
546
  LZ4_memcpy(v, srcPtr, 2);
529
547
  LZ4_memcpy(&v[2], srcPtr, 2);
530
- #if defined(_MSC_VER) && (_MSC_VER <= 1936) /* MSVC 2022 ver 17.6 or earlier */
548
+ #if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
531
549
  # pragma warning(push)
532
550
  # pragma warning(disable : 6385) /* warning C6385: Reading invalid data from 'v'. */
533
551
  #endif
534
552
  LZ4_memcpy(&v[4], v, 4);
535
- #if defined(_MSC_VER) && (_MSC_VER <= 1936) /* MSVC 2022 ver 17.6 or earlier */
553
+ #if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
536
554
  # pragma warning(pop)
537
555
  #endif
538
556
  break;
@@ -779,7 +797,12 @@ LZ4_FORCE_INLINE U32 LZ4_hash5(U64 sequence, tableType_t const tableType)
779
797
  LZ4_FORCE_INLINE U32 LZ4_hashPosition(const void* const p, tableType_t const tableType)
780
798
  {
781
799
  if ((sizeof(reg_t)==8) && (tableType != byU16)) return LZ4_hash5(LZ4_read_ARCH(p), tableType);
800
+
801
+ #ifdef LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT
802
+ return LZ4_hash4(LZ4_readLE32(p), tableType);
803
+ #else
782
804
  return LZ4_hash4(LZ4_read32(p), tableType);
805
+ #endif
783
806
  }
784
807
 
785
808
  LZ4_FORCE_INLINE void LZ4_clearHash(U32 h, void* tableBase, tableType_t const tableType)
@@ -898,7 +921,7 @@ LZ4_prepareTable(LZ4_stream_t_internal* const cctx,
898
921
  cctx->dictSize = 0;
899
922
  }
900
923
 
901
- /** LZ4_compress_generic() :
924
+ /** LZ4_compress_generic_validated() :
902
925
  * inlined, to ensure branches are decided at compilation time.
903
926
  * The following conditions are presumed already validated:
904
927
  * - source != NULL
@@ -1080,7 +1103,10 @@ LZ4_FORCE_INLINE int LZ4_compress_generic_validated(
1080
1103
 
1081
1104
  /* Catch up */
1082
1105
  filledIp = ip;
1083
- while (((ip>anchor) & (match > lowLimit)) && (unlikely(ip[-1]==match[-1]))) { ip--; match--; }
1106
+ assert(ip > anchor); /* this is always true as ip has been advanced before entering the main loop */
1107
+ if ((match > lowLimit) && unlikely(ip[-1] == match[-1])) {
1108
+ do { ip--; match--; } while (((ip > anchor) & (match > lowLimit)) && (unlikely(ip[-1] == match[-1])));
1109
+ }
1084
1110
 
1085
1111
  /* Encode Literals */
1086
1112
  { unsigned const litLength = (unsigned)(ip - anchor);
@@ -1095,7 +1121,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic_validated(
1095
1121
  goto _last_literals;
1096
1122
  }
1097
1123
  if (litLength >= RUN_MASK) {
1098
- int len = (int)(litLength - RUN_MASK);
1124
+ unsigned len = litLength - RUN_MASK;
1099
1125
  *token = (RUN_MASK<<ML_BITS);
1100
1126
  for(; len >= 255 ; len-=255) *op++ = 255;
1101
1127
  *op++ = (BYTE)len;
@@ -1452,22 +1478,30 @@ int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacit
1452
1478
  /* Note!: This function leaves the stream in an unclean/broken state!
1453
1479
  * It is not safe to subsequently use the same state with a _fastReset() or
1454
1480
  * _continue() call without resetting it. */
1455
- static int LZ4_compress_destSize_extState (LZ4_stream_t* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize)
1481
+ static int LZ4_compress_destSize_extState_internal(LZ4_stream_t* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize, int acceleration)
1456
1482
  {
1457
1483
  void* const s = LZ4_initStream(state, sizeof (*state));
1458
1484
  assert(s != NULL); (void)s;
1459
1485
 
1460
1486
  if (targetDstSize >= LZ4_compressBound(*srcSizePtr)) { /* compression success is guaranteed */
1461
- return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, 1);
1487
+ return LZ4_compress_fast_extState(state, src, dst, *srcSizePtr, targetDstSize, acceleration);
1462
1488
  } else {
1463
1489
  if (*srcSizePtr < LZ4_64Klimit) {
1464
- return LZ4_compress_generic(&state->internal_donotuse, src, dst, *srcSizePtr, srcSizePtr, targetDstSize, fillOutput, byU16, noDict, noDictIssue, 1);
1490
+ return LZ4_compress_generic(&state->internal_donotuse, src, dst, *srcSizePtr, srcSizePtr, targetDstSize, fillOutput, byU16, noDict, noDictIssue, acceleration);
1465
1491
  } else {
1466
1492
  tableType_t const addrMode = ((sizeof(void*)==4) && ((uptrval)src > LZ4_DISTANCE_MAX)) ? byPtr : byU32;
1467
- return LZ4_compress_generic(&state->internal_donotuse, src, dst, *srcSizePtr, srcSizePtr, targetDstSize, fillOutput, addrMode, noDict, noDictIssue, 1);
1493
+ return LZ4_compress_generic(&state->internal_donotuse, src, dst, *srcSizePtr, srcSizePtr, targetDstSize, fillOutput, addrMode, noDict, noDictIssue, acceleration);
1468
1494
  } }
1469
1495
  }
1470
1496
 
1497
+ int LZ4_compress_destSize_extState(void* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize, int acceleration)
1498
+ {
1499
+ int const r = LZ4_compress_destSize_extState_internal((LZ4_stream_t*)state, src, dst, srcSizePtr, targetDstSize, acceleration);
1500
+ /* clean the state on exit */
1501
+ LZ4_initStream(state, sizeof (LZ4_stream_t));
1502
+ return r;
1503
+ }
1504
+
1471
1505
 
1472
1506
  int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize)
1473
1507
  {
@@ -1479,7 +1513,7 @@ int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targe
1479
1513
  LZ4_stream_t* const ctx = &ctxBody;
1480
1514
  #endif
1481
1515
 
1482
- int result = LZ4_compress_destSize_extState(ctx, src, dst, srcSizePtr, targetDstSize);
1516
+ int result = LZ4_compress_destSize_extState_internal(ctx, src, dst, srcSizePtr, targetDstSize, 1);
1483
1517
 
1484
1518
  #if (LZ4_HEAPMODE)
1485
1519
  FREEMEM(ctx);
@@ -1548,8 +1582,11 @@ int LZ4_freeStream (LZ4_stream_t* LZ4_stream)
1548
1582
  #endif
1549
1583
 
1550
1584
 
1585
+ typedef enum { _ld_fast, _ld_slow } LoadDict_mode_e;
1551
1586
  #define HASH_UNIT sizeof(reg_t)
1552
- int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
1587
+ int LZ4_loadDict_internal(LZ4_stream_t* LZ4_dict,
1588
+ const char* dictionary, int dictSize,
1589
+ LoadDict_mode_e _ld)
1553
1590
  {
1554
1591
  LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;
1555
1592
  const tableType_t tableType = byU32;
@@ -1585,13 +1622,39 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
1585
1622
 
1586
1623
  while (p <= dictEnd-HASH_UNIT) {
1587
1624
  U32 const h = LZ4_hashPosition(p, tableType);
1625
+ /* Note: overwriting => favors positions end of dictionary */
1588
1626
  LZ4_putIndexOnHash(idx32, h, dict->hashTable, tableType);
1589
1627
  p+=3; idx32+=3;
1590
1628
  }
1591
1629
 
1630
+ if (_ld == _ld_slow) {
1631
+ /* Fill hash table with additional references, to improve compression capability */
1632
+ p = dict->dictionary;
1633
+ idx32 = dict->currentOffset - dict->dictSize;
1634
+ while (p <= dictEnd-HASH_UNIT) {
1635
+ U32 const h = LZ4_hashPosition(p, tableType);
1636
+ U32 const limit = dict->currentOffset - 64 KB;
1637
+ if (LZ4_getIndexOnHash(h, dict->hashTable, tableType) <= limit) {
1638
+ /* Note: not overwriting => favors positions beginning of dictionary */
1639
+ LZ4_putIndexOnHash(idx32, h, dict->hashTable, tableType);
1640
+ }
1641
+ p++; idx32++;
1642
+ }
1643
+ }
1644
+
1592
1645
  return (int)dict->dictSize;
1593
1646
  }
1594
1647
 
1648
+ int LZ4_loadDict(LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
1649
+ {
1650
+ return LZ4_loadDict_internal(LZ4_dict, dictionary, dictSize, _ld_fast);
1651
+ }
1652
+
1653
+ int LZ4_loadDictSlow(LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
1654
+ {
1655
+ return LZ4_loadDict_internal(LZ4_dict, dictionary, dictSize, _ld_slow);
1656
+ }
1657
+
1595
1658
  void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream)
1596
1659
  {
1597
1660
  const LZ4_stream_t_internal* dictCtx = (dictionaryStream == NULL) ? NULL :
@@ -1923,6 +1986,17 @@ read_variable_length(const BYTE** ip, const BYTE* ilimit,
1923
1986
  if (initial_check && unlikely((*ip) >= ilimit)) { /* read limit reached */
1924
1987
  return rvl_error;
1925
1988
  }
1989
+ s = **ip;
1990
+ (*ip)++;
1991
+ length += s;
1992
+ if (unlikely((*ip) > ilimit)) { /* read limit reached */
1993
+ return rvl_error;
1994
+ }
1995
+ /* accumulator overflow detection (32-bit mode only) */
1996
+ if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
1997
+ return rvl_error;
1998
+ }
1999
+ if (likely(s != 255)) return length;
1926
2000
  do {
1927
2001
  s = **ip;
1928
2002
  (*ip)++;
@@ -1931,10 +2005,10 @@ read_variable_length(const BYTE** ip, const BYTE* ilimit,
1931
2005
  return rvl_error;
1932
2006
  }
1933
2007
  /* accumulator overflow detection (32-bit mode only) */
1934
- if ((sizeof(length)<8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
2008
+ if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
1935
2009
  return rvl_error;
1936
2010
  }
1937
- } while (s==255);
2011
+ } while (s == 255);
1938
2012
 
1939
2013
  return length;
1940
2014
  }
@@ -2000,7 +2074,7 @@ LZ4_decompress_generic(
2000
2074
  * note : fast loop may show a regression for some client arm chips. */
2001
2075
  #if LZ4_FAST_DEC_LOOP
2002
2076
  if ((oend - op) < FASTLOOP_SAFE_DISTANCE) {
2003
- DEBUGLOG(6, "skip fast decode loop");
2077
+ DEBUGLOG(6, "move to safe decode loop");
2004
2078
  goto safe_decode;
2005
2079
  }
2006
2080
 
@@ -2012,6 +2086,7 @@ LZ4_decompress_generic(
2012
2086
  assert(ip < iend);
2013
2087
  token = *ip++;
2014
2088
  length = token >> ML_BITS; /* literal length */
2089
+ DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
2015
2090
 
2016
2091
  /* decode literal length */
2017
2092
  if (length == RUN_MASK) {
@@ -2025,49 +2100,47 @@ LZ4_decompress_generic(
2025
2100
  if (unlikely((uptrval)(ip)+length<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
2026
2101
 
2027
2102
  /* copy literals */
2028
- cpy = op+length;
2029
2103
  LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
2030
- if ((cpy>oend-32) || (ip+length>iend-32)) { goto safe_literal_copy; }
2031
- LZ4_wildCopy32(op, ip, cpy);
2032
- ip += length; op = cpy;
2033
- } else {
2034
- cpy = op+length;
2035
- DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)length);
2104
+ if ((op+length>oend-32) || (ip+length>iend-32)) { goto safe_literal_copy; }
2105
+ LZ4_wildCopy32(op, ip, op+length);
2106
+ ip += length; op += length;
2107
+ } else if (ip <= iend-(16 + 1/*max lit + offset + nextToken*/)) {
2036
2108
  /* We don't need to check oend, since we check it once for each loop below */
2037
- if (ip > iend-(16 + 1/*max lit + offset + nextToken*/)) { goto safe_literal_copy; }
2109
+ DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)length);
2038
2110
  /* Literals can only be <= 14, but hope compilers optimize better when copy by a register size */
2039
2111
  LZ4_memcpy(op, ip, 16);
2040
- ip += length; op = cpy;
2112
+ ip += length; op += length;
2113
+ } else {
2114
+ goto safe_literal_copy;
2041
2115
  }
2042
2116
 
2043
2117
  /* get offset */
2044
2118
  offset = LZ4_readLE16(ip); ip+=2;
2045
- DEBUGLOG(6, " offset = %zu", offset);
2119
+ DEBUGLOG(6, "blockPos%6u: offset = %u", (unsigned)(op-(BYTE*)dst), (unsigned)offset);
2046
2120
  match = op - offset;
2047
2121
  assert(match <= op); /* overflow check */
2048
2122
 
2049
2123
  /* get matchlength */
2050
2124
  length = token & ML_MASK;
2125
+ DEBUGLOG(7, " match length token = %u (len==%u)", (unsigned)length, (unsigned)length+MINMATCH);
2051
2126
 
2052
2127
  if (length == ML_MASK) {
2053
2128
  size_t const addl = read_variable_length(&ip, iend - LASTLITERALS + 1, 0);
2054
2129
  if (addl == rvl_error) {
2055
- DEBUGLOG(6, "error reading long match length");
2130
+ DEBUGLOG(5, "error reading long match length");
2056
2131
  goto _output_error;
2057
2132
  }
2058
2133
  length += addl;
2059
2134
  length += MINMATCH;
2135
+ DEBUGLOG(7, " long match length == %u", (unsigned)length);
2060
2136
  if (unlikely((uptrval)(op)+length<(uptrval)op)) { goto _output_error; } /* overflow detection */
2061
- if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) {
2062
- DEBUGLOG(6, "Error : offset outside buffers");
2063
- goto _output_error;
2064
- }
2065
2137
  if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
2066
2138
  goto safe_match_copy;
2067
2139
  }
2068
2140
  } else {
2069
2141
  length += MINMATCH;
2070
2142
  if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
2143
+ DEBUGLOG(7, "moving to safe_match_copy (ml==%u)", (unsigned)length);
2071
2144
  goto safe_match_copy;
2072
2145
  }
2073
2146
 
@@ -2086,7 +2159,7 @@ LZ4_decompress_generic(
2086
2159
  } } }
2087
2160
 
2088
2161
  if ( checkOffset && (unlikely(match + dictSize < lowPrefix)) ) {
2089
- DEBUGLOG(6, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
2162
+ DEBUGLOG(5, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
2090
2163
  goto _output_error;
2091
2164
  }
2092
2165
  /* match starting within external dictionary */
@@ -2143,6 +2216,7 @@ LZ4_decompress_generic(
2143
2216
  assert(ip < iend);
2144
2217
  token = *ip++;
2145
2218
  length = token >> ML_BITS; /* literal length */
2219
+ DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
2146
2220
 
2147
2221
  /* A two-stage shortcut for the most common case:
2148
2222
  * 1) If the literal length is 0..14, and there is enough space,
@@ -2163,6 +2237,7 @@ LZ4_decompress_generic(
2163
2237
  /* The second stage: prepare for match copying, decode full info.
2164
2238
  * If it doesn't work out, the info won't be wasted. */
2165
2239
  length = token & ML_MASK; /* match length */
2240
+ DEBUGLOG(7, "blockPos%6u: matchLength token = %u (len=%u)", (unsigned)(op-(BYTE*)dst), (unsigned)length, (unsigned)length + 4);
2166
2241
  offset = LZ4_readLE16(ip); ip += 2;
2167
2242
  match = op - offset;
2168
2243
  assert(match <= op); /* check overflow */
@@ -2194,11 +2269,12 @@ LZ4_decompress_generic(
2194
2269
  if (unlikely((uptrval)(ip)+length<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
2195
2270
  }
2196
2271
 
2197
- /* copy literals */
2198
- cpy = op+length;
2199
2272
  #if LZ4_FAST_DEC_LOOP
2200
2273
  safe_literal_copy:
2201
2274
  #endif
2275
+ /* copy literals */
2276
+ cpy = op+length;
2277
+
2202
2278
  LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
2203
2279
  if ((cpy>oend-MFLIMIT) || (ip+length>iend-(2+1+LASTLITERALS))) {
2204
2280
  /* We've either hit the input parsing restriction or the output parsing restriction.
@@ -2234,9 +2310,10 @@ LZ4_decompress_generic(
2234
2310
  * so check that we exactly consume the input and don't overrun the output buffer.
2235
2311
  */
2236
2312
  if ((ip+length != iend) || (cpy > oend)) {
2237
- DEBUGLOG(6, "should have been last run of literals")
2238
- DEBUGLOG(6, "ip(%p) + length(%i) = %p != iend (%p)", ip, (int)length, ip+length, iend);
2239
- DEBUGLOG(6, "or cpy(%p) > oend(%p)", cpy, oend);
2313
+ DEBUGLOG(5, "should have been last run of literals")
2314
+ DEBUGLOG(5, "ip(%p) + length(%i) = %p != iend (%p)", ip, (int)length, ip+length, iend);
2315
+ DEBUGLOG(5, "or cpy(%p) > (oend-MFLIMIT)(%p)", cpy, oend-MFLIMIT);
2316
+ DEBUGLOG(5, "after writing %u bytes / %i bytes available", (unsigned)(op-(BYTE*)dst), outputSize);
2240
2317
  goto _output_error;
2241
2318
  }
2242
2319
  }
@@ -2262,6 +2339,7 @@ LZ4_decompress_generic(
2262
2339
 
2263
2340
  /* get matchlength */
2264
2341
  length = token & ML_MASK;
2342
+ DEBUGLOG(7, "blockPos%6u: matchLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
2265
2343
 
2266
2344
  _copy_match:
2267
2345
  if (length == ML_MASK) {
@@ -2351,7 +2429,7 @@ LZ4_decompress_generic(
2351
2429
  while (op < cpy) { *op++ = *match++; }
2352
2430
  } else {
2353
2431
  LZ4_memcpy(op, match, 8);
2354
- if (length > 16) { LZ4_wildCopy8(op+8, match+8, cpy); }
2432
+ if (length > 16) { LZ4_wildCopy8(op+8, match+8, cpy); }
2355
2433
  }
2356
2434
  op = cpy; /* wildcopy correction */
2357
2435
  }
pyxcp/recorder/lz4.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * LZ4 - Fast LZ compression algorithm
3
3
  * Header File
4
- * Copyright (C) 2011-2020, Yann Collet.
4
+ * Copyright (C) 2011-2023, Yann Collet.
5
5
 
6
6
  BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
7
 
@@ -130,7 +130,7 @@ extern "C" {
130
130
  /*------ Version ------*/
131
131
  #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
132
132
  #define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
133
- #define LZ4_VERSION_RELEASE 4 /* for tweaks, bug-fixes, or development */
133
+ #define LZ4_VERSION_RELEASE 5 /* for tweaks, bug-fixes, or development */
134
134
 
135
135
  #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
136
136
 
@@ -144,23 +144,25 @@ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string;
144
144
 
145
145
 
146
146
  /*-************************************
147
- * Tuning parameter
147
+ * Tuning memory usage
148
148
  **************************************/
149
- #define LZ4_MEMORY_USAGE_MIN 10
150
- #define LZ4_MEMORY_USAGE_DEFAULT 14
151
- #define LZ4_MEMORY_USAGE_MAX 20
152
-
153
149
  /*!
154
150
  * LZ4_MEMORY_USAGE :
155
- * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
156
- * Increasing memory usage improves compression ratio, at the cost of speed.
151
+ * Can be selected at compile time, by setting LZ4_MEMORY_USAGE.
152
+ * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB)
153
+ * Increasing memory usage improves compression ratio, generally at the cost of speed.
157
154
  * Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
158
- * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
155
+ * Default value is 14, for 16KB, which nicely fits into most L1 caches.
159
156
  */
160
157
  #ifndef LZ4_MEMORY_USAGE
161
158
  # define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
162
159
  #endif
163
160
 
161
+ /* These are absolute limits, they should not be changed by users */
162
+ #define LZ4_MEMORY_USAGE_MIN 10
163
+ #define LZ4_MEMORY_USAGE_DEFAULT 14
164
+ #define LZ4_MEMORY_USAGE_MAX 20
165
+
164
166
  #if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
165
167
  # error "LZ4_MEMORY_USAGE is too small !"
166
168
  #endif
@@ -191,7 +193,7 @@ LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int
191
193
  /*! LZ4_decompress_safe() :
192
194
  * @compressedSize : is the exact complete size of the compressed block.
193
195
  * @dstCapacity : is the size of destination buffer (which must be already allocated),
194
- * is an upper bound of decompressed size.
196
+ * presumed an upper bound of decompressed size.
195
197
  * @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
196
198
  * If destination buffer is not large enough, decoding will stop and output an error code (negative value).
197
199
  * If the source stream is detected malformed, the function will stop decoding and return a negative result.
@@ -243,17 +245,17 @@ LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int d
243
245
  LZ4LIB_API int LZ4_sizeofState(void);
244
246
  LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
245
247
 
246
-
247
248
  /*! LZ4_compress_destSize() :
248
249
  * Reverse the logic : compresses as much data as possible from 'src' buffer
249
- * into already allocated buffer 'dst', of size >= 'targetDestSize'.
250
+ * into already allocated buffer 'dst', of size >= 'dstCapacity'.
250
251
  * This function either compresses the entire 'src' content into 'dst' if it's large enough,
251
252
  * or fill 'dst' buffer completely with as much data as possible from 'src'.
252
253
  * note: acceleration parameter is fixed to "default".
253
254
  *
254
- * *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
255
+ * *srcSizePtr : in+out parameter. Initially contains size of input.
256
+ * Will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
255
257
  * New value is necessarily <= input value.
256
- * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
258
+ * @return : Nb bytes written into 'dst' (necessarily <= dstCapacity)
257
259
  * or 0 if compression fails.
258
260
  *
259
261
  * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+):
@@ -267,8 +269,7 @@ LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* d
267
269
  * a dstCapacity which is > decompressedSize, by at least 1 byte.
268
270
  * See https://github.com/lz4/lz4/issues/859 for details
269
271
  */
270
- LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
271
-
272
+ LZ4LIB_API int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize);
272
273
 
273
274
  /*! LZ4_decompress_safe_partial() :
274
275
  * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
@@ -312,7 +313,7 @@ LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcS
312
313
  ***********************************************/
313
314
  typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
314
315
 
315
- /**
316
+ /*!
316
317
  Note about RC_INVOKED
317
318
 
318
319
  - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
@@ -362,13 +363,22 @@ LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
362
363
  * LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
363
364
  * The same dictionary will have to be loaded on decompression side for successful decoding.
364
365
  * Dictionary are useful for better compression of small data (KB range).
365
- * While LZ4 accept any input as dictionary,
366
- * results are generally better when using Zstandard's Dictionary Builder.
366
+ * While LZ4 itself accepts any input as dictionary, dictionary efficiency is also a topic.
367
+ * When in doubt, employ the Zstandard's Dictionary Builder.
367
368
  * Loading a size of 0 is allowed, and is the same as reset.
368
- * @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
369
+ * @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)
369
370
  */
370
371
  LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
371
372
 
373
+ /*! LZ4_loadDictSlow() : v1.9.5+
374
+ * Same as LZ4_loadDict(),
375
+ * but uses a bit more cpu to reference the dictionary content more thoroughly.
376
+ * This is expected to slightly improve compression ratio.
377
+ * The extra-cpu cost is likely worth it if the dictionary is re-used across multiple sessions.
378
+ * @return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)
379
+ */
380
+ LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
381
+
372
382
  /*! LZ4_compress_fast_continue() :
373
383
  * Compress 'src' content using data from previously compressed blocks, for better compression ratio.
374
384
  * 'dst' buffer must be already allocated.
@@ -546,9 +556,9 @@ LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
546
556
  #define LZ4_STATIC_3504398509
547
557
 
548
558
  #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
549
- #define LZ4LIB_STATIC_API LZ4LIB_API
559
+ # define LZ4LIB_STATIC_API LZ4LIB_API
550
560
  #else
551
- #define LZ4LIB_STATIC_API
561
+ # define LZ4LIB_STATIC_API
552
562
  #endif
553
563
 
554
564
 
@@ -564,6 +574,12 @@ LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
564
574
  */
565
575
  LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
566
576
 
577
+ /*! LZ4_compress_destSize_extState() :
578
+ * Same as LZ4_compress_destSize(), but using an externally allocated state.
579
+ * Also: exposes @acceleration
580
+ */
581
+ int LZ4_compress_destSize_extState(void* state, const char* src, char* dst, int* srcSizePtr, int targetDstSize, int acceleration);
582
+
567
583
  /*! LZ4_attach_dictionary() :
568
584
  * This is an experimental API that allows
569
585
  * efficient use of a static dictionary many times.
@@ -705,7 +721,7 @@ struct LZ4_stream_t_internal {
705
721
  /* Implicit padding to ensure structure is aligned */
706
722
  };
707
723
 
708
- #define LZ4_STREAM_MINSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
724
+ #define LZ4_STREAM_MINSIZE ((1UL << (LZ4_MEMORY_USAGE)) + 32) /* static size, for inter-version compatibility */
709
725
  union LZ4_stream_u {
710
726
  char minStateSize[LZ4_STREAM_MINSIZE];
711
727
  LZ4_stream_t_internal internal_donotuse;
@@ -726,7 +742,7 @@ union LZ4_stream_u {
726
742
  * Note2: An LZ4_stream_t structure guarantees correct alignment and size.
727
743
  * Note3: Before v1.9.0, use LZ4_resetStream() instead
728
744
  **/
729
- LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
745
+ LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* stateBuffer, size_t size);
730
746
 
731
747
 
732
748
  /*! LZ4_streamDecode_t :
@@ -838,11 +854,12 @@ LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4
838
854
  * But they may happen if input data is invalid (error or intentional tampering).
839
855
  * As a consequence, use these functions in trusted environments with trusted data **only**.
840
856
  */
841
- LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
857
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial() instead")
842
858
  LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
843
- LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
859
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating towards LZ4_decompress_safe_continue() instead. "
860
+ "Note that the contract will change (requires block's compressed size, instead of decompressed size)")
844
861
  LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
845
- LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
862
+ LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_partial_usingDict() instead")
846
863
  LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
847
864
 
848
865
  /*! LZ4_resetStream() :