summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2012-08-20 16:13:20 -0700
committer Mathieu Chartier <mathieuc@google.com> 2012-08-20 16:49:04 -0700
commit556fad3316f691e8ab39f187cfaae52e02c9f862 (patch)
tree9c2463da17f2b3da5d1084a77655ac5e146d6670
parent003e870b32ac2df76964d12ce7ef7706a2e66bff (diff)
Fix mac build pointer aliasing warnings
Now we cast to size_t before going to int32_t*, this removes the aliasing warning. Change-Id: I696f509a4d64c036b434f353293eb3c97eee7c18
-rw-r--r--src/heap.cc12
-rw-r--r--src/mark_stack.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/heap.cc b/src/heap.cc
index 3d84451d21..4576a9025a 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -497,8 +497,10 @@ void Heap::RecordAllocation(AllocSpace* space, const Object* obj) {
DCHECK_GT(size, 0u);
COMPILE_ASSERT(sizeof(size_t) == sizeof(int32_t),
int32_t_must_be_same_size_as_size_t_for_used_atomic_operations);
- android_atomic_add(size, reinterpret_cast<volatile int32_t*>(&num_bytes_allocated_));
- android_atomic_add(1, reinterpret_cast<volatile int32_t*>(&num_objects_allocated_));
+ android_atomic_add(size, reinterpret_cast<volatile int32_t*>(
+ reinterpret_cast<size_t>(&num_bytes_allocated_)));
+ android_atomic_add(1, reinterpret_cast<volatile int32_t*>(
+ reinterpret_cast<size_t>(&num_objects_allocated_)));
if (Runtime::Current()->HasStatsEnabled()) {
RuntimeStats* global_stats = Runtime::Current()->GetStats();
@@ -525,11 +527,13 @@ void Heap::RecordFree(size_t freed_objects, size_t freed_bytes) {
int32_t_must_be_same_size_as_size_t_for_used_atomic_operations);
DCHECK_LE(freed_objects, num_objects_allocated_);
android_atomic_add(-static_cast<int32_t>(freed_objects),
- reinterpret_cast<volatile int32_t*>(&num_objects_allocated_));
+ reinterpret_cast<volatile int32_t*>(
+ reinterpret_cast<size_t>(&num_objects_allocated_)));
DCHECK_LE(freed_bytes, num_bytes_allocated_);
android_atomic_add(-static_cast<int32_t>(freed_bytes),
- reinterpret_cast<volatile int32_t*>(&num_bytes_allocated_));
+ reinterpret_cast<volatile int32_t*>(
+ reinterpret_cast<size_t>(&num_bytes_allocated_)));
if (Runtime::Current()->HasStatsEnabled()) {
RuntimeStats* global_stats = Runtime::Current()->GetStats();
diff --git a/src/mark_stack.h b/src/mark_stack.h
index dada4a551a..224e6d4a78 100644
--- a/src/mark_stack.h
+++ b/src/mark_stack.h
@@ -48,7 +48,7 @@ class MarkStack {
DCHECK(obj != NULL);
DCHECK_NE(ptr_, limit_);
DCHECK_EQ(sizeof(ptr_), sizeof(int32_t));
- int32_t* ptr = reinterpret_cast<int32_t*>(&ptr_);
+ int32_t* ptr = reinterpret_cast<int32_t*>(reinterpret_cast<size_t>(&ptr_));
*reinterpret_cast<const Object**>(android_atomic_add(sizeof(*ptr_), ptr)) = obj;
}