X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=utils.h;h=137440ef82a42590460c965a1a61d7ead70e4af0;hb=dbcf1cfb8ad1086c21d64e249f012809403e7ddc;hp=4fa0750f9773cb5059c268d2d7ac7abac6557f10;hpb=da827678b21e94c74fd17c9b8683edb60f73e814;p=rsem.git diff --git a/utils.h b/utils.h index 4fa0750..137440e 100644 --- a/utils.h +++ b/utils.h @@ -10,7 +10,10 @@ #include #include #include -#include +#include + +typedef uint64_t HIT_INT_TYPE; +typedef uint64_t READ_INT_TYPE; const int STRLEN = 10005 ; const double EPSILON = 1e-300; @@ -20,7 +23,7 @@ const int RANGE = 201; const int OLEN = 25; // overlap length, number of bases must not be in poly(A) tails const int NBITS = 32; // use unsigned int, 32 bits per variable -bool verbose = true; // show detail intermediate outputs +static bool verbose = true; // show detail intermediate outputs inline bool isZero(double a) { return fabs(a) < 1e-8; } inline bool isLongZero(double a) { return fabs(a) < 1e-30; } @@ -121,21 +124,7 @@ inline std::string cleanStr(const std::string& str) { return (fr <= to ? str.substr(fr, to - fr + 1) : ""); } -void printTimeUsed(const time_t& a, const time_t& b, const char* filename = "") { - int hh = (b - a) / 3600; - int mm = (b - a) % 3600 / 60; - int ss = (b - a) % 60; - - printf("Time Used : %d h %02d m %02d s\n", hh, mm, ss); - - if (strcmp(filename, "")) { - FILE *fo = fopen(filename, "w"); - fprintf(fo, "Time Used : %d h %02d m %02d s\n", hh, mm, ss); - fclose(fo); - } -} - -void genReadFileNames(const char* readFN, int tagType, int read_type, int& s, char readFs[][STRLEN]){ +inline void genReadFileNames(const char* readFN, int tagType, int read_type, int& s, char readFs[][STRLEN]){ const char tags[3][STRLEN] = {"un", "alignable", "max"}; char suffix[STRLEN]; @@ -157,31 +146,12 @@ void genReadFileNames(const char* readFN, int tagType, int read_type, int& s, ch } } -void exitWithError(const char* errmsg) { - fprintf(stderr, "%s\n", errmsg); - exit(-1); -} +inline void printTimeUsed(const time_t& a, const time_t& b, const char* program_name) { + int hh = (b - a) / 3600; + int mm = (b - a) % 3600 / 60; + int ss = (b - a) % 60; -void pthread_exception(int rc) { - switch(rc) { - case EAGAIN: - fprintf(stderr, "Error code: EAGAIN. Insufficient resources to create another thread, or a system-imposed limit on the number of threads was encountered.\n"); - break; - case EINVAL: - fprintf(stderr, "Error code: EINVAL. Invalid settings in attr if pthread_create() is called. Or the implementation has detected that the value specified by thread_id does not refer to a joinable thread if pthread_join() is called.\n"); - break; - case EPERM: - fprintf(stderr, "Error code: EPERM. No permission to set the scheduling policy and parameters specified in attr.\n"); - break; - case EDEADLK: - fprintf(stderr, "Error code: EDEADLK. A deadlock was detected (e.g., two threads tried to join with each other); or thread_id specifies the calling thread."); - break; - case ESRCH: - fprintf(stderr, "Error code: ESRCH. No thread with thread_id could be found.\n"); - break; - default: fprintf(stderr, "Unknown error code: %d\n", rc); - } - exit(-1); + printf("Time Used for %s : %d h %02d m %02d s\n", program_name, hh, mm, ss); } #endif