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-2023 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.2.4
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 //ARM compiler V6?
38 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
39  #include <stdarg.h>
40 #endif
41 
42 //C++ guard
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 //Types
48 typedef char char_t;
49 typedef signed int int_t;
50 typedef unsigned int uint_t;
51 
52 #if !defined(R_TYPEDEFS_H) && !defined(USE_CHIBIOS_2)
53  typedef int bool_t;
54 #endif
55 
56 //ARM compiler?
57 #if defined(__CC_ARM)
58  #undef PRIu8
59  #undef PRIu16
60  #define PRIu8 "u"
61  #define PRIu16 "u"
62  #define PRIuSIZE "u"
63  #define PRIXSIZE "X"
64  #define PRIuTIME "lu"
65 //Microchip XC32 compiler?
66 #elif defined(__XC32)
67  #define PRIuSIZE "u"
68  #define PRIXSIZE "X"
69  #define PRIuTIME "u"
70 //NXP MCUXpresso compiler?
71 #elif defined(__MCUXPRESSO)
72  #undef PRIu64
73  #define PRIu64 "llu"
74  #define PRIuSIZE "u"
75  #define PRIXSIZE "X"
76  #define PRIuTIME "lu"
77 //NXP CodeWarrior compiler?
78 #elif defined(__CWCC__)
79  #define PRIu8 "u"
80  #define PRIu16 "u"
81  #define PRIu32 "u"
82  #define PRIx8 "x"
83  #define PRIx16 "x"
84  #define PRIx32 "x"
85  #define PRIX8 "X"
86  #define PRIX16 "X"
87  #define PRIX32 "X"
88  #define PRIuSIZE "u"
89  #define PRIXSIZE "X"
90  #define PRIuTIME "u"
91 //Espressif ESP-IDF compiler?
92 #elif defined(IDF_VER)
93  #undef PRIu8
94  #undef PRIu16
95  #undef PRIu32
96  #undef PRIx8
97  #undef PRIx16
98  #undef PRIx32
99  #undef PRIX8
100  #undef PRIX16
101  #undef PRIX32
102  #define PRIu8 "u"
103  #define PRIu16 "u"
104  #define PRIu32 "u"
105  #define PRIx8 "x"
106  #define PRIx16 "x"
107  #define PRIx32 "x"
108  #define PRIX8 "X"
109  #define PRIX16 "X"
110  #define PRIX32 "X"
111  #define PRIuSIZE "u"
112  #define PRIXSIZE "X"
113  #define PRIuTIME "lu"
114 //Linux GCC compiler
115 #elif defined(__linux__)
116  #define PRIuSIZE "zu"
117  #define PRIXSIZE "zX"
118  #define PRIuTIME "lu"
119 //Win32 compiler?
120 #elif defined(_WIN32)
121  #define PRIuSIZE "Iu"
122  #define PRIXSIZE "IX"
123  #define PRIuTIME "lu"
124 #else
125  #define PRIuSIZE "u"
126  #define PRIXSIZE "X"
127  #define PRIuTIME "lu"
128 #endif
129 
130 //ARM compiler V6?
131 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
132  int vsnprintf(char *dest, size_t size, const char *format, va_list ap);
133  char *strtok_r(char *s, const char *delim, char **last);
134 //GCC compiler?
135 #elif defined(__GNUC__)
136  int strcasecmp(const char *s1, const char *s2);
137  int strncasecmp(const char *s1, const char *s2, size_t n);
138  char *strtok_r(char *s, const char *delim, char **last);
139 //NXP CodeWarrior compiler?
140 #elif defined(__CWCC__)
141  typedef uint32_t time_t;
142  int strcasecmp(const char *s1, const char *s2);
143  int strncasecmp(const char *s1, const char *s2, size_t n);
144  char *strtok_r(char *s, const char *delim, char **last);
145 //TI ARM compiler?
146 #elif defined(__TI_ARM__)
147  int strcasecmp(const char *s1, const char *s2);
148  int strncasecmp(const char *s1, const char *s2, size_t n);
149  char *strtok_r(char *s, const char *delim, char **last);
150 //Microchip XC32 compiler?
151 #elif defined(__XC32)
152  #define sprintf _sprintf
153  int sprintf(char * str, const char * format, ...);
154  int strcasecmp(const char *s1, const char *s2);
155  int strncasecmp(const char *s1, const char *s2, size_t n);
156  char *strtok_r(char *s, const char *delim, char **last);
157 #endif
158 
159 //ARM compiler V6?
160 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
161  #undef __start_packed
162  #define __start_packed
163  #undef __end_packed
164  #define __end_packed __attribute__((packed))
165 //GCC compiler?
166 #elif defined(__GNUC__)
167  #undef __start_packed
168  #define __start_packed
169  #undef __end_packed
170  #define __end_packed __attribute__((__packed__))
171 //ARM compiler?
172 #elif defined(__CC_ARM)
173  #pragma anon_unions
174  #undef __start_packed
175  #define __start_packed __packed
176  #undef __end_packed
177  #define __end_packed
178 //IAR compiler?
179 #elif defined(__IAR_SYSTEMS_ICC__)
180  #undef __start_packed
181  #define __start_packed __packed
182  #undef __end_packed
183  #define __end_packed
184 //NXP CodeWarrior compiler?
185 #elif defined(__CWCC__)
186  #undef __start_packed
187  #define __start_packed
188  #undef __end_packed
189  #define __end_packed
190 //TI ARM compiler?
191 #elif defined(__TI_ARM__)
192  #undef __start_packed
193  #define __start_packed
194  #undef __end_packed
195  #define __end_packed __attribute__((__packed__))
196 //Win32 compiler?
197 #elif defined(_WIN32)
198  #undef interface
199  #undef __start_packed
200  #define __start_packed
201  #undef __end_packed
202  #define __end_packed
203 #endif
204 
205 #ifndef __weak_func
206  //ARM compiler V6?
207  #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
208  #define __weak_func __attribute__((weak))
209  //GCC compiler?
210  #elif defined(__GNUC__)
211  #define __weak_func __attribute__((weak))
212  //ARM compiler?
213  #elif defined(__CC_ARM)
214  #define __weak_func __weak
215  //IAR compiler?
216  #elif defined(__IAR_SYSTEMS_ICC__)
217  #define __weak_func __weak
218  //NXP CodeWarrior compiler?
219  #elif defined(__CWCC__)
220  #define __weak_func
221  //TI ARM compiler?
222  #elif defined(__TI_ARM__)
223  #define __weak_func __attribute__((weak))
224  //Win32 compiler?
225  #elif defined(_WIN32)
226  #define __weak_func
227  #endif
228 #endif
229 
230 //C++ guard
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif
int bool_t
Definition: compiler_port.h:53
signed int int_t
Definition: compiler_port.h:49
#define strncasecmp
uint16_t last
Definition: ipv4_frag.h:96
#define strtok_r(str, delim, p)
char char_t
Definition: compiler_port.h:48
uint8_t n
#define strcasecmp
uint8_t s
unsigned int uint_t
Definition: compiler_port.h:50