From: Joel Rosdahl Date: Sun, 21 Feb 2010 18:42:39 +0000 (+0100) Subject: Clean up some constants X-Git-Tag: v3.0pre0~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbe36a2bf0696e57b46cf20c7f104b9e5cd944b4;p=thirdparty%2Fccache.git Clean up some constants --- diff --git a/ccache.h b/ccache.h index 41b5ff0e3..bfcba1d3f 100644 --- a/ccache.h +++ b/ccache.h @@ -14,21 +14,10 @@ #define ATTR_FORMAT(x, y, z) #endif -#define STATUS_NOTFOUND 3 -#define STATUS_FATAL 4 -#define STATUS_NOCACHE 5 - #ifndef MYNAME #define MYNAME "ccache" #endif -#define LIMIT_MULTIPLE 0.8 - -/* default maximum cache size */ -#ifndef DEFAULT_MAXSIZE -#define DEFAULT_MAXSIZE (1000*1000) -#endif - /* statistics fields in storage order */ enum stats { STATS_NONE=0, diff --git a/cleanup.c b/cleanup.c index 4078ce9ed..ba8914aa8 100644 --- a/cleanup.c +++ b/cleanup.c @@ -29,6 +29,13 @@ #include #include +/* + * 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. + */ +#define LIMIT_MULTIPLE 0.8 + static struct files { char *fname; time_t mtime; diff --git a/execute.c b/execute.c index ec170a4f5..b14b9b352 100644 --- a/execute.c +++ b/execute.c @@ -45,7 +45,7 @@ int execute(char **argv, unlink(path_stdout); fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { - exit(STATUS_NOCACHE); + exit(1); } dup2(fd, 1); close(fd); @@ -53,7 +53,7 @@ int execute(char **argv, unlink(path_stderr); fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); if (fd == -1) { - exit(STATUS_NOCACHE); + exit(1); } dup2(fd, 2); close(fd); diff --git a/stats.c b/stats.c index c8d32a32a..6cb424d4d 100644 --- a/stats.c +++ b/stats.c @@ -33,6 +33,11 @@ extern char *stats_file; extern char *cache_dir; +/* default maximum cache size */ +#ifndef DEFAULT_MAXSIZE +#define DEFAULT_MAXSIZE (1000*1000) +#endif + #define FLAG_NOZERO 1 /* don't zero with the -z option */ #define FLAG_ALWAYS 2 /* always show, even if zero */