summaryrefslogtreecommitdiff
path: root/indra/llcommon/llunit.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-08-12 20:05:16 -0700
committerRichard Linden <none@none>2013-08-12 20:05:16 -0700
commitcc31b4ae7934010762b8aaaa7e190c74a1cd7820 (patch)
tree61bb7e622417a5223fa108522e16f6b7dee147f3 /indra/llcommon/llunit.h
parente340009fc59d59e59b2e8d903a884acb76b178eb (diff)
SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture queue bounces once per second
SH-4346 FIX: Interesting: some integer Statistics are displayed as floating point after crossing region boundary made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C") works, for example fixed unit tests remove llsimplestat
Diffstat (limited to 'indra/llcommon/llunit.h')
-rw-r--r--indra/llcommon/llunit.h64
1 files changed, 36 insertions, 28 deletions
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 2e4c0de28f..b135be48fa 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -517,71 +517,79 @@ struct LLGetUnitLabel<LLUnit<STORAGE_T, T> >
static const char* getUnitLabel() { return T::getUnitLabel(); }
};
-template<typename VALUE_TYPE>
+#define LL_UNIT_PROMOTE_VALUE(output_type, value) ((true ? (output_type)(1) : (value/value)) * value)
+
+template<typename INPUT_TYPE, typename OUTPUT_TYPE>
struct LLUnitLinearOps
{
- typedef LLUnitLinearOps<VALUE_TYPE> self_t;
- LLUnitLinearOps(VALUE_TYPE val) : mResult (val) {}
+ typedef LLUnitLinearOps<OUTPUT_TYPE, OUTPUT_TYPE> output_t;
+
+ LLUnitLinearOps(INPUT_TYPE val)
+ : mInput (val)
+ {}
- operator VALUE_TYPE() const { return mResult; }
- VALUE_TYPE mResult;
+ operator OUTPUT_TYPE() const { return (OUTPUT_TYPE)mInput; }
+ INPUT_TYPE mInput;
template<typename T>
- self_t operator * (T other)
+ output_t operator * (T other)
{
- return mResult * other;
+ return mInput * other;
}
template<typename T>
- self_t operator / (T other)
+ output_t operator / (T other)
{
- return mResult / other;
+ return LL_UNIT_PROMOTE_VALUE(OUTPUT_TYPE, mInput) / other;
}
template<typename T>
- self_t operator + (T other)
+ output_t operator + (T other)
{
- return mResult + other;
+ return mInput + other;
}
template<typename T>
- self_t operator - (T other)
+ output_t operator - (T other)
{
- return mResult - other;
+ return mInput - other;
}
};
-template<typename VALUE_TYPE>
+template<typename INPUT_TYPE, typename OUTPUT_TYPE>
struct LLUnitInverseLinearOps
{
- typedef LLUnitInverseLinearOps<VALUE_TYPE> self_t;
+ typedef LLUnitInverseLinearOps<OUTPUT_TYPE, OUTPUT_TYPE> output_t;
+
+ LLUnitInverseLinearOps(INPUT_TYPE val)
+ : mInput(val)
+ {}
- LLUnitInverseLinearOps(VALUE_TYPE val) : mResult (val) {}
- operator VALUE_TYPE() const { return mResult; }
- VALUE_TYPE mResult;
+ operator OUTPUT_TYPE() const { return (OUTPUT_TYPE)mInput; }
+ INPUT_TYPE mInput;
template<typename T>
- self_t operator * (T other)
+ output_t operator * (T other)
{
- return mResult / other;
+ return LL_UNIT_PROMOTE_VALUE(OUTPUT_TYPE, mInput) / other;
}
template<typename T>
- self_t operator / (T other)
+ output_t operator / (T other)
{
- return mResult * other;
+ return mInput * other;
}
template<typename T>
- self_t operator + (T other)
+ output_t operator + (T other)
{
- return mResult - other;
+ return mInput - other;
}
template<typename T>
- self_t operator - (T other)
+ output_t operator - (T other)
{
- return mResult + other;
+ return mInput + other;
}
};
@@ -613,13 +621,13 @@ struct unit_name
template<typename S1, typename S2> \
void ll_convert_units(LLUnit<S1, unit_name> in, LLUnit<S2, base_unit_name>& out) \
{ \
- out = LLUnit<S2, base_unit_name>((S2)(LLUnitLinearOps<S1>(in.value()) conversion_operation)); \
+ out = LLUnit<S2, base_unit_name>((S2)(LLUnitLinearOps<S1, S2>(in.value()) conversion_operation)); \
} \
\
template<typename S1, typename S2> \
void ll_convert_units(LLUnit<S1, base_unit_name> in, LLUnit<S2, unit_name>& out) \
{ \
- out = LLUnit<S2, unit_name>((S2)(LLUnitInverseLinearOps<S1>(in.value()) conversion_operation)); \
+ out = LLUnit<S2, unit_name>((S2)(LLUnitInverseLinearOps<S1, S2>(in.value()) conversion_operation)); \
}
//