X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=myutils.cpp;h=78bf5439091ade28ce3337094deda7fc91779c3b;hb=b9553248b33ebd169c6aee375c1cc1a9dda61848;hp=e9d52c2c936eb2d131109f7b46fe365d41931a9d;hpb=1e8d08e96f4fe99604a6b3502568de464bf60891;p=mothur.git diff --git a/myutils.cpp b/myutils.cpp index e9d52c2..78bf543 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,14 +141,24 @@ bool myisatty(int fd) return isatty(fd) != 0; } -#ifdef _MSC_VER -#include +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#else +//#ifdef BIT_VERSION +//#include +//int fseeko(FILE *stream, off_t offset, int whence) +//// { +// off_t FilePos = _fseeki64(stream, offset, 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 = _fseeki64(stream, offset, whence); +{ + off_t FilePos = fseek(stream, offset, whence); return (FilePos == -1L) ? -1 : 0; - } -#define ftello(fm) (off_t) _ftelli64(fm) +} +#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 } @@ -496,7 +513,8 @@ off_t GetStdioFilePos(FILE *f) off_t GetStdioFileSize(FILE *f) { off_t CurrentPos = GetStdioFilePos(f); - int Ok = fseeko(f, 0, SEEK_END); + off_t zeroPos = 0; + int Ok = fseeko(f, zeroPos, SEEK_END); if (Ok < 0) Die("fseek in GetFileSize"); @@ -596,10 +614,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 +643,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 +674,7 @@ double GetMemUseBytes() g_PeakMemUseBytes = Bytes; return Bytes; } -#elif defined(__MACH__) +#elif defined(__APPLE__) || (__MACH__) #include #include #include @@ -709,9 +715,9 @@ double GetMemUseBytes() } #else double GetMemUseBytes() - { +{ return 0; - } +} #endif double GetPeakMemUseBytes() @@ -949,7 +955,7 @@ void ProgressExit() // Skip exit(), which can be very slow in DEBUG build // VERY DANGEROUS practice, because it skips global destructors. // But if you know the rules, you can break 'em, right? - ExitProcess(0); + //ExitProcess(0); #endif } @@ -1201,7 +1207,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 @@ -1525,6 +1532,7 @@ static void GetArgsFromFile(const string &FileName, vector &Args) void MyCmdLine(int argc, char **argv) { + g_Opts.clear(); g_Argv.clear(); static unsigned RecurseDepth = 0; ++RecurseDepth;