master
Christien Rioux 9 years ago
parent 75ba1a9f4f
commit 26a739ed0b

@ -7,12 +7,14 @@
///////////////////////////////////////////////
#include"turbo_linecount.h"
#include<cstring>
#include<cstdio>
#ifdef _WIN32
#include<tchar.h>
#else
#elif defined(TLC_COMPATIBLE_UNIX)
#include<stdlib.h>
#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
// Copyright 2015, Christien Rioux
@ -8,6 +14,8 @@
#include"turbo_linecount.h"
#include<algorithm>
#include<cstring>
#include<errno.h>
#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__))

@ -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<Windows.h>
@ -49,7 +43,7 @@ typedef errno_t tlc_error_t;
#include<pthread.h>
#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;

Loading…
Cancel
Save