diff options
author | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-08-19 23:09:56 +0000 |
---|---|---|
committer | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-08-19 23:09:56 +0000 |
commit | 2c8ea58e4d76f54c98d71d3fcc64bc29da490908 (patch) | |
tree | 2d5021474a22fcea2425903bdc288e1405701f7a /gnuradio-core/src/lib/general/gr_math.h | |
parent | 6039ba34aee72974b0eacc9408627a0fa038dc81 (diff) |
Merged features/mp-sched -r8915:9335 into the trunk. The trunk now
contains the SMP aware scheduler. This changeset
introduces a dependency on boost 1.35 or later.
See source:gnuradio/trunk/README.building-boost for additional info.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9336 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/general/gr_math.h')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_math.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/general/gr_math.h b/gnuradio-core/src/lib/general/gr_math.h index 957a0e12aa..f1bd208b8c 100644 --- a/gnuradio-core/src/lib/general/gr_math.h +++ b/gnuradio-core/src/lib/general/gr_math.h @@ -174,4 +174,48 @@ static inline unsigned int gr_branchless_quad_45deg_slicer(gr_complex x) return gr_branchless_quad_45deg_slicer(x.real(), x.imag()); } +/*! + * \param x any value + * \param pow2 must be a power of 2 + * \returns \p x rounded down to a multiple of \p pow2. + */ +static inline size_t +gr_p2_round_down(size_t x, size_t pow2) +{ + return x & -pow2; +} + +/*! + * \param x any value + * \param pow2 must be a power of 2 + * \returns \p x rounded up to a multiple of \p pow2. + */ +static inline size_t +gr_p2_round_up(size_t x, size_t pow2) +{ + return gr_p2_round_down(x + pow2 - 1, pow2); +} + +/*! + * \param x any value + * \param pow2 must be a power of 2 + * \returns \p x modulo \p pow2. + */ +static inline size_t +gr_p2_modulo(size_t x, size_t pow2) +{ + return x & (pow2 - 1); +} + +/*! + * \param x any value + * \param pow2 must be a power of 2 + * \returns \p pow2 - (\p x modulo \p pow2). + */ +static inline size_t +gr_p2_modulo_neg(size_t x, size_t pow2) +{ + return pow2 - gr_p2_modulo(x, pow2); +} + #endif /* _GR_MATH_H_ */ |