2021-05-29 06:49:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-06 09:03:33 +08:00
|
|
|
#if MG_ARCH == MG_ARCH_FREERTOS
|
2021-05-29 06:49:26 +08:00
|
|
|
|
2022-02-08 21:36:04 +08:00
|
|
|
#include <ctype.h>
|
2022-11-06 09:03:33 +08:00
|
|
|
// #include <errno.h> // Cannot include errno - might conflict with lwip!
|
2021-05-29 06:49:26 +08:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
2022-08-15 06:46:33 +08:00
|
|
|
#include <stddef.h>
|
2021-05-29 06:49:26 +08:00
|
|
|
#include <stdint.h>
|
2021-09-29 17:13:02 +08:00
|
|
|
#include <stdio.h>
|
2022-11-24 21:15:03 +08:00
|
|
|
#include <stdlib.h> // rand(), strtol(), atoi()
|
2022-01-14 20:33:06 +08:00
|
|
|
#include <string.h>
|
2023-01-21 05:09:21 +08:00
|
|
|
#include <sys/stat.h>
|
2021-05-29 06:49:26 +08:00
|
|
|
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
|
|
|
|
2022-11-06 09:03:33 +08:00
|
|
|
#ifndef MG_IO_SIZE
|
|
|
|
#define MG_IO_SIZE 512
|
2021-08-11 14:56:46 +08:00
|
|
|
#endif
|
|
|
|
|
2022-11-06 09:03:33 +08:00
|
|
|
#define calloc(a, b) mg_calloc(a, b)
|
|
|
|
#define free(a) vPortFree(a)
|
|
|
|
#define malloc(a) pvPortMalloc(a)
|
|
|
|
#define strdup(s) ((char *) mg_strdup(mg_str(s)).ptr)
|
|
|
|
|
2021-05-29 06:49:26 +08:00
|
|
|
// Re-route calloc/free to the FreeRTOS's functions, don't use stdlib
|
2022-11-06 09:03:33 +08:00
|
|
|
static inline void *mg_calloc(size_t cnt, size_t size) {
|
2021-05-29 06:49:26 +08:00
|
|
|
void *p = pvPortMalloc(cnt * size);
|
2022-06-21 19:07:00 +08:00
|
|
|
if (p != NULL) memset(p, 0, size * cnt);
|
2021-05-29 06:49:26 +08:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2022-11-06 09:03:33 +08:00
|
|
|
#define mkdir(a, b) mg_mkdir(a, b)
|
|
|
|
static inline int mg_mkdir(const char *path, mode_t mode) {
|
|
|
|
(void) path, (void) mode;
|
|
|
|
return -1;
|
|
|
|
}
|
2022-02-11 19:02:06 +08:00
|
|
|
|
2022-11-06 09:03:33 +08:00
|
|
|
#endif // MG_ARCH == MG_ARCH_FREERTOS
|