[realtek-ambz] Update stdlib compatibility
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-02. */
|
||||
|
||||
// fix conflicting declaration with ArduinoCore-API
|
||||
#ifdef ARDUINO
|
||||
#define boolean boolean_rtl
|
||||
#endif
|
||||
#include_next "basic_types.h"
|
||||
#undef boolean
|
||||
|
||||
12
cores/realtek-ambz/base/fixups/hal_crypto.h
Normal file
12
cores/realtek-ambz/base/fixups/hal_crypto.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
#include_next "hal_crypto.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
// mbedTLS (ssl_tls.c) uses S1 and S2 as variable name
|
||||
// rtl8710b_pinmux.h defines them as integer values
|
||||
#if defined(CONFIG_SSL_RSA) && defined(RTL_HW_CRYPTO) && defined(S1)
|
||||
#undef S1
|
||||
#undef S2
|
||||
#endif
|
||||
9
cores/realtek-ambz/base/fixups/memproc.h
Normal file
9
cores/realtek-ambz/base/fixups/memproc.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define _memcmp memcmp
|
||||
#define _memcpy memcpy
|
||||
#define _memset memset
|
||||
@@ -0,0 +1,3 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
#include "../platform_stdlib.h"
|
||||
22
cores/realtek-ambz/base/fixups/platform_stdlib.h
Normal file
22
cores/realtek-ambz/base/fixups/platform_stdlib.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
#pragma once
|
||||
|
||||
// platform_stdlib.h in amb1_sdk includes some stdlib headers,
|
||||
// as well as Realtek's stdlib replacement headers. It also defines
|
||||
// some macros to map stdlib functions to SDK functions, so it's
|
||||
// generally just not needed at all.
|
||||
|
||||
// This is also the only file that publicly includes strproc.h and memproc.h,
|
||||
// so this fixup resolves all these issues.
|
||||
|
||||
#include <stdarg.h> /* va_list */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "basic_types.h" // fixup: replaces typedef boolean for Arduino compatibility
|
||||
#include "memproc.h" // fixup: redirects to stdlib
|
||||
#include "strproc.h" // fixup: redirects to stdlib
|
||||
|
||||
#include "diag.h"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,8 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-11-26. */
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
// make <strproc.h> not #define isprint, isdigit, isxdigit, islower and isspace
|
||||
// this conflicts with stdlib <ctype.h>, if <strproc.h> is included before it
|
||||
#pragma once
|
||||
|
||||
// include <ctype.h> before to get all its macros
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
// make 'static inline int _tolower' unused
|
||||
#undef _tolower
|
||||
#define _tolower _tolower_dummy
|
||||
|
||||
#include_next <strproc.h>
|
||||
|
||||
// restore _tolower to ctype's macro
|
||||
#undef _tolower
|
||||
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
|
||||
|
||||
// dirty fix for compiling mbedTLS which uses _B as variable name
|
||||
#ifdef CONFIG_SSL_RSA
|
||||
#undef _B
|
||||
#endif
|
||||
#define _strcpy strcpy
|
||||
#define _strlen strlen
|
||||
|
||||
115
cores/realtek-ambz/base/wraps/stdlib.c
Normal file
115
cores/realtek-ambz/base/wraps/stdlib.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-14. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ROM __attribute__((long_call))
|
||||
|
||||
ROM int prvAtoi(const char *str);
|
||||
ROM long simple_strtol(const char *str, char **str_end, int base);
|
||||
ROM unsigned long simple_strtoul(const char *str, char **str_end, int base);
|
||||
ROM int Rand();
|
||||
ROM char *__rtl_strcat_v1_00(char *dest, const char *src);
|
||||
ROM char *_strcpy(char *dest, const char *src);
|
||||
ROM char *__rtl_strncat_v1_00(char *dest, const char *src, size_t count);
|
||||
ROM char *_strncpy(char *dest, const char *src, size_t count);
|
||||
ROM char *_strchr(const char *str, int ch);
|
||||
ROM int prvStrCmp(const char *lhs, const char *rhs);
|
||||
ROM size_t prvStrLen(const char *str);
|
||||
ROM int _strncmp(const char *lhs, const char *rhs, size_t count);
|
||||
ROM char *_strpbrk(const char *dest, const char *breakset);
|
||||
ROM char *prvStrStr(const char *str, const char *substr);
|
||||
ROM char *prvStrtok(char *str, const char *delim);
|
||||
ROM void *__rtl_memchr_v1_00(const void *ptr, int ch, size_t count);
|
||||
ROM int _memcmp(const void *lhs, const void *rhs, size_t count);
|
||||
ROM void *_memcpy(void *dest, const void *src, size_t count);
|
||||
ROM void *__rtl_memmove_v1_00(void *dest, const void *src, size_t count);
|
||||
ROM void *_memset(void *dest, int ch, size_t count);
|
||||
ROM char *_strsep(char **stringp, const char *delim);
|
||||
|
||||
int __wrap_atoi(const char *str) {
|
||||
return prvAtoi(str);
|
||||
}
|
||||
|
||||
long __wrap_atol(const char *str) {
|
||||
return simple_strtol(str, NULL, 10);
|
||||
}
|
||||
|
||||
long __wrap_strtol(const char *str, char **str_end, int base) {
|
||||
return simple_strtol(str, str_end, base);
|
||||
}
|
||||
|
||||
unsigned long __wrap_strtoul(const char *str, char **str_end, int base) {
|
||||
return simple_strtoul(str, str_end, base);
|
||||
}
|
||||
|
||||
int __wrap_rand() {
|
||||
return Rand();
|
||||
}
|
||||
|
||||
char *__wrap_strcat(char *dest, const char *src) {
|
||||
return __rtl_strcat_v1_00(dest, src);
|
||||
}
|
||||
|
||||
char *__wrap_strcpy(char *dest, const char *src) {
|
||||
return _strcpy(dest, src);
|
||||
}
|
||||
|
||||
char *__wrap_strncat(char *dest, const char *src, size_t count) {
|
||||
return __rtl_strncat_v1_00(dest, src, count);
|
||||
}
|
||||
|
||||
char *__wrap_strncpy(char *dest, const char *src, size_t count) {
|
||||
return _strncpy(dest, src, count);
|
||||
}
|
||||
|
||||
char *__wrap_strchr(const char *str, int ch) {
|
||||
return _strchr(str, ch);
|
||||
}
|
||||
|
||||
int __wrap_strcmp(const char *lhs, const char *rhs) {
|
||||
return prvStrCmp(lhs, rhs);
|
||||
}
|
||||
|
||||
size_t __wrap_strlen(const char *str) {
|
||||
return prvStrLen(str);
|
||||
}
|
||||
|
||||
int __wrap_strncmp(const char *lhs, const char *rhs, size_t count) {
|
||||
return _strncmp(lhs, rhs, count);
|
||||
}
|
||||
|
||||
char *__wrap_strpbrk(const char *dest, const char *breakset) {
|
||||
return _strpbrk(dest, breakset);
|
||||
}
|
||||
|
||||
char *__wrap_strstr(const char *str, const char *substr) {
|
||||
return prvStrStr(str, substr);
|
||||
}
|
||||
|
||||
char *__wrap_strtok(char *str, const char *delim) {
|
||||
return prvStrtok(str, delim);
|
||||
}
|
||||
|
||||
void *__wrap_memchr(const void *ptr, int ch, size_t count) {
|
||||
return __rtl_memchr_v1_00(ptr, ch, count);
|
||||
}
|
||||
|
||||
int __wrap_memcmp(const void *lhs, const void *rhs, size_t count) {
|
||||
return _memcmp(lhs, rhs, count);
|
||||
}
|
||||
|
||||
void *__wrap_memcpy(void *dest, const void *src, size_t count) {
|
||||
return _memcpy(dest, src, count);
|
||||
}
|
||||
|
||||
void *__wrap_memmove(void *dest, const void *src, size_t count) {
|
||||
return __rtl_memmove_v1_00(dest, src, count);
|
||||
}
|
||||
|
||||
void *__wrap_memset(void *dest, int ch, size_t count) {
|
||||
return _memset(dest, ch, count);
|
||||
}
|
||||
|
||||
char *__wrap_strsep(char **stringp, const char *delim) {
|
||||
return _strsep(stringp, delim);
|
||||
}
|
||||
Reference in New Issue
Block a user