compiler_port.h
Go to the documentation of this file.
1/**
2 * @file compiler_port.h
3 * @brief Compiler specific definitions
4 *
5 * @section License
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * Copyright (C) 2010-2021 Oryx Embedded SARL. All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 *
25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
26 * @version 2.1.2
27 **/
28
29#ifndef _COMPILER_PORT_H
30#define _COMPILER_PORT_H
31
32//Dependencies
33#include <stddef.h>
34#include <stdint.h>
35#include <inttypes.h>
36
37//C++ guard
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42//Types
43typedef char char_t;
44typedef signed int int_t;
45typedef unsigned int uint_t;
46typedef uint32_t systime_t;
47
48#if !defined(R_TYPEDEFS_H) && !defined(USE_CHIBIOS_2)
49 typedef int bool_t;
50#endif
51
52#if defined(__linux__)
53 #define PRIuSIZE "zu"
54 #define PRIXSIZE "zX"
55 #define PRIuTIME "lu"
56#elif defined(_WIN32)
57 #define PRIuSIZE "Iu"
58 #define PRIXSIZE "IX"
59 #define PRIuTIME "lu"
60#elif defined(__XC32)
61 #define PRIuSIZE "u"
62 #define PRIXSIZE "X"
63 #define PRIuTIME "u"
64#elif defined(__CWCC__)
65 #define PRIu8 "u"
66 #define PRIu16 "u"
67 #define PRIu32 "u"
68 #define PRIx8 "x"
69 #define PRIx16 "x"
70 #define PRIx32 "x"
71 #define PRIX8 "X"
72 #define PRIX16 "X"
73 #define PRIX32 "X"
74 #define PRIuSIZE "u"
75 #define PRIXSIZE "X"
76 #define PRIuTIME "u"
77#else
78 #define PRIuSIZE "u"
79 #define PRIXSIZE "X"
80 #define PRIuTIME "lu"
81#endif
82
83#if defined(__CC_ARM)
84 #undef PRIu8
85 #define PRIu8 "u"
86 #undef PRIu16
87 #define PRIu16 "u"
88#endif
89
90#if defined(__MCUXPRESSO)
91 #undef PRIu64
92 #define PRIu64 "llu"
93#endif
94
95//ARM compiler V6?
96#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
97 char *strtok_r(char *s, const char *delim, char **last);
98//GCC compiler?
99#elif defined(__GNUC__)
100 int strcasecmp(const char *s1, const char *s2);
101 int strncasecmp(const char *s1, const char *s2, size_t n);
102 char *strtok_r(char *s, const char *delim, char **last);
103//CodeWarrior compiler?
104#elif defined(__CWCC__)
105 typedef uint32_t time_t;
106 int strcasecmp(const char *s1, const char *s2);
107 int strncasecmp(const char *s1, const char *s2, size_t n);
108 char *strtok_r(char *s, const char *delim, char **last);
109//TI ARM compiler?
110#elif defined(__TI_ARM__)
111 int strcasecmp(const char *s1, const char *s2);
112 int strncasecmp(const char *s1, const char *s2, size_t n);
113 char *strtok_r(char *s, const char *delim, char **last);
114//Microchip XC32 compiler?
115#elif defined(__XC32)
116 #define sprintf _sprintf
117 int sprintf(char * str, const char * format, ...);
118 int strcasecmp(const char *s1, const char *s2);
119 int strncasecmp(const char *s1, const char *s2, size_t n);
120 char *strtok_r(char *s, const char *delim, char **last);
121#endif
122
123//ARM compiler V6?
124#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
125 #undef __start_packed
126 #define __start_packed
127 #undef __end_packed
128 #define __end_packed __attribute__((packed))
129 #define __weak __attribute__((weak))
130//GCC compiler?
131#elif defined(__GNUC__)
132 #undef __start_packed
133 #define __start_packed
134 #undef __end_packed
135 #define __end_packed __attribute__((__packed__))
136 #define __weak __attribute__((weak))
137//ARM compiler?
138#elif defined(__CC_ARM)
139 #pragma anon_unions
140 #undef __start_packed
141 #define __start_packed __packed
142 #undef __end_packed
143 #define __end_packed
144//IAR compiler?
145#elif defined(__IAR_SYSTEMS_ICC__)
146 #undef __start_packed
147 #define __start_packed __packed
148 #undef __end_packed
149 #define __end_packed
150//CodeWarrior compiler?
151#elif defined(__CWCC__)
152 #undef __start_packed
153 #define __start_packed
154 #undef __end_packed
155 #define __end_packed
156 #define __weak
157//TI ARM compiler?
158#elif defined(__TI_ARM__)
159 #undef __start_packed
160 #define __start_packed
161 #undef __end_packed
162 #define __end_packed __attribute__((__packed__))
163 #define __weak
164//Win32 compiler?
165#elif defined(_WIN32)
166 #undef interface
167 #undef __start_packed
168 #define __start_packed
169 #undef __end_packed
170 #define __end_packed
171 #define __weak
172#endif
173
174//C++ guard
175#ifdef __cplusplus
176}
177#endif
178
179#endif
signed int int_t
Definition: compiler_port.h:44
unsigned int uint_t
Definition: compiler_port.h:45
char char_t
Definition: compiler_port.h:43
int bool_t
Definition: compiler_port.h:49
uint32_t systime_t
Definition: compiler_port.h:46
uint8_t n
uint16_t last
Definition: ipv4_frag.h:96
#define strtok_r(str, delim, p)
#define strncasecmp
#define strcasecmp