use waek platformPrint platformFree platformMalloc

This commit is contained in:
lyon 2021-10-05 12:34:08 +08:00
parent d1b0c9ec0c
commit b745c29217
6 changed files with 36 additions and 36 deletions

View File

@ -723,10 +723,10 @@ void obj_run(PikaObj* self, char* cmd) {
obj_setSysOut(self, sysOut);
obj_setErrorCode(self, errcode);
if (!strEqu("", sysOut)) {
printf("%s\r\n", sysOut);
platformPrintf("%s\r\n", sysOut);
}
if (0 != errcode) {
printf("[info] input commond: %s\r\n", cmd);
platformPrintf("[info] input commond: %s\r\n", cmd);
while (1)
;
}

View File

@ -9,19 +9,19 @@
PikaMemInfo pikaMemInfo = {0};
PIKA_WEAK void __pikaDisableIrqHandle(){
PIKA_WEAK void __pikaDisableIrqHandle() {
/* disable irq to support thread */
}
PIKA_WEAK void __pikaEnableIrqHandle(){
/* disable irq to support thread */
PIKA_WEAK void __pikaEnableIrqHandle() {
/* disable irq to support thread */
}
PIKA_WEAK void *pika_malloc(size_t size){
PIKA_WEAK void* platFormMalloc(size_t size) {
return malloc(size);
}
PIKA_WEAK void pika_free(void *ptr){
PIKA_WEAK void platFormFree(void* ptr) {
return free(ptr);
}
@ -31,10 +31,10 @@ void* pikaMalloc(uint32_t size) {
pikaMemInfo.heapUsedMax = pikaMemInfo.heapUsed;
}
__pikaDisableIrqHandle();
void* mem = pika_malloc(size);
void* mem = platFormMalloc(size);
__pikaEnableIrqHandle();
if (NULL == mem) {
printf("[error]: No heap space! Please reset the device.\r\n");
platformPrintf("[error]: No heap space! Please reset the device.\r\n");
while (1) {
}
}
@ -43,8 +43,8 @@ void* pikaMalloc(uint32_t size) {
void pikaFree(void* mem, uint32_t size) {
__pikaDisableIrqHandle();
pika_free(mem);
__pikaEnableIrqHandle();
platFormFree(mem);
__pikaEnableIrqHandle();
pikaMemInfo.heapUsed -= size;
}

View File

@ -10,15 +10,15 @@
#include <stdio.h>
#include <string.h>
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#define PIKA_WEAK __attribute__((weak))
#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
#define PIKA_WEAK __weak
#elif defined (__GNUC__) /* GNU GCC Compiler */
#define PIKA_WEAK __attribute__((weak))
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#define PIKA_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
#define PIKA_WEAK __weak
#elif defined(__GNUC__) /* GNU GCC Compiler */
#define PIKA_WEAK __attribute__((weak))
#endif
#define pika_printf(...) printf(__VA_ARGS__)
#define platformPrintf(...) printf(__VA_ARGS__)
typedef struct {
uint32_t heapUsed;

View File

@ -723,10 +723,10 @@ void obj_run(PikaObj* self, char* cmd) {
obj_setSysOut(self, sysOut);
obj_setErrorCode(self, errcode);
if (!strEqu("", sysOut)) {
printf("%s\r\n", sysOut);
platformPrintf("%s\r\n", sysOut);
}
if (0 != errcode) {
printf("[info] input commond: %s\r\n", cmd);
platformPrintf("[info] input commond: %s\r\n", cmd);
while (1)
;
}

View File

@ -9,19 +9,19 @@
PikaMemInfo pikaMemInfo = {0};
PIKA_WEAK void __pikaDisableIrqHandle(){
PIKA_WEAK void __pikaDisableIrqHandle() {
/* disable irq to support thread */
}
PIKA_WEAK void __pikaEnableIrqHandle(){
/* disable irq to support thread */
PIKA_WEAK void __pikaEnableIrqHandle() {
/* disable irq to support thread */
}
PIKA_WEAK void *pika_malloc(size_t size){
PIKA_WEAK void* platFormMalloc(size_t size) {
return malloc(size);
}
PIKA_WEAK void pika_free(void *ptr){
PIKA_WEAK void platFormFree(void* ptr) {
return free(ptr);
}
@ -31,10 +31,10 @@ void* pikaMalloc(uint32_t size) {
pikaMemInfo.heapUsedMax = pikaMemInfo.heapUsed;
}
__pikaDisableIrqHandle();
void* mem = pika_malloc(size);
void* mem = platFormMalloc(size);
__pikaEnableIrqHandle();
if (NULL == mem) {
printf("[error]: No heap space! Please reset the device.\r\n");
platformPrintf("[error]: No heap space! Please reset the device.\r\n");
while (1) {
}
}
@ -43,8 +43,8 @@ void* pikaMalloc(uint32_t size) {
void pikaFree(void* mem, uint32_t size) {
__pikaDisableIrqHandle();
pika_free(mem);
__pikaEnableIrqHandle();
platFormFree(mem);
__pikaEnableIrqHandle();
pikaMemInfo.heapUsed -= size;
}

View File

@ -10,15 +10,15 @@
#include <stdio.h>
#include <string.h>
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#define PIKA_WEAK __attribute__((weak))
#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
#define PIKA_WEAK __weak
#elif defined (__GNUC__) /* GNU GCC Compiler */
#define PIKA_WEAK __attribute__((weak))
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#define PIKA_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
#define PIKA_WEAK __weak
#elif defined(__GNUC__) /* GNU GCC Compiler */
#define PIKA_WEAK __attribute__((weak))
#endif
#define pika_printf(...) printf(__VA_ARGS__)
#define platformPrintf(...) printf(__VA_ARGS__)
typedef struct {
uint32_t heapUsed;