mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
improved console log of utils.h
removed a warning when compiling on Windows
This commit is contained in:
@ -105,13 +105,21 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*-****************************************
|
||||||
|
* Console log
|
||||||
|
******************************************/
|
||||||
|
static int g_utilDisplayLevel;
|
||||||
|
#define UTIL_DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||||
|
#define UTIL_DISPLAYLEVEL(l, ...) { if (g_utilDisplayLevel>=l) { UTIL_DISPLAY(__VA_ARGS__); } }
|
||||||
|
|
||||||
|
|
||||||
/*-****************************************
|
/*-****************************************
|
||||||
* Time functions
|
* Time functions
|
||||||
******************************************/
|
******************************************/
|
||||||
#if defined(_WIN32) /* Windows */
|
#if defined(_WIN32) /* Windows */
|
||||||
typedef LARGE_INTEGER UTIL_freq_t;
|
typedef LARGE_INTEGER UTIL_freq_t;
|
||||||
typedef LARGE_INTEGER UTIL_time_t;
|
typedef LARGE_INTEGER UTIL_time_t;
|
||||||
UTIL_STATIC void UTIL_initTimer(UTIL_freq_t* ticksPerSecond) { if (!QueryPerformanceFrequency(ticksPerSecond)) fprintf(stderr, "ERROR: QueryPerformance not present\n"); }
|
UTIL_STATIC void UTIL_initTimer(UTIL_freq_t* ticksPerSecond) { if (!QueryPerformanceFrequency(ticksPerSecond)) UTIL_DISPLAYLEVEL(1, "ERROR: QueryPerformance not present\n"); }
|
||||||
UTIL_STATIC void UTIL_getTime(UTIL_time_t* x) { QueryPerformanceCounter(x); }
|
UTIL_STATIC void UTIL_getTime(UTIL_time_t* x) { QueryPerformanceCounter(x); }
|
||||||
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_freq_t ticksPerSecond, UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; }
|
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_freq_t ticksPerSecond, UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; }
|
||||||
UTIL_STATIC U64 UTIL_getSpanTimeNano(UTIL_freq_t ticksPerSecond, UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; }
|
UTIL_STATIC U64 UTIL_getSpanTimeNano(UTIL_freq_t ticksPerSecond, UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart; }
|
||||||
@ -284,10 +292,6 @@ UTIL_STATIC void *UTIL_realloc(void *ptr, size_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int g_utilDisplayLevel;
|
|
||||||
#define UTIL_DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
|
||||||
#define UTIL_DISPLAYLEVEL(l, ...) { if (g_utilDisplayLevel>=l) { UTIL_DISPLAY(__VA_ARGS__); } }
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define UTIL_HAS_CREATEFILELIST
|
# define UTIL_HAS_CREATEFILELIST
|
||||||
|
|
||||||
@ -309,7 +313,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
|
|
||||||
hFile=FindFirstFileA(path, &cFile);
|
hFile=FindFirstFileA(path, &cFile);
|
||||||
if (hFile == INVALID_HANDLE_VALUE) {
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
fprintf(stderr, "Cannot open directory '%s'\n", dirName);
|
UTIL_DISPLAYLEVEL(1, "Cannot open directory '%s'\n", dirName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
@ -363,7 +367,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
int dirLength, fnameLength, pathLength, nbFiles = 0;
|
int dirLength, fnameLength, pathLength, nbFiles = 0;
|
||||||
|
|
||||||
if (!(dir = opendir(dirName))) {
|
if (!(dir = opendir(dirName))) {
|
||||||
fprintf(stderr, "Cannot open directory '%s': %s\n", dirName, strerror(errno));
|
UTIL_DISPLAYLEVEL(1, "Cannot open directory '%s': %s\n", dirName, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +412,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
fprintf(stderr, "readdir(%s) error: %s\n", dirName, strerror(errno));
|
UTIL_DISPLAYLEVEL(1, "readdir(%s) error: %s\n", dirName, strerror(errno));
|
||||||
free(*bufStart);
|
free(*bufStart);
|
||||||
*bufStart = NULL;
|
*bufStart = NULL;
|
||||||
}
|
}
|
||||||
@ -421,7 +425,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
|
|||||||
UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char** bufEnd, int followLinks)
|
UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_t* pos, char** bufEnd, int followLinks)
|
||||||
{
|
{
|
||||||
(void)bufStart; (void)bufEnd; (void)pos;
|
(void)bufStart; (void)bufEnd; (void)pos;
|
||||||
fprintf(stderr, "Directory %s ignored (compiled without _WIN32 or _POSIX_C_SOURCE)\n", dirName);
|
UTIL_DISPLAYLEVEL(1, "Directory %s ignored (compiled without _WIN32 or _POSIX_C_SOURCE)\n", dirName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user