Skip to contentSkip to conversation

Move zlib compression library to common directory

-mm Michael-Luke Jones 3 participants 6 messages May 29, 2007 – May 30, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This patch moves the zlib compression and decompression code to a common directory. The zutil.h header, which is not meant to be public, is moved from include/linux/ to lib/zlib/.

In addition, the PRESET_DICT definition from zutil.h, used by fs/jffs2/compr_zlib.c is moved to the 'true' public zlib header include/linux/zlib.h. This move is documented in comments.

Conditional compile of only inflate or deflate code is preserved by this patch.

fs/jffs2/compr_zlib.c +0 -1
index 2b87fcc..e2cc6c7 100644
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/zlib.h>
-#include <linux/zutil.h>
 #include "nodelist.h"
 #include "compr.h"
 
include/linux/zlib.h +0 -0
index 9e3192a..e9d32c5 100644
@@ -177,6 +177,9 @@ typedef z_stream *z_streamp;
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this 

version) */

+#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ +/* Required by fs/jffs2/compr_zlib.c */
+

                         /* basic functions */

extern int zlib_deflate_workspacesize (void);

lib/Makefile +2 -2
index c8c8e20..42c3903 100644
@@ -46,8 +46,8 @@ obj-$(CONFIG_CRC32)	+= crc32.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
 
-obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
-obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
+obj-$(CONFIG_ZLIB_INFLATE) += zlib/
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib/
 obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
 
 obj-$(CONFIG_TEXTSEARCH) += textsearch.o
lib/zlib/Makefile renamed from lib/zlib_inflate/Makefile +6 -2
similarity index 71%
rename from lib/zlib_inflate/Makefile
rename to lib/zlib/Makefile
index bf06548..528d903 100644
@@ -2,8 +2,8 @@
 # This is a modified version of zlib, which does all memory
 # allocation ahead of time.
 #
-# This is only the decompression, see zlib_deflate for the
-# the compression
+# The compression (deflate) and decompression (inflate) code
+# is present in this folder.
 #
 # Decompression needs to be serialized for each memory
 # allocation.
@@ -17,3 +17,7 @@ obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate.o
 
 zlib_inflate-objs := inffast.o inflate.o \
 		     inftrees.o inflate_syms.o
+
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate.o
+
+zlib_deflate-objs := deflate.o deftree.o deflate_syms.o
lib/zlib/deflate.c renamed from lib/zlib_deflate/deflate.c +1 -2
similarity index 100%
rename from lib/zlib_deflate/deflate.c
rename to lib/zlib/deflate.c
index c3e4a2b..1137780 100644
@@ -49,10 +49,9 @@
  */
 
 #include <linux/module.h>
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "defutil.h"
 
-
 /* 

===========================================================================
* Function prototypes.
*/

lib/zlib/deflate_syms.c renamed from lib/zlib_deflate/deflate_syms.c +0 -0
similarity index 100%
rename from lib/zlib_deflate/deflate_syms.c
rename to lib/zlib/deflate_syms.c
lib/zlib/deftree.c renamed from lib/zlib_deflate/deftree.c +1 -1
similarity index 100%
rename from lib/zlib_deflate/deftree.c
rename to lib/zlib/deftree.c
index ddf3482..d5ce87d 100644
@@ -34,7 +34,7 @@
 
 /* #include "deflate.h" */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "defutil.h"
 
 #ifdef DEBUG_ZLIB
lib/zlib/defutil.h renamed from lib/zlib_deflate/defutil.h +0 -0
similarity index 100%
rename from lib/zlib_deflate/defutil.h
rename to lib/zlib/defutil.h
lib/zlib/inffast.c renamed from lib/zlib_inflate/inffast.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inffast.c
rename to lib/zlib/inffast.c
index d84560c..50d3de1 100644
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
lib/zlib/inffast.h renamed from lib/zlib_inflate/inffast.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inffast.h
rename to lib/zlib/inffast.h
lib/zlib/inffixed.h renamed from lib/zlib_inflate/inffixed.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inffixed.h
rename to lib/zlib/inffixed.h
lib/zlib/inflate.c renamed from lib/zlib_inflate/inflate.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inflate.c
rename to lib/zlib/inflate.c
index 7e1e311..ba58871 100644
@@ -9,7 +9,7 @@
  *
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
lib/zlib/inflate.h renamed from lib/zlib_inflate/inflate.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inflate.h
rename to lib/zlib/inflate.h
lib/zlib/inflate_syms.c renamed from lib/zlib_inflate/inflate_syms.c +0 -0
similarity index 100%
rename from lib/zlib_inflate/inflate_syms.c
rename to lib/zlib/inflate_syms.c
lib/zlib/inftrees.c renamed from lib/zlib_inflate/inftrees.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inftrees.c
rename to lib/zlib/inftrees.c
index 3fe6ce5..faf6f75 100644
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 
 #define MAXBITS 15
lib/zlib/inftrees.h renamed from lib/zlib_inflate/inftrees.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inftrees.h
rename to lib/zlib/inftrees.h
lib/zlib/infutil.h renamed from lib/zlib_inflate/infutil.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/infutil.h
rename to lib/zlib/infutil.h
lib/zlib/patch-zlib new file binary +0 -0
new file mode 100644
index 0000000..d4a011b
Binary files /dev/null and b/lib/zlib/patch-zlib differ
lib/zlib/zutil.h renamed from include/linux/zutil.h +1 -1
similarity index 98%
rename from include/linux/zutil.h
rename to lib/zlib/zutil.h
index 6adfa9a..0467c8c 100644
@@ -32,7 +32,7 @@ typedef unsigned long  ulg;
 #define MAX_MATCH  258
 /* The minimum and maximum match lengths */
 
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+/* PRESET_DICT #define moved to <linux/zlib.h> for JFFS2 */
 
         /* target dependencies */
 
lib/zlib_deflate/Makefile deleted +0 -11
deleted file mode 100644
index 86275e3..0000000
@@ -1,11 +0,0 @@
-#
-# This is a modified version of zlib, which does all memory
-# allocation ahead of time.
-#
-# This is the compression code, see zlib_inflate for the
-# decompression code.
-#
-
-obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate.o
-
-zlib_deflate-objs := deflate.o deftree.o deflate_syms.o
#1 lore raw

[-mm] Move zlib compression library to common directory [TAKE TWO]

This patch moves the zlib compression and decompression code to a common directory. The zutil.h header, which is not meant to be public, is moved from include/linux/ to lib/zlib/.

In addition, the PRESET_DICT definition from zutil.h, used by fs/jffs2/compr_zlib.c is moved to the 'true' public zlib header include/linux/zlib.h.

Conditional compile of only inflate or deflate code is preserved by this patch. With a bit of luck, this version won't be whitespace-damaged. Grumble.

fs/jffs2/compr_zlib.c +0 -1
index 2b87fcc..e2cc6c7 100644
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/zlib.h>
-#include <linux/zutil.h>
 #include "nodelist.h"
 #include "compr.h"
 
include/linux/zlib.h +3 -0
index 9e3192a..e9d32c5 100644
@@ -177,6 +177,9 @@ typedef z_stream *z_streamp;
 #define Z_DEFLATED   8
 /* The deflate compression method (the only one supported in this version) */
 
+#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+/* Required by fs/jffs2/compr_zlib.c */
+
                         /* basic functions */
 
 extern int zlib_deflate_workspacesize (void);
lib/Makefile +2 -2
index c8c8e20..42c3903 100644
@@ -46,8 +46,8 @@ obj-$(CONFIG_CRC32)	+= crc32.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
 
-obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
-obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
+obj-$(CONFIG_ZLIB_INFLATE) += zlib/
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib/
 obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
 
 obj-$(CONFIG_TEXTSEARCH) += textsearch.o
lib/zlib/Makefile renamed from lib/zlib_inflate/Makefile +6 -2
similarity index 71%
rename from lib/zlib_inflate/Makefile
rename to lib/zlib/Makefile
index bf06548..528d903 100644
@@ -2,8 +2,8 @@
 # This is a modified version of zlib, which does all memory
 # allocation ahead of time.
 #
-# This is only the decompression, see zlib_deflate for the
-# the compression
+# The compression (deflate) and decompression (inflate) code
+# is present in this folder.
 #
 # Decompression needs to be serialized for each memory
 # allocation.
@@ -17,3 +17,7 @@ obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate.o
 
 zlib_inflate-objs := inffast.o inflate.o \
 		     inftrees.o inflate_syms.o
+
+obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate.o
+
+zlib_deflate-objs := deflate.o deftree.o deflate_syms.o
lib/zlib/deflate.c renamed from lib/zlib_deflate/deflate.c +1 -2
similarity index 100%
rename from lib/zlib_deflate/deflate.c
rename to lib/zlib/deflate.c
index c3e4a2b..1137780 100644
@@ -49,10 +49,9 @@
  */
 
 #include <linux/module.h>
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "defutil.h"
 
-
 /* ===========================================================================
  *  Function prototypes.
  */
lib/zlib/deflate_syms.c renamed from lib/zlib_deflate/deflate_syms.c +0 -0
similarity index 100%
rename from lib/zlib_deflate/deflate_syms.c
rename to lib/zlib/deflate_syms.c
lib/zlib/deftree.c renamed from lib/zlib_deflate/deftree.c +1 -1
similarity index 100%
rename from lib/zlib_deflate/deftree.c
rename to lib/zlib/deftree.c
index ddf3482..d5ce87d 100644
@@ -34,7 +34,7 @@
 
 /* #include "deflate.h" */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "defutil.h"
 
 #ifdef DEBUG_ZLIB
lib/zlib/defutil.h renamed from lib/zlib_deflate/defutil.h +0 -0
similarity index 100%
rename from lib/zlib_deflate/defutil.h
rename to lib/zlib/defutil.h
lib/zlib/inffast.c renamed from lib/zlib_inflate/inffast.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inffast.c
rename to lib/zlib/inffast.c
index d84560c..50d3de1 100644
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
lib/zlib/inffast.h renamed from lib/zlib_inflate/inffast.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inffast.h
rename to lib/zlib/inffast.h
lib/zlib/inffixed.h renamed from lib/zlib_inflate/inffixed.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inffixed.h
rename to lib/zlib/inffixed.h
lib/zlib/inflate.c renamed from lib/zlib_inflate/inflate.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inflate.c
rename to lib/zlib/inflate.c
index 7e1e311..ba58871 100644
@@ -9,7 +9,7 @@
  *
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 #include "inflate.h"
 #include "inffast.h"
lib/zlib/inflate.h renamed from lib/zlib_inflate/inflate.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inflate.h
rename to lib/zlib/inflate.h
lib/zlib/inflate_syms.c renamed from lib/zlib_inflate/inflate_syms.c +0 -0
similarity index 100%
rename from lib/zlib_inflate/inflate_syms.c
rename to lib/zlib/inflate_syms.c
lib/zlib/inftrees.c renamed from lib/zlib_inflate/inftrees.c +1 -1
similarity index 100%
rename from lib/zlib_inflate/inftrees.c
rename to lib/zlib/inftrees.c
index 3fe6ce5..faf6f75 100644
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-#include <linux/zutil.h>
+#include "zutil.h"
 #include "inftrees.h"
 
 #define MAXBITS 15
lib/zlib/inftrees.h renamed from lib/zlib_inflate/inftrees.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inftrees.h
rename to lib/zlib/inftrees.h
lib/zlib/infutil.h renamed from lib/zlib_inflate/infutil.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/infutil.h
rename to lib/zlib/infutil.h
lib/zlib/zutil.h renamed from include/linux/zutil.h +1 -1
similarity index 98%
rename from include/linux/zutil.h
rename to lib/zlib/zutil.h
index 6adfa9a..0467c8c 100644
@@ -32,7 +32,7 @@ typedef unsigned long  ulg;
 #define MAX_MATCH  258
 /* The minimum and maximum match lengths */
 
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+/* PRESET_DICT #define moved to <linux/zlib.h> for JFFS2 */
 
         /* target dependencies */
 
lib/zlib_deflate/Makefile deleted +0 -11
deleted file mode 100644
index 86275e3..0000000
@@ -1,11 +0,0 @@
-#
-# This is a modified version of zlib, which does all memory
-# allocation ahead of time.
-#
-# This is the compression code, see zlib_inflate for the
-# decompression code.
-#
-
-obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate.o
-
-zlib_deflate-objs := deflate.o deftree.o deflate_syms.o
maintainer
#2 lore raw

Re: [-mm] Move zlib compression library to common directory [TAKE TWO]

Quoted 11 lines · On Tue, 29 May 2007 17:31:05 +0100 Michael-Luke Jones…

This patch moves the zlib compression and decompression code to a common directory. The zutil.h header, which is not meant to be public, is moved from include/linux/ to lib/zlib/.

In addition, the PRESET_DICT definition from zutil.h, used by fs/jffs2/compr_zlib.c is moved to the 'true' public zlib header include/linux/zlib.h.

Conditional compile of only inflate or deflate code is preserved by this patch. With a bit of luck, this version won't be whitespace-damaged. Grumble.

umm, OK, if you say so. I'm not sure I understand the point behind all this, but I'm sure there is one ;)

lib/zlib/zutil.h

Quoted 35 lines
lib/zlib/deflate.c renamed from lib/zlib_deflate/deflate.c +0 -0
similarity index 100%
rename from lib/zlib_deflate/deflate.c
rename to lib/zlib/deflate.c
index c3e4a2b..1137780 100644
lib/zlib/deflate_syms.c renamed from lib/zlib_deflate/deflate_syms.c +0 -0
similarity index 100%
rename from lib/zlib_deflate/deflate_syms.c
rename to lib/zlib/deflate_syms.c
lib/zlib/deftree.c renamed from lib/zlib_deflate/deftree.c +0 -0
similarity index 100%
rename from lib/zlib_deflate/deftree.c
rename to lib/zlib/deftree.c
index ddf3482..d5ce87d 100644
lib/zlib/defutil.h renamed from lib/zlib_deflate/defutil.h +0 -0
similarity index 100%
rename from lib/zlib_deflate/defutil.h
rename to lib/zlib/defutil.h
lib/zlib/inffast.c renamed from lib/zlib_inflate/inffast.c +0 -0
similarity index 100%
rename from lib/zlib_inflate/inffast.c
rename to lib/zlib/inffast.c
lib/zlib/inftrees.h renamed from lib/zlib_inflate/inftrees.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/inftrees.h
rename to lib/zlib/inftrees.h
lib/zlib/infutil.h renamed from lib/zlib_inflate/infutil.h +0 -0
similarity index 100%
rename from lib/zlib_inflate/infutil.h
rename to lib/zlib/infutil.h
lib/zlib/zutil.h renamed from include/linux/zutil.h +0 -0
similarity index 98%
rename from include/linux/zutil.h
rename to lib/zlib/zutil.h
index 6adfa9a..0467c8c 100644

Lots of git goodies there - I didn't actually receive the patch: the parts which move files around were communicated via git metadata, not diffs. Presumably there's a way to tell git to not do that.

But probably it's best that this change be merged via git anyway. David, are you interested in handling it?

#4 lore raw

Re: [-mm] Move zlib compression library to common directory [TAKE TWO]

In reply to Michael-Luke Jones

Hi Michael,

Quoted 5 lines · Michael-Luke Jones

This patch moves the zlib compression and decompression code to a common directory. The zutil.h header, which is not meant to be public, is moved from include/linux/ to lib/zlib/.

You could remove the (now pointless) /* WARNING: ... */ comment from (the now truly private) zutil.h too ...

Quoted 3 lines

In addition, the PRESET_DICT definition from zutil.h, used by fs/jffs2/compr_zlib.c is moved to the 'true' public zlib header include/linux/zlib.h.

Ugh, I wish you had held on from this patch till the original thread discussing this reached some conclusion ... from Mark's response there it does seem PRESET_DICT is clearly an implementation (and not interface) detail -- which means to me that it must continue to live in zutil.h (the private header) ... but then, this change is clearly not so critical either, so it doesn't matter much, I guess.

[ Added zlib authors Mark Adler and Jean-Loup Gailly on this thread too. ]

Satyam

#5 lore raw

Re: [-mm] Move zlib compression library to common directory [TAKE TWO]

Quoted 6 lines · Satyam Sharma

Ugh, I wish you had held on from this patch till the original thread discussing this reached some conclusion ... from Mark's response there it does seem PRESET_DICT is clearly an implementation (and not interface) detail -- which means to me that it must continue to live in zutil.h (the private header) ... but then, this change is clearly not so critical either, so it doesn't matter much, I guess.

Satyam: Sorry about this, I wrote this before the conversation on this point started, expecting the discussion to happen here. My hope was to see if this minimal change to export PRESET_DICT was acceptable (if not ideal). Given that practically all of the implementation details are currently exported, it's probably an improvement to only export one :)

Andrew: The main reason for this change is to allow a private header to be moved from include/linux/ to this private folder. It's already been used apparently inappropriately by JFFS2 compression code. Minimal code changes, lots of file moving (as I'm sure you can see)...

I managed to get the patch to apply to a fresh tree using 'git apply', which may well mean that I didn't understand your comment that "the parts which move files around were communicated via git metadata, not diffs".

Given that, since I wrote this patch, no-one has actually said anything positive about it, there's probably not much point picking it up until people have worked out exactly what to do with JFFS2's inappropriate use of the public-private zutil.h header. At least it's just JFFS2 :)

Quoted 2 lines

[ Added zlib authors Mark Adler and Jean-Loup Gailly on this thread too. ]

Thanks, I should have CCed the authors/maintainers originally.

Quoted 1 line

Satyam

Michael-Luke

(PS: The stern warning is also present in the other private zlib header files.)

#3 lore raw

Re: [-mm] Move zlib compression library to common directory [TAKE TWO]

In reply to Andrew Morton
Quoted 6 lines · Andrew Morton

Lots of git goodies there - I didn't actually receive the patch: the parts which move files around were communicated via git metadata, not diffs. Presumably there's a way to tell git to not do that.

But probably it's best that this change be merged via git anyway. David, are you interested in handling it?

Update: totally ignore this patch. Even using git-apply something gets confused and git loses the meaning of the renames, turning them into file additions and deletions.

A better version will no doubt come along. In the mean time, it looks like I need to improve my git-foo skills...

M-L