Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ libdeflate_adler32(u32 adler, const void *buffer, size_t len)
{
if (buffer == NULL) /* Return initial value. */
return 1;
return adler32_impl(adler, buffer, len);
return adler32_impl(adler, (const u8*)buffer, len);
}
2 changes: 1 addition & 1 deletion lib/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,5 @@ libdeflate_crc32(u32 crc, const void *p, size_t len)
{
if (p == NULL) /* Return initial value. */
return 0;
return ~crc32_impl(~crc, p, len);
return ~crc32_impl(~crc, (const u8*)p, len);
}
4 changes: 2 additions & 2 deletions lib/decompress_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ FUNCNAME(struct libdeflate_decompressor * restrict d,
void * restrict out, size_t out_nbytes_avail,
size_t *actual_in_nbytes_ret, size_t *actual_out_nbytes_ret)
{
u8 *out_next = out;
u8 *out_next = (u8*)out;
u8 * const out_end = out_next + out_nbytes_avail;
u8 * const out_fastloop_end =
out_end - MIN(out_nbytes_avail, FASTLOOP_MAX_BYTES_WRITTEN);

/* Input bitstream state; see deflate_decompress.c for documentation */
const u8 *in_next = in;
const u8 *in_next = (const u8*)in;
const u8 * const in_end = in_next + in_nbytes;
const u8 * const in_fastloop_end =
in_end - MIN(in_nbytes, FASTLOOP_MAX_BYTES_READ);
Expand Down
10 changes: 5 additions & 5 deletions lib/deflate_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -3900,7 +3900,7 @@ libdeflate_alloc_compressor_ex(int compression_level,
size += sizeof(c->p.f);
}

c = libdeflate_aligned_malloc(options->malloc_func ?
c = (struct libdeflate_compressor*)libdeflate_aligned_malloc(options->malloc_func ?
options->malloc_func :
libdeflate_default_malloc_func,
MATCHFINDER_MEM_ALIGNMENT, size);
Expand Down Expand Up @@ -4032,18 +4032,18 @@ libdeflate_deflate_compress(struct libdeflate_compressor *c,
* uncompressed blocks.
*/
if (unlikely(in_nbytes <= c->max_passthrough_size))
return deflate_compress_none(in, in_nbytes,
out, out_nbytes_avail);
return deflate_compress_none((const u8*)in, in_nbytes,
(u8*)out, out_nbytes_avail);

/* Initialize the output bitstream structure. */
os.bitbuf = 0;
os.bitcount = 0;
os.next = out;
os.next = (u8*)out;
os.end = os.next + out_nbytes_avail;
os.overflow = false;

/* Call the actual compression function. */
(*c->impl)(c, in, in_nbytes, &os);
(*c->impl)(c, (const u8*)in, in_nbytes, &os);

/* Return 0 if the output buffer is too small. */
if (os.overflow)
Expand Down
2 changes: 1 addition & 1 deletion lib/deflate_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ libdeflate_alloc_decompressor_ex(const struct libdeflate_options *options)
if (options->sizeof_options != sizeof(*options))
return NULL;

d = (options->malloc_func ? options->malloc_func :
d = (struct libdeflate_decompressor*)(options->malloc_func ? options->malloc_func :
libdeflate_default_malloc_func)(sizeof(*d));
if (d == NULL)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion lib/gzip_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libdeflate_gzip_compress(struct libdeflate_compressor *c,
const void *in, size_t in_nbytes,
void *out, size_t out_nbytes_avail)
{
u8 *out_next = out;
u8 *out_next = (u8*)out;
unsigned compression_level;
u8 xfl;
size_t deflate_size;
Expand Down
2 changes: 1 addition & 1 deletion lib/gzip_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libdeflate_gzip_decompress_ex(struct libdeflate_decompressor *d,
size_t *actual_in_nbytes_ret,
size_t *actual_out_nbytes_ret)
{
const u8 *in_next = in;
const u8 *in_next = (const u8*)in;
const u8 * const in_end = in_next + in_nbytes;
u8 flg;
size_t actual_in_nbytes;
Expand Down
8 changes: 4 additions & 4 deletions lib/x86/adler32_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
# else
# define VDPBUSD(a, b, c) _mm_dpbusd_avx_epi32((a), (b), (c))
# endif
# define VLOAD(p) _mm_load_si128((const void *)(p))
# define VLOADU(p) _mm_loadu_si128((const void *)(p))
# define VLOAD(p) _mm_load_si128((const vec_t*)(const void *)(p))
# define VLOADU(p) _mm_loadu_si128((const vec_t*)(const void *)(p))
# define VMADD16(a, b) _mm_madd_epi16((a), (b))
# define VMASKZ_LOADU(mask, p) _mm_maskz_loadu_epi8((mask), (p))
# define VMULLO32(a, b) _mm_mullo_epi32((a), (b))
Expand All @@ -87,8 +87,8 @@
# else
# define VDPBUSD(a, b, c) _mm256_dpbusd_avx_epi32((a), (b), (c))
# endif
# define VLOAD(p) _mm256_load_si256((const void *)(p))
# define VLOADU(p) _mm256_loadu_si256((const void *)(p))
# define VLOAD(p) _mm256_load_si256((const vec_t*)(const void *)(p))
# define VLOADU(p) _mm256_loadu_si256((const vec_t*)(const void *)(p))
# define VMADD16(a, b) _mm256_madd_epi16((a), (b))
# define VMASKZ_LOADU(mask, p) _mm256_maskz_loadu_epi8((mask), (p))
# define VMULLO32(a, b) _mm256_mullo_epi32((a), (b))
Expand Down
30 changes: 15 additions & 15 deletions lib/x86/crc32_pclmul_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#if VL == 16
# define vec_t __m128i
# define fold_vec fold_vec128
# define VLOADU(p) _mm_loadu_si128((const void *)(p))
# define VLOADU(p) _mm_loadu_si128((const vec_t*)(const void *)(p))
# define VXOR(a, b) _mm_xor_si128((a), (b))
# define M128I_TO_VEC(a) a
# define MULTS_8V _mm_set_epi64x(CRC32_X991_MODG, CRC32_X1055_MODG)
Expand All @@ -78,7 +78,7 @@
#elif VL == 32
# define vec_t __m256i
# define fold_vec fold_vec256
# define VLOADU(p) _mm256_loadu_si256((const void *)(p))
# define VLOADU(p) _mm256_loadu_si256((const vec_t*)(const void *)(p))
# define VXOR(a, b) _mm256_xor_si256((a), (b))
# define M128I_TO_VEC(a) _mm256_zextsi128_si256(a)
# define MULTS(a, b) _mm256_set_epi64x(a, b, a, b)
Expand Down Expand Up @@ -160,19 +160,19 @@ static forceinline ATTRIBUTES __m128i
ADD_SUFFIX(fold_lessthan16bytes)(__m128i x, const u8 *p, size_t len,
__m128i /* __v2du */ mults_128b)
{
__m128i lshift = _mm_loadu_si128((const void *)&shift_tab[len]);
__m128i rshift = _mm_loadu_si128((const void *)&shift_tab[len + 16]);
__m128i lshift = _mm_loadu_si128((const __m128i *)(const void *)&shift_tab[len]);
__m128i rshift = _mm_loadu_si128((const __m128i *)(const void *)&shift_tab[len + 16]);
__m128i x0, x1;

/* x0 = x left-shifted by '16 - len' bytes */
/* x0 = x left-shifted by '16 - len' bytes */
x0 = _mm_shuffle_epi8(x, lshift);

/*
* x1 = the last '16 - len' bytes from x (i.e. x right-shifted by 'len'
* bytes) followed by the remaining data.
*/
x1 = _mm_blendv_epi8(_mm_shuffle_epi8(x, rshift),
_mm_loadu_si128((const void *)(p + len - 16)),
_mm_loadu_si128((const __m128i*)(const void *)(p + len - 16)),
/* msb 0/1 of each byte selects byte from arg1/2 */
rshift);

Expand Down Expand Up @@ -221,7 +221,7 @@ ADD_SUFFIX(crc32_x86)(u32 crc, const u8 *p, size_t len)
x0 = _mm_xor_si128(
x0, _mm_maskz_loadu_epi8((1 << len) - 1, p));
x0 = _mm_shuffle_epi8(
x0, _mm_loadu_si128((const void *)&shift_tab[len]));
x0, _mm_loadu_si128((const __m128i*)(const void *)&shift_tab[len]));
goto reduce_x0;
#else
return crc32_slice1(crc, p, len);
Expand All @@ -232,13 +232,13 @@ ADD_SUFFIX(crc32_x86)(u32 crc, const u8 *p, size_t len)
* Use 128-bit instructions so that these lengths aren't
* slower with VL > 16 than with VL=16.
*/
x0 = _mm_xor_si128(_mm_loadu_si128((const void *)p), x0);
x0 = _mm_xor_si128(_mm_loadu_si128((const __m128i*)(const void *)p), x0);
if (len >= 32) {
x0 = fold_vec128(x0, _mm_loadu_si128((const void *)(p + 16)),
x0 = fold_vec128(x0, _mm_loadu_si128((const __m128i*)(const void *)(p + 16)),
mults_128b);
if (len >= 48)
x0 = fold_vec128(x0, _mm_loadu_si128((const void *)(p + 32)),
mults_128b);
x0 = fold_vec128(x0, _mm_loadu_si128(
(const __m128i*)(const void *)(p + 32)), mults_128b);
}
p += len & ~15;
goto less_than_16_remaining;
Expand Down Expand Up @@ -268,7 +268,7 @@ ADD_SUFFIX(crc32_x86)(u32 crc, const u8 *p, size_t len)
size_t align = -(uintptr_t)p & (VL-1);

len -= align;
x0 = _mm_xor_si128(_mm_loadu_si128((const void *)p), x0);
x0 = _mm_xor_si128(_mm_loadu_si128((const __m128i*)(const void *)p), x0);
p += 16;
if (align & 15) {
x0 = fold_lessthan16bytes(x0, p, align & 15,
Expand Down Expand Up @@ -367,16 +367,16 @@ ADD_SUFFIX(crc32_x86)(u32 crc, const u8 *p, size_t len)
_mm512_extracti64x4_epi64(v0, 1),
mults_256b);
if (len & 32) {
y0 = fold_vec256(y0, _mm256_loadu_si256((const void *)p),
mults_256b);
y0 = fold_vec256(y0, _mm256_loadu_si256(
(const __m256i*)(const void *)p), mults_256b);
p += 32;
}
#endif
x0 = fold_vec128(_mm256_extracti128_si256(y0, 0),
_mm256_extracti128_si256(y0, 1), mults_128b);
}
if (len & 16) {
x0 = fold_vec128(x0, _mm_loadu_si128((const void *)p),
x0 = fold_vec128(x0, _mm_loadu_si128((const __m128i*)(const void *)p),
mults_128b);
p += 16;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/zlib_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libdeflate_zlib_compress(struct libdeflate_compressor *c,
const void *in, size_t in_nbytes,
void *out, size_t out_nbytes_avail)
{
u8 *out_next = out;
u8 *out_next = (u8*)out;
u16 hdr;
unsigned compression_level;
unsigned level_hint;
Expand Down
2 changes: 1 addition & 1 deletion lib/zlib_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libdeflate_zlib_decompress_ex(struct libdeflate_decompressor *d,
size_t *actual_in_nbytes_ret,
size_t *actual_out_nbytes_ret)
{
const u8 *in_next = in;
const u8 *in_next = (const u8*)in;
const u8 * const in_end = in_next + in_nbytes;
u16 hdr;
size_t actual_in_nbytes;
Expand Down