MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / Clock_parse_params

Function Clock_parse_params

libCacheSim/cache/eviction/Clock.c:291–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static void Clock_parse_params(cache_t *cache, const char *cache_specific_params) {
292 Clock_params_t *params = (Clock_params_t *)cache->eviction_params;
293 char *params_str = strdup(cache_specific_params);
294 char *old_params_str = params_str;
295 char *end;
296
297 while (params_str != NULL && params_str[0] != '\0') {
298 /* different parameters are separated by comma,
299 * key and value are separated by = */
300 char *key = strsep((char **)&params_str, "=");
301 char *value = strsep((char **)&params_str, ",");
302
303 // skip the white space
304 while (params_str != NULL && *params_str == ' ') {
305 params_str++;
306 }
307
308 if (strcasecmp(key, "n-bit-counter") == 0) {
309 params->n_bit_counter = (int)strtol(value, &end, 0);
310 params->max_freq = (1 << params->n_bit_counter) - 1;
311 if (strlen(end) > 2) {
312 ERROR("param parsing error, find string \"%s\" after number\n", end);
313 }
314 } else if (strcasecmp(key, "init-freq") == 0) {
315 params->init_freq = (int)strtol(value, &end, 0);
316 if (strlen(end) > 2) {
317 ERROR("param parsing error, find string \"%s\" after number\n", end);
318 }
319 } else if (strcasecmp(key, "print") == 0) {
320 printf("current parameters: %s\n", Clock_current_params(cache, params));
321 exit(0);
322 } else {
323 ERROR("%s does not have parameter %s, example parameters %s\n", cache->cache_name, key,
324 Clock_current_params(cache, params));
325 exit(1);
326 }
327 }
328 free(old_params_str);
329}
330
331#ifdef __cplusplus
332}

Callers 1

Clock_initFunction · 0.85

Calls 1

Clock_current_paramsFunction · 0.85

Tested by

no test coverage detected