From 26a739ed0b487eeeb9e5e5954be05294cd50dc9a Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sat, 12 Dec 2015 15:43:47 -0800 Subject: [PATCH] compat --- src/main.cpp | 4 +++- src/turbo_linecount.cpp | 14 +++++++++++--- src/turbo_linecount.h | 12 +++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8467246..d0d61d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,12 +7,14 @@ /////////////////////////////////////////////// #include"turbo_linecount.h" +#include +#include #ifdef _WIN32 #include -#else +#elif defined(TLC_COMPATIBLE_UNIX) #include #define _tprintf printf diff --git a/src/turbo_linecount.cpp b/src/turbo_linecount.cpp index 9576205..8c4b708 100644 --- a/src/turbo_linecount.cpp +++ b/src/turbo_linecount.cpp @@ -1,3 +1,9 @@ +#if defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__) +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE 1 +#endif +#endif + // // Turbo Linecount // Copyright 2015, Christien Rioux @@ -8,6 +14,8 @@ #include"turbo_linecount.h" #include +#include +#include #ifdef min #undef min #endif @@ -51,7 +59,7 @@ typedef off_t tlc_fileoffset_t; #define LCOPENFILE(name) ::open(name, O_RDONLY) #define LCCLOSEFILE(handle) (::close(handle) != -1) #define LCINVALIDHANDLE -1 -#define LCSETREALLASTERROR(err, errstr) { int __err = errno; setLastError(__err, ::strerror(__err)); } +#define LCSETREALLASTERROR(err, errstr) { int __err = errno; setLastError(__err, std::strerror(__err)); } #define _tcsdup strdup #endif @@ -72,13 +80,13 @@ CLineCount::CLineCount(PARAMETERS *parameters) // Set line count parameter defaults int cpucount; int allocationgranularity; -#ifdef _WIN32 +#if defined(_WIN32) || defined(__cygwin__) || defined(__MIN) SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); cpucount = sysinfo.dwNumberOfProcessors; allocationgranularity = sysinfo.dwAllocationGranularity; //#elif defined(__linux__) -#else +#elif TLC_COMPATIBLE_UNIX cpucount = sysconf(_SC_NPROCESSORS_ONLN); allocationgranularity = sysconf(_SC_PAGESIZE); //#elif (defined (__APPLE__) && defined (__MACH__)) diff --git a/src/turbo_linecount.h b/src/turbo_linecount.h index 109a5bd..b0e22ec 100644 --- a/src/turbo_linecount.h +++ b/src/turbo_linecount.h @@ -27,16 +27,10 @@ ////////////// Platform specific -#if defined(_APPLE__) || defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__) +#if defined(_APPLE__) || defined(__linux__) || defined(__CYGWIN__) #define TLC_COMPATIBLE_UNIX 1 #endif -#if defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__) -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE64_SOURCE 1 -#endif -#endif - #ifdef _WIN32 // Windows #include @@ -49,7 +43,7 @@ typedef errno_t tlc_error_t; #include #define _T(x) x #define TCHAR char -typedef tlc_error_t tlc_error_t; +typedef error_t tlc_error_t; #else #error Unsupported operating system. @@ -81,7 +75,7 @@ BEGIN_TURBOLINECOUNT_NAMESPACE; typedef off_t tlc_fileoffset_t; #define TLC_LINECOUNT_FMT "%lld" #elif defined(_LARGEFILE64_SOURCE) - typedef off64_t tlc_fileoffset_t; + typedef _off64_t tlc_fileoffset_t; #define TLC_LINECOUNT_FMT "%lld" #else typedef off_t tlc_fileoffset_t;