1
0
forked from 0ad/0ad

fixes from work:

- correct AllocateAligned deleter and alignment value
- workaround for boost #pragma pack warnings
add DivideRoundUp

This was SVN commit r7439.
This commit is contained in:
janwas 2010-04-06 12:06:02 +00:00
parent 4c0d47707b
commit b4f680594b
3 changed files with 11 additions and 2 deletions

View File

@ -66,14 +66,14 @@ struct AlignedDeleter
template<class T>
void operator()(T* t)
{
_mm_free(t);
rtl_FreeAligned(t);
}
};
template<class T>
shared_ptr<T> AllocateAligned(size_t size)
{
return shared_ptr<T>((T*)rtl_AllocateAligned(size, x86_x64_L1CacheLineSize()), AlignedDeleter());
return shared_ptr<T>((T*)rtl_AllocateAligned(size, x86_x64_L2CacheLineSize()), AlignedDeleter());
}
#endif // #ifndef INCLUDED_SHARED_PTR

View File

@ -218,6 +218,12 @@ STMT(\
//-----------------------------------------------------------------------------
template<typename T>
T DivideRoundUp(T dividend, T divisor)
{
return (dividend + divisor-1) / divisor;
}
/// 16-bit saturating (does not overflow) addition.
extern u16 addusw(u16 x, u16 y);
/// 16-bit saturating (does not underflow) subtraction.

View File

@ -105,6 +105,8 @@
# define BOOST_ALL_DYN_LINK
#endif
// work around Boost bug (missing #pragma pack(pop)?)
#pragma pack(push, lib_precompiled)
// the following boost libraries have been included in TR1 and are
// thus deemed usable:
#include <boost/shared_ptr.hpp>
@ -121,6 +123,7 @@ using boost::function;
using boost::bind;
#include "lib/external_libraries/boost_filesystem.h"
#endif // !MINIMAL_PCH
#pragma pack(pop, lib_precompiled)
// (this must come after boost and common lib headers)
#include "lib/posix/posix.h"