summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile6
-rw-r--r--lib/libcrc32.c (renamed from lib/crc32.c)11
-rw-r--r--lib/libfec.c (renamed from lib/fec.c)0
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 82194e4..621ed63 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -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))
diff --git a/lib/crc32.c b/lib/libcrc32.c
index 6b1e50c..d556e91 100644
--- a/lib/crc32.c
+++ b/lib/libcrc32.c
@@ -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;
+}
diff --git a/lib/fec.c b/lib/libfec.c
index 6d9020f..6d9020f 100644
--- a/lib/fec.c
+++ b/lib/libfec.c