X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=myutils.cpp;h=b9c01470f75a9f26baae58a174765fc154ce20d3;hb=75962c819c16814e5c2340d99af1aa62e564dc20;hp=e9d52c2c936eb2d131109f7b46fe365d41931a9d;hpb=fe0f86cb70ff3ce31df98ed49e404c7e12e21b3d;p=mothur.git diff --git a/myutils.cpp b/myutils.cpp index e9d52c2..b9c0147 100755 --- a/myutils.cpp +++ b/myutils.cpp @@ -13,19 +13,19 @@ #include #include -#ifdef _MSC_VER -#include -#include -#include -#include -#include -#else +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #include #include #include #include #include #include +#else +//#include +#include +#include +#include +#include #endif #include "myutils.h" @@ -141,7 +141,9 @@ bool myisatty(int fd) return isatty(fd) != 0; } -#ifdef _MSC_VER +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#else +#ifdef BIT_VERSION #include int fseeko(FILE *stream, off_t offset, int whence) { @@ -149,6 +151,14 @@ int fseeko(FILE *stream, off_t offset, int whence) return (FilePos == -1L) ? -1 : 0; } #define ftello(fm) (off_t) _ftelli64(fm) +#else +int fseeko(FILE *stream, off_t offset, int whence) +{ + off_t FilePos = fseek(stream, offset, whence); + return (FilePos == -1L) ? -1 : 0; +} +#define ftello(fm) (off_t) ftell(fm) +#endif #endif void LogStdioFileState(FILE *f) @@ -168,9 +178,16 @@ void LogStdioFileState(FILE *f) Log("fpos %ld (retval %d)\n", (long) fpos, fgetpos_retval); // Log("eof %d\n", _eof(fd)); #endif -#ifdef _MSC_VER +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#else +#ifdef BIT_VERSION __int64 pos64 = _ftelli64(f); Log("_ftelli64 %lld\n", pos64); +#else + __int32 pos32 = ftell(f); + Log("ftell %lld\n", pos32); + +#endif #endif } @@ -596,10 +613,11 @@ void Die(const char *Format, ...) fprintf(stderr, "\n---Fatal error---\n%s\n", szStr); Log("\n---Fatal error---\n%s\n", szStr); -#ifdef _MSC_VER - if (IsDebuggerPresent()) - __debugbreak(); - _CrtSetDbgFlag(0); +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#else + //if (IsDebuggerPresent()) + // __debugbreak(); + //_CrtSetDbgFlag(0); #endif exit(1); @@ -624,20 +642,7 @@ void Warning(const char *Format, ...) } } -#ifdef _MSC_VER -double GetMemUseBytes() - { - HANDLE hProc = GetCurrentProcess(); - PROCESS_MEMORY_COUNTERS PMC; - BOOL bOk = GetProcessMemoryInfo(hProc, &PMC, sizeof(PMC)); - if (!bOk) - return 1000000; - double Bytes = (double) PMC.WorkingSetSize; - if (Bytes > g_PeakMemUseBytes) - g_PeakMemUseBytes = Bytes; - return Bytes; - } -#elif linux || __linux__ +#if defined linux || __linux__ double GetMemUseBytes() { static char statm[64]; @@ -668,7 +673,7 @@ double GetMemUseBytes() g_PeakMemUseBytes = Bytes; return Bytes; } -#elif defined(__MACH__) +#elif defined(__APPLE__) || (__MACH__) #include #include #include @@ -709,9 +714,9 @@ double GetMemUseBytes() } #else double GetMemUseBytes() - { +{ return 0; - } +} #endif double GetPeakMemUseBytes() @@ -1201,7 +1206,8 @@ static void AddOpt(const OptInfo &Opt) g_Opts.insert(Opt); } -#ifdef _MSC_VER +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#else #pragma warning(disable: 4505) // unreferenced local function #endif