summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-03-07 18:30:45 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-03-07 18:30:45 (GMT)
commit32a85fc76d3da9345c2e49ce33a9d8d1e79dfa1f (patch)
treeaee40bd10700328f45d98da46c5c9e1d5cb01151
parent488029ec3b23b1e00a69f1ac3fcdd49d24cb7d3f (diff)
downloadlz4-32a85fc76d3da9345c2e49ce33a9d8d1e79dfa1f.zip
lz4-32a85fc76d3da9345c2e49ce33a9d8d1e79dfa1f.tar.gz
lz4-32a85fc76d3da9345c2e49ce33a9d8d1e79dfa1f.tar.bz2
NetBSD compatibility (#48)
-rw-r--r--Makefile2
-rw-r--r--NEWS1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/lz4.c20
-rw-r--r--programs/frametest.c38
-rw-r--r--programs/fuzzer.c41
6 files changed, 79 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index c486239..5662cb4 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@
# ################################################################
# Version number
-export VERSION=126
+export VERSION=128
export RELEASE=r$(VERSION)
DESTDIR?=
diff --git a/NEWS b/NEWS
index 05ac6b5..dbea778 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
r128:
New : command -m, to compress multiple files in a single command
Fixed : Restored lz4hc compression ratio (slightly lower since r124)
+Fixed : Fuzzer + frametest compatibility with NetBSD (issue #48)
Added : Visual project directory
r126:
diff --git a/lib/Makefile b/lib/Makefile
index dcb481f..aab4369 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -32,7 +32,7 @@
# ################################################################
# Version numbers
-VERSION ?= 126
+VERSION ?= 128
LIBVER_MAJOR=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER_MINOR=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER_PATCH=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
diff --git a/lib/lz4.c b/lib/lz4.c
index ed928ce..a8b4531 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -64,7 +64,7 @@
* Program will crash.
* If uncommenting results in better performance (case 1)
* please report your configuration to upstream (https://groups.google.com/forum/#!forum/lz4c)
- * An automatic detection macro will be added to match your case within future versions of the library.
+ * This way, an automatic detection macro can be added to match your case within later versions of the library.
*/
/* #define CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS 1 */
@@ -98,7 +98,7 @@
/**************************************
- Compiler Options
+* Compiler Options
**************************************/
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
/* "restrict" is a known keyword */
@@ -316,14 +316,14 @@ static const int LZ4_minLength = (MFLIMIT+1);
/**************************************
- Common Utils
+* Common Utils
**************************************/
#define LZ4_STATIC_ASSERT(c) { enum { LZ4_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
-/********************************
- Common functions
-********************************/
+/**************************************
+* Common functions
+**************************************/
static unsigned LZ4_NbCommonBytes (register size_t val)
{
if (LZ4_isLittleEndian())
@@ -412,7 +412,7 @@ static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLi
#ifndef LZ4_COMMONDEFS_ONLY
/**************************************
- Local Constants
+* Local Constants
**************************************/
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
#define HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
@@ -423,14 +423,14 @@ static const U32 LZ4_skipTrigger = 6; /* Increase this value ==> compression ru
/**************************************
- Local Utils
+* Local Utils
**************************************/
int LZ4_versionNumber (void) { return LZ4_VERSION_NUMBER; }
int LZ4_compressBound(int isize) { return LZ4_COMPRESSBOUND(isize); }
/**************************************
- Local Structures and types
+* Local Structures and types
**************************************/
typedef struct {
U32 hashTable[HASH_SIZE_U32];
@@ -453,7 +453,7 @@ typedef enum { full = 0, partial = 1 } earlyEnd_directive;
/********************************
- Compression functions
+* Compression functions
********************************/
static U32 LZ4_hashSequence(U32 sequence, tableType_t tableType)
diff --git a/programs/frametest.c b/programs/frametest.c
index 71490a6..a5a23c2 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -23,7 +23,7 @@
*/
/**************************************
- Compiler specific
+* Compiler specific
**************************************/
#define _CRT_SECURE_NO_WARNINGS // fgets
#ifdef _MSC_VER /* Visual Studio */
@@ -36,20 +36,31 @@
# pragma GCC diagnostic ignored "-Wmissing-field-initializers" /* GCC bug 53119 : doesn't accept { 0 } as initializer (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119) */
#endif
+/* S_ISREG & gettimeofday() are not supported by MSVC */
+#if defined(_MSC_VER) || defined(_WIN32)
+# define FUZ_LEGACY_TIMER 1
+#endif
+
/**************************************
- Includes
+* Includes
**************************************/
#include <stdlib.h> // free
#include <stdio.h> // fgets, sscanf
-#include <sys/timeb.h> // timeb
#include <string.h> // strcmp
#include "lz4frame_static.h"
#include "xxhash.h" // XXH64
+/* Use ftime() if gettimeofday() is not available on your target */
+#if defined(FUZ_LEGACY_TIMER)
+# include <sys/timeb.h> /* timeb, ftime */
+#else
+# include <sys/time.h> /* gettimeofday */
+#endif
+
/**************************************
- Basic Types
+* Basic Types
**************************************/
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
# include <stdint.h>
@@ -68,7 +79,7 @@ typedef unsigned long long U64;
/**************************************
- Constants
+* Constants
**************************************/
#ifndef LZ4_VERSION
# define LZ4_VERSION ""
@@ -109,8 +120,10 @@ static U32 pause = 0;
/*********************************************************
- Fuzzer functions
+* Fuzzer functions
*********************************************************/
+#if defined(FUZ_LEGACY_TIMER)
+
static U32 FUZ_GetMilliStart(void)
{
struct timeb tb;
@@ -120,6 +133,19 @@ static U32 FUZ_GetMilliStart(void)
return nCount;
}
+#else
+
+static U32 FUZ_GetMilliStart(void)
+{
+ struct timeval tv;
+ U32 nCount;
+ gettimeofday(&tv, NULL);
+ nCount = (U32) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
+ return nCount;
+}
+
+#endif
+
static U32 FUZ_GetMilliSpan(U32 nTimeStart)
{
diff --git a/programs/fuzzer.c b/programs/fuzzer.c
index 6d3b077..f9467d9 100644
--- a/programs/fuzzer.c
+++ b/programs/fuzzer.c
@@ -25,7 +25,7 @@
*/
/**************************************
-* Remove Visual warning messages
+* Compiler options
**************************************/
#ifdef _MSC_VER /* Visual Studio */
# define _CRT_SECURE_NO_WARNINGS /* fgets */
@@ -34,21 +34,32 @@
# pragma warning(disable : 4310) /* disable: C4310: constant char value > 127 */
#endif
+/* S_ISREG & gettimeofday() are not supported by MSVC */
+#if defined(_MSC_VER) || defined(_WIN32)
+# define FUZ_LEGACY_TIMER 1
+#endif
+
/**************************************
-* Includes
+* Includes
**************************************/
#include <stdlib.h>
#include <stdio.h> /* fgets, sscanf */
-#include <sys/timeb.h> /* timeb */
#include <string.h> /* strcmp */
#include "lz4.h"
#include "lz4hc.h"
#include "xxhash.h"
+/* Use ftime() if gettimeofday() is not available on your target */
+#if defined(FUZ_LEGACY_TIMER)
+# include <sys/timeb.h> /* timeb, ftime */
+#else
+# include <sys/time.h> /* gettimeofday */
+#endif
+
/**************************************
-* Basic Types
+* Basic Types
**************************************/
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
# include <stdint.h>
@@ -67,7 +78,7 @@ typedef unsigned long long U64;
/**************************************
-* Constants
+* Constants
**************************************/
#ifndef LZ4_VERSION
# define LZ4_VERSION ""
@@ -88,7 +99,7 @@ typedef unsigned long long U64;
/*****************************************
-* Macros
+* Macros
*****************************************/
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
@@ -98,8 +109,10 @@ static U32 g_time = 0;
/*********************************************************
- Fuzzer functions
+* Fuzzer functions
*********************************************************/
+#if defined(FUZ_LEGACY_TIMER)
+
static U32 FUZ_GetMilliStart(void)
{
struct timeb tb;
@@ -109,6 +122,20 @@ static U32 FUZ_GetMilliStart(void)
return nCount;
}
+#else
+
+static U32 FUZ_GetMilliStart(void)
+{
+ struct timeval tv;
+ U32 nCount;
+ gettimeofday(&tv, NULL);
+ nCount = (U32) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
+ return nCount;
+}
+
+#endif
+
+
static U32 FUZ_GetMilliSpan(U32 nTimeStart)
{
U32 nCurrent = FUZ_GetMilliStart();