# FIXME: To fix this, test.sh needs to be able to take ccache from the
# installed prefix, not from the source dir.
-installcheck:
+installcheck:
@echo "WARNING! This is not really \"installcheck\" yet."
$(MAKE) check
Andrew Tridgell
http://samba.org/~tridge/
bugs@ccache.samba.org
-
convenient routines for argument list handling
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
void args_remove_first(ARGS *args)
{
free(args->argv[0]);
- memmove(&args->argv[0],
+ memmove(&args->argv[0],
&args->argv[1],
args->argc * sizeof(args->argv[0]));
args->argc--;
void args_add_prefix(ARGS *args, const char *s)
{
args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
- memmove(&args->argv[1], &args->argv[0],
+ memmove(&args->argv[1], &args->argv[0],
(args->argc+1) * sizeof(args->argv[0]));
args->argv[0] = x_strdup(s);
args->argc++;
for (i=0; i<args->argc; ) {
if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) {
free(args->argv[i]);
- memmove(&args->argv[i],
- &args->argv[i+1],
+ memmove(&args->argv[i],
+ &args->argv[i+1],
args->argc * sizeof(args->argv[i]));
args->argc--;
} else {
Copyright (C) Andrew Tridgell 2002
Copyright (C) Martin Pool 2003
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
-/* return a string to be used to distinguish temporary files
- this also tries to cope with NFS by adding the local hostname
+/* return a string to be used to distinguish temporary files
+ this also tries to cope with NFS by adding the local hostname
*/
static const char *tmp_string(void)
{
*
* unsetenv() is on BSD and Linux but not portable. */
putenv("DEPENDENCIES_OUTPUT");
-
+
if (getenv("CCACHE_CPP2")) {
args_add(args, input_file);
} else {
exit(status);
}
}
-
+
unlink(tmp_stderr);
unlink(tmp_hashname);
failed();
int nlevels = 2;
char *input_base;
char *tmp;
-
+
if ((s = getenv("CCACHE_NLEVELS"))) {
nlevels = atoi(s);
if (nlevels < 1) nlevels = 1;
}
}
- /* ~/hello.c -> tmp.hello.123.i
+ /* ~/hello.c -> tmp.hello.123.i
limit the basename to 10
characters in order to cope with filesystem with small
maximum filename length limits */
/* now the run */
x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir,
- input_base, tmp_string(),
+ input_base, tmp_string(),
i_extension);
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
/* if the compilation is with -g then we have to include the whole of the
preprocessor output, which means we are sensitive to line number
information. Otherwise we can discard line number info, which makes
- us less sensitive to reformatting changes
+ us less sensitive to reformatting changes
Note! I have now disabled the unification code by default
as it gives the wrong line numbers for warnings. Pity.
data and output it just before the main stderr from the compiler
pass */
cpp_stderr = path_stderr;
- } else {
+ } else {
unlink(path_stderr);
free(path_stderr);
}
}
-/*
+/*
try to return the compile result from cache. If we can return from
cache then this function exits with the correct status code,
otherwise it returns */
if (ret == -1) {
ret = copy_file(hashname, output_file);
if (ret == -1) {
- cc_log("failed to copy %s -> %s (%s)\n",
+ cc_log("failed to copy %s -> %s (%s)\n",
hashname, output_file, strerror(errno));
stats_update(STATS_ERROR);
failed();
exit(0);
}
-/* find the real compiler. We just search the PATH to find a executable of the
+/* find the real compiler. We just search the PATH to find a executable of the
same name that isn't a link to ourselves */
static void find_compiler(int argc, char **argv)
{
}
-/*
- process the compiler options to form the correct set of options
+/*
+ process the compiler options to form the correct set of options
for obtaining the preprocessor output
*/
static void process_args(int argc, char **argv)
found_S_opt = 1;
continue;
}
-
+
/* we need to work out where the output was meant to go */
if (strcmp(argv[i], "-o") == 0) {
if (i == argc-1) {
i++;
continue;
}
-
+
/* alternate form of -o, with no space */
if (strncmp(argv[i], "-o", 2) == 0) {
output_file = &argv[i][2];
}
/* debugging is handled specially, so that we know if we
- can strip line number info
+ can strip line number info
*/
if (strncmp(argv[i], "-g", 2) == 0) {
args_add(stripped_args, argv[i]);
{
const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
"-iwithprefix", "-iwithprefixbefore",
- "-L", "-D", "-U", "-x", "-MF",
+ "-L", "-D", "-U", "-x", "-MF",
"-MT", "-MQ", "-isystem", "-aux-info",
"--param", "-A", "-Xlinker", "-u",
- "-idirafter",
+ "-idirafter",
NULL};
int j;
for (j=0;opts[j];j++) {
if (strcmp(argv[i], opts[j]) == 0) {
if (i == argc-1) {
- cc_log("missing argument to %s\n",
+ cc_log("missing argument to %s\n",
argv[i]);
stats_update(STATS_ARGS);
failed();
}
-
+
args_add(stripped_args, argv[i]);
args_add(stripped_args, argv[i+1]);
i++;
cope better with unusual compiler options */
if (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode)) {
args_add(stripped_args, argv[i]);
- continue;
+ continue;
}
if (input_file) {
}
else {
int len = p - default_depfile_name;
-
+
p = x_malloc(len + 3);
strncpy(default_depfile_name, p, len - 1);
free(default_depfile_name);
cc_log("ccache is disabled\n");
failed();
}
-
+
/* we might be disabled */
if (getenv("CCACHE_DISABLE")) {
cc_log("ccache is disabled\n");
cc_log("read-only set - doing real compile\n");
failed();
}
-
+
prefix = getenv("CCACHE_PREFIX");
if (prefix) {
char *p = find_executable(prefix, MYNAME);
{
printf("ccache, a compiler cache. Version %s\n", CCACHE_VERSION);
printf("Copyright Andrew Tridgell, 2002\n\n");
-
+
printf("Usage:\n");
printf("\tccache [options]\n");
printf("\tccache compiler [compile options]\n");
case 'h':
usage();
exit(0);
-
+
case 's':
check_cache_dir();
stats_summary();
{
char *buf;
int uncached_fd;
-
+
uncached_fd = dup(2);
if (uncached_fd == -1) {
cc_log("dup(2) failed\n");
cache_logfile = getenv("CCACHE_LOGFILE");
setup_uncached_err();
-
+
/* the user might have set CCACHE_UMASK */
p = getenv("CCACHE_UMASK");
/* make sure the cache dir exists */
if (cache_dir && (create_dir(cache_dir) != 0)) {
- fprintf(stderr,"ccache: failed to create %s (%s)\n",
+ fprintf(stderr,"ccache: failed to create %s (%s)\n",
cache_dir, strerror(errno));
exit(1);
}
void cleanup_all(const char *dir);
void wipe_all(const char *dir);
-int execute(char **argv,
+int execute(char **argv,
const char *path_stdout,
const char *path_stderr);
char *find_executable(const char *name, const char *exclude_name);
manpagedescription()
-ccache is a compiler cache. It speeds up re-compilation of C/C++ code
+ccache is a compiler cache. It speeds up re-compilation of C/C++ code
by caching previous compiles and detecting when the same compile is
being done again.
the cache. Using "ccache -s" adds up the statistics across all
subdirectories and prints the totals.
-dit(bf(-z, --zero-stats)) Zero the cache statistics.
+dit(bf(-z, --zero-stats)) Zero the cache statistics.
dit(bf(-V, --version)) Print the ccache version number
wish to use ccache for all your compiles.
To install for usage by the first method just copy ccache to somewhere
-in your path.
+in your path.
To install for the second method do something like this:
verb(
command line options as the compiler you are using. The only exception
to this is the option '--ccache-skip'. That option can be used to tell
ccache that the next option is definitely not a input filename, and
-should be passed along to the compiler as-is.
+should be passed along to the compiler as-is.
The reason this can be important is that ccache does need to parse the
command line and determine what is an input filename and what is a
dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows
you to choose the number of levels of hash in the cache directory. The
-default is 2. The minimum is 1 and the maximum is 8.
+default is 2. The minimum is 1 and the maximum is 8.
dit(bf(CCACHE_HARDLINK)) If you set the environment variable
CCACHE_HARDLINK then ccache will attempt to use hard links from the
To use distcc with ccache I recommend using the CCACHE_PREFIX
option. You just need to set the environment variable CCACHE_PREFIX to
'distcc' and ccache will prefix the command line used with the
-compiler with the command 'distcc'.
+compiler with the command 'distcc'.
manpagesection(SHARING A CACHE)
to 002, this ensures that cached files are accessible to everyone in
the group.
it() Make sure that all users have write permission in the entire
- cache directory (and that you trust all users of the shared cache).
+ cache directory (and that you trust all users of the shared cache).
it() Make sure that the setgid bit is set on all directories in the
cache. This tells the filesystem to inherit group ownership for new
directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
ccache was inspired by the compilercache shell script script written
by Erik Thiele and I would like to thank him for an excellent piece of
-work. See
+work. See
url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/)
for the Erik's scripts.
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
- functions to cleanup the cache directory when it gets too large
+ functions to cleanup the cache directory when it gets too large
*/
#include "ccache.h"
if (num_files == allocated) {
allocated = 10000 + num_files*2;
- files = (struct files **)x_realloc(files,
+ files = (struct files **)x_realloc(files,
sizeof(struct files *)*allocated);
}
if (num_files > 1) {
/* sort in ascending data order */
- qsort(files, num_files, sizeof(struct files *),
+ qsort(files, num_files, sizeof(struct files *),
(COMPAR_FN_T)files_compare);
}
-
+
/* delete enough files to bring us below the threshold */
for (i=0;i<num_files; i++) {
if ((size_threshold==0 || total_size < size_threshold) &&
(files_threshold==0 || (num_files-i) < files_threshold)) break;
if (unlink(files[i]->fname) != 0 && errno != ENOENT) {
- fprintf(stderr, "unlink %s - %s\n",
+ fprintf(stderr, "unlink %s - %s\n",
files[i]->fname, strerror(errno));
continue;
}
-
+
total_size -= files[i]->size;
- }
+ }
total_files = num_files - i;
}
unsigned counters[STATS_END];
char *dname, *sfile;
int i;
-
+
for (i=0;i<=0xF;i++) {
x_asprintf(&dname, "%s/%1x", dir, i);
x_asprintf(&sfile, "%s/%1x/stats", dir, i);
memset(counters, 0, sizeof(counters));
stats_read(sfile, counters);
- cleanup_dir(dname,
- counters[STATS_MAXFILES],
+ cleanup_dir(dname,
+ counters[STATS_MAXFILES],
counters[STATS_MAXSIZE]);
free(dname);
free(sfile);
{
char *dname;
int i;
-
+
for (i=0;i<=0xF;i++) {
x_asprintf(&dname, "%s/%1x", dir, i);
traverse(dir, wipe_fn);
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
-void foo(const char *format, ...) {
+void foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
execute a compiler backend, capturing all output to the given paths
the full path to the compiler to run is in argv[0]
*/
-int execute(char **argv,
+int execute(char **argv,
const char *path_stdout,
const char *path_stderr)
{
pid = fork();
if (pid == -1) fatal("Failed to fork");
-
+
if (pid == 0) {
int fd;
/*
- find an executable by name in $PATH. Exclude any that are links to exclude_name
+ find an executable by name in $PATH. Exclude any that are links to exclude_name
*/
char *find_executable(const char *name, const char *exclude_name)
{
}
path = x_strdup(path);
-
+
/* search the path looking for the first compiler of the right name
that isn't us */
for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) {
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
hash_buffer(NULL, 0);
mdfour_result(&md, sum);
-
+
for (i=0;i<16;i++) {
sprintf(&ret[i*2], "%02x", (unsigned)sum[i]);
}
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
-
+
if [ -d $dst ]; then
instcmd=:
else
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
+# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
echo "install: $src does not exist"
exit 1
fi
-
+
if [ x"$dst" = x ]
then
echo "install: no destination specified"
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
-defaultIFS='
+defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
# If we're going to rename the final executable, determine the name now.
- if [ x"$transformarg" = x ]
+ if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
- dstfile=`basename $dst $transformbasename |
+ dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
- if [ x"$dstfile" = x ]
+ if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
-/*
+/*
a implementation of MD4 designed for use in the SMB authentication protocol
Copyright (C) Andrew Tridgell 1997-1998.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "ccache.h"
-/* NOTE: This code makes no attempt to be fast!
+/* NOTE: This code makes no attempt to be fast!
It assumes that a int is at least 32 bits long
*/
uint32 AA, BB, CC, DD;
uint32 A,B,C,D;
- A = m->A; B = m->B; C = m->C; D = m->D;
+ A = m->A; B = m->B; C = m->C; D = m->D;
AA = A; BB = B; CC = C; DD = D;
- ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
+ ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
- ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
+ ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
- ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
+ ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
- ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
- ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
+ ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
+ ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
- ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
+ ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
- ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
+ ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
- ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
+ ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
- ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
+ ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
- ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
+ ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
- ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
+ ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
- ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
+ ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
- ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
+ ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
- A += AA; B += BB;
+ A += AA; B += BB;
C += CC; D += DD;
-
- A &= MASK32; B &= MASK32;
+
+ A &= MASK32; B &= MASK32;
C &= MASK32; D &= MASK32;
m->A = A; m->B = B; m->C = C; m->D = D;
copy64(M, buf);
mdfour64(M);
} else {
- copy4(buf+120, b);
+ copy4(buf+120, b);
copy64(M, buf);
mdfour64(M);
copy64(M, buf+64);
struct mdfour md;
unsigned char buf[1024], sum[16];
unsigned chunk;
-
+
fd = open(fname,O_RDONLY|O_BINARY);
if (fd == -1) {
perror("fname");
}
chunk = 1 + random() % (sizeof(buf) - 1);
-
+
mdfour_begin(&md);
while (1) {
perror("fname");
exit(1);
}
-
+
MDbegin(&md);
while (1) {
-/*
+/*
Unix SMB/Netbios implementation.
Version 1.9.
a implementation of MD4 designed for use in the SMB authentication protocol
Copyright (C) Andrew Tridgell 1997-1998.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
uint32 A, B, C, D;
uint32 totalN;
unsigned char tail[64];
- unsigned tail_len;
+ unsigned tail_len;
};
void mdfour_begin(struct mdfour *md);
void mdfour_update(struct mdfour *md, const unsigned char *in, int n);
void mdfour_result(struct mdfour *md, unsigned char *out);
void mdfour(unsigned char *out, const unsigned char *in, int n);
-
-
-
-
* original. Also, there is now a builtin-test, just compile with:
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
* and run snprintf for results.
- *
+ *
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
- * The PGP code was using unsigned hexadecimal formats.
+ * The PGP code was using unsigned hexadecimal formats.
* Unfortunately, unsigned formats simply didn't work.
*
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
#include <stdio.h>
/* make the compiler happy with an empty file */
- void dummy_snprintf(void) {}
+ void dummy_snprintf(void) {}
#else
#ifdef HAVE_LONG_DOUBLE
#define LLONG long
#endif
-static size_t dopr(char *buffer, size_t maxlen, const char *format,
+static size_t dopr(char *buffer, size_t maxlen, const char *format,
va_list args);
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
char *value, int flags, int min, int max);
int flags;
int cflags;
size_t currlen;
-
+
state = DP_S_DEFAULT;
currlen = flags = cflags = min = 0;
max = -1;
ch = *format++;
-
+
while (state != DP_S_DONE) {
- if (ch == '\0')
+ if (ch == '\0')
state = DP_S_DONE;
switch(state) {
case DP_S_DEFAULT:
- if (ch == '%')
+ if (ch == '%')
state = DP_S_FLAGS;
- else
+ else
dopr_outch (buffer, &currlen, maxlen, ch);
ch = *format++;
break;
if (ch == '.') {
state = DP_S_MAX;
ch = *format++;
- } else {
+ } else {
state = DP_S_MOD;
}
break;
switch (ch) {
case 'd':
case 'i':
- if (cflags == DP_C_SHORT)
+ if (cflags == DP_C_SHORT)
value = va_arg (args, int);
else if (cflags == DP_C_LONG)
value = va_arg (args, long int);
}
}
if (maxlen != 0) {
- if (currlen < maxlen - 1)
+ if (currlen < maxlen - 1)
buffer[currlen] = '\0';
- else if (maxlen > 0)
+ else if (maxlen > 0)
buffer[maxlen - 1] = '\0';
}
-
+
return currlen;
}
for (strln = 0; value[strln]; ++strln); /* strlen */
padlen = min - strln;
- if (padlen < 0)
+ if (padlen < 0)
padlen = 0;
- if (flags & DP_F_MINUS)
+ if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justify */
-
+
while ((padlen > 0) && (cnt < max)) {
dopr_outch (buffer, currlen, maxlen, ' ');
--padlen;
int spadlen = 0; /* amount to space pad */
int zpadlen = 0; /* amount to zero pad */
int caps = 0;
-
+
if (max < 0)
max = 0;
-
+
uvalue = value;
-
+
if(!(flags & DP_F_UNSIGNED)) {
if( value < 0 ) {
signvalue = '-';
signvalue = ' ';
}
}
-
+
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
do {
zpadlen = MAX(zpadlen, spadlen);
spadlen = 0;
}
- if (flags & DP_F_MINUS)
+ if (flags & DP_F_MINUS)
spadlen = -spadlen; /* Left Justifty */
#ifdef DEBUG_SNPRINTF
}
/* Sign */
- if (signvalue)
+ if (signvalue)
dopr_outch (buffer, currlen, maxlen, signvalue);
/* Zeros */
}
/* Digits */
- while (place > 0)
+ while (place > 0)
dopr_outch (buffer, currlen, maxlen, convert[--place]);
-
+
/* Left Justified spaces */
while (spadlen < 0) {
dopr_outch (buffer, currlen, maxlen, ' ');
if (value < 0)
result = -value;
-
+
return result;
}
static LDOUBLE POW10(int exp)
{
LDOUBLE result = 1;
-
+
while (exp) {
result *= 10;
exp--;
}
-
+
return result;
}
intpart = (LLONG)value;
value = value - intpart;
if (value >= 0.5) intpart++;
-
+
return intpart;
}
ret = my_modf(x0-l*f, &i2);
(*iptr) = l*f + i2;
return ret;
- }
+ }
(*iptr) = l;
return x - (*iptr);
int iplace = 0;
int fplace = 0;
int padlen = 0; /* amount to pad */
- int zpadlen = 0;
+ int zpadlen = 0;
int caps = 0;
int index;
double intpart;
double fracpart;
double temp;
-
- /*
+
+ /*
* AIX manpage says the default is 0, but Solaris says the default
* is 6, and sprintf on AIX defaults to 6
*/
if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
#endif
- /*
- * Sorry, we only support 16 digits past the decimal because of our
+ /*
+ * Sorry, we only support 16 digits past the decimal because of our
* conversion method
*/
if (max > 16)
my_modf(temp, &intpart);
fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
-
+
if (fracpart >= POW10(max)) {
intpart++;
fracpart -= POW10(max);
if (fplace == 311) fplace--;
}
fconvert[fplace] = 0;
-
+
/* -1 for decimal point, another -1 if we are printing a sign */
- padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
+ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
zpadlen = max - fplace;
if (zpadlen < 0) zpadlen = 0;
- if (padlen < 0)
+ if (padlen < 0)
padlen = 0;
- if (flags & DP_F_MINUS)
+ if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justifty */
-
+
if ((flags & DP_F_ZERO) && (padlen > 0)) {
if (signvalue) {
dopr_outch (buffer, currlen, maxlen, signvalue);
dopr_outch (buffer, currlen, maxlen, ' ');
--padlen;
}
- if (signvalue)
+ if (signvalue)
dopr_outch (buffer, currlen, maxlen, signvalue);
-
- while (iplace > 0)
+
+ while (iplace > 0)
dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
#ifdef DEBUG_SNPRINTF
*/
if (max > 0) {
dopr_outch (buffer, currlen, maxlen, '.');
-
- while (fplace > 0)
+
+ while (fplace > 0)
dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
}
-
+
while (zpadlen > 0) {
dopr_outch (buffer, currlen, maxlen, '0');
--zpadlen;
{
size_t ret;
va_list ap;
-
+
va_start(ap, fmt);
ret = vsnprintf(str, count, fmt, ap);
va_end(ap);
}
#endif
-#endif
+#endif
#ifndef HAVE_VASPRINTF
int vasprintf(char **ptr, const char *format, va_list ap)
{
int ret;
-
+
ret = vsnprintf(0, 0, format, ap);
if (ret <= 0) return ret;
{
va_list ap;
int ret;
-
+
*ptr = 0;
va_start(ap, format);
ret = vasprintf(ptr, format, ap);
"-16.16f",
0
};
- double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+ double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
0.9996, 1.996, 4.136, 0};
char *int_fmt[] = {
"%-1.5d",
int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
sprintf (buf2, fp_fmt[x], fp_nums[y]);
if (strcmp (buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
fp_fmt[x], buf1, buf2);
fail++;
}
int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
sprintf (buf2, int_fmt[x], int_nums[y]);
if (strcmp (buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
int_fmt[x], buf1, buf2);
fail++;
}
int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
sprintf (buf2, str_fmt[x], str_vals[y]);
if (strcmp (buf1, buf2)) {
- printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
str_fmt[x], buf1, buf2);
fail++;
}
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
for (i=0;stats_info[i].message;i++) {
enum stats stat = stats_info[i].stat;
- if (counters[stat] == 0 &&
+ if (counters[stat] == 0 &&
!(stats_info[i].flags & FLAG_ALWAYS)) {
continue;
}
$CCACHE_COMPILE -c test1.c
checkstat 'cache hit' 0
checkstat 'cache miss' 1
-
+
testname="BASIC2"
$CCACHE_COMPILE -c test1.c
checkstat 'cache hit' 1
checkstat 'cache miss' 1
-
+
testname="debug"
$CCACHE_COMPILE -c test1.c -g
checkstat 'cache hit' 1
checkstat 'cache miss' 2
-
+
testname="debug2"
$CCACHE_COMPILE -c test1.c -g
checkstat 'cache hit' 2
checkstat 'cache miss' 2
-
+
testname="output"
$CCACHE_COMPILE -c test1.c -o foo.o
checkstat 'cache hit' 3
testname="find"
$CCACHE blahblah -c test1.c 2> /dev/null
- checkstat "couldn't find the compiler" 1
+ checkstat "couldn't find the compiler" 1
testname="bad"
$CCACHE_COMPILE -c test1.c -I 2> /dev/null
testname="CCACHE_DISABLE"
CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
- checkstat 'cache hit' 3
+ checkstat 'cache hit' 3
$CCACHE_COMPILE -c test1.c
- checkstat 'cache hit' 4
+ checkstat 'cache hit' 4
testname="CCACHE_CPP2"
CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
- checkstat 'cache hit' 4
+ checkstat 'cache hit' 4
checkstat 'cache miss' 3
CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
- checkstat 'cache hit' 5
+ checkstat 'cache hit' 5
checkstat 'cache miss' 3
testname="CCACHE_NOSTATS"
CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O
checkstat 'cache hit' 5
checkstat 'cache miss' 3
-
+
testname="CCACHE_RECACHE"
CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O
- checkstat 'cache hit' 5
+ checkstat 'cache hit' 5
checkstat 'cache miss' 4
# strictly speaking should be 6 - RECACHE causes a double counting!
- checkstat 'files in cache' 8
+ checkstat 'files in cache' 8
$CCACHE -c > /dev/null
checkstat 'files in cache' 6
checkstat 'cache miss' 5
checkstat 'files in cache' 8
-
+
testname="comments"
echo '/* a silly comment */' > test1-comment.c
cat test1.c >> test1-comment.c
checkstat 'cache miss' 38
# removed these tests as some compilers (including newer versions of gcc)
- # determine which language to use based on .ii/.i extension, and C++ may
+ # determine which language to use based on .ii/.i extension, and C++ may
# not be installed
# testname="direct .ii file"
# mv test1.i test1.ii
# $CCACHE_COMPILE -c test1.ii
# checkstat 'cache hit' 11
# checkstat 'cache miss' 39
-
+
testname="zero-stats"
$CCACHE -z > /dev/null
checkstat 'cache hit' 0
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
this unifier is much faster (about 2x) and more forgiving of
syntactic errors. Continuing on syntactic errors is important to
cope with C/C++ extensions in the local compiler (for example,
- inline assembly systems).
+ inline assembly systems).
*/
#include "ccache.h"
do {
pushchar(p[ofs]);
ofs++;
- } while (ofs < size &&
+ } while (ofs < size &&
(tokens[p[ofs]].type & (C_ALPHA|C_DIGIT)));
pushchar('\n');
continue;
do {
pushchar(p[ofs]);
ofs++;
- } while (ofs < size &&
+ } while (ofs < size &&
((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.'));
if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) {
do {
if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) {
pushchar(p[ofs]);
ofs++;
- while (ofs < size &&
+ while (ofs < size &&
(tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) {
pushchar(p[ofs]);
ofs++;
} while (ofs < size && (tokens[p[ofs]].type & C_SPACE));
continue;
}
-
+
if (tokens[p[ofs]].type & C_QUOTE) {
q = p[ofs];
pushchar(p[ofs]);
}
-/* hash a file that consists of preprocessor output, but remove any line
+/* hash a file that consists of preprocessor output, but remove any line
number information from the hash
*/
int unify_hash(const char *fname)
{
int fd;
- struct stat st;
+ struct stat st;
char *map;
fd = open(fname, O_RDONLY|O_BINARY);
return 0;
}
-
/*
Copyright (C) Andrew Tridgell 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
if (!logfile) logfile = fopen(cache_logfile, "a");
if (!logfile) return;
-
+
va_start(ap, format);
vfprintf(logfile, format, ap);
va_end(ap);
return -1;
}
}
-
+
/* move a file using rename */
int move_file(const char *src, const char *dest) {
return safe_rename(src, dest);
}
-/* copy a file - used when hard links don't work
+/* copy a file - used when hard links don't work
the copy is done via a temporary file and atomic rename
*/
int copy_file(const char *src, const char *dest)
fclose(f);
return 0;
}
-
+
fclose(f);
return 1;
}
fatal("out of memory in x_asprintf");
}
va_end(ap);
-
+
if (!*ptr) fatal("out of memory in x_asprintf");
}
}
-/*
+/*
revsusive directory traversal - used for cleanup
fn() is called on all files/dirs in the tree
*/
char *p = strrchr(s, '/');
if (p) {
return x_strdup(p+1);
- }
+ }
return x_strdup(s);
}
p = strrchr(s, '/');
if (p) {
*p = 0;
- }
+ }
return s;
}
/*
- a sane realpath() function, trying to cope with stupid path limits and
+ a sane realpath() function, trying to cope with stupid path limits and
a broken API
*/
char *x_realpath(const char *path)
maxlen = pathconf(path, _PC_PATH_MAX);
#endif
if (maxlen < 4096) maxlen = 4096;
-
+
ret = x_malloc(maxlen);
#if HAVE_REALPATH