Do some include shuffling for `**.h` files within lib, programs, tests, and zlibWrapper.
`lib/legacy` and `lib/deprecated` are untouched.
`#include`s within `extern "C"` blocks in .cpp files are untouched.
todo: shuffling for `xxhash.h`
#ifndef SEEKABLE_H
#define SEEKABLE_H
+#include <stdio.h>
+#include "zstd.h" /* ZSTDLIB_API */
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include <stdio.h>
-#include "zstd.h" /* ZSTDLIB_API */
-
#define ZSTD_seekTableFooterSize 9
#ifndef BITSTREAM_H_MODULE
#define BITSTREAM_H_MODULE
-#if defined (__cplusplus)
-extern "C" {
-#endif
/*
* This API consists of small unitary functions, which must be inlined for best performance.
* Since link-time-optimization is not available for all compilers,
#include "error_private.h" /* error codes and messages */
#include "bits.h" /* ZSTD_highbit32 */
-
/*=========================================
* Target specific
=========================================*/
# endif
#endif
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
#define STREAM_ACCUMULATOR_MIN_32 25
#define STREAM_ACCUMULATOR_MIN_64 57
#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
#ifndef DEBUG_H_12987983217
#define DEBUG_H_12987983217
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
/* static assert is triggered at compile time, leaving no runtime artefact.
* static assert only works with compile-time constants.
# endif
#endif
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
#if (DEBUGLEVEL>=2)
# define ZSTD_DEPS_NEED_IO
-# include "zstd_deps.h"
extern int g_debuglevel; /* the variable is only declared,
it actually lives in debug.c,
and is shared by the whole process.
#ifndef ERROR_H_MODULE
#define ERROR_H_MODULE
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
/* ****************************************
* Dependencies
******************************************/
#include "debug.h"
#include "zstd_deps.h" /* size_t */
+#if defined (__cplusplus)
+extern "C" {
+#endif
/* ****************************************
* Compiler-specific
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
****************************************************************** */
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#ifndef FSE_H
#define FSE_H
******************************************/
#include "zstd_deps.h" /* size_t, ptrdiff_t */
+#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
+#define FSE_H_FSE_STATIC_LINKING_ONLY
+#include "bitstream.h"
+#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
/*-*****************************************
* FSE_PUBLIC_API : control library symbols visibility
#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
#define FSE_H_FSE_STATIC_LINKING_ONLY
-/* *** Dependency *** */
-#include "bitstream.h"
-
/* *****************************************
* Static allocation
* You may select, at your option, one of the above-listed licenses.
****************************************************************** */
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#ifndef HUF_H_298734234
#define HUF_H_298734234
#define FSE_STATIC_LINKING_ONLY
#include "fse.h"
+#if defined (__cplusplus)
+extern "C" {
+#endif
/* *** Tool functions *** */
#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
#ifndef MEM_H_MODULE
#define MEM_H_MODULE
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
/*-****************************************
* Dependencies
******************************************/
#endif
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/*-**************************************************************
* Memory I/O API
*****************************************************************/
#ifndef POOL_H
#define POOL_H
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#include "zstd_deps.h"
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */
#include "../zstd.h"
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
typedef struct POOL_ctx_s POOL_ctx;
/*! POOL_create() :
#include "debug.h"
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
/**
#define ZSTD_pthread_cond_signal(a) WakeConditionVariable((a))
#define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a))
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/* ZSTD_pthread_create() and ZSTD_pthread_join() */
typedef HANDLE ZSTD_pthread_t;
*/
+#if defined (__cplusplus)
+}
+#endif
+
#elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
/* === POSIX Systems === */
# include <pthread.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
#if DEBUGLEVEL < 1
#define ZSTD_pthread_mutex_t pthread_mutex_t
#endif
+#if defined (__cplusplus)
+}
+#endif
+
#else /* ZSTD_MULTITHREAD not defined */
/* No multithreading support */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
typedef int ZSTD_pthread_mutex_t;
#define ZSTD_pthread_mutex_init(a, b) ((void)(a), (void)(b), 0)
#define ZSTD_pthread_mutex_destroy(a) ((void)(a))
#ifndef ZSTD_TRACE_H
#define ZSTD_TRACE_H
+#include <stddef.h>
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include <stddef.h>
-
/* weak symbol support
* For now, enable conservatively:
* - Only GNUC
#ifndef ZSTD_DOUBLE_FAST_H
#define ZSTD_DOUBLE_FAST_H
+#include "../common/mem.h" /* U32 */
+#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include "../common/mem.h" /* U32 */
-#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */
-
#ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
#ifndef ZSTD_FAST_H
#define ZSTD_FAST_H
+#include "../common/mem.h" /* U32 */
+#include "zstd_compress_internal.h"
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include "../common/mem.h" /* U32 */
-#include "zstd_compress_internal.h"
-
void ZSTD_fillHashTable(ZSTD_matchState_t* ms,
void const* end, ZSTD_dictTableLoadMethod_e dtlm,
ZSTD_tableFillPurpose_e tfp);
#ifndef ZSTD_LAZY_H
#define ZSTD_LAZY_H
+#include "zstd_compress_internal.h"
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include "zstd_compress_internal.h"
-
/**
* Dedicated Dictionary Search Structure bucket log. In the
* ZSTD_dedicatedDictSearch mode, the hashTable has
#ifndef ZSTD_LDM_H
#define ZSTD_LDM_H
+#include "zstd_compress_internal.h" /* ldmParams_t, U32 */
+#include "../zstd.h" /* ZSTD_CCtx, size_t */
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include "zstd_compress_internal.h" /* ldmParams_t, U32 */
-#include "../zstd.h" /* ZSTD_CCtx, size_t */
-
/*-*************************************
* Long distance matching
***************************************/
#ifndef ZSTD_OPT_H
#define ZSTD_OPT_H
+#include "zstd_compress_internal.h"
+
#if defined (__cplusplus)
extern "C" {
#endif
-#include "zstd_compress_internal.h"
-
#if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \
|| !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \
|| !defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR)
#ifndef ZSTDMT_COMPRESS_H
#define ZSTDMT_COMPRESS_H
+/* === Dependencies === */
+#include "../common/zstd_deps.h" /* size_t */
+#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
+#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
+
#if defined (__cplusplus)
extern "C" {
#endif
* otherwise ZSTDMT_createCCtx*() will fail.
*/
-/* === Dependencies === */
-#include "../common/zstd_deps.h" /* size_t */
-#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
-#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
-
-
/* === Constants === */
#ifndef ZSTDMT_NBWORKERS_MAX /* a different value can be selected at compile time */
# define ZSTDMT_NBWORKERS_MAX ((sizeof(void*)==4) /*32-bit*/ ? 64 : 256)
* You may select, at your option, one of the above-listed licenses.
*/
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#ifndef ZSTD_ZDICT_H
#define ZSTD_ZDICT_H
+
/*====== Dependencies ======*/
#include <stddef.h> /* size_t */
+#if defined (__cplusplus)
+extern "C" {
+#endif
/* ===== ZDICTLIB_API : control library symbols visibility ===== */
#ifndef ZDICTLIB_VISIBLE
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
-#if defined (__cplusplus)
-extern "C" {
-#endif
#ifndef ZSTD_H_235446
#define ZSTD_H_235446
+
/* ====== Dependencies ======*/
#include <stddef.h> /* size_t */
+#include "zstd_errors.h" /* list of errors */
+#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
+#include <limits.h> /* INT_MAX */
+#endif /* ZSTD_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
/* ===== ZSTDLIB_API : control library symbols visibility ===== */
#ifndef ZSTDLIB_VISIBLE
/*====== Error helper functions ======*/
-#include "zstd_errors.h" /* list of errors */
/* ZSTD_isError() :
* Most ZSTD_* functions returning a size_t value can be tested for error,
* using ZSTD_isError().
#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
-#include <limits.h> /* INT_MAX */
-
/* This can be overridden externally to hide static symbols. */
#ifndef ZSTDLIB_STATIC_API
# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
* or detecting and returning an error
*/
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#ifndef BENCH_FN_H_23876
#define BENCH_FN_H_23876
#include <stddef.h> /* size_t */
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/* ==== Benchmark any function, iterated on a set of blocks ==== */
/* BMK_runTime_t: valid result return type */
* and display progress result and final summary
*/
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#ifndef BENCH_ZSTD_H_3242387
#define BENCH_ZSTD_H_3242387
#include "../lib/zstd.h" /* ZSTD_compressionParameters */
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/* === Constants === */
#define MB_UNIT 1000000
#ifndef ZSTD_FILEIO_ASYNCIO_H
#define ZSTD_FILEIO_ASYNCIO_H
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#include "../lib/common/mem.h" /* U32, U64 */
#include "fileio_types.h"
#include "platform.h"
#define MAX_IO_JOBS (10)
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
typedef struct {
/* These struct fields should be set only on creation and not changed afterwards */
POOL_ctx* threadPool;
#ifndef ZSTD_FILEIO_COMMON_H
#define ZSTD_FILEIO_COMMON_H
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
#include "../lib/common/mem.h" /* U32, U64 */
#include "fileio_types.h"
#include "platform.h"
#include "timefn.h" /* UTIL_getTime, UTIL_clockSpanMicro */
+#if !(defined(_MSC_VER) && _MSC_VER >= 1400) \
+ && !(!defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L)) \
+ && !(defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__)) \
+ && (defined(_WIN32) && !defined(__DJGPP__))
+# include <windows.h>
+#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/*-*************************************
* Macros
***************************************/
# define LONG_SEEK fseeko64
# define LONG_TELL ftello64
#elif defined(_WIN32) && !defined(__DJGPP__)
-# include <windows.h>
static int LONG_SEEK(FILE* file, __int64 offset, int origin) {
LARGE_INTEGER off;
DWORD method;
#ifndef PLATFORM_H_MODULE
#define PLATFORM_H_MODULE
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
-
/* **************************************
* Compiler Options
****************************************/
# include <io.h> /* _isatty */
# include <windows.h> /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */
# include <stdio.h> /* FILE */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
static __inline int IS_CONSOLE(FILE* stdStream) {
DWORD dummy;
return _isatty(_fileno(stdStream)) && GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdStream)), &dummy);
}
+
+#if defined (__cplusplus)
+}
+#endif
+
#else
# define IS_CONSOLE(stdStream) 0
#endif
# endif
#endif
-
-#if defined (__cplusplus)
-}
-#endif
-
#endif /* PLATFORM_H_MODULE */
#ifndef TIME_FN_H_MODULE_287987
#define TIME_FN_H_MODULE_287987
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
-
/*-****************************************
* Types
******************************************/
typedef unsigned long long PTime; /* does not support compilers without long long support */
#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/* UTIL_time_t contains a nanosecond time counter.
* The absolute value is not meaningful.
* It's only valid to compute the difference between 2 measurements. */
* You may select, at your option, one of the above-listed licenses.
*/
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
/*-****************************************
* Dependencies
******************************************/
{
return UTIL_countCores(1);
}
-
-#if defined (__cplusplus)
-}
-#endif
#include <sys/types.h> /* stat, utime */
#include <sys/stat.h> /* stat, chmod */
#include "../lib/common/mem.h" /* U64 */
+#if not (defined(_MSC_VER) || defined(__MINGW32__) || defined (__MSVCRT__))
+#include <libgen.h>
+#endif
/*-************************************************************
* Fix fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW
#define STRDUP(s) _strdup(s)
#else
#define PATH_SEP '/'
-#include <libgen.h>
#define STRDUP(s) strdup(s)
#endif
#ifndef ZSTD_ZLIBWRAPPER_H
#define ZSTD_ZLIBWRAPPER_H
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-
#define ZLIB_CONST
#define Z_PREFIX
#define ZLIB_INTERNAL /* disables gz*64 functions but fixes zlib 1.2.4 with Z_PREFIX */
#define _Z_OF OF
#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
/* returns a string with version of zstd library */
const char * zstdVersion(void);