src/components/pcp/linux-pcp.c
//----------------------------------------------------------------------------
// Helper routine to subtract zero value from an event value. Although we
// store an unsigned long long value for both our zero value and a read-in
// value, it can be recast to signed or double. So zeroing on those must be
// done in the type intended, and we have to recast to do it. Note that 32
// bit signed int or float were saved and cast as 64 bit int or double,
// respectively.
//
// There are three types of 'semantics' in a description; only one is a 
// counter; the other two are instantaneous values. We do not subtract a
// zero reference value from instantaneous values. 
// PM_SEM_COUNTER    // cumulative counter (monotonic increasing)
// PM_SEM_INSTANT    // instantaneous value, continuous domain
// PM_SEM_DISCRETE   // instantaneous value, discrete domain
//----------------------------------------------------------------------------
Helper routine to subtract zero value from an event value. Although we
store an unsigned long long value for both our zero value and a read-in
value, it can be recast to signed or double. So zeroing on those must be
done in the type intended, and we have to recast to do it. Note that 32
bit signed int or float were saved and cast as 64 bit int or double,
respectively.

There are three types of 'semantics' in a description; only one is a
counter; the other two are instantaneous values. We do not subtract a
zero reference value from instantaneous values.
Helper routine to subtract zero value from an event value . Although we store an unsigned long long value for both our zero value and a read - in value it can be recast to signed or double . So zeroing on those must be done in the type intended and we have to recast to do it . Note that 32 bit signed int or float were saved and cast as 64 bit int or double respectively . There are three types of ' semantics ' in a description ; only one is a counter ; the other two are instantaneous values . We do not subtract a zero reference value from instantaneous values .
static void subZero(_pcp_control_state_t *myCtl, int event)
{
   int k = myCtl->pcpIndex[event];                                      
   if (pcp_event_info[k].desc.sem != PM_SEM_COUNTER) return;            
   convert_64_t zero, rawval;
   rawval.ull = myCtl->pcpValue[event];                                 
   zero.ull = pcp_event_info[k].zeroValue;                              
   switch (pcp_event_info[k].valType) {                                 
      case  PM_TYPE_32:                                                 
      case  PM_TYPE_64:                                                 
         rawval.ll -= zero.ll;                                          
         break;
      case  PM_TYPE_U32:                                                
      case  PM_TYPE_U64:                                                
         rawval.ull -= zero.ull;                                        
         break;
      case  PM_TYPE_FLOAT:                                              
      case  PM_TYPE_DOUBLE:                                             
         rawval.d -= zero.d;                                            
         break;
      case  PM_TYPE_STRING:                                             
         break;
      default:
         fprintf(stderr, "%s:%i pcp_event_info[%s] contains an unrecognized value type=%i.\n",
            __FILE__, __LINE__,  pcp_event_info[k].name, pcp_event_info[k].valType);
         exit(-1);                                                      
         break;
   } 
   myCtl->pcpValue[event] = rawval.ull;                                 
}
static void subZero ( _pcp_control_state_t * myCtl , int event ) { int k = myCtl -> pcpIndex [ event ] ; if ( pcp_event_info [ k ] . desc . sem != PM_SEM_COUNTER ) return ; convert_64_t zero , rawval ; rawval . ull = myCtl -> pcpValue [ event ] ; zero . ull = pcp_event_info [ k ] . zeroValue ; switch ( pcp_event_info [ k ] . valType ) { case PM_TYPE_32 : case PM_TYPE_64 : rawval . ll -= zero . ll ; break ; case PM_TYPE_U32 : case PM_TYPE_U64 : rawval . ull -= zero . ull ; break ; case PM_TYPE_FLOAT : case PM_TYPE_DOUBLE : rawval . d -= zero . d ; break ; case PM_TYPE_STRING : break ; default : fprintf ( stderr , " \n " , __FILE__ , __LINE__ , pcp_event_info [ k ] . name , pcp_event_info [ k ] . valType ) ; exit ( -1 ) ; break ; } myCtl -> pcpValue [ event ] = rawval . ull ; }
Helper routine to subtract zero value from an event value.
Helper routine to subtract zero value from an event value .
// get pcp_event_info[] index. // Don't subtract from instantaneous values. // collect the raw value. // collect the zero (base) value. // Note we restricted the types in init; these cases should agree. // 32 bit was converted to long long. // long long. // converted. // 32-bit was converted to 64 bit. // 64-bit unsigned integer // converted. // 32-bit was converted to double. // 64-bit floating point // converted. // array of char, do nothing for pointer. // Quit, this shouldn't happen; something needs updating. // end switch on type.  // The adjusted value.