From 3b17e8fff1087790c2c65f6f8d56d6be4ce9511e Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 14 Apr 2015 15:43:22 +0200 Subject: [PATCH] Fix issue tracking memory allocations of more than 2GB at a time on 64-bit systems --- dtool/src/dtoolbase/atomicAdjustGccImpl.h | 2 +- dtool/src/dtoolbase/pallocator.T | 4 ++-- dtool/src/dtoolbase/typeHandle.cxx | 4 ++-- dtool/src/dtoolbase/typeHandle.h | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.h b/dtool/src/dtoolbase/atomicAdjustGccImpl.h index 2059addbbe..ec3050f14c 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.h @@ -26,7 +26,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_DTOOL AtomicAdjustGccImpl { public: -#if __GCC_ATOMIC_LONG_LOCK_FREE > __GCC_ATOMIC_INT_LOCK_FREE +#if __GCC_ATOMIC_LONG_LOCK_FREE >= __GCC_ATOMIC_INT_LOCK_FREE // If the long can be more lock-free than int, use it instead. typedef __attribute__ ((aligned (__SIZEOF_LONG__))) long Integer; #else diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index bb09b2633d..0a3c8a460a 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -51,7 +51,7 @@ allocate(TYPENAME pallocator_array::size_type n, TYPENAME allocator: size_t alloc_size = n * sizeof(Type); // We also need to store the total number of bytes we allocated. alloc_size += header_reserved_bytes; - _type_handle.inc_memory_usage(TypeHandle::MC_array, (int)alloc_size); + _type_handle.inc_memory_usage(TypeHandle::MC_array, alloc_size); void *ptr = (TYPENAME pallocator_array::pointer)PANDA_MALLOC_ARRAY(alloc_size); *((size_t *)ptr) = alloc_size; return (TYPENAME pallocator_array::pointer)(((char *)ptr) + header_reserved_bytes); @@ -69,7 +69,7 @@ deallocate(TYPENAME pallocator_array::pointer p, TYPENAME pallocator_array const size_t header_reserved_bytes = MemoryHook::get_header_reserved_bytes(); void *ptr = (void *)((char *)p - header_reserved_bytes); size_t alloc_size = *((size_t *)ptr); - _type_handle.dec_memory_usage(TypeHandle::MC_array, (int)alloc_size); + _type_handle.dec_memory_usage(TypeHandle::MC_array, alloc_size); PANDA_FREE_ARRAY(ptr); #else free(p); diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index b1d50fffaa..cca55062c1 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -49,7 +49,7 @@ get_memory_usage(MemoryClass memory_class) const { // allocated memory for objects of this type. //////////////////////////////////////////////////////////////////// void TypeHandle:: -inc_memory_usage(MemoryClass memory_class, int size) { +inc_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); if ((*this) != TypeHandle::none()) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); @@ -72,7 +72,7 @@ inc_memory_usage(MemoryClass memory_class, int size) { // the total allocated memory for objects of this type. //////////////////////////////////////////////////////////////////// void TypeHandle:: -dec_memory_usage(MemoryClass memory_class, int size) { +dec_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); if ((*this) != TypeHandle::none()) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index b060689c01..9573cb2ffb 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -125,12 +125,12 @@ PUBLISHED: #ifdef DO_MEMORY_USAGE int get_memory_usage(MemoryClass memory_class) const; - void inc_memory_usage(MemoryClass memory_class, int size); - void dec_memory_usage(MemoryClass memory_class, int size); + void inc_memory_usage(MemoryClass memory_class, size_t size); + void dec_memory_usage(MemoryClass memory_class, size_t size); #else static CONSTEXPR int get_memory_usage(MemoryClass) { return 0; } - INLINE void inc_memory_usage(MemoryClass, int) { } - INLINE void dec_memory_usage(MemoryClass, int) { } + INLINE void inc_memory_usage(MemoryClass, size_t) { } + INLINE void dec_memory_usage(MemoryClass, size_t) { } #endif // DO_MEMORY_USAGE INLINE int get_index() const;