From: Joel Rosdahl Date: Sun, 6 Dec 2009 14:39:50 +0000 (+0100) Subject: Require zlib X-Git-Tag: v3.0pre0~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8190792e35df60c1bc2ee8f131be2f367417aa95;p=thirdparty%2Fccache.git Require zlib --- diff --git a/ccache.c b/ccache.c index ce78850b6..f6e06c70c 100644 --- a/ccache.c +++ b/ccache.c @@ -498,7 +498,6 @@ static void to_cache(ARGS *args) failed(); } -#if ENABLE_ZLIB /* do an extra stat on the cache files for the size statistics */ if (stat(path_stderr, &st1) != 0 || @@ -507,7 +506,6 @@ static void to_cache(ARGS *args) stats_update(STATS_ERROR); failed(); } -#endif cc_log("Placed object file into the cache\n"); stats_tocache(file_size(&st1) + file_size(&st2)); @@ -820,12 +818,7 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest } /* the user might be disabling cache hits */ - if ((mode != FROMCACHE_COMPILED_MODE && getenv("CCACHE_RECACHE")) -#ifndef ENABLE_ZLIB - /* if the cache file is compressed we must recache */ - || test_if_compressed(object_path) -#endif - ) { + if (mode != FROMCACHE_COMPILED_MODE && getenv("CCACHE_RECACHE")) { close(fd_stderr); unlink(stderr_file); unlink(object_path); diff --git a/ccache.h b/ccache.h index 0095dabda..5e8b1873f 100644 --- a/ccache.h +++ b/ccache.h @@ -29,9 +29,7 @@ #include #endif -#ifdef ENABLE_ZLIB #include -#endif #ifdef __GNUC__ #define ATTR_FORMAT(x, y, z) __attribute__((format (x, y, z))) @@ -53,11 +51,9 @@ #endif /* file copy mode */ -#ifdef ENABLE_ZLIB #define COPY_UNCOMPRESSED 0 #define COPY_FROM_CACHE 1 #define COPY_TO_CACHE 2 -#endif /* statistics fields in storage order */ enum stats { diff --git a/configure.ac b/configure.ac index 72391f5ca..94f3637e9 100644 --- a/configure.ac +++ b/configure.ac @@ -78,14 +78,14 @@ if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then fi dnl Check for zlib. -AC_DEFINE([ENABLE_ZLIB], [], [Define to 1 if you have zlib]) -AC_ARG_ENABLE([zlib], - AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, - [enable_zlib=yes]) - -if test x"$enable_zlib" = x"yes"; then - AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) -fi +AC_CHECK_HEADER( + zlib.h, + AC_CHECK_LIB( + z, + gzdopen, + LIBS="-lz $LIBS", + AC_MSG_ERROR(Required library zlib missing.)), + AC_MSG_ERROR(Header file for required library zlib missing.)) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/util.c b/util.c index fab119093..665d7dc76 100644 --- a/util.c +++ b/util.c @@ -61,105 +61,6 @@ void fatal(const char *format, ...) exit(1); } -#ifndef ENABLE_ZLIB -/* copy all data from one file descriptor to another */ -void copy_fd(int fd_in, int fd_out) -{ - char buf[10240]; - int n; - - while ((n = read(fd_in, buf, sizeof(buf))) > 0) { - if (write(fd_out, buf, n) != n) { - fatal("Failed to copy fd\n"); - } - } -} - -static int safe_rename(const char* oldpath, const char* newpath) -{ - /* safe_rename is for creating entries in the cache. - - Works like rename(), but it never overwrites an existing - cache entry. This avoids corruption on NFS. */ - int status = link(oldpath, newpath); - if (status == 0 || errno == EEXIST) { - return unlink(oldpath); - } - else { - 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 - the copy is done via a temporary file and atomic rename -*/ -int copy_file(const char *src, const char *dest) -{ - int fd1, fd2; - char buf[10240]; - int n; - char *tmp_name; - mode_t mask; - - x_asprintf(&tmp_name, "%s.XXXXXX", dest); - - fd1 = open(src, O_RDONLY|O_BINARY); - if (fd1 == -1) { - free(tmp_name); - return -1; - } - - fd2 = mkstemp(tmp_name); - if (fd2 == -1) { - close(fd1); - free(tmp_name); - return -1; - } - - while ((n = read(fd1, buf, sizeof(buf))) > 0) { - if (write(fd2, buf, n) != n) { - close(fd2); - close(fd1); - unlink(tmp_name); - free(tmp_name); - return -1; - } - } - - close(fd1); - - /* get perms right on the tmp file */ - mask = umask(0); - fchmod(fd2, 0666 & ~mask); - umask(mask); - - /* the close can fail on NFS if out of space */ - if (close(fd2) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - unlink(dest); - - if (rename(tmp_name, dest) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - free(tmp_name); - - return 0; -} - -#else /* ENABLE_ZLIB */ - /* copy all data from one file descriptor to another possibly decompressing it */ @@ -305,7 +206,6 @@ int move_file(const char *src, const char *dest) { int copy_file(const char *src, const char *dest) { return _copy_file(src, dest, COPY_FROM_CACHE); } -#endif /* ENABLE_ZLIB */ /* test if a file is zlib compressed */ int test_if_compressed(const char *filename) {