*limit_multiple* (*CCACHE_LIMIT_MULTIPLE*)::
- Sets the limit when cleaning up. Files are deleted (in LRU order)
- until the levels are below the limit. The default is 0.8 (= 80%).
+ Sets the limit when cleaning up. Files are deleted (in LRU order) until the
+ levels are below the limit. The default is 0.8 (= 80%).
*log_file* (*CCACHE_LOGFILE*)::
conf->direct_mode = false;
}
- if (conf->limit_multiple < 0.0) conf->limit_multiple = 0.0;
- if (conf->limit_multiple > 1.0) conf->limit_multiple = 1.0;
+ conf->limit_multiple = MIN(MAX(conf->limit_multiple, 0.0), 1.0);
// Arguments (except -E) to send to the preprocessor.
struct args *preprocessor_args;
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
#endif // ifndef CCACHE_H
{
cc_log("Cleaning up cache directory %s", dir);
- /*
- * When "max files" or "max cache size" is reached, one of the 16 cache
- * subdirectories is cleaned up. When doing so, files are deleted (in LRU
- * order) until the levels are below limit_multiple.
- */
+ // When "max files" or "max cache size" is reached, one of the 16 cache
+ // subdirectories is cleaned up. When doing so, files are deleted (in LRU
+ // order) until the levels are below limit_multiple.
cache_size_threshold = conf->max_size * conf->limit_multiple / 16;
files_in_cache_threshold = conf->max_files * conf->limit_multiple / 16;
parse_float(const char *str, void *result, char **errmsg)
{
float *value = (float *)result;
- float x;
- char *endptr;
errno = 0;
- x = strtof(str, &endptr);
+ char *endptr;
+ float x = strtof(str, &endptr);
if (errno == 0 && *str != '\0' && *endptr == '\0') {
*value = x;
return true;
printer(s, conf->item_origins[find_conf(
"keep_comments_cpp")->number], context);
- reformat(&s, "limit_multiple = %.1f", (double) conf->limit_multiple);
+ reformat(&s, "limit_multiple = %.1f", (double)conf->limit_multiple);
printer(s, conf->item_origins[find_conf("limit_multiple")->number], context);
reformat(&s, "log_file = %s", conf->log_file);
} \
} while (false)
+// ============================================================================
+
#define CHECK_FLOAT_EQ(expected, actual) \
do { \
if (!cct_check_float_eq(__FILE__, __LINE__, #actual, (expected), \
CHECK(conf->hash_dir);
CHECK_STR_EQ("", conf->ignore_headers_in_manifest);
CHECK(!conf->keep_comments_cpp);
+ CHECK_FLOAT_EQ(0.8f, conf->limit_multiple);
CHECK_STR_EQ("", conf->log_file);
CHECK_INT_EQ(0, conf->max_files);
CHECK_INT_EQ((uint64_t)5 * 1000 * 1000 * 1000, conf->max_size);