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