Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: misc.c Log Message: Tweak debug message printing. =================================================================== RCS file: /cvs/e/e16/e/src/misc.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -3 -r1.75 -r1.76 --- misc.c 17 Jan 2007 01:10:43 -0000 1.75 +++ misc.c 18 May 2007 20:37:11 -0000 1.76 @@ -185,21 +185,39 @@ /* * Debug/error message printing. */ +static struct timeval tv0 = { 0, 0 }; + +static void +_tvdiff(struct timeval *tvd, const struct timeval *tv1, + const struct timeval *tv2) +{ + long tsec, tus; + + tsec = tv2->tv_sec - tv1->tv_sec; + tus = tv2->tv_usec - tv1->tv_usec; + if (tus < 0) + { + tus += 1000000; + tsec -= 1; + } + tvd->tv_sec = tsec; + tvd->tv_usec = tus; +} #if 1 /* Set to 0 for differential time */ void Eprintf(const char *fmt, ...) { - static time_t t0 = 0; va_list args; struct timeval tv; - if (t0 == 0) - t0 = time(NULL); + if (tv0.tv_sec == 0) + gettimeofday(&tv0, NULL); gettimeofday(&tv, NULL); - fprintf(stdout, "[%d] %4ld.%06ld: ", getpid(), tv.tv_sec - t0, tv.tv_usec); + _tvdiff(&tv, &tv0, &tv); + fprintf(stdout, "[%d] %4ld.%06ld: ", getpid(), tv.tv_sec, tv.tv_usec); va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); @@ -210,25 +228,25 @@ void Eprintf(const char *fmt, ...) { - static struct timeval t0; + static struct timeval tv1; va_list args; - struct timeval tv; - long ts, tus; + struct timeval tv, tvd; + unsigned long nreq; + + if (tv0.tv_sec == 0) + gettimeofday(&tv0, NULL); gettimeofday(&tv, NULL); - ts = tv.tv_sec - t0.tv_sec; - tus = tv.tv_usec - t0.tv_usec; - if (tus < 0) - { - tus += 1000000; - ts -= 1; - } - fprintf(stdout, "[%d] %#lx %4ld.%06ld: ", getpid(), NextRequest(disp), ts, - tus); + _tvdiff(&tv, &tv0, &tv); + _tvdiff(&tvd, &tv1, &tv); + tv1 = tv; + + nreq = (disp) ? NextRequest(disp) : 0; + fprintf(stdout, "[%d] %#8lx %4ld.%06ld [%3ld.%06ld]: ", getpid(), + nreq, tv1.tv_sec, tv1.tv_usec, tvd.tv_sec, tvd.tv_usec); va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); - gettimeofday(&t0, NULL); } #endif ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs