diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 2073cb8ca5..350305f573 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -256,18 +256,12 @@ set(llcommon_HEADER_FILES SET( llcommon_ND_SOURCE_FILES nd/ndexceptions.cpp - nd/ndintrin.cpp nd/ndlogthrottle.cpp nd/ndetw.cpp ) SET( llcommon_ND_HEADER_FILES - nd/ndboolswitch.h nd/ndexceptions.h - nd/ndintrin.h - nd/ndlocks.h nd/ndlogthrottle.h - nd/ndobjectpool.h - nd/ndstlallocator.h nd/ndetw.h ) diff --git a/indra/llcommon/nd/ndboolswitch.h b/indra/llcommon/nd/ndboolswitch.h deleted file mode 100644 index 5ec3d33624..0000000000 --- a/indra/llcommon/nd/ndboolswitch.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef NDBOOLSWITCH_H -#define NDBOOLSWITCH_H - -/** - * $LicenseInfo:firstyear=2013&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2013, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - -namespace nd -{ - namespace utils - { - class boolSwitch - { - bool *mLocation; - bool mOriginalValue; - bool mNeedsReset; - public: - boolSwitch( bool *aLocation, bool aValue ) - : mLocation( aLocation ) - , mNeedsReset( false ) - { - if( mLocation ) - { - mOriginalValue = *mLocation; - mNeedsReset = true; - *mLocation = aValue; - } - } - - ~boolSwitch( ) - { - reset(); - } - - void reset() - { - if( mLocation && mNeedsReset ) - *mLocation = mOriginalValue; - - mNeedsReset = false; - } - - }; - } -} - -#endif diff --git a/indra/llcommon/nd/ndintrin.cpp b/indra/llcommon/nd/ndintrin.cpp deleted file mode 100644 index 148e764791..0000000000 --- a/indra/llcommon/nd/ndintrin.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * $LicenseInfo:firstyear=2012&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2012, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - -#if LL_WINDOWS -#include "stdtypes.h" -#include "ndintrin.h" - -#include - -namespace nd -{ - namespace intrin - { - U32 CAS( volatile U32 *aLoc, U32 aCmp, U32 aVal ) - { return InterlockedCompareExchange( aLoc, aVal, aCmp ); } - - void* CASPTR( void * volatile *aLoc, void* aCmp, void * aVal ) - { return InterlockedCompareExchangePointer ( aLoc, aVal, aCmp ); } - - void FAA( volatile U32 *aLoc ) - { InterlockedIncrement( aLoc ); } - - U32 FAD( volatile U32 *aLoc ) - { return InterlockedDecrement( aLoc ); } - } -} - -#endif diff --git a/indra/llcommon/nd/ndintrin.h b/indra/llcommon/nd/ndintrin.h deleted file mode 100644 index b2a77d13f8..0000000000 --- a/indra/llcommon/nd/ndintrin.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef NDINTRIN_H -#define NDINTRIN_H - -/** - * $LicenseInfo:firstyear=2012&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2012, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - - -#include "stdtypes.h" - -#ifdef ND_DECL_GCC_INTRINSICS - -U32 __sync_val_compare_and_swap( volatile U32*, U32, U32 ); -void* __sync_val_compare_and_swap( void volatile * aLoc, void *aCmp, void *aVal ); -void __sync_add_and_fetch( volatile U32* aLoc, U32 ); -U32 __sync_sub_and_fetch( volatile U32 *aLoc, U32 ); - -#endif - -namespace nd -{ - namespace intrin - { - #if LL_WINDOWS - U32 CAS( volatile U32 *aLoc, U32 aCmp, U32 aVal ); - void* CASPTR( void * volatile *aLoc, void* aCmp, void * aVal ); - void FAA( volatile U32 *aLoc ); - U32 FAD( volatile U32 *aLoc ); - #else - inline U32 CAS( volatile U32 *aLoc, U32 aCmp, U32 aVal ) - { return __sync_val_compare_and_swap( aLoc, aCmp, aVal ); } - - inline void* CASPTR( void * volatile *aLoc, void* aCmp, void * aVal ) - { return __sync_val_compare_and_swap( aLoc, aCmp, aVal ); } - - inline void FAA( volatile U32 *aLoc ) - { __sync_add_and_fetch( aLoc, 1 ); } - - inline U32 FAD( volatile U32 *aLoc ) - { return __sync_sub_and_fetch( aLoc,1 ); } - #endif - } -} - -#endif diff --git a/indra/llcommon/nd/ndlocks.h b/indra/llcommon/nd/ndlocks.h deleted file mode 100644 index 84a62c1069..0000000000 --- a/indra/llcommon/nd/ndlocks.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * $LicenseInfo:firstyear=2012&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2012, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - -#ifndef NDLOCKS_H -#define NDLOCKS_H - -#include "ndintrin.h" - -namespace nd -{ - namespace locks - { - class NoLock - { - public: - void lock(){} - void unlock() {} - }; - - inline void lock( volatile U32 *aLock ) - { - while( 0 != nd::intrin::CAS( aLock, 0, 1 ) ) - ; - } - - inline void unlock ( volatile U32 *aLock ) - { - *aLock = 0; - } - - inline bool tryLock( volatile U32 *aLock ) - { - return 0 == nd::intrin::CAS( aLock, 0, 1 ); - } - - class LockHolder - { - volatile U32 *mLock; - public: - LockHolder( volatile U32 *aLock ) - : mLock( aLock ) - { - if( mLock ) - lock( mLock ); - } - - ~LockHolder() - { - if( mLock ) - unlock( mLock ); - } - - void attach( volatile U32 *aLock ) - { - mLock = aLock; - } - }; - } -} - -#endif diff --git a/indra/llcommon/nd/ndobjectpool.h b/indra/llcommon/nd/ndobjectpool.h deleted file mode 100644 index 56e26f6e80..0000000000 --- a/indra/llcommon/nd/ndobjectpool.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef NDOBJECTPOOL_H -#define NDOBJECTPOOL_H - -/** - * $LicenseInfo:firstyear=2013&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2013, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - -#include "ndlocks.h" - -namespace nd -{ - namespace objectpool - { - template class ObjectPool - { - struct ObjectMemory - { - ObjectMemory *mNext; - }; - - Lock mLock; - unsigned int mObjectSize; - ObjectMemory mMemory; - - void grow() - { - char *pMemory = reinterpret_cast< char* >( ll_aligned_malloc( mObjectSize * AllocationSize, Alignment ) ); - ObjectMemory *pPrev = &mMemory; - - for( int i = 0; i < AllocationSize; ++i ) - { - ObjectMemory *pCur = reinterpret_cast< ObjectMemory* >( pMemory ); - pPrev->mNext = pCur; - pPrev = pCur; - pPrev->mNext = 0; - - pMemory += mObjectSize; - } - } - - void destroy() - { - // Just leak. Process is exiting and the OS will clean up after us. This is ok. - } - - public: - ObjectPool() - { - mObjectSize = sizeof( T ) > sizeof(ObjectMemory) ? sizeof( T ) : sizeof(ObjectMemory); - mObjectSize += Alignment-1; - mObjectSize &= ~(Alignment-1); - mMemory.mNext = 0; - } - - ~ObjectPool() - { - this->destroy(); - } - - T *allocMemoryForObject() - { - mLock.lock(); - if( !mMemory.mNext ) - this->grow(); - - ObjectMemory *pRet = mMemory.mNext; - mMemory.mNext = pRet->mNext; - - mLock.unlock(); - - T *pT = reinterpret_cast< T* >( pRet ); - return pT; - } - - T *allocObject() - { - T *pT = this->allocMemoryForObject(); - new (pT)T; - return pT; - } - - void freeMemoryOfObject( void *aObject ) - { - mLock.lock(); - ObjectMemory *pMemory = reinterpret_cast< ObjectMemory* >( aObject ); - pMemory->mNext = mMemory.mNext; - mMemory.mNext = pMemory; - mLock.unlock(); - } - - void freeObject( T *aObject ) - { - if( !aObject) - return; - - aObject->~T(); - this->freeMemoryOfObject( aObject ); - } - }; - } -} - -#endif diff --git a/indra/llcommon/nd/ndstlallocator.h b/indra/llcommon/nd/ndstlallocator.h deleted file mode 100644 index a3b8ffec43..0000000000 --- a/indra/llcommon/nd/ndstlallocator.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef NDSTLALLOCATOR_H -#define NDSTLALLOCATOR_H - -/** - * $LicenseInfo:firstyear=2013&license=fsviewerlgpl$ - * Phoenix Firestorm Viewer Source Code - * Copyright (C) 2013, Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA - * http://www.firestormviewer.org - * $/LicenseInfo$ - */ - -#include -#include -#include - -namespace nd -{ - namespace stl - { - template class allocator - { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; - - template struct rebind - { typedef allocator other; }; - - pointer address (reference value) const - { return &value; } - - const_pointer address (const_reference value) const - { return &value; } - - allocator() - { } - - allocator(const allocator&) - { } - - template allocator (const allocator&) - { } - - ~allocator() - { } - - size_type max_size () const - { return std::numeric_limits::max() / sizeof(T); } - - pointer allocate (size_type num) - { return (pointer) ::malloc (num*sizeof(T)); } - - void construct (pointer p, const T& value) - { new((void*)p)T(value); } - - void destroy (pointer p) - { p->~T(); } - - void deallocate (pointer p, size_type num) - { ::free((void*)p); } - }; - - template bool operator== (const allocator&, const allocator&) - { return true; } - template bool operator!= (const allocator&, const allocator&) - { return false; } - } -} - -#endif