157{
158 papisde_library_desc_t *lib_handle;
159 sde_counter_t *tmp_item;
160 uint32_t counter_uniq_id;
161 char *full_event_name;
163 int needs_overflow = 0;
164
165 lib_handle = (papisde_library_desc_t *)
handle;
166 if( (NULL == lib_handle) || (NULL == lib_handle->libraryName) ){
167 SDE_ERROR(
"sdei_setup_counter_internals(): 'handle' is clobbered. Unable to register counter.");
169 }
170
171 size_t str_len = strlen(lib_handle->libraryName)+strlen(
event_name)+2+1;
172 full_event_name = (char *)malloc(str_len*sizeof(char));
173 snprintf(full_event_name, str_len,
"%s::%s", lib_handle->libraryName,
event_name);
174
175 SDEDBG(
"%s: Counter: '%s' will be added in library: %s.\n", __FILE__, full_event_name, lib_handle->libraryName);
176
178 SDE_ERROR(
"Unknown mode %d. SDE counter mode must be either Instant or Delta.",cntr_mode);
179 free(full_event_name);
181 }
182
183
185
186 if( NULL != tmp_item ){
188
189 SDEDBG(
"%s: Counter: '%s' was already in library: %s.\n", __FILE__, full_event_name, lib_handle->libraryName);
190 free(full_event_name);
192 }
193
195 needs_overflow = 1;
196 }
197
198
199 SDEDBG(
"%s: Updating placeholder for counter: '%s' in library: %s.\n", __FILE__, full_event_name, lib_handle->libraryName);
200
201 tmp_item->u = cntr_union;
202 tmp_item->cntr_class = cntr_class;
203 tmp_item->cntr_mode = cntr_mode;
204 tmp_item->cntr_type = cntr_type;
205 free(full_event_name);
206
208 }
209
210
211
213 counter_uniq_id = gctl->num_reg_events++;
214 gctl->num_live_events++;
215
216 SDEDBG(
"%s: Counter %s has unique ID = %d\n", __FILE__, full_event_name, counter_uniq_id);
217
218 tmp_item =
allocate_and_insert( gctl, lib_handle, full_event_name, counter_uniq_id, cntr_mode, cntr_type, cntr_class, cntr_union );
219
220 if(NULL == tmp_item) {
221 SDEDBG(
"%s: Counter not inserted in SDE %s\n", __FILE__, lib_handle->libraryName);
222 free(full_event_name);
224 }
225
226 free(full_event_name);
227
228
229 if( needs_overflow ){
231 }
232
233 return ret_val;
234}
static papi_handle_t handle
int sdei_set_timer_for_overflow(void)
sde_counter_t * allocate_and_insert(papisde_control_t *gctl, papisde_library_desc_t *lib_handle, const char *name, uint32_t uniq_id, int cntr_mode, int cntr_type, enum CNTR_CLASS cntr_class, cntr_class_specific_t cntr_union)