RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   13-May-2017 09:04:47
  Branch: rpm-5_4                          Handle: 2017051307044700

  Modified files:           (Branch: rpm-5_4)
    rpm                     CHANGES
    rpm/rpmio               rpmsw.c rpmsw.h

  Log:
    - rpmsw: use clock_gettime (if available).

  Summary:
    Revision    Changes     Path
    1.3501.2.550+1  -0      rpm/CHANGES
    2.20.4.4    +42 -5      rpm/rpmio/rpmsw.c
    2.12.4.5    +9  -0      rpm/rpmio/rpmsw.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3501.2.549 -r1.3501.2.550 CHANGES
  --- rpm/CHANGES       13 May 2017 07:03:14 -0000      1.3501.2.549
  +++ rpm/CHANGES       13 May 2017 07:04:47 -0000      1.3501.2.550
  @@ -1,4 +1,5 @@
   5.4.17 -> 5.4.18:
  +    - jbj: rpmsw: use clock_gettime (if available).
       - jbj: poptALL: spew info for rpm itself with -vv.
       - jbj: poptIO: spew info for rpm utilities with -vv.
       - jbj: mcheck: link -lmcheck to enable, wrap mtrace et al in rpmio.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmsw.c
  ============================================================================
  $ cvs diff -u -r2.20.4.3 -r2.20.4.4 rpmsw.c
  --- rpm/rpmio/rpmsw.c 12 May 2017 18:53:26 -0000      2.20.4.3
  +++ rpm/rpmio/rpmsw.c 13 May 2017 07:04:47 -0000      2.20.4.4
  @@ -4,6 +4,7 @@
   
   #include "system.h"
   #include <rpmiotypes.h>
  +#include <rpmlog.h>
   #include <rpmsw.h>
   #include "debug.h"
   
  @@ -75,8 +76,13 @@
        return NULL;
       switch (rpmsw_type) {
       case 0:
  +#if defined(HAVE_CLOCK_GETTIME)
  +     if (clock_gettime(CLOCK_MONOTONIC, &sw->u.ts))
  +         return NULL;
  +#else
        if (gettimeofday(&sw->u.tv, NULL))
            return NULL;
  +#endif
        break;
   #if defined(HP_TIMING_NOW)
       case 1:
  @@ -88,15 +94,32 @@
   }
   
   /** \ingroup rpmio
  + * Return difference of 2 timespec stamps in micro-seconds.
  + * @param *ets               end timespec
  + * @param *bts               begin timespec
  + * @return           difference in micro-seconds
  + */
  +RPM_GNUC_PURE
  +static inline
  +rpmtime_t tssub(const struct timespec * ets, const struct timespec * bts)
  +{
  +    time_t secs, nsecs;
  +    if (ets == NULL  || bts == NULL) return 0;
  +    secs = ets->tv_sec - bts->tv_sec;
  +    for (nsecs = ets->tv_nsec - bts->tv_nsec; nsecs < 0; nsecs += 1000000000)
  +     secs--;
  +    return (rpmtime_t) ((secs * 1000000) + nsecs/1000);
  +}
  +
  +/** \ingroup rpmio
    * Return difference of 2 timeval stamps in micro-seconds.
  - * @param etv                *etv end timeval
  - * @param btv                *btv begin timeval
  - * @return           difference in milli-seconds
  + * @param *etv               end timeval
  + * @param *btv               begin timeval
  + * @return           difference in micro-seconds
    */
   RPM_GNUC_PURE
   static inline
  -rpmtime_t tvsub(const struct timeval * etv,
  -             const struct timeval * btv)
  +rpmtime_t tvsub(const struct timeval * etv, const struct timeval * btv)
   {
       time_t secs, usecs;
       if (etv == NULL  || btv == NULL) return 0;
  @@ -115,7 +138,11 @@
       switch (rpmsw_type) {
       default:
       case 0:
  +#if defined(HAVE_CLOCK_GETTIME)
  +     ticks = tssub(&end->u.ts, &begin->u.ts);
  +#else
        ticks = tvsub(&end->u.tv, &begin->u.tv);
  +#endif
        break;
   #if defined(HP_TIMING_NOW)
       case 1:
  @@ -278,3 +305,13 @@
                   (unsigned long)op->bytes/scale, (unsigned 
long)op->bytes%scale,
                   op->usecs/scale, op->usecs%scale);
   }
  +
  +void rpmswLog(const char * name, rpmop op, int lvl)
  +{
  +    static unsigned int scale = (1000 * 1000);
  +    if (op != NULL && op->count > 0)
  +        rpmlog(lvl, "   %s %8d %6lu.%06lu MB %6lu.%06lu secs\n",
  +                name, op->count,
  +                (unsigned long)op->bytes/scale, (unsigned 
long)op->bytes%scale,
  +                op->usecs/scale, op->usecs%scale);
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmsw.h
  ============================================================================
  $ cvs diff -u -r2.12.4.4 -r2.12.4.5 rpmsw.h
  --- rpm/rpmio/rpmsw.h 25 Jun 2016 07:31:08 -0000      2.12.4.4
  +++ rpm/rpmio/rpmsw.h 13 May 2017 07:04:47 -0000      2.12.4.5
  @@ -28,6 +28,7 @@
   struct rpmsw_s {
       union {
        struct timeval tv;
  +     struct timespec ts;
        unsigned long long int ticks;
        unsigned long int tocks[2];
       } u;
  @@ -136,6 +137,14 @@
    */
   void rpmswPrint(const char * name, rpmop op, FILE * fp);
   
  +/** \ingroup rpmio
  + * Log operation statistics.
  + * @param name                       operation name
  + * @param op                 operation statistics
  + * @param lvl                        rpmlog level
  + */
  +void rpmswLog(const char * name, rpmop op, int lvl);
  +
   #ifdef __cplusplus
   }
   #endif
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to