]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Require zlib
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 6 Dec 2009 14:39:50 +0000 (15:39 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 Jan 2010 17:53:02 +0000 (18:53 +0100)
ccache.c
ccache.h
configure.ac
util.c

index ce78850b6a105bc1195d12876c760de1916d3463..f6e06c70ce82f1fe4c0b6efa0a789678126cb544 100644 (file)
--- 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);
index 0095dabdab5da12a796139d62a74438f5889b74e..5e8b1873f5c601a35c621ae221a64f4254460cb5 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -29,9 +29,7 @@
 #include <sys/time.h>
 #endif
 
-#ifdef ENABLE_ZLIB
 #include <zlib.h>
-#endif
 
 #ifdef __GNUC__
 #define ATTR_FORMAT(x, y, z) __attribute__((format (x, y, z)))
 #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 {
index 72391f5ca9fd6f210249869f3968f9adf014c146..94f3637e9a8854c903a597ac71658d0b3e3ba774 100644 (file)
@@ -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 fab119093ae8796e24f97c35c3fdd7e5f62b5f3c..665d7dc7633093296db5686868e7d7a5089b3df1 100644 (file)
--- 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) {