mongoose/src/arch_freertos_lwip.h

50 lines
1019 B
C
Raw Normal View History

2021-05-28 23:49:26 +01:00
#pragma once
#if MG_ARCH == MG_ARCH_FREERTOS_LWIP
#include <ctype.h>
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>
2022-01-14 12:33:06 +00:00
#include <string.h>
2021-05-28 23:49:26 +01:00
#if defined(__GNUC__)
2021-07-24 03:44:00 +01:00
#include <sys/stat.h>
2021-05-28 23:49:26 +01:00
#include <sys/time.h>
#else
struct timeval {
time_t tv_sec;
2022-01-14 12:33:06 +00:00
long tv_usec;
2021-05-28 23:49:26 +01:00
};
#endif
#include <FreeRTOS.h>
#include <task.h>
#include <lwip/sockets.h>
2021-08-11 09:56:46 +03:00
#if LWIP_SOCKET != 1
2021-09-15 07:43:48 +01:00
// Sockets support disabled in LWIP by default
2021-08-11 09:56:46 +03:00
#error Set LWIP_SOCKET variable to 1 (in lwipopts.h)
#endif
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(int cnt, size_t size) {
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 calloc(a, b) mg_calloc((a), (b))
#define free(a) vPortFree(a)
#define malloc(a) pvPortMalloc(a)
2022-08-20 00:02:36 +01:00
#define strdup(s) ((char *) mg_strdup(mg_str(s)).ptr)
2022-01-18 19:31:10 +00:00
#define mkdir(a, b) (-1)
2021-05-28 23:49:26 +01:00
2022-02-11 11:02:06 +00:00
#ifndef MG_IO_SIZE
#define MG_IO_SIZE 512
#endif
2021-05-28 23:49:26 +01:00
#endif // MG_ARCH == MG_ARCH_FREERTOS_LWIP