@@ -27,6 +27,7 @@ Changes compared to CPython:
27
27
#include "isal_shared.h"
28
28
29
29
#include <isa-l/crc.h>
30
+ #include "crc32_combine.h"
30
31
31
32
#define Z_DEFAULT_STRATEGY 0
32
33
#define Z_FILTERED 1
@@ -1187,6 +1188,39 @@ isal_zlib_Decompress_flush(decompobject *self, PyObject *const *args, Py_ssize_t
1187
1188
return isal_zlib_Decompress_flush_impl (self , length );
1188
1189
}
1189
1190
1191
+ PyDoc_STRVAR (isal_zlib_crc32_combine__doc__ ,
1192
+ "crc32_combine($module, crc1, crc2, crc2_length /)\n"
1193
+ "--\n"
1194
+ "\n"
1195
+ "Combine crc1 and crc2 into a new crc that is accurate for the combined data \n"
1196
+ "blocks that crc1 and crc2 where calculated from.\n"
1197
+ "\n"
1198
+ " crc1\n"
1199
+ " the first crc32 checksum\n"
1200
+ " crc2\n"
1201
+ " the second crc32 checksum\n"
1202
+ " crc2_length\n"
1203
+ " the lenght of the data block crc2 was calculated from\n"
1204
+ );
1205
+
1206
+
1207
+ #define ISAL_ZLIB_CRC32_COMBINE_METHODDEF \
1208
+ {"crc32_combine", (PyCFunction)(void(*)(void))isal_zlib_crc32_combine, \
1209
+ METH_VARARGS, isal_zlib_crc32_combine__doc__}
1210
+
1211
+ static PyObject *
1212
+ isal_zlib_crc32_combine (PyObject * module , PyObject * args ) {
1213
+ uint32_t crc1 = 0 ;
1214
+ uint32_t crc2 = 0 ;
1215
+ Py_ssize_t crc2_length = 0 ;
1216
+ static char * format = "IIn:crc32combine" ;
1217
+ if (PyArg_ParseTuple (args , format , & crc1 , & crc2 , & crc2_length ) < 0 ) {
1218
+ return NULL ;
1219
+ }
1220
+ return PyLong_FromUnsignedLong (
1221
+ crc32_comb (crc1 , crc2 , crc2_length ) & 0xFFFFFFFF );
1222
+ }
1223
+
1190
1224
1191
1225
typedef struct {
1192
1226
PyTypeObject * Comptype ;
@@ -1197,6 +1231,7 @@ typedef struct {
1197
1231
static PyMethodDef IsalZlibMethods [] = {
1198
1232
ISAL_ZLIB_ADLER32_METHODDEF ,
1199
1233
ISAL_ZLIB_CRC32_METHODDEF ,
1234
+ ISAL_ZLIB_CRC32_COMBINE_METHODDEF ,
1200
1235
ISAL_ZLIB_COMPRESS_METHODDEF ,
1201
1236
ISAL_ZLIB_DECOMPRESS_METHODDEF ,
1202
1237
ISAL_ZLIB_COMPRESSOBJ_METHODDEF ,
0 commit comments