Fixed BMI behavior on x86 and x32 targets, reported by @tycho (#178)
parent
cf8584c90a
commit
6f9c056662
15
Makefile
15
Makefile
|
@ -54,6 +54,9 @@ all:
|
||||||
zstdprogram:
|
zstdprogram:
|
||||||
$(MAKE) -C $(PRGDIR)
|
$(MAKE) -C $(PRGDIR)
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(MAKE) -C $(PRGDIR) $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
|
@$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
|
||||||
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
|
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
|
||||||
|
@ -75,9 +78,6 @@ uninstall:
|
||||||
travis-install:
|
travis-install:
|
||||||
$(MAKE) install PREFIX=~/install_test_dir
|
$(MAKE) install PREFIX=~/install_test_dir
|
||||||
|
|
||||||
test:
|
|
||||||
$(MAKE) -C $(PRGDIR) $@
|
|
||||||
|
|
||||||
cmaketest:
|
cmaketest:
|
||||||
cd contrib/cmake ; cmake . ; $(MAKE)
|
cd contrib/cmake ; cmake . ; $(MAKE)
|
||||||
|
|
||||||
|
@ -88,6 +88,15 @@ clangtest: clean
|
||||||
gpptest: clean
|
gpptest: clean
|
||||||
$(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
|
$(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
|
||||||
|
|
||||||
|
bmix64test: clean
|
||||||
|
CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(PRGDIR) test
|
||||||
|
|
||||||
|
bmix32test: clean
|
||||||
|
CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(PRGDIR) test
|
||||||
|
|
||||||
|
bmi32test: clean
|
||||||
|
CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(PRGDIR) test
|
||||||
|
|
||||||
armtest: clean
|
armtest: clean
|
||||||
$(MAKE) -C $(PRGDIR) datagen # use native, faster
|
$(MAKE) -C $(PRGDIR) datagen # use native, faster
|
||||||
$(MAKE) -C $(PRGDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static"
|
$(MAKE) -C $(PRGDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static"
|
||||||
|
|
|
@ -301,7 +301,12 @@ MEM_STATIC size_t BIT_getUpperBits(size_t bitD, U32 const start)
|
||||||
MEM_STATIC size_t BIT_getMiddleBits(size_t bitD, U32 const nbBits, U32 const start)
|
MEM_STATIC size_t BIT_getMiddleBits(size_t bitD, U32 const nbBits, U32 const start)
|
||||||
{
|
{
|
||||||
#if defined(__BMI__) && defined(__GNUC__) /* experimental */
|
#if defined(__BMI__) && defined(__GNUC__) /* experimental */
|
||||||
return __builtin_ia32_bextr_u64(bitD, (nbBits<<8) | start );
|
# if defined(__x86_64__)
|
||||||
|
if (sizeof(bitD)==8)
|
||||||
|
return _bextr_u64(bitD, start, nbBits);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
return _bextr_u32(bitD, start, nbBits);
|
||||||
#else
|
#else
|
||||||
return (bitD >> start) & BIT_mask[nbBits];
|
return (bitD >> start) & BIT_mask[nbBits];
|
||||||
#endif
|
#endif
|
||||||
|
@ -322,7 +327,12 @@ MEM_STATIC size_t BIT_getLowerBits(size_t bitD, U32 const nbBits)
|
||||||
MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
||||||
{
|
{
|
||||||
#if defined(__BMI__) && defined(__GNUC__) /* experimental */
|
#if defined(__BMI__) && defined(__GNUC__) /* experimental */
|
||||||
return __builtin_ia32_bextr_u64(bitD->bitContainer, (nbBits<<8) | (64 - bitD->bitsConsumed - nbBits) );
|
# if defined(__x86_64__)
|
||||||
|
if (sizeof(bitD->bitContainer)==8)
|
||||||
|
return _bextr_u64(bitD->bitContainer, 64 - bitD->bitsConsumed - nbBits, nbBits);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
return _bextr_u32(bitD->bitContainer, 32 - bitD->bitsConsumed - nbBits, nbBits);
|
||||||
#else
|
#else
|
||||||
U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
||||||
return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask-nbBits) & bitMask);
|
return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask-nbBits) & bitMask);
|
||||||
|
|
|
@ -266,10 +266,9 @@ void ZSTD_copyDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
|
||||||
* @return : size of the Frame Header */
|
* @return : size of the Frame Header */
|
||||||
static size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
|
static size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
U32 fcsId;
|
|
||||||
if (srcSize < ZSTD_frameHeaderSize_min) return ERROR(srcSize_wrong);
|
if (srcSize < ZSTD_frameHeaderSize_min) return ERROR(srcSize_wrong);
|
||||||
fcsId = (((const BYTE*)src)[4]) >> 6;
|
{ U32 const fcsId = (((const BYTE*)src)[4]) >> 6;
|
||||||
return ZSTD_frameHeaderSize_min + ZSTD_fcs_fieldSize[fcsId];
|
return ZSTD_frameHeaderSize_min + ZSTD_fcs_fieldSize[fcsId]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
# define ZSTD_VERSION "v" ZSTD_VERSION_STRING
|
# define ZSTD_VERSION "v" ZSTD_VERSION_STRING
|
||||||
#endif
|
#endif
|
||||||
#define AUTHOR "Yann Collet"
|
#define AUTHOR "Yann Collet"
|
||||||
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), ZSTD_VERSION, AUTHOR
|
#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(size_t)*8), ZSTD_VERSION, AUTHOR
|
||||||
|
|
||||||
#define ZSTD_EXTENSION ".zst"
|
#define ZSTD_EXTENSION ".zst"
|
||||||
#define ZSTD_CAT "zstdcat"
|
#define ZSTD_CAT "zstdcat"
|
||||||
|
|
Loading…
Reference in New Issue