#define _POSIX_C_SOURCE 199309L

dev
inikep 2016-03-22 13:05:26 +01:00
parent 2b942881ac
commit 5192b3ee65
2 changed files with 12 additions and 15 deletions

View File

@ -46,7 +46,7 @@ DESTDIR?=
PREFIX ?= /usr/local PREFIX ?= /usr/local
CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\" CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\"
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
CFLAGS += -std=gnu99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef CFLAGS += -std=c99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin

View File

@ -44,31 +44,28 @@
/* ************************************* /* *************************************
* Includes * Includes
***************************************/ ***************************************/
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) #define _POSIX_C_SOURCE 199309L /* before time.h */
#define WINDOWS
#endif
#include <stdlib.h> /* malloc, free */ #include <stdlib.h> /* malloc, free */
#include <string.h> /* memset */ #include <string.h> /* memset */
#include <stdio.h> /* fprintf, fopen, ftello64 */ #include <stdio.h> /* fprintf, fopen, ftello64 */
#include <sys/types.h> /* stat64 */ #include <sys/types.h> /* stat64 */
#include <sys/stat.h> /* stat64 */ #include <sys/stat.h> /* stat64 */
#include <time.h> /* clock_t, clock, nanosleep, CLOCKS_PER_SEC */ #include <time.h> /* clock_t, clock, nanosleep, CLOCKS_PER_SEC */
#ifdef WINDOWS
#define mili_sleep(mili) Sleep(mili)
#else
#include <sys/resource.h> /* setpriority */
#define mili_sleep(mili) { struct timespec t; t.tv_sec=0; t.tv_nsec=mili*1000000L; nanosleep(&t, NULL); }
#endif
/* sleep : posix - windows - others */ /* sleep : posix - windows - others */
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
# include <unistd.h> # include <unistd.h>
# include <sys/resource.h> /* setpriority */
# define BMK_sleep(s) sleep(s) # define BMK_sleep(s) sleep(s)
# define mili_sleep(mili) { struct timespec t; t.tv_sec=0; t.tv_nsec=mili*1000000L; nanosleep(&t, NULL); }
#elif defined(_WIN32) #elif defined(_WIN32)
# include <windows.h> # include <windows.h>
# define BMK_sleep(s) Sleep(1000*s) # define BMK_sleep(s) Sleep(1000*s)
# define mili_sleep(mili) Sleep(mili)
#else #else
# define BMK_sleep(s) /* disabled */ # define BMK_sleep(s) /* disabled */
# define mili_sleep(mili) /* disabled */
#error "disabled"
#endif #endif
#include "mem.h" #include "mem.h"
@ -424,7 +421,7 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
{ {
benchResult_t result, total; benchResult_t result, total;
int l; int l;
#ifdef WINDOWS #ifdef _WIN32
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
#else #else
setpriority(PRIO_PROCESS, 0, -20); setpriority(PRIO_PROCESS, 0, -20);
@ -437,8 +434,8 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
memset(&total, 0, sizeof(total)); memset(&total, 0, sizeof(total));
if (g_displayLevel == 1 && !additionalParam) // if (g_displayLevel == 1 && !additionalParam)
DISPLAY("bench %s: input %u bytes, %i iterations, %u KB blocks\n", ZSTD_VERSION, (U32)benchedSize, g_nbIterations, (U32)(g_blockSize>>10)); // DISPLAY("bench %s: input %u bytes, %i iterations, %u KB blocks\n", ZSTD_VERSION, (U32)benchedSize, g_nbIterations, (U32)(g_blockSize>>10));
if (cLevelLast < cLevel) cLevelLast = cLevel; if (cLevelLast < cLevel) cLevelLast = cLevel;
@ -448,8 +445,8 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
fileSizes, nbFiles, fileSizes, nbFiles,
dictBuffer, dictBufferSize, &result); dictBuffer, dictBufferSize, &result);
if (g_displayLevel == 1) { if (g_displayLevel == 1) {
if (additionalParam) if (1)// && additionalParam)
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (param=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam); DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (kSlotNew=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam);
else else
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName); DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName);
total.cSize += result.cSize; total.cSize += result.cSize;