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