mirror of
https://github.com/facebook/zstd.git
synced 2025-07-03 06:20:42 +02:00
fix : unused attribute for FORCE_INLINE functions
fix2 : reloadDStreamFast is used by decompress4x2, modified the entry point, so that it works fine in this case too.
This commit is contained in:
@ -375,23 +375,34 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! BIT_reloadDStreamFast() :
|
/*! BIT_reloadDStream_internal() :
|
||||||
* Simple variant of BIT_reloadDStream(), with two conditions:
|
* Simple variant of BIT_reloadDStream(), with two conditions:
|
||||||
* 1. bitsConsumed <= sizeof(bitD->bitContainer)*8
|
* 1. bitstream is valid : bitsConsumed <= sizeof(bitD->bitContainer)*8
|
||||||
* 2. bitD->ptr >= bitD->limitPtr
|
* 2. look window is valid after shifted down : bitD->ptr >= bitD->start
|
||||||
* These conditions guarantee that bitstream is in a valid state,
|
|
||||||
* and shifting the position of the look window is safe.
|
|
||||||
*/
|
*/
|
||||||
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
|
MEM_STATIC BIT_DStream_status BIT_reloadDStream_internal(BIT_DStream_t* bitD)
|
||||||
{
|
{
|
||||||
assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
|
assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
|
||||||
assert(bitD->ptr >= bitD->limitPtr);
|
|
||||||
bitD->ptr -= bitD->bitsConsumed >> 3;
|
bitD->ptr -= bitD->bitsConsumed >> 3;
|
||||||
|
assert(bitD->ptr >= bitD->start);
|
||||||
bitD->bitsConsumed &= 7;
|
bitD->bitsConsumed &= 7;
|
||||||
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
||||||
return BIT_DStream_unfinished;
|
return BIT_DStream_unfinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! BIT_reloadDStreamFast() :
|
||||||
|
* Similar to BIT_reloadDStream(), but with two differences:
|
||||||
|
* 1. bitsConsumed <= sizeof(bitD->bitContainer)*8 must hold!
|
||||||
|
* 2. Returns BIT_DStream_overflow when bitD->ptr < bitD->limitPtr, at this
|
||||||
|
* point you must use BIT_reloadDStream() to reload.
|
||||||
|
*/
|
||||||
|
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
|
||||||
|
{
|
||||||
|
if (UNLIKELY(bitD->ptr < bitD->limitPtr))
|
||||||
|
return BIT_DStream_overflow;
|
||||||
|
return BIT_reloadDStream_internal(bitD);
|
||||||
|
}
|
||||||
|
|
||||||
/*! BIT_reloadDStream() :
|
/*! BIT_reloadDStream() :
|
||||||
* Refill `bitD` from buffer previously set in BIT_initDStream() .
|
* Refill `bitD` from buffer previously set in BIT_initDStream() .
|
||||||
* This function is safe, it guarantees it will not never beyond src buffer.
|
* This function is safe, it guarantees it will not never beyond src buffer.
|
||||||
@ -410,7 +421,7 @@ FORCE_INLINE_TEMPLATE BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
|
|||||||
assert(bitD->ptr >= bitD->start);
|
assert(bitD->ptr >= bitD->start);
|
||||||
|
|
||||||
if (bitD->ptr >= bitD->limitPtr) {
|
if (bitD->ptr >= bitD->limitPtr) {
|
||||||
return BIT_reloadDStreamFast(bitD);
|
return BIT_reloadDStream_internal(bitD);
|
||||||
}
|
}
|
||||||
if (bitD->ptr == bitD->start) {
|
if (bitD->ptr == bitD->start) {
|
||||||
/* reached end of bitStream => no update */
|
/* reached end of bitStream => no update */
|
||||||
|
@ -51,12 +51,19 @@
|
|||||||
# define WIN_CDECL
|
# define WIN_CDECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# define UNUSED_ATTR __attribute__((unused))
|
||||||
|
#else
|
||||||
|
# define UNUSED_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
|
* FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
|
||||||
* parameters. They must be inlined for the compiler to eliminate the constant
|
* parameters. They must be inlined for the compiler to eliminate the constant
|
||||||
* branches.
|
* branches.
|
||||||
*/
|
*/
|
||||||
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR UNUSED_ATTR
|
||||||
/**
|
/**
|
||||||
* HINT_INLINE is used to help the compiler generate better code. It is *not*
|
* HINT_INLINE is used to help the compiler generate better code. It is *not*
|
||||||
* used for "templates", so it can be tweaked based on the compilers
|
* used for "templates", so it can be tweaked based on the compilers
|
||||||
@ -71,14 +78,7 @@
|
|||||||
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
|
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
|
||||||
# define HINT_INLINE static INLINE_KEYWORD
|
# define HINT_INLINE static INLINE_KEYWORD
|
||||||
#else
|
#else
|
||||||
# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
# define HINT_INLINE FORCE_INLINE_TEMPLATE
|
||||||
#endif
|
|
||||||
|
|
||||||
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
# define UNUSED_ATTR __attribute__((unused))
|
|
||||||
#else
|
|
||||||
# define UNUSED_ATTR
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* "soft" inline :
|
/* "soft" inline :
|
||||||
|
@ -37,15 +37,6 @@ extern "C" {
|
|||||||
# include <stdlib.h> /* _byteswap_ulong */
|
# include <stdlib.h> /* _byteswap_ulong */
|
||||||
# include <intrin.h> /* _byteswap_* */
|
# include <intrin.h> /* _byteswap_* */
|
||||||
#endif
|
#endif
|
||||||
#if defined(__GNUC__)
|
|
||||||
# define MEM_STATIC static __attribute__((unused))
|
|
||||||
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
|
||||||
# define MEM_STATIC static inline
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
# define MEM_STATIC static __inline
|
|
||||||
#else
|
|
||||||
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
|
Reference in New Issue
Block a user