Portability to Debian based distros.
Enable SSE4/AVX detection for AMD platforms (Bulldozer has both). Portable long long int print formatting to silence gcc 4.6 warnings.
This commit is contained in:
parent
45487469d1
commit
c5ebe1f30a
10 changed files with 114 additions and 36 deletions
|
@ -99,10 +99,12 @@ RM = rm -f
|
|||
COMMON_CPPFLAGS = -I. -I./lzma -I./lzfx -I./lz4 -I./rabin -I./bsdiff -DNODEFAULT_PROPS \
|
||||
-DFILE_OFFSET_BITS=64 -D_REENTRANT -D__USE_SSE_INTRIN__ -D_LZMA_PROB32 \
|
||||
-I./lzp @LIBBSCCPPFLAGS@ -I./crypto/skein -I./utils -I@OPENSSL_INCDIR@ \
|
||||
-I./crypto/sha2 -I./crypto/scrypt -I./crypto/aes -I./crypto @KEYLEN@
|
||||
-I./crypto/sha2 -I./crypto/scrypt -I./crypto/aes -I./crypto @KEYLEN@ \
|
||||
@LIBBZ2_INC@ @LIBZ_INC@
|
||||
COMMON_VEC_FLAGS = -ftree-vectorize
|
||||
COMMON_LOOP_OPTFLAGS = $(VEC_FLAGS) -floop-interchange -floop-block
|
||||
LDLIBS = -ldl -lbz2 $(ZLIB_DIR) -lz -lm @LIBBSCLFLAGS@ -L@OPENSSL_LIBDIR@ -lcrypto -lrt
|
||||
LDLIBS = -ldl -L@LIBBZ2_DIR@ -lbz2 -L@LIBZ_DIR@ -lz -lm @LIBBSCLFLAGS@ \
|
||||
-L@OPENSSL_LIBDIR@ -lcrypto -lrt
|
||||
OBJS = $(MAINOBJS) $(LZMAOBJS) $(PPMDOBJS) $(LZFXOBJS) $(LZ4OBJS) $(CRCOBJS) \
|
||||
$(RABINOBJS) $(BSDIFFOBJS) $(LZPOBJS) @LIBBSCWRAPOBJ@ $(SKEINOBJS) $(SKEIN_BLOCK_OBJ) \
|
||||
@SHA256ASM_OBJS@ @SHA256_OBJS@
|
||||
|
|
12
allocator.c
12
allocator.c
|
@ -183,7 +183,7 @@ slab_cleanup(int quiet)
|
|||
while (slab) {
|
||||
if (slab->avail) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "%21llu %21llu %21llu\n",slab->sz,
|
||||
fprintf(stderr, "%21" PRIu64 " %21" PRIu64 " %21" PRIu64 "\n",slab->sz,
|
||||
slab->allocs, slab->hits);
|
||||
}
|
||||
slab->allocs = 0;
|
||||
|
@ -201,10 +201,10 @@ slab_cleanup(int quiet)
|
|||
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "==================================================================\n");
|
||||
fprintf(stderr, "Oversize Allocations : %llu\n", oversize_allocs);
|
||||
fprintf(stderr, "Total Requests : %llu\n", total_allocs);
|
||||
fprintf(stderr, "Hash collisions : %llu\n", hash_collisions);
|
||||
fprintf(stderr, "Leaked allocations : %llu\n", hash_entries);
|
||||
fprintf(stderr, "Oversize Allocations : %" PRIu64 "\n", oversize_allocs);
|
||||
fprintf(stderr, "Total Requests : %" PRIu64 "\n", total_allocs);
|
||||
fprintf(stderr, "Hash collisions : %" PRIu64 "\n", hash_collisions);
|
||||
fprintf(stderr, "Leaked allocations : %" PRIu64 "\n", hash_entries);
|
||||
}
|
||||
|
||||
if (hash_entries > 0) {
|
||||
|
@ -238,7 +238,7 @@ slab_cleanup(int quiet)
|
|||
slab = &slabheads[i];
|
||||
do {
|
||||
if (slab->allocs > 0)
|
||||
fprintf(stderr, "%21llu %21llu\n", \
|
||||
fprintf(stderr, "%21" PRIu64 " %21" PRIu64 "\n", \
|
||||
slab->sz, slab->allocs);
|
||||
slab = slab->next;
|
||||
} while (slab);
|
||||
|
|
83
config
83
config
|
@ -37,6 +37,8 @@ libbsccppflags=
|
|||
openssl_prefix=
|
||||
openssl_libdir=
|
||||
openssl_incdir=
|
||||
libbz2_libdir=
|
||||
libz_libdir=
|
||||
sha256asmobjs=
|
||||
sha256objs=
|
||||
keylen=
|
||||
|
@ -93,7 +95,7 @@ OS=$(uname)
|
|||
skeinblock='\$\(SKEIN_BLOCK_C\)'
|
||||
if [ "$OS" = "Linux" ]
|
||||
then
|
||||
plat=$(uname -r)
|
||||
plat=$(uname -m)
|
||||
elif [ "$OS" = "SunOS" ]
|
||||
then
|
||||
plat=$(isainfo -v)
|
||||
|
@ -138,11 +140,13 @@ fi
|
|||
# Detect OpenSSL library
|
||||
for lib in "${openssl_prefix}/lib64" "${openssl_prefix}/usr/lib64" \
|
||||
"${openssl_prefix}/lib" "${openssl_prefix}/usr/lib" \
|
||||
"${openssl_prefix}/ssl/lib64" "${openssl_prefix}/ssl/lib"
|
||||
"${openssl_prefix}/ssl/lib64" "${openssl_prefix}/ssl/lib" \
|
||||
"${openssl_prefix}/lib/x86_64-linux-gnu" \
|
||||
"${openssl_prefix}/usr/lib/x86_64-linux-gnu"
|
||||
do
|
||||
if [ -d ${lib} ]
|
||||
then
|
||||
if [ -f "${lib}/libcrypto.so" ]
|
||||
if [ -f "${lib}/libcrypto.so" -o -h "${lib}/libcrypto.so" ]
|
||||
then
|
||||
openssl_libdir=${lib}
|
||||
break
|
||||
|
@ -182,12 +186,75 @@ then
|
|||
echo "ERROR: OpenSSL header files not detected."
|
||||
if [ "x${openssl_prefix}" = "x" ]
|
||||
then
|
||||
echo "Depending on your system you may need to install the openssl-devel package."
|
||||
echo "Depending on your system you may need to install the openssl-devel or openssl-dev package."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Detect other library packages
|
||||
for libname in "libbz2" "libz"
|
||||
do
|
||||
for lib in "/lib64" "/usr/lib64" "/lib" "/usr/lib" "/lib/x86_64-linux-gnu" \
|
||||
"/usr/lib/x86_64-linux-gnu" \
|
||||
"${prefix}/lib64" "${prefix}/lib" "${prefix}/lib/x86_64-linux-gnu"
|
||||
do
|
||||
if [ -d ${lib} ]
|
||||
then
|
||||
if [ -f "${lib}/${libname}.so" -o -h "${lib}/${libname}.so" ]
|
||||
then
|
||||
eval "${libname}_libdir=${lib}"
|
||||
break
|
||||
else
|
||||
if [ -f "${lib}/${libname}.a" ]
|
||||
then
|
||||
eval "${libname}_libdir=${lib}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ "x${libbz2_libdir}" = "x" ]
|
||||
then
|
||||
echo "ERROR: Libbz2 not detected."
|
||||
echo " You may have to install libbz2-devel or libbz2-dev"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "x${libz_libdir}" = "x" ]
|
||||
then
|
||||
echo "ERROR: Zlib not detected."
|
||||
echo " You may have to install libz-devel or libz-dev"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
libbz2_inc=
|
||||
libz_inc=
|
||||
# Detect other library headers
|
||||
for hdr in "libbz2_inc:bzlib.h" "libz_inc:zlib.h"
|
||||
do
|
||||
_OIFS="$IFS"
|
||||
IFS=":"
|
||||
set -- ${hdr}
|
||||
var=$1
|
||||
hdrf=$2
|
||||
IFS="$_OIFS"
|
||||
|
||||
for inc in "${prefix}/include" "/usr/include"
|
||||
do
|
||||
if [ -d ${inc} ]
|
||||
then
|
||||
if [ -f "${inc}/${hdrf}" ]
|
||||
then
|
||||
eval "${var}=\"-I${inc}\""
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
linkvar="LINK"
|
||||
compilevar="COMPILE"
|
||||
compilecppvar="COMPILE_cpp"
|
||||
|
@ -214,6 +281,10 @@ yasmvar="YASM"
|
|||
|
||||
openssllibdirvar="OPENSSL_LIBDIR"
|
||||
opensslincdirvar="OPENSSL_INCDIR"
|
||||
libbz2libdirvar="LIBBZ2_DIR"
|
||||
libzlibdirvar="LIBZ_DIR"
|
||||
libbz2incvar="LIBBZ2_INC"
|
||||
libzincvar="LIBZ_INC"
|
||||
|
||||
noslabcppflagsval=
|
||||
debugstatscppflagsval=
|
||||
|
@ -246,5 +317,9 @@ s#@${sha256asmobjsvar}@#${sha256asmobjs}#g
|
|||
s#@${sha256objsvar}@#${sha256objs}#g
|
||||
s#@${yasmvar}@#${yasm}#g
|
||||
s#@${keylenvar}@#${keylen}#g
|
||||
s#@${libbz2libdirvar}@#${libbz2_libdir}#g
|
||||
s#@${libzlibdirvar}@#${libz_libdir}#g
|
||||
s#@${libbz2incvar}@#${libbz2_inc}#g
|
||||
s#@${libzincvar}@#${libz_inc}#g
|
||||
" > Makefile
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ aes_init(aes_ctx_t *ctx, uchar_t *salt, int saltlen, uchar_t *pwd, int pwd_len,
|
|||
} else {
|
||||
tv = tp.tv_sec * 1000UL + tp.tv_nsec;
|
||||
}
|
||||
sprintf(num, "%llu", tv);
|
||||
sprintf(num, "%" PRIu64, tv);
|
||||
PKCS5_PBKDF2_HMAC(num, strlen(num), salt, saltlen, PBE_ROUNDS, EVP_sha256(), 32, IV);
|
||||
ctx->nonce = lzma_crc64(IV, 32, 0) & 0xffffffff00000000ULL;
|
||||
// Nullify stack components
|
||||
|
|
|
@ -86,7 +86,7 @@ static update_func_ptr sha_update_func;
|
|||
int
|
||||
APS_NAMESPACE(Init_SHA) (processor_info_t *pc)
|
||||
{
|
||||
if (pc->proc_type == PROC_X64_INTEL) {
|
||||
if (pc->proc_type == PROC_X64_INTEL || pc->proc_type == PROC_X64_AMD) {
|
||||
if (pc->avx_level > 0) {
|
||||
sha_update_func = sha256_avx;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ lz4_init(void **data, int *level, int nthreads, ssize_t chunksize)
|
|||
int lev;
|
||||
|
||||
if (chunksize > LZ4_MAX_CHUNK) {
|
||||
fprintf(stderr, "Max allowed chunk size for LZ4 is: %d \n",
|
||||
fprintf(stderr, "Max allowed chunk size for LZ4 is: %ld \n",
|
||||
LZ4_MAX_CHUNK);
|
||||
return (1);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ create_dedupe_context(uint64_t chunksize, uint64_t real_chunksize, int rab_blk_s
|
|||
}
|
||||
|
||||
if (chunksize < RAB_MIN_CHUNK_SIZE) {
|
||||
fprintf(stderr, "Minimum chunk size for Dedup must be %llu bytes\n",
|
||||
fprintf(stderr, "Minimum chunk size for Dedup must be %" PRIu64 " bytes\n",
|
||||
RAB_MIN_CHUNK_SIZE);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size, ssize_t offs
|
|||
|
||||
process_blocks:
|
||||
// If we found at least a few chunks, perform dedup.
|
||||
DEBUG_STAT_EN(printf("Original size: %lld, blknum: %u\n", *size, blknum));
|
||||
DEBUG_STAT_EN(printf("Original size: %" PRId64 ", blknum: %u\n", *size, blknum));
|
||||
if (blknum > 2) {
|
||||
ssize_t pos, matchlen, pos1;
|
||||
int valid = 1;
|
||||
|
@ -700,7 +700,7 @@ cont:
|
|||
entries[2] = htonll(pos1 - dedupe_index_sz - RABIN_HDR_SIZE);
|
||||
*size = pos1;
|
||||
ctx->valid = 1;
|
||||
DEBUG_STAT_EN(printf("Deduped size: %lld, blknum: %u, delta_calls: %u, delta_fails: %u\n",
|
||||
DEBUG_STAT_EN(printf("Deduped size: %" PRId64 ", blknum: %u, delta_calls: %u, delta_fails: %u\n",
|
||||
*size, blknum, delta_calls, delta_fails));
|
||||
/*
|
||||
* Remaining header entries: size of compressed index and size of
|
||||
|
|
|
@ -112,23 +112,23 @@ cpuid_basic_identify(processor_info_t *pc)
|
|||
pc->proc_type = PROC_X64_INTEL;
|
||||
|
||||
pc->sse_level = 2;
|
||||
if (raw.basic_cpuid[0][0] >= 1) {
|
||||
// ECX has SSE 4.2 and AVX flags
|
||||
// Bit 20 is SSE 4.2 and bit 28 indicates AVX
|
||||
if (raw.basic_cpuid[1][2] & (1 << 20)) {
|
||||
pc->sse_level = 4;
|
||||
} else {
|
||||
pc->sse_level = 3;
|
||||
}
|
||||
pc->avx_level = 0;
|
||||
if (raw.basic_cpuid[1][2] & (1 << 28)) {
|
||||
pc->avx_level = 1;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(raw.vendor_str, "AuthenticAMD") == 0) {
|
||||
pc->proc_type = PROC_X64_AMD;
|
||||
pc->sse_level = 2;
|
||||
}
|
||||
if (raw.basic_cpuid[0][0] >= 1) {
|
||||
// ECX has SSE 4.2 and AVX flags
|
||||
// Bit 20 is SSE 4.2 and bit 28 indicates AVX
|
||||
if (raw.basic_cpuid[1][2] & (1 << 20)) {
|
||||
pc->sse_level = 4;
|
||||
} else {
|
||||
pc->sse_level = 3;
|
||||
}
|
||||
pc->avx_level = 0;
|
||||
if (raw.basic_cpuid[1][2] & (1 << 28)) {
|
||||
pc->avx_level = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -155,19 +155,19 @@ bytes_to_size(uint64_t bytes)
|
|||
uint64_t terabyte = gigabyte * 1024;
|
||||
|
||||
if (bytes < kilobyte) {
|
||||
sprintf(num, "%llu B", bytes);
|
||||
sprintf(num, "%" PRIu64 " B", bytes);
|
||||
|
||||
} else if (bytes < megabyte) {
|
||||
sprintf(num, "%llu KB", bytes / kilobyte);
|
||||
sprintf(num, "%" PRIu64 " KB", bytes / kilobyte);
|
||||
|
||||
} else if (bytes < gigabyte) {
|
||||
sprintf(num, "%llu MB", bytes / megabyte);
|
||||
sprintf(num, "%" PRIu64 " MB", bytes / megabyte);
|
||||
|
||||
} else if (bytes < terabyte) {
|
||||
sprintf(num, "%llu GB", bytes / gigabyte);
|
||||
sprintf(num, "%" PRIu64 " GB", bytes / gigabyte);
|
||||
|
||||
} else {
|
||||
sprintf(num, "%llu B", bytes);
|
||||
sprintf(num, "%" PRIu64 " B", bytes);
|
||||
}
|
||||
return (num);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <arpa/nameser_compat.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in a new issue