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