From: Yann Collet Date: Sat, 4 Jun 2016 17:12:48 +0000 (+0200) Subject: merged `zbuff_static.h` into `zbuff.h` . Now requires `ZBUFF_STATIC_LINKING_ONLY... X-Git-Tag: v0.7.0^2~49^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5347aee8f7f5260b500e3f096dbc06a35f3cfb10;p=thirdparty%2Fzstd.git merged `zbuff_static.h` into `zbuff.h` . Now requires `ZBUFF_STATIC_LINKING_ONLY` macro --- diff --git a/lib/common/zbuff.h b/lib/common/zbuff.h index 89207bd24..d761a273f 100644 --- a/lib/common/zbuff.h +++ b/lib/common/zbuff.h @@ -28,8 +28,8 @@ You can contact the author at : - zstd homepage : http://www.zstd.net/ */ -#ifndef ZSTD_BUFFERED_H -#define ZSTD_BUFFERED_H +#ifndef ZSTD_BUFFERED_H_23987 +#define ZSTD_BUFFERED_H_23987 #if defined (__cplusplus) extern "C" { @@ -160,8 +160,48 @@ ZSTDLIB_API size_t ZBUFF_recommendedDInSize(void); ZSTDLIB_API size_t ZBUFF_recommendedDOutSize(void); +#ifdef ZBUFF_STATIC_LINKING_ONLY + +/* ************************************* +* Includes +***************************************/ +#include "zstd_static.h" /* ZSTD_parameters */ + +/* internal util function */ +#define ZBUFF_MIN(a,b) ((a)<(b) ? (a) : (b)) +MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize) +{ + size_t length = ZBUFF_MIN(dstCapacity, srcSize); + memcpy(dst, src, length); + return length; +} + + +/*-************************************* +* Advanced functions +***************************************/ +/*! ZBUFF_createCCtx_advanced() : + * Create a ZBUFF compression context using external alloc and free functions */ +ZSTDLIB_API ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem); + +/*! ZBUFF_createDCtx_advanced() : + * Create a ZBUFF decompression context using external alloc and free functions */ +ZSTDLIB_API ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem); + + +/* ************************************* +* Advanced Streaming functions +***************************************/ +ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc, + const void* dict, size_t dictSize, + ZSTD_parameters params, U64 pledgedSrcSize); + + +#endif + + #if defined (__cplusplus) } #endif -#endif /* ZSTD_BUFFERED_H */ +#endif /* ZSTD_BUFFERED_H_23987 */ diff --git a/lib/common/zbuff_static.h b/lib/common/zbuff_static.h deleted file mode 100644 index 44a0321d1..000000000 --- a/lib/common/zbuff_static.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - zstd - buffered version of compression library - experimental complementary API, for static linking only - Copyright (C) 2015-2016, Yann Collet. - - BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - You can contact the author at : - - zstd homepage : http://www.zstd.net -*/ -#ifndef ZSTD_BUFFERED_STATIC_H -#define ZSTD_BUFFERED_STATIC_H - -/* The objects defined into this file must be considered experimental. - * Their prototype may change in future versions. - * Never use them with a dynamic library. - */ - -#if defined (__cplusplus) -extern "C" { -#endif - -/* ************************************* -* Includes -***************************************/ -#include "zstd_static.h" /* ZSTD_parameters */ -#include "zbuff.h" - -#define ZBUFF_MIN(a,b) ((a)<(b) ? (a) : (b)) - - -/*-************************************* -* Advanced functions -***************************************/ -/*! ZBUFF_createCCtx_advanced() : - * Create a ZBUFF compression context using external alloc and free functions */ -ZSTDLIB_API ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem); - -/*! ZBUFF_createDCtx_advanced() : - * Create a ZBUFF decompression context using external alloc and free functions */ -ZSTDLIB_API ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem); - - -/* ************************************* -* Advanced Streaming functions -***************************************/ -ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc, - const void* dict, size_t dictSize, - ZSTD_parameters params, U64 pledgedSrcSize); - - -/* internal util function */ - -MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize) -{ - size_t length = ZBUFF_MIN(dstCapacity, srcSize); - memcpy(dst, src, length); - return length; -} - - -#if defined (__cplusplus) -} -#endif - -#endif /* ZSTD_BUFFERED_STATIC_H */ diff --git a/lib/compress/zbuff_compress.c b/lib/compress/zbuff_compress.c index bae668154..65390c29b 100644 --- a/lib/compress/zbuff_compress.c +++ b/lib/compress/zbuff_compress.c @@ -37,7 +37,8 @@ #include "error_private.h" #include "zstd_internal.h" /* MIN, ZSTD_blockHeaderSize */ #include "zstd_static.h" /* ZSTD_BLOCKSIZE_MAX */ -#include "zbuff_static.h" +#define ZBUFF_STATIC_LINKING_ONLY +#include "zbuff.h" /* ************************************* diff --git a/lib/decompress/zbuff_decompress.c b/lib/decompress/zbuff_decompress.c index 01937bb06..e3d574355 100644 --- a/lib/decompress/zbuff_decompress.c +++ b/lib/decompress/zbuff_decompress.c @@ -37,7 +37,8 @@ #include "error_private.h" #include "zstd_internal.h" /* MIN, ZSTD_blockHeaderSize */ #include "zstd_static.h" /* ZSTD_BLOCKSIZE_MAX */ -#include "zbuff_static.h" +#define ZBUFF_STATIC_LINKING_ONLY +#include "zbuff.h" /*-*************************************************************************** @@ -183,7 +184,7 @@ size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd, } } if (zbd->fParams.windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN) zbd->fParams.windowLog = ZSTD_WINDOWLOG_ABSOLUTEMIN; /* required for buffer allocation */ - + /* Frame header instruct buffer sizes */ { size_t const blockSize = MIN(1 << zbd->fParams.windowLog, ZSTD_BLOCKSIZE_MAX); zbd->blockSize = blockSize; diff --git a/programs/fileio.c b/programs/fileio.c index 4211e4a0f..e00a123f8 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -58,7 +58,8 @@ #include "fileio.h" #include "zstd_static.h" /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */ #include "zstd_internal.h" /* MIN, KB, MB */ -#include "zbuff_static.h" +#define ZBUFF_STATIC_LINKING_ONLY +#include "zbuff.h" #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1) # include "zstd_legacy.h" /* ZSTD_isLegacy */ diff --git a/programs/zbufftest.c b/programs/zbufftest.c index 387119815..a50e08541 100644 --- a/programs/zbufftest.c +++ b/programs/zbufftest.c @@ -40,12 +40,12 @@ #include /* timeb */ #include /* strcmp */ #include "mem.h" -#include "zbuff.h" #include "zstd_static.h" /* ZSTD_compressBound(), ZSTD_maxCLevel() */ -#include "zbuff_static.h" /* ZBUFF_createCCtx_advanced */ +#define ZBUFF_STATIC_LINKING_ONLY +#include "zbuff.h" /* ZBUFF_createCCtx_advanced */ #include "datagen.h" /* RDG_genBuffer */ #define XXH_STATIC_LINKING_ONLY -#include "xxhash.h" /* XXH64 */ +#include "xxhash.h" /* XXH64_* */ /*-************************************