[Darshan-commits] [Darshan] branch, dev-modular, updated. darshan-2.3.1-147-ga850ea7

Service Account git at mcs.anl.gov
Tue Aug 18 14:39:50 CDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".

The branch, dev-modular has been updated
       via  a850ea7453abc28a3e46e554cd48ab49739ea156 (commit)
      from  dcc9c7feafae1d129b5ce5e4d6db38b10344259a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a850ea7453abc28a3e46e554cd48ab49739ea156
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Tue Aug 18 14:39:20 2015 -0500

    add bzip2 comp/decomp functions

-----------------------------------------------------------------------

Summary of changes:
 darshan-util/darshan-logutils.c |  161 ++++++++++++++++++++++++++++-----------
 1 files changed, 115 insertions(+), 46 deletions(-)


Diff of changes:
diff --git a/darshan-util/darshan-logutils.c b/darshan-util/darshan-logutils.c
index 33fb8a0..e61447c 100644
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -213,6 +213,7 @@ int darshan_log_putheader(darshan_fd fd)
     memset(&header, 0, sizeof(header));
     strcpy(header.version_string, DARSHAN_LOG_VERSION);
     header.magic_nr = DARSHAN_MAGIC_NR;
+    header.comp_type = fd->comp_type;
 
     /* copy the mapping information to the header */
     memcpy(&header.rec_map, &fd->rec_map, sizeof(struct darshan_log_map));
@@ -975,6 +976,33 @@ static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
     return(ret);
 }
 
+static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz,
+    enum darshan_comp_type comp_type)
+{
+    int ret;
+
+    switch(comp_type)
+    {
+        case DARSHAN_ZLIB_COMP:
+            ret = darshan_zlib_comp(decomp_buf, decomp_buf_sz,
+                comp_buf, inout_comp_buf_sz);
+            break;
+#ifdef HAVE_LIBBZ2
+        case DARSHAN_BZIP2_COMP:
+            ret = darshan_bzip2_comp(decomp_buf, decomp_buf_sz,
+                comp_buf, inout_comp_buf_sz);
+            break;
+#endif
+        default:
+            fprintf(stderr, "Error: invalid compression method.\n");
+            return(-1);
+    }
+
+    return(ret);
+
+}
+
 static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
     char* decomp_buf, int* inout_decomp_buf_sz)
 {
@@ -1031,38 +1059,10 @@ static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
     return(0);
 }
 
-static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz,
-    enum darshan_comp_type comp_type)
-{
-    int ret;
-
-    switch(comp_type)
-    {
-        case DARSHAN_ZLIB_COMP:
-            ret = darshan_zlib_comp(decomp_buf, decomp_buf_sz,
-                comp_buf, inout_comp_buf_sz);
-            break;
-#ifdef HAVE_LIBBZ2
-        case DARSHAN_BZIP2_COMP:
-            ret = darshan_bzip2_comp(decomp_buf, decomp_buf_sz,
-                comp_buf, inout_comp_buf_sz);
-            break;
-#endif
-        default:
-            fprintf(stderr, "Error: invalid compression method.\n");
-            return(-1);
-    }
-
-    return(ret);
-
-}
-
 static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
     char* comp_buf, int* inout_comp_buf_sz)
 {
     int ret;
-    int total_out = 0;
     z_stream tmp_stream;
 
     memset(&tmp_stream, 0, sizeof(tmp_stream));
@@ -1080,48 +1080,117 @@ static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
         return(-1);
     }
 
+    /* compress data */
+    ret = deflate(&tmp_stream, Z_FINISH);
+    if(ret != Z_STREAM_END)
+    {
+        deflateEnd(&tmp_stream);
+        return(-1);
+    }
+    deflateEnd(&tmp_stream);
+
+    *inout_comp_buf_sz = tmp_stream.total_out;
+    return(0);
+}
+
+#ifdef HAVE_LIBBZ2
+static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
+    char* decomp_buf, int* inout_decomp_buf_sz)
+{
+    int ret;
+    int total_out = 0;
+    bz_stream tmp_stream;
+
+    memset(&tmp_stream, 0, sizeof(tmp_stream));
+    tmp_stream.bzalloc = NULL;
+    tmp_stream.bzfree = NULL;
+    tmp_stream.opaque = NULL;
+    tmp_stream.next_in = comp_buf;
+    tmp_stream.avail_in = comp_buf_sz;
+    tmp_stream.next_out = decomp_buf;
+    tmp_stream.avail_out = *inout_decomp_buf_sz;
+
+    ret = BZ2_bzDecompressInit(&tmp_stream, 1, 0);
+    if(ret != BZ_OK)
+    {
+        return(-1);
+    }
+
     /* while we have not finished consuming all of the uncompressed input data */
     while(tmp_stream.avail_in)
     {
         if(tmp_stream.avail_out == 0)
         {
-            /* We ran out of buffer space for compression.  In theory,
+            /* We ran out of buffer space for decompression.  In theory,
              * we could just alloc more space, but probably just easier
              * to bump up the default size of the output buffer.
              */
-            deflateEnd(&tmp_stream);
+            BZ2_bzDecompressEnd(&tmp_stream);
             return(-1);
         }
 
-        /* compress data */
-        ret = deflate(&tmp_stream, Z_FINISH);
-        if(ret != Z_STREAM_END)
+        /* decompress data */
+        ret = BZ2_bzDecompress(&tmp_stream);
+        if(ret != BZ_STREAM_END)
         {
-            deflateEnd(&tmp_stream);
+            BZ2_bzDecompressEnd(&tmp_stream);
             return(-1);
         }
 
-        total_out += tmp_stream.total_out;
+        assert(tmp_stream.total_out_hi32 == 0);
+        total_out += tmp_stream.total_out_lo32;
         if(tmp_stream.avail_in)
-            deflateReset(&tmp_stream);
+        {
+            /* reinitialize bzip2 stream, we have more data to
+             * decompress
+             */
+            BZ2_bzDecompressEnd(&tmp_stream);
+            ret = BZ2_bzDecompressInit(&tmp_stream, 1, 0);
+            if(ret != BZ_OK)
+            {
+                return(-1);
+            }
+        }
     }
-    deflateEnd(&tmp_stream);
+    BZ2_bzDecompressEnd(&tmp_stream);
 
-    *inout_comp_buf_sz = total_out;
+    *inout_decomp_buf_sz = total_out;
     return(0);
 }
 
-#ifdef HAVE_LIBBZ2
-static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz)
-{
-    return(-1);
-}
-
 static int darshan_bzip2_comp(char* decomp_buf, int decomp_buf_sz,
     char* comp_buf, int* inout_comp_buf_sz)
 {
-    return(-1);
+    int ret;
+    bz_stream tmp_stream;
+
+    memset(&tmp_stream, 0, sizeof(tmp_stream));
+    tmp_stream.bzalloc = NULL;
+    tmp_stream.bzfree = NULL;
+    tmp_stream.opaque = NULL;
+    tmp_stream.next_in = decomp_buf;
+    tmp_stream.avail_in = decomp_buf_sz;
+    tmp_stream.next_out = comp_buf;
+    tmp_stream.avail_out = *inout_comp_buf_sz;
+
+    ret = BZ2_bzCompressInit(&tmp_stream, 9, 1, 30);
+    if(ret != BZ_OK)
+    {
+        return(-1);
+    }
+
+    /* compress data */
+    ret = BZ2_bzCompress(&tmp_stream, BZ_FINISH);
+    if(ret != BZ_STREAM_END)
+    {
+        BZ2_bzCompressEnd(&tmp_stream);
+        return(-1);
+    }
+    BZ2_bzCompressEnd(&tmp_stream);
+
+    assert(tmp_stream.total_out_hi32 == 0);
+    *inout_comp_buf_sz = tmp_stream.total_out_lo32;
+    return(0);
 }
 #endif
 


hooks/post-receive
--



More information about the Darshan-commits mailing list