mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-11-27 10:00:59 +00:00
fix: exclude standard library functions from generated checked headers
This commit is contained in:
parent
096461cbaf
commit
58a9bae9c6
|
|
@ -268,6 +268,27 @@ def generate_checked_headers(header_paths):
|
|||
for node in ast.ext
|
||||
if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl)
|
||||
]
|
||||
# remove std headers functions
|
||||
functions = [
|
||||
f
|
||||
for f in functions
|
||||
if f.name
|
||||
not in (
|
||||
"__mempcpy",
|
||||
"__stpcpy",
|
||||
"memmem",
|
||||
"memmove",
|
||||
"mempcpy",
|
||||
"memset",
|
||||
"strcasestr",
|
||||
"strcat",
|
||||
"strchrnul",
|
||||
"strcmp",
|
||||
"strlcat",
|
||||
"strlcpy",
|
||||
"strlen",
|
||||
)
|
||||
]
|
||||
functions = sorted(functions, key=lambda f: f.name)
|
||||
|
||||
return_types = {
|
||||
|
|
|
|||
|
|
@ -130,27 +130,6 @@ __memcmpeq_checked(void *__s1, void *__s2, size_t __n)
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
__stpcpy_checked(void *__dest, void *__src)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __dest
|
||||
if (__dest == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Check for null pointer parameter: __src
|
||||
if (__src == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
__stpcpy(__dest, __src);
|
||||
// Assign return value and error code
|
||||
res.error_code = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
__stpncpy_checked(void *__dest, void *__src, size_t __n)
|
||||
{
|
||||
|
|
@ -430,43 +409,6 @@ memcpy_checked(void *__dest, void *__src, size_t __n)
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
memmove_checked(void *__dest, void *__src, size_t __n)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __dest
|
||||
if (__dest == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Check for null pointer parameter: __src
|
||||
if (__src == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
memmove(__dest, __src, __n);
|
||||
// Assign return value and error code
|
||||
res.error_code = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
memset_checked(void *__s, int __c, size_t __n)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __s
|
||||
if (__s == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
memset(__s, __c, __n);
|
||||
// Assign return value and error code
|
||||
res.error_code = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
rindex_checked(void *__s, int __c)
|
||||
{
|
||||
|
|
@ -579,27 +521,6 @@ strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc)
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strcat_checked(void *__dest, void *__src)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __dest
|
||||
if (__dest == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Check for null pointer parameter: __src
|
||||
if (__src == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
strcat(__dest, __src);
|
||||
// Assign return value and error code
|
||||
res.error_code = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strchr_checked(void *__s, int __c)
|
||||
{
|
||||
|
|
@ -616,33 +537,6 @@ strchr_checked(void *__s, int __c)
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strcmp_checked(void *__s1, void *__s2)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __s1
|
||||
if (__s1 == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Check for null pointer parameter: __s2
|
||||
if (__s2 == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
int original_result = strcmp(__s1, __s2);
|
||||
// Assign return value and error code
|
||||
if (original_result == 0) {
|
||||
res.error_code = 0;
|
||||
res.value.int_value = original_result;
|
||||
}
|
||||
else {
|
||||
res.error_code = -2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strcoll_checked(void *__s1, void *__s2)
|
||||
{
|
||||
|
|
@ -805,28 +699,6 @@ strerror_r_checked(int __errnum, void *__buf, size_t __buflen)
|
|||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strlen_checked(void *__s)
|
||||
{
|
||||
Result res;
|
||||
// Check for null pointer parameter: __s
|
||||
if (__s == NULL) {
|
||||
res.error_code = -1;
|
||||
return res;
|
||||
}
|
||||
// Execute the original function
|
||||
size_t original_result = strlen(__s);
|
||||
// Assign return value and error code
|
||||
if (original_result == 0) {
|
||||
res.error_code = 0;
|
||||
res.value.size_t_value = original_result;
|
||||
}
|
||||
else {
|
||||
res.error_code = -2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline Result
|
||||
strncasecmp_checked(void *__s1, void *__s2, size_t __n)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user