#define _LARGEFILE64_SOURCE\r
\r
// MSVC does not support S_ISREG\r
-#ifndef S_ISREG\r
-#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)\r
+#if defined(_MSC_VER)\r
+# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)\r
+# define BMK_LEGACY_TIMER 1\r
#endif\r
\r
// GCC does not support _rotl outside of Windows\r
//**************************************\r
// Includes\r
//**************************************\r
-#include <stdlib.h> // malloc\r
-#include <stdio.h> // fprintf, fopen, ftello64\r
-#include <sys/timeb.h> // timeb\r
-#include <sys/types.h> // stat64\r
-#include <sys/stat.h> // stat64\r
+#include <stdlib.h> // malloc\r
+#include <stdio.h> // fprintf, fopen, ftello64\r
+#include <sys/types.h> // stat64\r
+#include <sys/stat.h> // stat64\r
+\r
+// Use ftime() if gettimeofday() is not available on your target\r
+#if defined(BMK_LEGACY_TIMER) \r
+# include <sys/timeb.h> // timeb, ftime\r
+#else\r
+# include <sys/time.h> // gettimeofday\r
+#endif\r
\r
#include "lz4.h"\r
#define COMPRESSOR0 LZ4_compress\r
// Private functions\r
//*********************************************************\r
\r
+#if defined(BMK_LEGACY_TIMER)\r
+\r
static int BMK_GetMilliStart()\r
{\r
- // Supposed to be portable\r
+ // Based on Legacy ftime()\r
// Rolls over every ~ 12.1 days (0x100000/24/60/60)\r
// Use GetMilliSpan to correct for rollover\r
struct timeb tb;\r
return nCount;\r
}\r
\r
+#else\r
+\r
+static int BMK_GetMilliStart()\r
+{\r
+ // Based on newer gettimeofday()\r
+ // Use GetMilliSpan to correct for rollover\r
+ struct timeval tv;\r
+ int nCount;\r
+ gettimeofday(&tv, NULL);\r
+ nCount = (int) (tv.tv_usec/1000 + (tv.tv_sec & 0xfffff) * 1000);\r
+ return nCount;\r
+}\r
+\r
+#endif\r
+\r
\r
static int BMK_GetMilliSpan( int nTimeStart )\r
{\r