Ensure alignment of CMock_Guts_Buffer

Another attempt to fix something that was previously fixed by
73255670 but got reversed due to breaking something else.

The issue is that CMock_Guts_Buffer was unsigned char thus it
may have been unaligned (byte aligned). Portions from this buffer
where casted to a structure. On certain architectures alignment
must be maintained when accessing 32bit or 64 bit data and that
was not maintained with byte aligned array.

Instead of using attribute that may be complier specific, changing
type of array to long long.
This commit is contained in:
Krzysztof Chruscinski
2022-05-30 13:06:51 +02:00
parent 9934754d1f
commit 9b9f93ff7d
+4 -2
View File
@@ -25,8 +25,10 @@ static unsigned char* CMock_Guts_Buffer = NULL;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_ALIGN_SIZE;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
#else
static unsigned char CMock_Guts_Buffer[CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE];
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE;
static long long CMock_Guts_Space[(CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE + sizeof(long long) - 1) /
sizeof(long long)];
static unsigned char* CMock_Guts_Buffer = (unsigned char *)CMock_Guts_Space;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = sizeof(CMock_Guts_Space);
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
#endif