70 #if !(defined __ICCARM__) && !(defined _ADI_COMPILER) && !defined(__APPLE__) && !defined(__CRCC__) && !(defined(__arm__) && defined(__ARMCC_VERSION))
75 #ifdef XSENS_ASSERT_MALLOC
77 #undef XSENS_ASSERT_MALLOC
78 #define XSENS_ASSERT_MALLOC(x) assert(x)
80 #define XSENS_ASSERT_MALLOC(x)
83 #if !(defined __ICCARM__) && !(defined _ADI_COMPILER) && defined(XSENS_DEBUG)
88 int lastAllocIdx = -1;
89 void* lastAllocs[TRACK_ALLOCS];
91 void* lastFrees[TRACK_ALLOCS];
93 int lastAlignedAllocIdx = -1;
94 void* lastAlignedAllocs[TRACK_ALLOCS];
95 int lastAlignedFreeIdx = -1;
96 void* lastAlignedFrees[TRACK_ALLOCS];
101 # define _aligned_malloc(size, align) memalign(align, size)
102 # elif (defined __ICCARM__) || (defined _ADI_COMPILER) || (defined __CRCC__) || (defined IAR_ARM_CM3) || (defined __ARMEL__) || (defined(__arm__) && defined(__ARMCC_VERSION))
103 # define _aligned_malloc(a, b) malloc(a)
109 int err = posix_memalign(&rv, _Alignment, _Size);
117 #define _aligned_realloc(p, n, a) realloc(p, n)
118 #define _aligned_free(_Memory) free(_Memory)
127 void* ptr = malloc(sz);
129 lastAllocIdx = (lastAllocIdx + 1) & (TRACK_ALLOCS - 1);
130 lastAllocs[lastAllocIdx] = ptr;
133 void* ptr = malloc(sz);
143 lastFreeIdx = (lastFreeIdx + 1) & (TRACK_ALLOCS - 1);
144 lastFrees[lastFreeIdx] = ptr;
146 ptr = realloc(ptr, sz);
148 lastAllocIdx = (lastAllocIdx + 1) & (TRACK_ALLOCS - 1);
149 lastAllocs[lastAllocIdx] = ptr;
152 void* mem = realloc(ptr, sz);
162 lastFreeIdx = (lastFreeIdx + 1) & (TRACK_ALLOCS - 1);
163 lastFrees[lastFreeIdx] = ptr;
174 lastAlignedAllocIdx = (lastAlignedAllocIdx + 1) & (TRACK_ALLOCS - 1);
175 lastAlignedAllocs[lastAlignedAllocIdx] = ptr;
188 lastFreeIdx = (lastAlignedFreeIdx + 1) & (TRACK_ALLOCS - 1);
189 lastAlignedFrees[lastAlignedFreeIdx] = ptr;
193 lastAlignedAllocIdx = (lastAlignedAllocIdx + 1) & (TRACK_ALLOCS - 1);
194 lastAlignedAllocs[lastAlignedAllocIdx] = ptr;
207 lastAlignedFreeIdx = (lastAlignedFreeIdx + 1) & (TRACK_ALLOCS - 1);
208 lastAlignedFrees[lastAlignedFreeIdx] = ptr;