From f6a32897ba81c50b78ea728434588f8d8364dc68 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 21 Dec 2011 02:31:37 +0000 Subject: [PATCH] build correctly without DO_MEMORY_USAGE --- dtool/src/dtoolbase/dtoolbase.h | 41 ++++++++++++++++++++++++++++---- dtool/src/dtoolbase/memoryHook.h | 31 ------------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index f17612dedb..390ab6b408 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -336,12 +336,39 @@ #define ALIGN_16BYTE #endif +// Do we need to implement memory-alignment enforcement within the +// MemoryHook class, or will the underlying malloc implementation +// provide it automatically? +#if !defined(LINMATH_ALIGN) +// We don't actually require any special memory-alignment beyond what +// the underlying implementation is likely to provide anyway. +#undef MEMORY_HOOK_DO_ALIGN + +#elif defined(USE_MEMORY_DLMALLOC) +// This specialized malloc implementation can perform the required +// alignment. +#undef MEMORY_HOOK_DO_ALIGN + +#elif defined(USE_MEMORY_PTMALLOC2) +// But not this one. For some reason it crashes when we try to build +// it with alignment 16. So if we're using ptmalloc2, we need to +// enforce alignment externally. +#define MEMORY_HOOK_DO_ALIGN 1 + +#elif defined(IS_OSX) || defined(_WIN64) +// The OS-provided malloc implementation will do the required +// alignment. +#undef MEMORY_HOOK_DO_ALIGN + +#else +// Whoops, we need memory alignment, and we have to provide it ourselves. +#define MEMORY_HOOK_DO_ALIGN 1 + +#endif + /* Determine our memory-allocation requirements. */ -#if defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) -/* If we are using our own alternative malloc, or if we're building - with DO_MEMORY_USAGE in effect, it follows we need to use our - custom STL allocator. */ -#define USE_STL_ALLOCATOR 1 +#if defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) || defined(MEMORY_HOOK_DO_ALIGN) +/* In this case we have some custom memory management requirements. */ #else /* Otherwise, if we have no custom memory management needs at all, we might as well turn it all off and go straight to the OS-level @@ -349,6 +376,10 @@ #define USE_MEMORY_NOWRAPPERS 1 #endif +/* We must always use the STL allocator nowadays, because we have + redefined the constructors for pvector, pmap, etc. */ +#define USE_STL_ALLOCATOR 1 + /* We define the macros BEGIN_PUBLISH and END_PUBLISH to bracket functions and global variable definitions that are to be published diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index 2ee9439031..bdb57916fc 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -23,37 +23,6 @@ class DeletedBufferChain; - -// Do we need to implement memory-alignment enforcement within the -// MemoryHook class, or will the underlying malloc implementation -// provide it automatically? -#if !defined(LINMATH_ALIGN) -// We don't actually require any special memory-alignment beyond what -// the underlying implementation is likely to provide anyway. -#undef MEMORY_HOOK_DO_ALIGN - -#elif defined(USE_MEMORY_DLMALLOC) -// This specialized malloc implementation can perform the required -// alignment. -#undef MEMORY_HOOK_DO_ALIGN - -#elif defined(USE_MEMORY_PTMALLOC2) -// But not this one. For some reason it crashes when we try to build -// it with alignment 16. So if we're using ptmalloc2, we need to -// enforce alignment externally. -#define MEMORY_HOOK_DO_ALIGN 1 - -#elif defined(IS_OSX) || defined(_WIN64) -// The OS-provided malloc implementation will do the required -// alignment. -#undef MEMORY_HOOK_DO_ALIGN - -#else -// Whoops, we need memory alignment, and we have to provide it ourselves. -#define MEMORY_HOOK_DO_ALIGN 1 - -#endif - //////////////////////////////////////////////////////////////////// // Class : MemoryHook // Description : This class provides a wrapper around the various