src/components/pcp/linux-pcp.c
//----------------------------------------------------------------------------
// Collect the name of the event from the EventCode, given here as our index
// into pcp_event_info[]. We must fit it into name[len].
//----------------------------------------------------------------------------
Collect the name of the event from the EventCode, given here as our index
into pcp_event_info[]. We must fit it into name[len].
Collect the name of the event from the EventCode given here as our index into pcp_event_info [] . We must fit it into name [ len ] .
static int _pcp_ntv_code_to_name(unsigned int pcpIdx, char *name, int len)
{
   mRtnCnt(_pcp_ntv_code_to_name);                                      
   pcpIdx &= PAPI_NATIVE_AND_MASK;                                      
   if (pcpIdx >= (unsigned int) sEventCount) {                          
      fprintf(stderr, "%s:%i:%s called with out-of-range pcpIdx=%u.\n", 
         __FILE__, __LINE__, FUNC, pcpIdx);
      return PAPI_EINVAL;                                               
   }
   if (len < 1)  {                                                      
      fprintf(stderr, "%s:%i:%s called with out-of-range descr len=%i.\n", 
         __FILE__, __LINE__, FUNC, len);
      return PAPI_EINVAL;                                               
   }
   strncpy(name, pcp_event_info[pcpIdx].name, len);                     
   name[len-1]=0;                                                       
   return PAPI_OK;
}
static int _pcp_ntv_code_to_name ( unsigned int pcpIdx , char * name , int len ) { mRtnCnt ( _pcp_ntv_code_to_name ) ; pcpIdx &= PAPI_NATIVE_AND_MASK ; if ( pcpIdx >= ( unsigned int ) sEventCount ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ , FUNC , pcpIdx ) ; return PAPI_EINVAL ; } if ( len < 1 ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ , FUNC , len ) ; return PAPI_EINVAL ; } strncpy ( name , pcp_event_info [ pcpIdx ] . name , len ) ; name [ len - 1 ] = 0 ; return PAPI_OK ; }
Collect the name of the event from the EventCode, given here as our index
into pcp_event_info[].
Collect the name of the event from the EventCode given here as our index into pcp_event_info [] .
// count this function. // We can be called with the NATIVE bit set. // out of range? // exit with error. // If length is ridiculous, // exit with error. // just copy the name. // force z-termination.