Loading...
Searching...
No Matches
platform.h
1#ifndef CS_COMMON_PLATFORM_H_
2#define CS_COMMON_PLATFORM_H_
3
4/*
5 * For the "custom" platform, includes and dependencies can be
6 * provided through mg_locals.h.
7 */
8#define CS_P_CUSTOM 0
9#define CS_P_UNIX 1
10#define CS_P_WINDOWS 2
11#define CS_P_ESP32 15
12#define CS_P_ESP8266 3
13#define CS_P_CC3100 6
14#define CS_P_CC3200 4
15#define CS_P_CC3220 17
16#define CS_P_MSP432 5
17#define CS_P_TM4C129 14
18#define CS_P_MBED 7
19#define CS_P_WINCE 8
20#define CS_P_NXP_LPC 13
21#define CS_P_NXP_KINETIS 9
22#define CS_P_NRF51 12
23#define CS_P_NRF52 10
24#define CS_P_PIC32 11
25#define CS_P_RS14100 18
26#define CS_P_STM32 16
27#define CS_P_FLIPPER 19
28/* Next id: 20 */
29
30#ifndef CS_PLATFORM
31#define CS_PLATFORM CS_P_FLIPPER
32#endif
33
34#ifndef CS_PLATFORM
35#error "CS_PLATFORM is not specified and we couldn't guess it."
36#endif
37
38#define MG_NET_IF_SOCKET 1
39#define MG_NET_IF_SIMPLELINK 2
40#define MG_NET_IF_LWIP_LOW_LEVEL 3
41#define MG_NET_IF_PIC32 4
42#define MG_NET_IF_NULL 5
43
44#define MG_SSL_IF_OPENSSL 1
45#define MG_SSL_IF_MBEDTLS 2
46#define MG_SSL_IF_SIMPLELINK 3
47
48#if CS_PLATFORM == CS_P_FLIPPER
49#include "platforms/platform_flipper.h"
50#endif
51
52/* Common stuff */
53
54#if !defined(PRINTF_LIKE)
55#if defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)
56#define PRINTF_LIKE(f, a) __attribute__((format(printf, f, a)))
57#else
58#define PRINTF_LIKE(f, a)
59#endif
60#endif
61
62#if !defined(WEAK)
63#if(defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)) && \
64 !defined(_WIN32)
65#define WEAK __attribute__((weak))
66#else
67#define WEAK
68#endif
69#endif
70
71#ifdef __GNUC__
72#define NORETURN __attribute__((noreturn))
73#define NOINLINE __attribute__((noinline))
74#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
75#define NOINSTR __attribute__((no_instrument_function))
76#define DO_NOT_WARN_UNUSED __attribute__((unused))
77#else
78#define NORETURN
79#define NOINLINE
80#define WARN_UNUSED_RESULT
81#define NOINSTR
82#define DO_NOT_WARN_UNUSED
83#endif /* __GNUC__ */
84
85#ifndef ARRAY_SIZE
86#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
87#endif
88
89#endif /* CS_COMMON_PLATFORM_H_ */