diff --git a/templates/web-make/Makefile b/templates/web-make/Makefile index 8dec608..1f60ce3 100644 --- a/templates/web-make/Makefile +++ b/templates/web-make/Makefile @@ -21,6 +21,7 @@ LDFLAGS_ALL = \ -Wl,--export=calloc \ -Wl,--export=free \ -Wl,--export=memset \ + -Wl,--export=memcpy \ -Wl,--export=processor_new \ -Wl,--export=processor_free \ -Wl,--export=processor_get_x_buf \ @@ -40,7 +41,7 @@ LDFLAGS_ALL += ${LDFLAGS} ${LDFLAGS_EXTRA} CXXFLAGS = ${CFLAGS} CXXFLAGS_ALL = -I${COMMON_DIR}/src -I${DATA_DIR}/src -I${PLUGIN_DIR} --target=wasm32 -flto -fvisibility=hidden ${CXXFLAGS} ${CXXFLAGS_EXTRA} -C_SRCS = ${COMMON_DIR}/src/processor.c ${COMMON_DIR}/src/walloc.c ${COMMON_DIR}/src/memset.c +C_SRCS = ${COMMON_DIR}/src/processor.c ${COMMON_DIR}/src/walloc.c ${COMMON_DIR}/src/string.c C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o))) ifeq ($(CXX_SRCS_EXTRA),) diff --git a/templates/web/src/memset.c b/templates/web/src/memset.c deleted file mode 100644 index 8a3b7eb..0000000 --- a/templates/web/src/memset.c +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2023 Orastron Srl unipersonale - */ - -#include "memset.h" - -void *memset(void *ptr, int value, size_t num) { - unsigned char *p = (unsigned char *)ptr; - for (size_t i = 0; i < num; i++) - p[i] = (unsigned char)value; - return ptr; -} diff --git a/templates/web/src/processor.c b/templates/web/src/processor.c index 9ee16f6..ee0ed31 100644 --- a/templates/web/src/processor.c +++ b/templates/web/src/processor.c @@ -8,7 +8,7 @@ #include "data.h" #include "plugin.h" -#include "memset.h" +#include "string.h" #include "walloc.h" typedef struct { diff --git a/templates/web/src/string.c b/templates/web/src/string.c new file mode 100644 index 0000000..5871569 --- /dev/null +++ b/templates/web/src/string.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2023, 2024 Orastron Srl unipersonale + */ + +#include "string.h" + +void *memset(void *ptr, int value, size_t num) { + unsigned char *p = (unsigned char *)ptr; + for (size_t i = 0; i < num; i++) + p[i] = (unsigned char)value; + return ptr; +} + +void *memcpy(void *dest, const void *src, size_t num) { + char *d = (char *)dest; + char *s = (char *)src; + for (size_t i = 0; i < num; i++) + d[i] = s[i]; + return dest; +} diff --git a/templates/web/src/memset.h b/templates/web/src/string.h similarity index 69% rename from templates/web/src/memset.h rename to templates/web/src/string.h index 61a5ad0..0d1d32a 100644 --- a/templates/web/src/memset.h +++ b/templates/web/src/string.h @@ -2,8 +2,8 @@ * Copyright (C) 2023 Orastron Srl unipersonale */ -#ifndef MEMSET_H -#define MEMSET_H +#ifndef STRING_H +#define STRING_H #include @@ -12,6 +12,7 @@ extern "C" { #endif void *memset(void *ptr, int value, size_t num); +void *memcpy(void *dest, const void *src, size_t num); #ifdef __cplusplus } diff --git a/templates/web/src/walloc.c b/templates/web/src/walloc.c index 3ea4b2d..4fb7939 100644 --- a/templates/web/src/walloc.c +++ b/templates/web/src/walloc.c @@ -5,7 +5,7 @@ #include "walloc.h" #include -#include "memset.h" +#include "string.h" extern unsigned char __heap_base; diff --git a/templates/web/tibia-index.js b/templates/web/tibia-index.js index 50fcb17..7065667 100644 --- a/templates/web/tibia-index.js +++ b/templates/web/tibia-index.js @@ -2,8 +2,8 @@ var path = require("path"); var sep = path.sep; module.exports = function (data, api) { - api.copyFile(`src${sep}memset.h`, `src${sep}memset.h`); - api.copyFile(`src${sep}memset.c`, `src${sep}memset.c`); + api.copyFile(`src${sep}string.h`, `src${sep}string.h`); + api.copyFile(`src${sep}string.c`, `src${sep}string.c`); api.copyFile(`src${sep}walloc.h`, `src${sep}walloc.h`); api.copyFile(`src${sep}walloc.c`, `src${sep}walloc.c`); api.copyFile(`src${sep}new.cpp`, `src${sep}new.cpp`);