lz4: add memmove to arm string.c

This commit is contained in:
Philippe Teuwen 2020-06-07 12:46:34 +02:00
parent d48fcbf5eb
commit 381b47f64e
4 changed files with 19 additions and 21 deletions

View file

@ -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

View file

@ -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) {

View file

@ -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);

View file

@ -182,26 +182,6 @@
#include <string.h> /* 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
**************************************/