ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
cmock_internals.h
1/* ==========================================
2 CMock Project - Automatic Mock Generation for C
3 Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4 [Released under MIT License. Please refer to license.txt for details]
5========================================== */
6
7#ifndef CMOCK_FRAMEWORK_INTERNALS_H
8#define CMOCK_FRAMEWORK_INTERNALS_H
9
10#include "unity.h"
11
12/* These are constants that the generated mocks have access to */
13extern const char *CMockStringOutOfMemory;
14extern const char *CMockStringCalledMore;
15extern const char *CMockStringCalledLess;
16extern const char *CMockStringCalledEarly;
17extern const char *CMockStringCalledLate;
18extern const char *CMockStringCallOrder;
19extern const char *CMockStringIgnPreExp;
20extern const char *CMockStringPtrPreExp;
21extern const char *CMockStringPtrIsNULL;
22extern const char *CMockStringExpNULL;
23extern const char *CMockStringMismatch;
24
25/* define CMOCK_MEM_DYNAMIC to grab memory as needed with malloc
26 * when you do that, CMOCK_MEM_SIZE is used for incremental size instead of
27 * total */
28#ifdef CMOCK_MEM_STATIC
29#undef CMOCK_MEM_DYNAMIC
30#endif
31
32#ifdef CMOCK_MEM_DYNAMIC
33#include <stdlib.h>
34#endif
35
36/* this is used internally during pointer arithmetic. make sure this type is the
37 * same size as the target's pointer type */
38#ifndef CMOCK_MEM_PTR_AS_INT
39#ifdef UNITY_POINTER_WIDTH
40#ifdef UNITY_INT_WIDTH
41#if UNITY_POINTER_WIDTH == UNITY_INT_WIDTH
42#define CMOCK_MEM_PTR_AS_INT unsigned int
43#endif
44#endif
45#endif
46#endif
47
48#ifndef CMOCK_MEM_PTR_AS_INT
49#ifdef UNITY_POINTER_WIDTH
50#ifdef UNITY_LONG_WIDTH
51#if UNITY_POINTER_WIDTH == UNITY_LONG_WIDTH
52#define CMOCK_MEM_PTR_AS_INT unsigned long
53#endif
54#if UNITY_POINTER_WIDTH > UNITY_LONG_WIDTH
55#define CMOCK_MEM_PTR_AS_INT unsigned long long
56#endif
57#endif
58#endif
59#endif
60
61#ifndef CMOCK_MEM_PTR_AS_INT
62#define CMOCK_MEM_PTR_AS_INT unsigned long
63#endif
64
65/* 0 for no alignment, 1 for 16-bit, 2 for 32-bit, 3 for 64-bit */
66#ifndef CMOCK_MEM_ALIGN
67#ifdef UNITY_LONG_WIDTH
68#if (UNITY_LONG_WIDTH == 16)
69#define CMOCK_MEM_ALIGN (1)
70#elif (UNITY_LONG_WIDTH == 32)
71#define CMOCK_MEM_ALIGN (2)
72#elif (UNITY_LONG_WIDTH == 64)
73#define CMOCK_MEM_ALIGN (3)
74#else
75#define CMOCK_MEM_ALIGN (2)
76#endif
77#else
78#define CMOCK_MEM_ALIGN (2)
79#endif
80#endif
81
82/* amount of memory to allow cmock to use in its internal heap */
83#ifndef CMOCK_MEM_SIZE
84#define CMOCK_MEM_SIZE (32768)
85#endif
86
87/* automatically calculated defs for easier reading */
88#define CMOCK_MEM_ALIGN_SIZE (CMOCK_MEM_INDEX_TYPE)(1u << CMOCK_MEM_ALIGN)
89#define CMOCK_MEM_ALIGN_MASK (CMOCK_MEM_INDEX_TYPE)(CMOCK_MEM_ALIGN_SIZE - 1)
90#define CMOCK_MEM_INDEX_SIZE \
91 (CMOCK_MEM_INDEX_TYPE)(CMOCK_MEM_PTR_AS_INT)( \
92 (sizeof(CMOCK_MEM_INDEX_TYPE) > CMOCK_MEM_ALIGN_SIZE) \
93 ? sizeof(CMOCK_MEM_INDEX_TYPE) \
94 : CMOCK_MEM_ALIGN_SIZE)
95
96#endif /* end of CMOCK_FRAMEWORK_INTERNALS_H */