Skip to content

Commit 16c38b4

Browse files
committed
Add __UNALIGNED_UINT64_READ/WRITE
Extend unaligned access support macros to cover 64-bit accesses.
1 parent c9d4a4a commit 16c38b4

File tree

10 files changed

+183
-24
lines changed

10 files changed

+183
-24
lines changed

CMSIS/Core/Include/cmsis_armcc.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_armcc.h
33
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
4-
* @version V5.1.1
5-
* @date 30. July 2019
4+
* @version V5.2.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -98,6 +98,12 @@
9898
#ifndef __UNALIGNED_UINT32_READ
9999
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
100100
#endif
101+
#ifndef __UNALIGNED_UINT64_WRITE
102+
#define __UNALIGNED_UINT64_WRITE(addr, val) ((*((__packed uint64_t *)(addr))) = (val))
103+
#endif
104+
#ifndef __UNALIGNED_UINT64_READ
105+
#define __UNALIGNED_UINT64_READ(addr) (*((const __packed uint64_t *)(addr)))
106+
#endif
101107
#ifndef __ALIGNED
102108
#define __ALIGNED(x) __attribute__((aligned(x)))
103109
#endif

CMSIS/Core/Include/cmsis_armclang.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_armclang.h
33
* @brief CMSIS compiler armclang (Arm Compiler 6) header file
4-
* @version V5.2.1
5-
* @date 30. July 2019
4+
* @version V5.3.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -104,6 +104,22 @@
104104
#pragma clang diagnostic pop
105105
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
106106
#endif
107+
#ifndef __UNALIGNED_UINT64_WRITE
108+
#pragma clang diagnostic push
109+
#pragma clang diagnostic ignored "-Wpacked"
110+
/*lint -esym(9058, T_UINT64_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_WRITE */
111+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
112+
#pragma clang diagnostic pop
113+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
114+
#endif
115+
#ifndef __UNALIGNED_UINT64_READ
116+
#pragma clang diagnostic push
117+
#pragma clang diagnostic ignored "-Wpacked"
118+
/*lint -esym(9058, T_UINT64_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_READ */
119+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
120+
#pragma clang diagnostic pop
121+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
122+
#endif
107123
#ifndef __ALIGNED
108124
#define __ALIGNED(x) __attribute__((aligned(x)))
109125
#endif

CMSIS/Core/Include/cmsis_armclang_ltm.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_armclang_ltm.h
33
* @brief CMSIS compiler armclang (Arm Compiler 6) header file
4-
* @version V1.2.1
5-
* @date 30. July 2019
4+
* @version V1.3.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2018-2019 Arm Limited. All rights reserved.
@@ -104,6 +104,22 @@
104104
#pragma clang diagnostic pop
105105
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
106106
#endif
107+
#ifndef __UNALIGNED_UINT64_WRITE
108+
#pragma clang diagnostic push
109+
#pragma clang diagnostic ignored "-Wpacked"
110+
/*lint -esym(9058, T_UINT64_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_WRITE */
111+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
112+
#pragma clang diagnostic pop
113+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
114+
#endif
115+
#ifndef __UNALIGNED_UINT64_READ
116+
#pragma clang diagnostic push
117+
#pragma clang diagnostic ignored "-Wpacked"
118+
/*lint -esym(9058, T_UINT64_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_READ */
119+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
120+
#pragma clang diagnostic pop
121+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
122+
#endif
107123
#ifndef __ALIGNED
108124
#define __ALIGNED(x) __attribute__((aligned(x)))
109125
#endif

CMSIS/Core/Include/cmsis_compiler.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_compiler.h
33
* @brief CMSIS compiler generic header file
4-
* @version V5.1.0
5-
* @date 09. October 2018
4+
* @version V5.2.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
@@ -117,6 +117,14 @@
117117
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
118118
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
119119
#endif
120+
#ifndef __UNALIGNED_UINT64_WRITE
121+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
122+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
123+
#endif
124+
#ifndef __UNALIGNED_UINT64_READ
125+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
126+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
127+
#endif
120128
#ifndef __ALIGNED
121129
#define __ALIGNED(x) __attribute__((aligned(x)))
122130
#endif
@@ -189,6 +197,14 @@
189197
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
190198
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
191199
#endif
200+
#ifndef __UNALIGNED_UINT64_WRITE
201+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
202+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
203+
#endif
204+
#ifndef __UNALIGNED_UINT64_READ
205+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
206+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
207+
#endif
192208
#ifndef __ALIGNED
193209
#define __ALIGNED(x) __align(x)
194210
#endif
@@ -260,6 +276,14 @@
260276
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
261277
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
262278
#endif
279+
#ifndef __UNALIGNED_UINT64_WRITE
280+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
281+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
282+
#endif
283+
#ifndef __UNALIGNED_UINT64_READ
284+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
285+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
286+
#endif
263287
#ifndef __ALIGNED
264288
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
265289
#define __ALIGNED(x)

CMSIS/Core/Include/cmsis_gcc.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_gcc.h
33
* @brief CMSIS compiler GCC header file
4-
* @version V5.2.1
5-
* @date 30. July 2019
4+
* @version V5.3.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -107,6 +107,22 @@
107107
#pragma GCC diagnostic pop
108108
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
109109
#endif
110+
#ifndef __UNALIGNED_UINT64_WRITE
111+
#pragma GCC diagnostic push
112+
#pragma GCC diagnostic ignored "-Wpacked"
113+
#pragma GCC diagnostic ignored "-Wattributes"
114+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
115+
#pragma GCC diagnostic pop
116+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
117+
#endif
118+
#ifndef __UNALIGNED_UINT64_READ
119+
#pragma GCC diagnostic push
120+
#pragma GCC diagnostic ignored "-Wpacked"
121+
#pragma GCC diagnostic ignored "-Wattributes"
122+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
123+
#pragma GCC diagnostic pop
124+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
125+
#endif
110126
#ifndef __ALIGNED
111127
#define __ALIGNED(x) __attribute__((aligned(x)))
112128
#endif

CMSIS/Core/Include/cmsis_iccarm.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_iccarm.h
33
* @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
4-
* @version V5.1.1
5-
* @date 30. July 2019
4+
* @version V5.2.0
5+
* @date 19. December 2019
66
******************************************************************************/
77

88
//------------------------------------------------------------------------------
@@ -192,7 +192,7 @@ __IAR_FT uint16_t __iar_uint16_read(void const *ptr)
192192
#pragma language=extended
193193
__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
194194
{
195-
*(__packed uint16_t*)(ptr) = val;;
195+
*(__packed uint16_t*)(ptr) = val;
196196
}
197197
#pragma language=restore
198198
#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
@@ -214,7 +214,7 @@ __IAR_FT uint32_t __iar_uint32_read(void const *ptr)
214214
#pragma language=extended
215215
__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
216216
{
217-
*(__packed uint32_t*)(ptr) = val;;
217+
*(__packed uint32_t*)(ptr) = val;
218218
}
219219
#pragma language=restore
220220
#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
@@ -228,6 +228,28 @@ __packed struct __iar_u32 { uint32_t v; };
228228
#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
229229
#endif
230230

231+
#ifndef __UNALIGNED_UINT64_READ
232+
#pragma language=save
233+
#pragma language=extended
234+
__IAR_FT uint64_t __iar_uint64_read(void const *ptr)
235+
{
236+
return *(__packed uint64_t*)(ptr);
237+
}
238+
#pragma language=restore
239+
#define __UNALIGNED_UINT64_READ(PTR) __iar_uint64_read(PTR)
240+
#endif
241+
242+
#ifndef __UNALIGNED_UINT64_WRITE
243+
#pragma language=save
244+
#pragma language=extended
245+
__IAR_FT void __iar_uint64_write(void const *ptr, uint64_t val)
246+
{
247+
*(__packed uint64_t*)(ptr) = val;
248+
}
249+
#pragma language=restore
250+
#define __UNALIGNED_UINT64_WRITE(PTR,VAL) __iar_uint64_write(PTR,VAL)
251+
#endif
252+
231253
#ifndef __USED
232254
#if __ICCARM_V8
233255
#define __USED __attribute__((used))

CMSIS/Core_A/Include/cmsis_armcc.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_armcc.h
33
* @brief CMSIS compiler specific macros, functions, instructions
4-
* @version V1.0.4
5-
* @date 30. July 2019
4+
* @version V1.1.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -80,6 +80,12 @@
8080
#ifndef __UNALIGNED_UINT32_READ
8181
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
8282
#endif
83+
#ifndef __UNALIGNED_UINT64_WRITE
84+
#define __UNALIGNED_UINT64_WRITE(addr, val) ((*((__packed uint64_t *)(addr))) = (val))
85+
#endif
86+
#ifndef __UNALIGNED_UINT64_READ
87+
#define __UNALIGNED_UINT64_READ(addr) (*((const __packed uint64_t *)(addr)))
88+
#endif
8389
#ifndef __ALIGNED
8490
#define __ALIGNED(x) __attribute__((aligned(x)))
8591
#endif

CMSIS/Core_A/Include/cmsis_armclang.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_armclang.h
33
* @brief CMSIS compiler specific macros, functions, instructions
4-
* @version V1.1.2
5-
* @date 30. July 2019
4+
* @version V1.2.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -96,6 +96,22 @@
9696
#pragma clang diagnostic pop
9797
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
9898
#endif
99+
#ifndef __UNALIGNED_UINT64_WRITE
100+
#pragma clang diagnostic push
101+
#pragma clang diagnostic ignored "-Wpacked"
102+
/*lint -esym(9058, T_UINT64_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_WRITE */
103+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
104+
#pragma clang diagnostic pop
105+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
106+
#endif
107+
#ifndef __UNALIGNED_UINT64_READ
108+
#pragma clang diagnostic push
109+
#pragma clang diagnostic ignored "-Wpacked"
110+
/*lint -esym(9058, T_UINT64_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_READ */
111+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
112+
#pragma clang diagnostic pop
113+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
114+
#endif
99115
#ifndef __ALIGNED
100116
#define __ALIGNED(x) __attribute__((aligned(x)))
101117
#endif

CMSIS/Core_A/Include/cmsis_gcc.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_gcc.h
33
* @brief CMSIS compiler specific macros, functions, instructions
4-
* @version V1.2.1
5-
* @date 30. July 2019
4+
* @version V1.3.0
5+
* @date 19. December 2019
66
******************************************************************************/
77
/*
88
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
@@ -102,6 +102,21 @@
102102
#pragma GCC diagnostic pop
103103
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
104104
#endif
105+
#ifndef __UNALIGNED_UINT64_WRITE
106+
#pragma GCC diagnostic push
107+
#pragma GCC diagnostic ignored "-Wpacked"
108+
/*lint -esym(9058, T_UINT64_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT64_WRITE */
109+
__PACKED_STRUCT T_UINT64_WRITE { uint64_t v; };
110+
#pragma GCC diagnostic pop
111+
#define __UNALIGNED_UINT64_WRITE(addr, val) (void)((((struct T_UINT64_WRITE *)(void *)(addr))->v) = (val))
112+
#endif
113+
#ifndef __UNALIGNED_UINT64_READ
114+
#pragma GCC diagnostic push
115+
#pragma GCC diagnostic ignored "-Wpacked"
116+
__PACKED_STRUCT T_UINT64_READ { uint64_t v; };
117+
#pragma GCC diagnostic pop
118+
#define __UNALIGNED_UINT64_READ(addr) (((const struct T_UINT64_READ *)(const void *)(addr))->v)
119+
#endif
105120
#ifndef __ALIGNED
106121
#define __ALIGNED(x) __attribute__((aligned(x)))
107122
#endif

CMSIS/Core_A/Include/cmsis_iccarm.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**************************************************************************//**
22
* @file cmsis_iccarm.h
33
* @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
4-
* @version V5.0.7
5-
* @date 15. May 2019
4+
* @version V5.1.0
5+
* @date 19. December 2019
66
******************************************************************************/
77

88
//------------------------------------------------------------------------------
@@ -155,7 +155,7 @@
155155
#pragma language=extended
156156
__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
157157
{
158-
*(__packed uint16_t*)(ptr) = val;;
158+
*(__packed uint16_t*)(ptr) = val;
159159
}
160160
#pragma language=restore
161161
#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
@@ -177,12 +177,34 @@
177177
#pragma language=extended
178178
__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
179179
{
180-
*(__packed uint32_t*)(ptr) = val;;
180+
*(__packed uint32_t*)(ptr) = val;
181181
}
182182
#pragma language=restore
183183
#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
184184
#endif
185185

186+
#ifndef __UNALIGNED_UINT64_READ
187+
#pragma language=save
188+
#pragma language=extended
189+
__IAR_FT uint64_t __iar_uint64_read(void const *ptr)
190+
{
191+
return *(__packed uint64_t*)(ptr);
192+
}
193+
#pragma language=restore
194+
#define __UNALIGNED_UINT64_READ(PTR) __iar_uint64_read(PTR)
195+
#endif
196+
197+
#ifndef __UNALIGNED_UINT64_WRITE
198+
#pragma language=save
199+
#pragma language=extended
200+
__IAR_FT void __iar_uint64_write(void const *ptr, uint64_t val)
201+
{
202+
*(__packed uint64_t*)(ptr) = val;
203+
}
204+
#pragma language=restore
205+
#define __UNALIGNED_UINT64_WRITE(PTR,VAL) __iar_uint64_write(PTR,VAL)
206+
#endif
207+
186208
#if 0
187209
#ifndef __UNALIGNED_UINT32 /* deprecated */
188210
#pragma language=save

0 commit comments

Comments
 (0)