Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
godlikepanos committed Aug 22, 2019
1 parent 5f0e86a commit b8c9029
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/anki/math/Functions.h
Expand Up @@ -107,9 +107,7 @@ inline T modf(T x, T& intPart)

/// The same as abs/fabs. For ints and floats.
template<typename T,
typename std::enable_if<std::is_floating_point<T>::value
|| (std::is_integral<T>::value && std::is_signed<T>::value),
int>::type = 0>
ANKI_ENABLE(std::is_floating_point<T>::value || (std::is_integral<T>::value && std::is_signed<T>::value))>
inline T absolute(const T f)
{
return (f < T(0)) ? -f : f;
Expand All @@ -121,6 +119,12 @@ inline T pow(const T x, const T power)
return T(std::pow(x, power));
}

template<typename T>
inline T log2(const T x)
{
return T(std::log2(x));
}

template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
inline Bool isZero(const T f, const T e = EPSILON)
{
Expand Down
10 changes: 6 additions & 4 deletions src/anki/util/StdTypes.h
Expand Up @@ -260,14 +260,16 @@ static constexpr long double operator""_ns(long double x)
using _SelfRef = decltype(((_selfFn*)0)()); \
using Self = std::remove_reference<_SelfRef>::type;

#if ANKI_COMPILER_GCC_COMPATIBLE
/// Redefine the sizeof because the default returns size_t and that will require casting when used with U32 for example.
#define _ANKI_SIZEOF(type) ((anki::U32)(sizeof(type)))
#define sizeof(type) _ANKI_SIZEOF(type)
# define _ANKI_SIZEOF(type) ((anki::U32)(sizeof(type)))
# define sizeof(type) _ANKI_SIZEOF(type)

/// Redefine the alignof because the default returns size_t and that will require casting when used with U32 for
/// example.
#define _ANKI_ALIGNOF(type) ((anki::U32)(alignof(type)))
#define alignof(type) _ANKI_ALIGNOF(type)
# define _ANKI_ALIGNOF(type) ((anki::U32)(alignof(type)))
# define alignof(type) _ANKI_ALIGNOF(type)
#endif
/// @}

} // end namespace anki
2 changes: 1 addition & 1 deletion tests/util/SparseArray.cpp
Expand Up @@ -324,7 +324,7 @@ ANKI_TEST(Util, SparseArrayBench)
StlMap stdMap(10, std::hash<int>(), std::equal_to<int>(), allocStl);

using AkMap = SparseArray<int, U32>;
AkMap akMap(256, log2(256), 0.90f);
AkMap akMap(256, log2(256.0f), 0.90f);

HighRezTimer timer;

Expand Down

0 comments on commit b8c9029

Please sign in to comment.