memcpy in web
This commit is contained in:
parent
c688a0e209
commit
98e1510955
@ -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),)
|
||||
|
@ -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;
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
#include "data.h"
|
||||
#include "plugin.h"
|
||||
|
||||
#include "memset.h"
|
||||
#include "string.h"
|
||||
#include "walloc.h"
|
||||
|
||||
typedef struct {
|
||||
|
20
templates/web/src/string.c
Normal file
20
templates/web/src/string.c
Normal file
@ -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;
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
*/
|
||||
|
||||
#ifndef MEMSET_H
|
||||
#define MEMSET_H
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@ -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
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
#include "walloc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "memset.h"
|
||||
#include "string.h"
|
||||
|
||||
extern unsigned char __heap_base;
|
||||
|
||||
|
@ -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`);
|
||||
|
Loading…
Reference in New Issue
Block a user