2021-05-28 23:49:26 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-06 01:03:33 +00:00
|
|
|
#if MG_ARCH == MG_ARCH_FREERTOS
|
2021-05-28 23:49:26 +01:00
|
|
|
|
2022-02-08 13:36:04 +00:00
|
|
|
#include <ctype.h>
|
2023-03-21 12:09:00 -03:00
|
|
|
#if !defined(MG_ENABLE_LWIP) || !MG_ENABLE_LWIP
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
2021-05-28 23:49:26 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
2022-08-14 23:46:33 +01:00
|
|
|
#include <stddef.h>
|
2021-05-28 23:49:26 +01:00
|
|
|
#include <stdint.h>
|
2021-09-29 12:13:02 +03:00
|
|
|
#include <stdio.h>
|
2024-02-26 12:05:35 +00:00
|
|
|
#include <stdlib.h> // rand(), strtol(), atoi()
|
2022-01-14 12:33:06 +00:00
|
|
|
#include <string.h>
|
2023-03-21 12:09:00 -03:00
|
|
|
#if defined(__ARMCC_VERSION)
|
|
|
|
#define mode_t size_t
|
2024-01-16 14:17:20 -03:00
|
|
|
#include <alloca.h>
|
2024-02-26 12:05:35 +00:00
|
|
|
#include <time.h>
|
|
|
|
#elif defined(__CCRH__)
|
2023-03-21 12:09:00 -03:00
|
|
|
#else
|
2023-01-20 18:09:21 -03:00
|
|
|
#include <sys/stat.h>
|
2023-03-21 12:09:00 -03:00
|
|
|
#endif
|
2021-05-28 23:49:26 +01:00
|
|
|
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
|
|
|
|
2022-11-06 01:03:33 +00:00
|
|
|
#ifndef MG_IO_SIZE
|
|
|
|
#define MG_IO_SIZE 512
|
2021-08-11 09:56:46 +03:00
|
|
|
#endif
|
|
|
|
|
2022-11-06 01:03:33 +00: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-28 23:49:26 +01:00
|
|
|
// Re-route calloc/free to the FreeRTOS's functions, don't use stdlib
|
2022-11-06 01:03:33 +00:00
|
|
|
static inline void *mg_calloc(size_t cnt, size_t size) {
|
2021-05-28 23:49:26 +01:00
|
|
|
void *p = pvPortMalloc(cnt * size);
|
2022-06-21 12:07:00 +01:00
|
|
|
if (p != NULL) memset(p, 0, size * cnt);
|
2021-05-28 23:49:26 +01:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2022-11-06 01:03:33 +00: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 11:02:06 +00:00
|
|
|
|
2022-11-06 01:03:33 +00:00
|
|
|
#endif // MG_ARCH == MG_ARCH_FREERTOS
|