]> www.infradead.org Git - mtd-utils.git/commitdiff
libs: make crc32 and fec to be libraries
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sat, 17 Jul 2010 06:43:08 +0000 (09:43 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sat, 17 Jul 2010 06:43:08 +0000 (09:43 +0300)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
include/crc32.h
lib/Makefile
lib/libcrc32.c [moved from lib/crc32.c with 96% similarity]
lib/libfec.c [moved from lib/fec.c with 100% similarity]
mkfs.ubifs/Makefile

index 4b5117706634828fbca3ec3166d455465bca3d1b..affa303fe94461d7aaf8c3ec5a67003f48cefd35 100644 (file)
@@ -7,16 +7,7 @@
 
 #include <stdint.h>
 
-extern const uint32_t crc32_table[256];
-
-/* Return a 32-bit CRC of the contents of the buffer. */
-static inline uint32_t crc32(uint32_t val, const void *ss, int len)
-{
-       const unsigned char *s = ss;
-
-       while (--len >= 0)
-               val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
-       return val;
-}
+/* Return a 32-bit CRC of the contents of the buffer */
+extern uint32_t crc32(uint32_t val, const void *ss, int len);
 
 #endif /* __CRC32_H__ */
index 82194e4b835a0f88362b2e79273f2b34b72bd1be..621ed633aef4dcff5a565a52c4f6efd3b827f7d6 100644 (file)
@@ -6,13 +6,13 @@ SUBDIRS =
 
 # CFLAGS += -Werror
 CPPFLAGS += -I../include
-LIBS = libmtd
-TARGETS = libmtd.a
+LIBS = libmtd libcrc32
+TARGETS = libmtd.a libcrc32.a
 
 include ../common.mk
 
 $(BUILDDIR)/libmtd.a: $(addprefix $(BUILDDIR)/,\
-       libmtd.o libmtd_legacy.o crc32.o fec.o)
+       libmtd.o libmtd_legacy.o libcrc32.o libfec.o)
 
 clean::
        rm -f $(addsuffix .a, $(LIBS))
similarity index 96%
rename from lib/crc32.c
rename to lib/libcrc32.c
index 6b1e50c42d9b646c4eba4d591bfb4b0941ac3c17..d556e9165410d09cdbb416ebb26802bd389f2b00 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <stdint.h>
 
-const uint32_t crc32_table[256] = {
+const static uint32_t crc32_table[256] = {
        0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
        0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
        0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
@@ -93,3 +93,12 @@ const uint32_t crc32_table[256] = {
        0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
        0x2d02ef8dL
 };
+
+uint32_t crc32(uint32_t val, const void *ss, int len)
+{
+       const unsigned char *s = ss;
+
+       while (--len >= 0)
+               val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
+       return val;
+}
similarity index 100%
rename from lib/fec.c
rename to lib/libfec.c
index ba21a8c1eb291d81ee3a091ebe1ee657d1df5bef..499f9e5e359395d5f0651518d6b3313c74ca4ec2 100644 (file)
@@ -7,7 +7,7 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
 TARGETS = mkfs.ubifs
 
 LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
-LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
+LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd -lcrc32
 LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
 
 include ../common.mk