mongoose/src/arch_freertos.h

42 lines
978 B
C
Raw Normal View History

2021-05-29 06:49:26 +08:00
#pragma once
#if MG_ARCH == MG_ARCH_FREERTOS
2021-05-29 06:49:26 +08:00
#include <ctype.h>
// #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>
#include <stdlib.h> // rand(), strtol(), atoi()
2022-01-14 20:33:06 +08:00
#include <string.h>
#include <sys/stat.h>
2021-05-29 06:49:26 +08:00
#include <FreeRTOS.h>
#include <task.h>
#ifndef MG_IO_SIZE
#define MG_IO_SIZE 512
2021-08-11 14:56:46 +08:00
#endif
#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
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;
}
#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
#endif // MG_ARCH == MG_ARCH_FREERTOS