diff --git a/lib/common/mem.h b/lib/common/mem.h index fb73ef09..32c63dd1 100644 --- a/lib/common/mem.h +++ b/lib/common/mem.h @@ -46,8 +46,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size /*-************************************************************** * Basic Types *****************************************************************/ -#ifndef BASIC_TYPES_DEFINED -#define BASIC_TYPES_DEFINED #if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # include typedef uint8_t BYTE; @@ -68,7 +66,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size typedef signed long long S64; typedef ptrdiff_t iPtrDiff; #endif -#endif /*-************************************************************** diff --git a/programs/bench.c b/programs/bench.c index 2b7436a4..9b7f9888 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -8,16 +8,27 @@ */ + +/* ************************************** +* Compiler Warnings +****************************************/ +#ifdef _MSC_VER +# define _CRT_SECURE_NO_WARNINGS /* fopen */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +#endif + + /* ************************************* * Includes ***************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* UTIL_GetFileSize, UTIL_sleep */ +#include "platform.h" /* Large Files support */ +#include "util.h" /* UTIL_getFileSize, UTIL_sleep */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ +#include "mem.h" #define ZSTD_STATIC_LINKING_ONLY #include "zstd.h" #include "datagen.h" /* RDG_genBuffer */ diff --git a/programs/datagen.c b/programs/datagen.c index 8209c851..06b5ab97 100644 --- a/programs/datagen.c +++ b/programs/datagen.c @@ -9,14 +9,22 @@ +/* ************************************* +* Compiler Options +***************************************/ +#if defined(_MSC_VER) +# define _CRT_SECURE_NO_WARNINGS /* removes Visual warning on strerror() */ +# define _CRT_SECURE_NO_DEPRECATE /* removes VS2005 warning on strerror() */ +#endif + /*-************************************ * Dependencies **************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* U32 */ +#include "platform.h" /* SET_BINARY_MODE */ #include /* malloc, free */ #include /* FILE, fwrite, fprintf */ #include /* memcpy */ +#include "mem.h" /* U32 */ /*-************************************ diff --git a/programs/dibio.c b/programs/dibio.c index 1c22949f..b99e717c 100644 --- a/programs/dibio.c +++ b/programs/dibio.c @@ -9,17 +9,27 @@ +/* ************************************** +* Compiler Warnings +****************************************/ +#ifdef _MSC_VER +# define _CRT_SECURE_NO_WARNINGS /* fopen */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +#endif + + /*-************************************* * Includes ***************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* UTIL_GetFileSize, UTIL_getTotalFileSize */ +#include "platform.h" /* Large Files support */ +#include "util.h" /* UTIL_getFileSize, UTIL_getTotalFileSize */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ #include /* errno */ +#include "mem.h" /* read */ #include "error_private.h" #include "dibio.h" diff --git a/programs/fileio.c b/programs/fileio.c index fa52f9af..e2a90a67 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -11,21 +11,26 @@ * Compiler Options ***************************************/ #ifdef _MSC_VER /* Visual */ +# define _CRT_SECURE_NO_WARNINGS /* removes Visual warning on strerror() */ # pragma warning(disable : 4204) /* non-constant aggregate initializer */ #endif +#if defined(__MINGW32__) && !defined(_POSIX_SOURCE) +# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */ +#endif /*-************************************* * Includes ***************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* UTIL_GetFileSize, _LARGEFILE64_SOURCE */ +#include "platform.h" /* Large Files support, SET_BINARY_MODE */ +#include "util.h" /* UTIL_getFileSize */ #include /* fprintf, fopen, fread, _fileno, stdin, stdout */ #include /* malloc, free */ #include /* strcmp, strlen */ #include /* clock */ #include /* errno */ +#include "mem.h" #include "fileio.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */ #include "zstd.h" diff --git a/programs/platform.h b/programs/platform.h index fe4bfded..0b82e46b 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -25,25 +25,6 @@ extern "C" { #endif -/* ************************************** -* Compiler Options -****************************************/ -#if defined(__INTEL_COMPILER) -# pragma warning(disable : 177) /* disable: message #177: function was declared but never referenced */ -#endif -#if defined(_MSC_VER) -# define _CRT_SECURE_NO_WARNINGS /* Disable some Visual warning messages for fopen, strncpy */ -# define _CRT_SECURE_NO_DEPRECATE /* VS2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# if (_MSC_VER <= 1800) /* (1800 = Visual Studio 2013) */ -# define snprintf sprintf_s /* snprintf unsupported by Visual <= 2013 */ -# endif -#endif -#if defined(__MINGW32__) && !defined(_POSIX_SOURCE) -# define _POSIX_C_SOURCE 1 /* enable __VA_ARGS__ and disable %llu warnings with MinGW on Windows */ -#endif - - /* ************************************** * Detect 64-bit OS * http://nadeausoftware.com/articles/2012/02/c_c_tip_how_detect_processor_type_using_compiler_predefined_macros @@ -110,6 +91,7 @@ extern "C" { * Detect if isatty() and fileno() are available ************************************************/ #if (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || (PLATFORM_POSIX_VERSION >= 200112L) || defined(__DJGPP__) +# include /* isatty */ # define IS_CONSOLE(stdStream) isatty(fileno(stdStream)) #elif defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) # include /* _isatty */ diff --git a/programs/util.h b/programs/util.h index 409f6d7c..8b480b22 100644 --- a/programs/util.h +++ b/programs/util.h @@ -25,24 +25,35 @@ extern "C" { #endif +/* ************************************** +* Compiler Options +****************************************/ +#if defined(_MSC_VER) +# if (_MSC_VER <= 1800) /* (1800 = Visual Studio 2013) */ +# define snprintf sprintf_s /* snprintf unsupported by Visual <= 2013 */ +# endif +#endif + + /*-**************************************** * Dependencies ******************************************/ -#include "platform.h" /* Compiler options, PLATFORM_POSIX_VERSION */ -#include /* malloc */ -#include /* size_t, ptrdiff_t */ -#include /* fprintf */ -#include /* stat, utime */ -#include /* stat */ +#include "platform.h" /* PLATFORM_POSIX_VERSION */ +#include /* malloc */ +#include /* size_t, ptrdiff_t */ +#include /* fprintf */ +#include /* stat, utime */ +#include /* stat */ #if defined(_MSC_VER) -# include /* utime */ -# include /* _chmod */ +# include /* utime */ +# include /* _chmod */ #else # include /* chown, stat */ # include /* utime */ #endif -#include /* time */ +#include /* time */ #include +#include "mem.h" /* U32, U64 */ /*-**************************************** @@ -81,35 +92,12 @@ extern "C" { #define LIST_SIZE_INCREASE (8*1024) -/*-************************************************************** -* Basic Types -*****************************************************************/ -#ifndef BASIC_TYPES_DEFINED -#define BASIC_TYPES_DEFINED -#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) -# include - typedef uint8_t BYTE; - typedef uint16_t U16; - typedef int16_t S16; - typedef uint32_t U32; - typedef int32_t S32; - typedef uint64_t U64; - typedef int64_t S64; -#else - typedef unsigned char BYTE; - typedef unsigned short U16; - typedef signed short S16; - typedef unsigned int U32; - typedef signed int S32; - typedef unsigned long long U64; - typedef signed long long S64; -#endif -#endif - - /*-**************************************** * Compiler specifics ******************************************/ +#if defined(__INTEL_COMPILER) +# pragma warning(disable : 177) /* disable: message #177: function was declared but never referenced, useful with UTIL_STATIC */ +#endif #if defined(__GNUC__) # define UTIL_STATIC static __attribute__((unused)) #elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 29fcb746..978ffcfe 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -23,7 +23,7 @@ /*-************************************ * Dependencies **************************************/ -#include "platform.h" /* Compiler options, PLATFORM_POSIX_VERSION */ +#include "platform.h" /* IS_CONSOLE, PLATFORM_POSIX_VERSION */ #include "util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */ #include /* strcmp, strlen */ #include /* errno */ diff --git a/tests/datagencli.c b/tests/datagencli.c index c4bf4893..2f3ebc4d 100644 --- a/tests/datagencli.c +++ b/tests/datagencli.c @@ -11,8 +11,7 @@ /*-************************************ * Dependencies **************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* U32 */ +#include "util.h" /* Compiler options */ #include /* fprintf, stderr */ #include "datagen.h" /* RDG_generate */ diff --git a/tests/fullbench.c b/tests/fullbench.c index 439de5c7..233b4e93 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -11,12 +11,12 @@ /*_************************************ * Includes **************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* U32 */ +#include "util.h" /* Compiler options, UTIL_GetFileSize */ #include /* malloc */ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ +#include "mem.h" #ifndef ZSTD_DLL_IMPORT #include "zstd_internal.h" /* ZSTD_blockHeaderSize, blockType_e, KB, MB */ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressBegin, ZSTD_compressContinue, etc. */ diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 9088e248..86d4c6be 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -12,6 +12,8 @@ * Compiler specific **************************************/ #ifdef _MSC_VER /* Visual Studio */ +# define _CRT_SECURE_NO_WARNINGS /* fgets */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ # pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */ #endif @@ -19,8 +21,6 @@ /*-************************************ * Includes **************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* U32 */ #include /* free */ #include /* fgets, sscanf */ #include /* strcmp */ @@ -30,6 +30,7 @@ #include "zstd_errors.h" /* ZSTD_getErrorCode */ #include "zdict.h" /* ZDICT_trainFromBuffer */ #include "datagen.h" /* RDG_genBuffer */ +#include "mem.h" #define XXH_STATIC_LINKING_ONLY #include "xxhash.h" /* XXH64 */ diff --git a/tests/paramgrill.c b/tests/paramgrill.c index 0825b37a..5eabcba2 100644 --- a/tests/paramgrill.c +++ b/tests/paramgrill.c @@ -11,15 +11,14 @@ /*-************************************ * Dependencies **************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* UTIL_getFileSize */ +#include "util.h" /* Compiler options, UTIL_GetFileSize */ #include /* malloc */ #include /* fprintf, fopen, ftello64 */ #include /* strcmp */ #include /* log */ #include /* clock_t */ -#include "mem.h" /* MEM_32bits() */ +#include "mem.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_estimateCCtxSize */ #include "zstd.h" #include "datagen.h" diff --git a/tests/zbufftest.c b/tests/zbufftest.c index 87cf80b5..14b73923 100644 --- a/tests/zbufftest.c +++ b/tests/zbufftest.c @@ -12,6 +12,8 @@ * Compiler specific **************************************/ #ifdef _MSC_VER /* Visual Studio */ +# define _CRT_SECURE_NO_WARNINGS /* fgets */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ # pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */ #endif @@ -19,12 +21,11 @@ /*-************************************ * Includes **************************************/ -#include "platform.h" /* Compiler options */ #include /* free */ #include /* fgets, sscanf */ #include /* clock_t, clock() */ #include /* strcmp */ -#include "mem.h" /* MEM_writeLE32 */ +#include "mem.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_maxCLevel */ #include "zstd.h" /* ZSTD_compressBound */ #define ZBUFF_STATIC_LINKING_ONLY /* ZBUFF_createCCtx_advanced */ diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index 9da0010b..ce619308 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c @@ -12,6 +12,8 @@ * Compiler specific **************************************/ #ifdef _MSC_VER /* Visual Studio */ +# define _CRT_SECURE_NO_WARNINGS /* fgets */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ # pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */ #endif @@ -19,12 +21,11 @@ /*-************************************ * Includes **************************************/ -#include "platform.h" /* Compiler options */ #include /* free */ #include /* fgets, sscanf */ #include /* clock_t, clock() */ #include /* strcmp */ -#include "mem.h" /* MEM_writeLE32 */ +#include "mem.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_maxCLevel, ZSTD_customMem */ #include "zstd.h" /* ZSTD_compressBound */ #include "zstd_errors.h" /* ZSTD_error_srcSize_wrong */ diff --git a/zlibWrapper/examples/zwrapbench.c b/zlibWrapper/examples/zwrapbench.c index 8999657f..e0aca001 100644 --- a/zlibWrapper/examples/zwrapbench.c +++ b/zlibWrapper/examples/zwrapbench.c @@ -11,14 +11,14 @@ /* ************************************* * Includes ***************************************/ -#include "platform.h" /* Compiler options */ -#include "util.h" /* U32, UTIL_GetFileSize, UTIL_sleep */ +#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_sleep */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ #include /* toupper */ +#include "mem.h" #define ZSTD_STATIC_LINKING_ONLY #include "zstd.h" #include "datagen.h" /* RDG_genBuffer */