Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
iar_missing_defs.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 IAR Systems AB
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/*
8 * Basic macro definitions that gcc and clang provide on their own
9 * but that iccarm lacks. Only those that Zephyr requires are provided here.
10 */
11
12#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_ICCARM_MISSING_DEFS_H_
13#define ZEPHYR_INCLUDE_TOOLCHAIN_ICCARM_MISSING_DEFS_H_
14
15 /* We need to define NULL with a parenthesis around _NULL
16 * otherwise the DEBRACE macros won't work correctly
17 */
18
19#undef NULL
20#define NULL (_NULL)
21
22#if defined(__IAR_SYSTEMS_ICC__)
23#ifndef __CHAR_BIT__
24#define __CHAR_BIT__ __CHAR_BITS__
25#endif
26#define __SCHAR_MAX__ __SIGNED_CHAR_MAX__
27
28#define __INT_MAX__ __SIGNED_INT_MAX__
29#define __INT_WIDTH__ (__INT_SIZE__*8)
30#define __SIZEOF_INT__ __INT_SIZE__
31
32#define __SHRT_MAX__ __SIGNED_SHORT_MAX__
33#define __SHRT_WIDTH__ (__SHORT_SIZE__*8)
34#define __SIZEOF_SHORT__ __SHORT_SIZE__
35
36#define __LONG_MAX__ __SIGNED_LONG_MAX__
37#define __LONG_WIDTH__ (__LONG_SIZE__*8)
38#define __SIZEOF_LONG__ __LONG_SIZE__
39
40#define __LONG_LONG_MAX__ __SIGNED_LONG_LONG_MAX__
41#define __LONG_LONG_WIDTH__ (__LONG_LONG_SIZE__*8)
42#define __SIZEOF_LONG_LONG__ __LONG_LONG_SIZE__
43
44#define __INTMAX_MAX__ __INTMAX_T_MAX__
45#define __SIZEOF_INTMAX__ sizeof(__INTMAX_T_TYPE__)
46#define __INTMAX_WIDTH__ (__SIZEOF_INTMAX__*8)
47#define __UINTMAX_MAX__ __UINTMAX_T_MAX__
48#define __SIZEOF_UINTMAX__ sizeof(__UINTMAX_T_TYPE__)
49#define __UINTMAX_WIDTH__ (__SIZEOF_UINTMAX__*8)
50
51#define __INTPTR_MAX__ __INTPTR_T_MAX__
52#define __INTPTR_TYPE__ __INTPTR_T_TYPE__
53#define __INTPTR_WIDTH__ (__INTPTR_T_SIZE__*8)
54#define __SIZEOF_POINTER__ __INTPTR_T_SIZE__
55
56#define __PTRDIFF_MAX__ __PTRDIFF_T_MAX__
57#define __PTRDIFF_WIDTH__ (__PTRDIFF_T_SIZE__*8)
58#define __SIZEOF_PTRDIFF_T__ __PTRDIFF_T_SIZE__
59
60#define __UINTPTR_MAX__ __UINTPTR_T_MAX__
61#define __UINTPTR_TYPE__ __UINTPTR_T_TYPE__
62
63/*
64 * ICCARM already defines __SIZE_T_MAX__ as "unsigned int" but there is no way
65 * to safeguard that here with preprocessor equality.
66 */
67
68#define __SIZE_TYPE__ __SIZE_T_TYPE__
69#define __SIZE_MAX__ __SIZE_T_MAX__
70#define __SIZE_WIDTH__ ((__SIZEOF_SIZE_T__)*8)
71/* #define __SIZEOF_SIZE_T__ 4 */
72
73/*
74 * The following defines are inferred from the ICCARM provided defines
75 * already tested above.
76 */
77
78
79#define __INT8_MAX__ __INT8_T_MAX__
80#define __INT8_TYPE__ __INT8_T_TYPE__
81
82#define __UINT8_MAX__ __UINT8_T_MAX__
83#define __UINT8_TYPE__ __UINT8_T_TYPE__
84
85#define __INT16_MAX__ __INT16_T_MAX__
86#define __INT16_TYPE__ __INT16_T_TYPE__
87
88#define __UINT16_MAX__ __UINT16_T_MAX__
89#define __UINT16_TYPE__ __UINT16_T_TYPE__
90
91#define __INT32_MAX__ __INT32_T_MAX__
92#define __INT32_TYPE__ __INT32_T_TYPE__
93
94#define __UINT32_MAX__ __UINT32_T_MAX__
95#define __UINT32_TYPE__ __UINT32_T_TYPE__
96
97#define __INT64_MAX__ __INT64_T_MAX__
98#define __INT64_TYPE__ __INT64_T_TYPE__
99
100#define __UINT64_MAX__ __UINT64_T_MAX__
101#define __UINT64_TYPE__ __UINT64_T_TYPE__
102
103#define __INT_FAST8_MAX__ __INT_FAST8_T_MAX__
104#define __INT_FAST8_TYPE__ __INT_FAST8_T_TYPE__
105#define __INT_FAST8_WIDTH__ (__INT_FAST8_T_SIZE__*8)
106
107#define __INT_FAST16_MAX__ __INT_FAST16_T_MAX__
108#define __INT_FAST16_TYPE__ __INT_FAST16_T_TYPE__
109#define __INT_FAST16_WIDTH__ (__INT_FAST16_T_SIZE__*8)
110
111#define __INT_FAST32_MAX__ __INT_FAST32_T_MAX__
112#define __INT_FAST32_TYPE__ __INT_FAST32_T_TYPE__
113#define __INT_FAST32_WIDTH__ (__INT_FAST32_T_SIZE__*8)
114
115#define __INT_FAST64_MAX__ __INT_FAST64_T_MAX__
116#define __INT_FAST64_TYPE__ __INT_FAST64_T_TYPE__
117#define __INT_FAST64_WIDTH__ (__INT_FAST64_T_SIZE__*8)
118
119#define __INT_LEAST8_MAX__ __INT_LEAST8_T_MAX__
120#define __INT_LEAST8_TYPE__ __INT_LEAST8_T_TYPE__
121#define __INT_LEAST8_WIDTH__ (__INT_LEAST8_T_SIZE__*8)
122
123#define __INT_LEAST16_MAX__ __INT_LEAST16_T_MAX__
124#define __INT_LEAST16_TYPE__ __INT_LEAST16_T_TYPE__
125#define __INT_LEAST16_WIDTH__ (__INT_LEAST16_T_SIZE__*8)
126
127#define __INT_LEAST32_MAX__ __INT_LEAST32_T_MAX__
128#define __INT_LEAST32_TYPE__ __INT_LEAST32_T_TYPE__
129#define __INT_LEAST32_WIDTH__ (__INT_LEAST32_T_SIZE__*8)
130
131#define __INT_LEAST64_MAX__ __INT_LEAST64_T_MAX__
132#define __INT_LEAST64_TYPE__ __INT_LEAST64_T_TYPE__
133#define __INT_LEAST64_WIDTH__ (__INT_LEAST64_T_SIZE__*8)
134
135#define __UINT_FAST8_MAX__ __UINT_FAST8_T_MAX__
136#define __UINT_FAST8_TYPE__ __UINT_FAST8_T_TYPE__
137
138#define __UINT_FAST16_MAX__ __UINT_FAST16_T_MAX__
139#define __UINT_FAST16_TYPE__ __UINT_FAST16_T_TYPE__
140
141#define __UINT_FAST32_MAX__ __UINT_FAST32_T_MAX__
142#define __UINT_FAST32_TYPE__ __UINT_FAST32_T_TYPE__
143
144#define __UINT_FAST64_MAX__ __UINT_FAST64_T_MAX__
145#define __UINT_FAST64_TYPE__ __UINT_FAST64_T_TYPE__
146
147#define __UINT_LEAST8_MAX__ __UINT_LEAST8_T_MAX__
148#define __UINT_LEAST8_TYPE__ __UINT_LEAST8_T_TYPE__
149
150#define __UINT_LEAST16_MAX__ __UINT_LEAST16_T_MAX__
151#define __UINT_LEAST16_TYPE__ __UINT_LEAST16_T_TYPE__
152
153#define __UINT_LEAST32_MAX__ __UINT_LEAST32_T_MAX__
154#define __UINT_LEAST32_TYPE__ __UINT_LEAST32_T_TYPE__
155
156#define __UINT_LEAST64_MAX__ __UINT_LEAST64_T_MAX__
157#define __UINT_LEAST64_TYPE__ __UINT_LEAST64_T_TYPE__
158
159#endif /* __IAR_SYSTEMS_ICC__ */
160
161#endif