From f2e55c2ff8f6fba0cba61251027fe899ac2fdd1a Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 14 Oct 2009 16:02:00 +0300 Subject: [PATCH] Move fd statistics foo inside rpmio.c now that it can --- rpmio/rpmio.c | 55 +++++++++++++++++++++++++++++++++++++++++++ rpmio/rpmio_internal.h | 63 -------------------------------------------------- 2 files changed, 55 insertions(+), 63 deletions(-) diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 66035fb..9ad1547 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -160,6 +160,61 @@ static const char * fdbg(FD_t fd) return buf; } +static void fdstat_enter(FD_t fd, int opx) +{ + if (fd == NULL) return; + if (fd->stats != NULL) + (void) rpmswEnter(fdOp(fd, opx), (ssize_t) 0); +} + +static void fdstat_exit(FD_t fd, int opx, ssize_t rc) +{ + if (fd == NULL) return; + if (rc == -1) + fd->syserrno = errno; + else if (rc > 0 && fd->bytesRemain > 0) + switch (opx) { + case FDSTAT_READ: + case FDSTAT_WRITE: + fd->bytesRemain -= rc; + break; + default: + break; + } + if (fd->stats != NULL) + (void) rpmswExit(fdOp(fd, opx), rc); +} + +static void fdstat_print(FD_t fd, const char * msg, FILE * fp) +{ + static const int usec_scale = (1000*1000); + int opx; + + if (fd == NULL || fd->stats == NULL) return; + for (opx = 0; opx < 4; opx++) { + rpmop op = &fd->stats->ops[opx]; + if (op->count <= 0) continue; + switch (opx) { + case FDSTAT_READ: + if (msg) fprintf(fp, "%s:", msg); + fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n", + op->count, (long)op->bytes, + (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); + break; + case FDSTAT_WRITE: + if (msg) fprintf(fp, "%s:", msg); + fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n", + op->count, (long)op->bytes, + (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); + break; + case FDSTAT_SEEK: + break; + case FDSTAT_CLOSE: + break; + } + } +} + /* =============================================================== */ off_t fdSize(FD_t fd) { diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h index 65d6ead..9e5bc26 100644 --- a/rpmio/rpmio_internal.h +++ b/rpmio/rpmio_internal.h @@ -153,69 +153,6 @@ void fdPop(FD_t fd) fd->nfps--; } -/** \ingroup rpmio - */ -static inline -void fdstat_enter(FD_t fd, int opx) -{ - if (fd == NULL) return; - if (fd->stats != NULL) - (void) rpmswEnter(fdOp(fd, opx), (ssize_t) 0); -} - -/** \ingroup rpmio - */ -static inline -void fdstat_exit(FD_t fd, int opx, ssize_t rc) -{ - if (fd == NULL) return; - if (rc == -1) - fd->syserrno = errno; - else if (rc > 0 && fd->bytesRemain > 0) - switch (opx) { - case FDSTAT_READ: - case FDSTAT_WRITE: - fd->bytesRemain -= rc; - break; - default: - break; - } - if (fd->stats != NULL) - (void) rpmswExit(fdOp(fd, opx), rc); -} - -/** \ingroup rpmio - */ -static inline -void fdstat_print(FD_t fd, const char * msg, FILE * fp) -{ - static const int usec_scale = (1000*1000); - int opx; - - if (fd == NULL || fd->stats == NULL) return; - for (opx = 0; opx < 4; opx++) { - rpmop op = &fd->stats->ops[opx]; - if (op->count <= 0) continue; - switch (opx) { - case FDSTAT_READ: - if (msg) fprintf(fp, "%s:", msg); - fprintf(fp, "%8d reads, %8ld total bytes in %d.%06d secs\n", - op->count, (long)op->bytes, - (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); - break; - case FDSTAT_WRITE: - if (msg) fprintf(fp, "%s:", msg); - fprintf(fp, "%8d writes, %8ld total bytes in %d.%06d secs\n", - op->count, (long)op->bytes, - (int)(op->usecs/usec_scale), (int)(op->usecs%usec_scale)); - break; - case FDSTAT_SEEK: - break; - case FDSTAT_CLOSE: - break; - } - } -} /** \ingroup rpmio */ -- 2.7.4