summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--programs/lz4io.c6
-rw-r--r--programs/platform.h13
-rw-r--r--programs/util.h72
-rw-r--r--tests/frametest.c2
-rw-r--r--tests/fullbench.c1
-rw-r--r--tests/fuzzer.c3
6 files changed, 50 insertions, 47 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index ca3cea5..36498b2 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -31,10 +31,14 @@
*/
+#if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
+# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
+#endif
+
/*****************************
* Includes
*****************************/
-#include "platform.h" /* Compiler options, Large File Support, SET_BINARY_MODE, SET_SPARSE_FILE_MODE */
+#include "platform.h" /* Large File Support, SET_BINARY_MODE, SET_SPARSE_FILE_MODE */
#include "util.h" /* UTIL_getFileStat, UTIL_setFileStat */
#include <stdio.h> /* fprintf, fopen, fread, stdin, stdout, fflush, getchar */
#include <stdlib.h> /* malloc, free */
diff --git a/programs/platform.h b/programs/platform.h
index fe4bfde..f1040c0 100644
--- a/programs/platform.h
+++ b/programs/platform.h
@@ -25,23 +25,17 @@ 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 */
+# define _CRT_SECURE_NO_WARNINGS /* Disable Visual Studio warning messages for fopen, strncpy, strerror */
+# define _CRT_SECURE_NO_DEPRECATE /* VS2005 - must be declared before <io.h> and <windows.h> */
# 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
/* **************************************
@@ -110,6 +104,7 @@ extern "C" {
* Detect if isatty() and fileno() are available
************************************************/
#if (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || (PLATFORM_POSIX_VERSION >= 200112L) || defined(__DJGPP__)
+# include <unistd.h> /* isatty */
# define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
#elif defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
# include <io.h> /* _isatty */
diff --git a/programs/util.h b/programs/util.h
index 409f6d7..c670c20 100644
--- a/programs/util.h
+++ b/programs/util.h
@@ -25,26 +25,51 @@ extern "C" {
#endif
+
/*-****************************************
* Dependencies
******************************************/
-#include "platform.h" /* Compiler options, PLATFORM_POSIX_VERSION */
-#include <stdlib.h> /* malloc */
-#include <stddef.h> /* size_t, ptrdiff_t */
-#include <stdio.h> /* fprintf */
-#include <sys/types.h> /* stat, utime */
-#include <sys/stat.h> /* stat */
+#include "platform.h" /* PLATFORM_POSIX_VERSION */
+#include <stdlib.h> /* malloc */
+#include <stddef.h> /* size_t, ptrdiff_t */
+#include <stdio.h> /* fprintf */
+#include <sys/types.h> /* stat, utime */
+#include <sys/stat.h> /* stat */
#if defined(_MSC_VER)
-# include <sys/utime.h> /* utime */
-# include <io.h> /* _chmod */
+# include <sys/utime.h> /* utime */
+# include <io.h> /* _chmod */
#else
# include <unistd.h> /* chown, stat */
# include <utime.h> /* utime */
#endif
-#include <time.h> /* time */
+#include <time.h> /* time */
#include <errno.h>
+
+/*-**************************************************************
+* Basic Types
+*****************************************************************/
+#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ 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
+
+
/*-****************************************
* Sleep functions: Windows - Posix - others
******************************************/
@@ -81,35 +106,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 <stdint.h>
- 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/tests/frametest.c b/tests/frametest.c
index 8b7caba..869be76 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -27,6 +27,7 @@
* Compiler specific
**************************************/
#ifdef _MSC_VER /* Visual Studio */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
#endif
@@ -34,7 +35,6 @@
/*-************************************
* Includes
**************************************/
-#include "platform.h" /* Compiler options */
#include "util.h" /* U32 */
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* fprintf */
diff --git a/tests/fullbench.c b/tests/fullbench.c
index 8d55d2d..f489392 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -33,6 +33,7 @@
/**************************************
* Includes
**************************************/
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS, Large Files support */
#include "util.h" /* U32, UTIL_getFileSize */
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* fprintf, fopen, ftello */
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 10e9139..ff02e0c 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -27,6 +27,7 @@
* Compiler options
**************************************/
#ifdef _MSC_VER /* Visual Studio */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
# pragma warning(disable : 4310) /* disable: C4310: constant char value > 127 */
#endif
@@ -35,7 +36,7 @@
/*-************************************
* Dependencies
**************************************/
-#include "platform.h" /* Compiler options */
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS */
#include "util.h" /* U32 */
#include <stdlib.h>
#include <stdio.h> /* fgets, sscanf */