mongoose/src/arch_freertos.h

51 lines
1.1 KiB
C
Raw Normal View History

2021-05-28 23:49:26 +01:00
#pragma once
#if MG_ARCH == MG_ARCH_FREERTOS
2021-05-28 23:49:26 +01: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>
#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>
#include <time.h>
#elif defined(__CCRH__)
2023-03-21 12:09:00 -03:00
#else
#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>
#ifndef MG_IO_SIZE
#define MG_IO_SIZE 512
2021-08-11 09:56:46 +03: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-28 23:49:26 +01: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-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;
}
#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
#endif // MG_ARCH == MG_ARCH_FREERTOS