Remove ndboolswitch, ndintrin, ndlocks, ndojectpool and ndstlallocator that aren't used anymore

master
Ansariel 2018-05-08 01:06:54 +02:00
parent c3ea573fb4
commit e01a68b601
7 changed files with 0 additions and 483 deletions

View File

@ -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
)

View File

@ -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

View File

@ -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 <Windows.h>
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

View File

@ -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

View File

@ -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

View File

@ -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<typename T, typename Lock = nd::locks::NoLock, int Alignment = 16, int AllocationSize = 32 > 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

View File

@ -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 <limits>
#include <stdlib.h>
#include <cstddef>
namespace nd
{
namespace stl
{
template <typename T> 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 <typename V> struct rebind
{ typedef allocator<V> other; };
pointer address (reference value) const
{ return &value; }
const_pointer address (const_reference value) const
{ return &value; }
allocator()
{ }
allocator(const allocator&)
{ }
template <typename V> allocator (const allocator<V>&)
{ }
~allocator()
{ }
size_type max_size () const
{ return std::numeric_limits<size_t>::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 <typename T1, typename T2> bool operator== (const allocator<T1>&, const allocator<T2>&)
{ return true; }
template <typename T1, typename T2> bool operator!= (const allocator<T1>&, const allocator<T2>&)
{ return false; }
}
}
#endif