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-2019 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 1.9.6
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 typedef 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 //CodeWarrior compiler?
91 #if defined(__CWCC__)
92  typedef uint32_t time_t;
93  int strcasecmp(const char *s1, const char *s2);
94  int strncasecmp(const char *s1, const char *s2, size_t n);
95  char *strtok_r(char *s, const char *delim, char **last);
96 //TI ARM C compiler?
97 #elif defined(__TI_ARM__)
98  int strcasecmp(const char *s1, const char *s2);
99  int strncasecmp(const char *s1, const char *s2, size_t n);
100  char *strtok_r(char *s, const char *delim, char **last);
101 #endif
102 
103 //Microchip XC32 compiler?
104 #if defined(__XC32)
105  #define sprintf _sprintf
106  int sprintf(char * str, const char * format, ...);
107  int strcasecmp(const char *s1, const char *s2);
108  int strncasecmp(const char *s1, const char *s2, size_t n);
109  char *strtok_r(char *s, const char *delim, char **last);
110 #endif
111 
112 //GCC compiler?
113 #if defined(__GNUC__)
114  #undef __start_packed
115  #define __start_packed
116  #undef __end_packed
117  #define __end_packed __attribute__((__packed__))
118  #define __weak __attribute__((weak))
119 //Keil MDK-ARM compiler?
120 #elif defined(__CC_ARM)
121  #pragma anon_unions
122  #undef __start_packed
123  #define __start_packed __packed
124  #undef __end_packed
125  #define __end_packed
126 //IAR C compiler?
127 #elif defined(__IAR_SYSTEMS_ICC__)
128  #undef __start_packed
129  #define __start_packed __packed
130  #undef __end_packed
131  #define __end_packed
132 //CodeWarrior compiler?
133 #elif defined(__CWCC__)
134  #undef __start_packed
135  #define __start_packed
136  #undef __end_packed
137  #define __end_packed
138  #define __weak
139 //TI ARM C compiler?
140 #elif defined(__TI_ARM__)
141  #undef __start_packed
142  #define __start_packed
143  #undef __end_packed
144  #define __end_packed __attribute__((__packed__))
145  #define __weak
146 //Win32 compiler?
147 #elif defined(_WIN32)
148  #undef interface
149  #undef __start_packed
150  #define __start_packed
151  #undef __end_packed
152  #define __end_packed
153  #define __weak
154 #endif
155 
156 //C++ guard
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif
int bool_t
Definition: compiler_port.h:49
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
unsigned int uint_t
Definition: compiler_port.h:45
uint32_t systime_t
Definition: compiler_port.h:46