mirror of
https://github.com/crioux/turbo-linecount.git
synced 2024-10-27 17:24:01 +00:00
compat
This commit is contained in:
parent
75ba1a9f4f
commit
26a739ed0b
@ -7,12 +7,14 @@
|
|||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
#include"turbo_linecount.h"
|
#include"turbo_linecount.h"
|
||||||
|
#include<cstring>
|
||||||
|
#include<cstdio>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include<tchar.h>
|
#include<tchar.h>
|
||||||
|
|
||||||
#else
|
#elif defined(TLC_COMPATIBLE_UNIX)
|
||||||
|
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
#define _tprintf printf
|
#define _tprintf printf
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
#if defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__)
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Turbo Linecount
|
// Turbo Linecount
|
||||||
// Copyright 2015, Christien Rioux
|
// Copyright 2015, Christien Rioux
|
||||||
@ -8,6 +14,8 @@
|
|||||||
|
|
||||||
#include"turbo_linecount.h"
|
#include"turbo_linecount.h"
|
||||||
#include<algorithm>
|
#include<algorithm>
|
||||||
|
#include<cstring>
|
||||||
|
#include<errno.h>
|
||||||
#ifdef min
|
#ifdef min
|
||||||
#undef min
|
#undef min
|
||||||
#endif
|
#endif
|
||||||
@ -51,7 +59,7 @@ typedef off_t tlc_fileoffset_t;
|
|||||||
#define LCOPENFILE(name) ::open(name, O_RDONLY)
|
#define LCOPENFILE(name) ::open(name, O_RDONLY)
|
||||||
#define LCCLOSEFILE(handle) (::close(handle) != -1)
|
#define LCCLOSEFILE(handle) (::close(handle) != -1)
|
||||||
#define LCINVALIDHANDLE -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
|
#define _tcsdup strdup
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -72,13 +80,13 @@ CLineCount::CLineCount(PARAMETERS *parameters)
|
|||||||
// Set line count parameter defaults
|
// Set line count parameter defaults
|
||||||
int cpucount;
|
int cpucount;
|
||||||
int allocationgranularity;
|
int allocationgranularity;
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) || defined(__cygwin__) || defined(__MIN)
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
cpucount = sysinfo.dwNumberOfProcessors;
|
cpucount = sysinfo.dwNumberOfProcessors;
|
||||||
allocationgranularity = sysinfo.dwAllocationGranularity;
|
allocationgranularity = sysinfo.dwAllocationGranularity;
|
||||||
//#elif defined(__linux__)
|
//#elif defined(__linux__)
|
||||||
#else
|
#elif TLC_COMPATIBLE_UNIX
|
||||||
cpucount = sysconf(_SC_NPROCESSORS_ONLN);
|
cpucount = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
allocationgranularity = sysconf(_SC_PAGESIZE);
|
allocationgranularity = sysconf(_SC_PAGESIZE);
|
||||||
//#elif (defined (__APPLE__) && defined (__MACH__))
|
//#elif (defined (__APPLE__) && defined (__MACH__))
|
||||||
|
@ -27,16 +27,10 @@
|
|||||||
|
|
||||||
////////////// Platform specific
|
////////////// Platform specific
|
||||||
|
|
||||||
#if defined(_APPLE__) || defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__)
|
#if defined(_APPLE__) || defined(__linux__) || defined(__CYGWIN__)
|
||||||
#define TLC_COMPATIBLE_UNIX 1
|
#define TLC_COMPATIBLE_UNIX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__CYGWIN__) || defined(__linux__) || defined(__MINGW32__)
|
|
||||||
#ifndef _LARGEFILE64_SOURCE
|
|
||||||
#define _LARGEFILE64_SOURCE 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows
|
#ifdef _WIN32 // Windows
|
||||||
|
|
||||||
#include<Windows.h>
|
#include<Windows.h>
|
||||||
@ -49,7 +43,7 @@ typedef errno_t tlc_error_t;
|
|||||||
#include<pthread.h>
|
#include<pthread.h>
|
||||||
#define _T(x) x
|
#define _T(x) x
|
||||||
#define TCHAR char
|
#define TCHAR char
|
||||||
typedef tlc_error_t tlc_error_t;
|
typedef error_t tlc_error_t;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Unsupported operating system.
|
#error Unsupported operating system.
|
||||||
@ -81,7 +75,7 @@ BEGIN_TURBOLINECOUNT_NAMESPACE;
|
|||||||
typedef off_t tlc_fileoffset_t;
|
typedef off_t tlc_fileoffset_t;
|
||||||
#define TLC_LINECOUNT_FMT "%lld"
|
#define TLC_LINECOUNT_FMT "%lld"
|
||||||
#elif defined(_LARGEFILE64_SOURCE)
|
#elif defined(_LARGEFILE64_SOURCE)
|
||||||
typedef off64_t tlc_fileoffset_t;
|
typedef _off64_t tlc_fileoffset_t;
|
||||||
#define TLC_LINECOUNT_FMT "%lld"
|
#define TLC_LINECOUNT_FMT "%lld"
|
||||||
#else
|
#else
|
||||||
typedef off_t tlc_fileoffset_t;
|
typedef off_t tlc_fileoffset_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user