From 88668dd2d1a746bc03f77170a715c6b9a63ceb96 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 8 Oct 2011 09:15:36 +1100 Subject: [PATCH] ap_common: use intptr_t for pointer casts this allows building on systems with pointers that aren't 16 bits long --- libraries/AP_Common/AP_MetaClass.h | 4 ++-- libraries/AP_Common/c++.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Common/AP_MetaClass.h b/libraries/AP_Common/AP_MetaClass.h index b46f4308d1..1025fad962 100644 --- a/libraries/AP_Common/AP_MetaClass.h +++ b/libraries/AP_Common/AP_MetaClass.h @@ -108,7 +108,7 @@ public: /// @return An opaque handle /// Meta_handle meta_get_handle(void) const { - return ((Meta_handle)meta_type_id() << 16) | (uint16_t)this; + return ((Meta_handle)meta_type_id() << 16) | (uintptr_t)this; } /// Validates an AP_Meta_class handle. @@ -134,7 +134,7 @@ public: // Note that this implies that we cannot deal with objects in ROM or EEPROM, // but the constructor wouldn't be able to populate a vtable pointer there anyway... // - if ((uint16_t)candidate >= (RAMEND - 2)) { // -2 to account for the type_id + if ((uintptr_t)candidate >= (RAMEND - 2)) { // -2 to account for the type_id return NULL; } diff --git a/libraries/AP_Common/c++.cpp b/libraries/AP_Common/c++.cpp index c1307ea13f..e2fc437a2f 100644 --- a/libraries/AP_Common/c++.cpp +++ b/libraries/AP_Common/c++.cpp @@ -78,10 +78,10 @@ int freeMemory() { int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); + if ((intptr_t)__brkval == 0) + free_memory = ((intptr_t)&free_memory) - ((intptr_t)&__bss_end); else - free_memory = ((int)&free_memory) - ((int)__brkval); + free_memory = ((intptr_t)&free_memory) - ((intptr_t)__brkval); return free_memory; }