diff options
author | Adam Moss <moss@lindenlab.com> | 2009-03-09 23:42:07 +0000 |
---|---|---|
committer | Adam Moss <moss@lindenlab.com> | 2009-03-09 23:42:07 +0000 |
commit | 7573288ab3ede23f97bff2f5caefcb622e7e9842 (patch) | |
tree | 1429e7d758e282e123d31a21246603d0b9814273 /indra/llcommon | |
parent | 2d60d45aead0b49787fb8ad8b5a03614fe17c170 (diff) |
svn merge -r113780:113785
svn+ssh://svn.lindenlab.com/svn/linden/branches/moss/gst3-t113732
QAR-1333 linux gstreamer compatibility improvements and ADD_BUILD_TEST
improvements - combo merge
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/is_approx_equal_fraction.h | 62 | ||||
-rw-r--r-- | indra/llcommon/llapp.cpp | 6 |
2 files changed, 67 insertions, 1 deletions
diff --git a/indra/llcommon/is_approx_equal_fraction.h b/indra/llcommon/is_approx_equal_fraction.h new file mode 100644 index 0000000000..f95b148590 --- /dev/null +++ b/indra/llcommon/is_approx_equal_fraction.h @@ -0,0 +1,62 @@ +/** + * @file is_approx_equal_fraction.h + * @author Nat Goodspeed + * @date 2009-01-28 + * @brief lltut.h uses is_approx_equal_fraction(). Moved to this header + * file in llcommon so we can use lltut.h for llcommon tests without + * making llcommon depend on llmath. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_IS_APPROX_EQUAL_FRACTION_H) +#define LL_IS_APPROX_EQUAL_FRACTION_H + +#include "lldefs.h" +#include <cmath> + +/** + * Originally llmath.h contained two complete implementations of + * is_approx_equal_fraction(), with signatures as below, bodies identical save + * where they specifically mentioned F32/F64. Unifying these into a template + * makes sense -- but to preserve the compiler's overload-selection behavior, + * we still wrap the template implementation with the specific overloaded + * signatures. + */ +template <typename FTYPE> +inline BOOL is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) +{ + BOOL ret = TRUE; + FTYPE diff = (FTYPE) fabs(x - y); + + S32 diffInt = (S32) diff; + S32 diffFracTolerance = (S32) ((diff - (FTYPE) diffInt) * (1 << frac_bits)); + + // if integer portion is not equal, not enough bits were used for packing + // so error out since either the use case is not correct OR there is + // an issue with pack/unpack. should fail in either case. + // for decimal portion, make sure that the delta is no more than 1 + // based on the number of bits used for packing decimal portion. + if (diffInt != 0 || diffFracTolerance > 1) + { + ret = FALSE; + } + + return ret; +} + +/// F32 flavor +inline BOOL is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits) +{ + return is_approx_equal_fraction_impl<F32>(x, y, frac_bits); +} + +/// F64 flavor +inline BOOL is_approx_equal_fraction(F64 x, F64 y, U32 frac_bits) +{ + return is_approx_equal_fraction_impl<F64>(x, y, frac_bits); +} + +#endif /* ! defined(LL_IS_APPROX_EQUAL_FRACTION_H) */ diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 998b47450d..199315f34e 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -58,7 +58,7 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *); /* OSX doesn't support SIGRT* */ S32 LL_SMACKDOWN_SIGNAL = SIGUSR1; S32 LL_HEARTBEAT_SIGNAL = SIGUSR2; -# else +# else // linux or (assumed) other similar unixoid /* We want reliable delivery of our signals - SIGRT* is it. */ /* Old LinuxThreads versions eat SIGRTMIN+0 to SIGRTMIN+2, avoid those. */ /* Note that SIGRTMIN/SIGRTMAX may expand to a glibc function call with a @@ -559,7 +559,9 @@ void setup_signals() sigaction(LL_SMACKDOWN_SIGNAL, &act, NULL); // Asynchronous signals that are normally ignored +#ifndef LL_IGNORE_SIGCHLD sigaction(SIGCHLD, &act, NULL); +#endif // LL_IGNORE_SIGCHLD sigaction(SIGUSR2, &act, NULL); // Asynchronous signals that result in attempted graceful exit @@ -593,7 +595,9 @@ void clear_signals() sigaction(LL_SMACKDOWN_SIGNAL, &act, NULL); // Asynchronous signals that are normally ignored +#ifndef LL_IGNORE_SIGCHLD sigaction(SIGCHLD, &act, NULL); +#endif // LL_IGNORE_SIGCHLD // Asynchronous signals that result in attempted graceful exit sigaction(SIGHUP, &act, NULL); |