Rename memcpy to local_memcpy in rs_allocations.c.
This is so it doesn't get linked with instead of the bionic version.
This fixes a crash when compiling with -O0, where the memcpy version
in rs_allocations.c was hanging around (not being inlined) and was
linked with in unrelated code, which led to a crash because the ABI
was not the expected.
Change-Id: I0c699bf3e0ed7b353d0e2108c52fcb19660eecc5
Signed-off-by: Verena Beckham <[email protected]>
(cherry picked from commit 6fb5a4f5411c16d36f123c7c2c9add4d937479ef)
Bug: 30312793
diff --git a/driver/runtime/rs_allocation.c b/driver/runtime/rs_allocation.c
index 490112c..fc60ea9 100644
--- a/driver/runtime/rs_allocation.c
+++ b/driver/runtime/rs_allocation.c
@@ -48,7 +48,7 @@
}
// TODO: this needs to be optimized, obviously
-static void memcpy(void* dst, const void* src, size_t size) {
+static void local_memcpy(void* dst, const void* src, size_t size) {
char* dst_c = (char*) dst;
const char* src_c = (const char*) src;
for (; size > 0; size--) {
@@ -281,7 +281,7 @@
Allocation_t *alloc = (Allocation_t *)a.p;
const uint8_t *p = (const uint8_t *)alloc->mHal.drvState.lod[0].mallocPtr;
const uint32_t eSize = alloc->mHal.state.elementSizeBytes;
- memcpy((void*)&p[eSize * x], ptr, eSize);
+ local_memcpy((void*)&p[eSize * x], ptr, eSize);
}
extern void __attribute__((overloadable))
@@ -290,7 +290,7 @@
const uint8_t *p = (const uint8_t *)alloc->mHal.drvState.lod[0].mallocPtr;
const uint32_t eSize = alloc->mHal.state.elementSizeBytes;
const uint32_t stride = alloc->mHal.drvState.lod[0].stride;
- memcpy((void*)&p[(eSize * x) + (y * stride)], ptr, eSize);
+ local_memcpy((void*)&p[(eSize * x) + (y * stride)], ptr, eSize);
}
extern void __attribute__((overloadable))
@@ -300,7 +300,7 @@
const uint32_t eSize = alloc->mHal.state.elementSizeBytes;
const uint32_t stride = alloc->mHal.drvState.lod[0].stride;
const uint32_t dimY = alloc->mHal.drvState.lod[0].dimY;
- memcpy((void*)&p[(eSize * x) + (y * stride) + (z * stride * dimY)], ptr, eSize);
+ local_memcpy((void*)&p[(eSize * x) + (y * stride) + (z * stride * dimY)], ptr, eSize);
}
#endif // RS_DEBUG_RUNTIME
@@ -412,13 +412,13 @@
void __rsAllocationVStoreXImpl_##T \
(rs_allocation a, const T val, uint32_t x, uint32_t y, uint32_t z) {\
T *val_ptr = (T*)rsOffsetNs(a, x, y, z); \
- memcpy(val_ptr, &val, sizeof(T)); \
+ local_memcpy(val_ptr, &val, sizeof(T)); \
} \
T __rsAllocationVLoadXImpl_##T \
(rs_allocation a, uint32_t x, uint32_t y, uint32_t z) { \
T result = {}; \
T* val_ptr = (T*)rsOffsetNs(a, x, y, z); \
- memcpy(&result, val_ptr, sizeof(T)); \
+ local_memcpy(&result, val_ptr, sizeof(T)); \
return result; \
}