From 381b47f64eb65366eeda824814f9d0e4f3315a8f Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 7 Jun 2020 12:46:34 +0200 Subject: [PATCH] lz4: add memmove to arm string.c --- armsrc/Makefile | 2 +- armsrc/string.c | 17 +++++++++++++++++ armsrc/string.h | 1 + common/lz4/lz4.c | 20 -------------------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 14747c7ed..5544c1aca 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -78,7 +78,7 @@ FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit #the lz4 source files required for decompressing the fpga config at run time SRC_LZ4 = lz4.c #additional defines required to compile lz4 -LZ4_CFLAGS = -DNEED_MEMMOVE -DLZ4_MEMORY_USAGE=8 +LZ4_CFLAGS = -DLZ4_MEMORY_USAGE=8 APP_CFLAGS += $(LZ4_CFLAGS) # lz4 includes: APP_CFLAGS += -I../common/lz4 diff --git a/armsrc/string.c b/armsrc/string.c index 8dbe26808..300e911df 100644 --- a/armsrc/string.c +++ b/armsrc/string.c @@ -20,6 +20,23 @@ void *memcpy(void *dest, const void *src, int len) { return dest; } +void *memmove (void *dest, const void *src, size_t len) +{ + char *d = dest; + const char *s = src; + if (d < s) + while (len--) + *d++ = *s++; + else + { + char *lasts = (char*)s + (len-1); + char *lastd = d + (len-1); + while (len--) + *lastd-- = *lasts--; + } + return dest; +} + void *memset(void *dest, int c, int len) { uint8_t *d = dest; while ((len--) > 0) { diff --git a/armsrc/string.h b/armsrc/string.h index f8388d0a1..53f8e8f71 100644 --- a/armsrc/string.h +++ b/armsrc/string.h @@ -16,6 +16,7 @@ int strlen(const char *str); void *memcpy(void *dest, const void *src, int len); +void *memmove (void *dest, const void *src, size_t len); void *memset(void *dest, int c, int len); int memcmp(const void *av, const void *bv, int len); void memxor(uint8_t *dest, uint8_t *src, size_t len); diff --git a/common/lz4/lz4.c b/common/lz4/lz4.c index 25be146fd..375287c8a 100644 --- a/common/lz4/lz4.c +++ b/common/lz4/lz4.c @@ -182,26 +182,6 @@ #include /* memset, memcpy */ #define MEM_INIT(p,v,s) memset((p),(v),(s)) -#ifdef NEED_MEMMOVE -void * -memmove (void *dest, const void *src, size_t len) -{ - char *d = dest; - const char *s = src; - if (d < s) - while (len--) - *d++ = *s++; - else - { - char *lasts = (char*)s + (len-1); - char *lastd = d + (len-1); - while (len--) - *lastd-- = *lasts--; - } - return dest; -} -#endif - /*-************************************ * Common Constants **************************************/