summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-10-27 18:26:58 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-10-27 18:26:58 (GMT)
commit206f5f48cf4db19dad3de3adca1d95db335555e0 (patch)
tree23792fb6322a17fa077ef9519eb02389c77b9c40
parent7185dc04a6fa3b3cb59c9897c0865465daa14118 (diff)
downloadlz4-206f5f48cf4db19dad3de3adca1d95db335555e0.zip
lz4-206f5f48cf4db19dad3de3adca1d95db335555e0.tar.gz
lz4-206f5f48cf4db19dad3de3adca1d95db335555e0.tar.bz2
Corrected issue 39 : bench.c for NetBSD. Thanks to Thomas Klausner.
git-svn-id: https://lz4.googlecode.com/svn/trunk@81 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
-rw-r--r--bench.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/bench.c b/bench.c
index f379f99..a48029d 100644
--- a/bench.c
+++ b/bench.c
@@ -33,8 +33,9 @@
#define _LARGEFILE64_SOURCE
// MSVC does not support S_ISREG
-#ifndef S_ISREG
-#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
+#if defined(_MSC_VER)
+# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
+# define BMK_LEGACY_TIMER 1
#endif
// GCC does not support _rotl outside of Windows
@@ -46,11 +47,17 @@
//**************************************
// Includes
//**************************************
-#include <stdlib.h> // malloc
-#include <stdio.h> // fprintf, fopen, ftello64
-#include <sys/timeb.h> // timeb
-#include <sys/types.h> // stat64
-#include <sys/stat.h> // stat64
+#include <stdlib.h> // malloc
+#include <stdio.h> // fprintf, fopen, ftello64
+#include <sys/types.h> // stat64
+#include <sys/stat.h> // stat64
+
+// Use ftime() if gettimeofday() is not available on your target
+#if defined(BMK_LEGACY_TIMER)
+# include <sys/timeb.h> // timeb, ftime
+#else
+# include <sys/time.h> // gettimeofday
+#endif
#include "lz4.h"
#define COMPRESSOR0 LZ4_compress
@@ -139,9 +146,11 @@ void BMK_SetNbIterations(int nbLoops)
// Private functions
//*********************************************************
+#if defined(BMK_LEGACY_TIMER)
+
static int BMK_GetMilliStart()
{
- // Supposed to be portable
+ // Based on Legacy ftime()
// Rolls over every ~ 12.1 days (0x100000/24/60/60)
// Use GetMilliSpan to correct for rollover
struct timeb tb;
@@ -151,6 +160,21 @@ static int BMK_GetMilliStart()
return nCount;
}
+#else
+
+static int BMK_GetMilliStart()
+{
+ // Based on newer gettimeofday()
+ // Use GetMilliSpan to correct for rollover
+ struct timeval tv;
+ int nCount;
+ gettimeofday(&tv, NULL);
+ nCount = (int) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);
+ return nCount;
+}
+
+#endif
+
static int BMK_GetMilliSpan( int nTimeStart )
{