src/components/sde/sde.c
/** This function optionally replaces an event's default description with a 
  description provided by the library developer within the SDE component 
  structure attached to the handle.  
  @param[in] handle -- (void *) pointer to sde structure for an individual 
  library
  @param[in] event_name -- name of the event 
  @param[in] event_description -- description of the event
  */
This function optionally replaces an event's default description with a
description provided by the library developer within the SDE component
structure attached to the handle.
This function optionally replaces an event ' s default description with a description provided by the library developer within the SDE component structure attached to the handle .
int 
__attribute__((visibility("default")))
papi_sde_describe_counter( void *handle, const char *event_name, const char *event_description )
{   
    sde_counter_t *tmp_item;
    papisde_library_desc_t *lib_handle;
    char *full_event_name;
    lib_handle = (papisde_library_desc_t *) handle;
    if( (NULL == lib_handle) || (NULL == lib_handle->libraryName) ){
        PAPIERROR("papi_sde_describe_counter(): 'handle' is clobbered. Unable to add description for counter.\n");
        return PAPI_EINVAL;
    }
    size_t str_len = strlen(lib_handle->libraryName)+strlen(event_name)+2+1; 
    full_event_name = malloc(str_len*sizeof(char));
    snprintf(full_event_name, str_len, "%s::%s", lib_handle->libraryName, event_name);
    papi_sde_lock();
    tmp_item = ht_lookup_by_name(lib_handle->lib_counters, full_event_name);
    if( NULL != tmp_item ){
        tmp_item->description = strdup(event_description);
        free(full_event_name);
        papi_sde_unlock();
        return PAPI_OK;
    }
    SUBDBG("papi_sde_describe_counter() Event: '%s' is not registered in SDE library: '%s'\n", full_event_name, lib_handle->libraryName);
    free(full_event_name);
    papi_sde_unlock();
    return PAPI_EINVAL;
}
int __attribute__ ( ( visibility ( " " ) ) ) papi_sde_describe_counter ( void * handle , const char * event_name , const char * event_description ) { sde_counter_t * tmp_item ; papisde_library_desc_t * lib_handle ; char * full_event_name ; lib_handle = ( papisde_library_desc_t * ) handle ; if ( ( NULL == lib_handle ) || ( NULL == lib_handle -> libraryName ) ) { PAPIERROR ( " \n " ) ; return PAPI_EINVAL ; } size_t str_len = strlen ( lib_handle -> libraryName ) + strlen ( event_name ) + 2 + 1 ; full_event_name = malloc ( str_len * sizeof ( char ) ) ; snprintf ( full_event_name , str_len , " " , lib_handle -> libraryName , event_name ) ; papi_sde_lock ( ) ; tmp_item = ht_lookup_by_name ( lib_handle -> lib_counters , full_event_name ) ; if ( NULL != tmp_item ) { tmp_item -> description = strdup ( event_description ) ; free ( full_event_name ) ; papi_sde_unlock ( ) ; return PAPI_OK ; } SUBDBG ( " \n " , full_event_name , lib_handle -> libraryName ) ; free ( full_event_name ) ; papi_sde_unlock ( ) ; return PAPI_EINVAL ; }
This function optionally replaces an event's default description with a
description provided by the library developer within the SDE component
structure attached to the handle.
This function optionally replaces an event ' s default description with a description provided by the library developer within the SDE component structure attached to the handle .
// +2 for "::" and +1 for '\0' // After this point we will be modifying data structures, so we need to acquire a lock. // This function has multiple exist points. If you add more, make sure you unlock before each one of them. // We will not use the name beyond this point