From 2aef3d85cf7d2a3c455b20eab790cc44974fadde Mon Sep 17 00:00:00 2001 From: Liny Date: Fri, 2 Nov 2012 13:43:29 -0700 Subject: [PATCH] Code cleanup to make it look less hacky. --- indra/llcommon/CMakeLists.txt | 6 +-- indra/llcommon/llmemory.h | 22 +---------- indra/llcommon/ndallocators.cpp | 2 +- .../ndallocators.h} | 38 ++++++++++++++++--- indra/llplugin/slplugin/CMakeLists.txt | 1 - .../media_plugins/gstreamer010/CMakeLists.txt | 1 - indra/media_plugins/quicktime/CMakeLists.txt | 1 - indra/media_plugins/webkit/CMakeLists.txt | 1 - indra/newview/CMakeLists.txt | 4 -- indra/win_crash_logger/CMakeLists.txt | 1 - 10 files changed, 36 insertions(+), 41 deletions(-) rename indra/{newview/ndallocators.cpp => llcommon/ndallocators.h} (62%) diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index c719ba4ac5..d2846e0bd4 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -109,6 +109,7 @@ set(llcommon_SOURCE_FILES timing.cpp u64.cpp ndintrin.cpp + ndallocators.cpp ndmemorypool.cpp ) @@ -266,6 +267,7 @@ set(llcommon_HEADER_FILES timer.h timing.h u64.h + ndallocators.h ndmemorypool.h ndintrin.h ndlocks.h @@ -277,10 +279,6 @@ set_source_files_properties(${llcommon_HEADER_FILES} list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) -if(WINDOWS) - list(APPEND llcommon_SOURCE_FILES ndallocators.cpp) -endif(WINDOWS) - if(LLCOMMON_LINK_SHARED) add_library (llcommon SHARED ${llcommon_SOURCE_FILES}) if(WINDOWS) diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index da8ff3542f..153ca6bb06 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,27 +27,7 @@ #define LLMEMORY_H #include "llmemtype.h" -namespace ndAllocators -{ -#ifdef ND_USE_ND_ALLOCS -void *ndMalloc( size_t aSize, size_t aAlign ); -void ndFree( void* ptr ); -void *ndRealloc( void *ptr, size_t aSize, size_t aAlign ); -#else -inline void *ndMalloc( size_t aSize, size_t aAlign ) -{ - return malloc( aSize ); -} -inline void ndFree( void* ptr ) -{ - return free( ptr ); -} -void *ndRealloc( void *ptr, size_t aSize, size_t aAlign ) -{ - return realloc( ptr, aSize ); -} -#endif -} +#include "ndallocators.h" #if LL_DEBUG inline void* ll_aligned_malloc( size_t size, int align ) diff --git a/indra/llcommon/ndallocators.cpp b/indra/llcommon/ndallocators.cpp index e265ddd83d..92f0f082be 100644 --- a/indra/llcommon/ndallocators.cpp +++ b/indra/llcommon/ndallocators.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "ndmemorypool.h" +#include "ndallocators.h" #ifdef ND_USE_ND_ALLOCS diff --git a/indra/newview/ndallocators.cpp b/indra/llcommon/ndallocators.h similarity index 62% rename from indra/newview/ndallocators.cpp rename to indra/llcommon/ndallocators.h index 5ff81deb41..cf8dfb6201 100644 --- a/indra/newview/ndallocators.cpp +++ b/indra/llcommon/ndallocators.h @@ -23,9 +23,35 @@ */ -// Yes, that a hack :( -// MSVC really complains badly if you do not compiler the pch header into every source files that uses it. -// Usage of pch could be disabled for ../llcommon/ndallocators in newview/CMakeLists.txt, but that's even more magic -// that needs to be merged when upstream changes CMakeLists.txt -#include "llviewerprecompiledheaders.h" -#include "../llcommon/ndallocators.cpp" +#ifndef NdAllocators_H +#define NdAllocators_H + + +#include +#include +#include +#include "ndmemorypool.h" + +namespace ndAllocators +{ +#ifdef ND_USE_ND_ALLOCS +void *ndMalloc( size_t aSize, size_t aAlign ); +void ndFree( void* ptr ); +void *ndRealloc( void *ptr, size_t aSize, size_t aAlign ); +#else +inline void *ndMalloc( size_t aSize, size_t aAlign ) +{ + return malloc( aSize ); +} +inline void ndFree( void* ptr ) +{ + return free( ptr ); +} +void *ndRealloc( void *ptr, size_t aSize, size_t aAlign ) +{ + return realloc( ptr, aSize ); +} +#endif +} + +#endif //NdAllocators_H \ No newline at end of file diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 5a62592c22..3fc54573a7 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -24,7 +24,6 @@ endif (DARWIN) set(SLPlugin_SOURCE_FILES slplugin.cpp - ../../llcommon/ndallocators.cpp ) if (DARWIN) diff --git a/indra/media_plugins/gstreamer010/CMakeLists.txt b/indra/media_plugins/gstreamer010/CMakeLists.txt index 3692c28868..5786bd1e25 100644 --- a/indra/media_plugins/gstreamer010/CMakeLists.txt +++ b/indra/media_plugins/gstreamer010/CMakeLists.txt @@ -42,7 +42,6 @@ set(media_plugin_gstreamer010_SOURCE_FILES media_plugin_gstreamer010.cpp llmediaimplgstreamer_syms.cpp llmediaimplgstreamervidplug.cpp - ../../llcommon/ndallocators.cpp ) set(media_plugin_gstreamer010_HEADER_FILES diff --git a/indra/media_plugins/quicktime/CMakeLists.txt b/indra/media_plugins/quicktime/CMakeLists.txt index 3c33eda9c7..f0b8f0d167 100644 --- a/indra/media_plugins/quicktime/CMakeLists.txt +++ b/indra/media_plugins/quicktime/CMakeLists.txt @@ -35,7 +35,6 @@ endif (DARWIN) set(media_plugin_quicktime_SOURCE_FILES media_plugin_quicktime.cpp - ../../llcommon/ndallocators.cpp ) add_library(media_plugin_quicktime diff --git a/indra/media_plugins/webkit/CMakeLists.txt b/indra/media_plugins/webkit/CMakeLists.txt index 72bb6133ca..b36291f0e8 100644 --- a/indra/media_plugins/webkit/CMakeLists.txt +++ b/indra/media_plugins/webkit/CMakeLists.txt @@ -43,7 +43,6 @@ endif(NOT WORD_SIZE EQUAL 32) set(media_plugin_webkit_SOURCE_FILES media_plugin_webkit.cpp - ../../llcommon/ndallocators.cpp ) set(media_plugin_webkit_HEADER_FILES diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 0effd00b73..2e309e1b61 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -738,10 +738,6 @@ else (HAS_OPENSIM_SUPPORT) ) endif (HAS_OPENSIM_SUPPORT) -if( ND_USE_ND_ALLOCS ) - list(APPEND viewer_SOURCE_FILES ndallocators.cpp) -endif( ND_USE_ND_ALLOCS ) - set(VIEWER_BINARY_NAME "firestorm-bin" CACHE STRING "The name of the viewer executable to create.") diff --git a/indra/win_crash_logger/CMakeLists.txt b/indra/win_crash_logger/CMakeLists.txt index bbb177e373..a298c1497c 100644 --- a/indra/win_crash_logger/CMakeLists.txt +++ b/indra/win_crash_logger/CMakeLists.txt @@ -26,7 +26,6 @@ set(win_crash_logger_SOURCE_FILES win_crash_logger.cpp llcrashloggerwindows.cpp llcrashlookupwindows.cpp - ../llcommon/ndallocators.cpp ) set(win_crash_logger_HEADER_FILES