2019-05-07 02:18:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
2019-11-11 23:45:21 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-05-07 02:18:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BH_COMMON_H
|
|
|
|
#define _BH_COMMON_H
|
|
|
|
|
|
|
|
#include "bh_platform.h"
|
2019-08-28 07:08:52 +00:00
|
|
|
|
2020-03-16 08:43:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-05-07 02:18:18 +00:00
|
|
|
#define bh_memcpy_s(dest, dlen, src, slen) do { \
|
|
|
|
int _ret = slen == 0 ? 0 : b_memcpy_s (dest, dlen, src, slen); \
|
|
|
|
(void)_ret; \
|
|
|
|
bh_assert (_ret == 0); \
|
|
|
|
} while (0)
|
|
|
|
|
2020-06-02 06:53:06 +00:00
|
|
|
#define bh_memmove_s(dest, dlen, src, slen) do { \
|
|
|
|
int _ret = slen == 0 ? 0 : b_memmove_s (dest, dlen, src, slen); \
|
|
|
|
(void)_ret; \
|
|
|
|
bh_assert (_ret == 0); \
|
|
|
|
} while (0)
|
|
|
|
|
2019-05-07 02:18:18 +00:00
|
|
|
#define bh_strcat_s(dest, dlen, src) do { \
|
|
|
|
int _ret = b_strcat_s (dest, dlen, src); \
|
|
|
|
(void)_ret; \
|
|
|
|
bh_assert (_ret == 0); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define bh_strcpy_s(dest, dlen, src) do { \
|
|
|
|
int _ret = b_strcpy_s (dest, dlen, src); \
|
|
|
|
(void)_ret; \
|
|
|
|
bh_assert (_ret == 0); \
|
|
|
|
} while (0)
|
|
|
|
|
2020-03-10 11:54:44 +00:00
|
|
|
int b_memcpy_s(void * s1, unsigned int s1max, const void * s2, unsigned int n);
|
2020-06-02 06:53:06 +00:00
|
|
|
int b_memmove_s(void * s1, unsigned int s1max, const void * s2, unsigned int n);
|
2020-03-16 08:43:57 +00:00
|
|
|
int b_strcat_s(char * s1, unsigned int s1max, const char * s2);
|
|
|
|
int b_strcpy_s(char * s1, unsigned int s1max, const char * s2);
|
2020-03-10 11:54:44 +00:00
|
|
|
|
|
|
|
/* strdup with string allocated by BH_MALLOC */
|
|
|
|
char *bh_strdup(const char *s);
|
|
|
|
|
|
|
|
/* strdup with string allocated by WA_MALLOC */
|
|
|
|
char *wa_strdup(const char *s);
|
|
|
|
|
2020-03-16 08:43:57 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-07 02:18:18 +00:00
|
|
|
#endif
|