diff options
author | Max <max.suraev@fairwaves.co> | 2014-06-04 19:07:42 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2014-06-16 14:36:37 +0200 |
commit | e2c1390d1badbce07945d19ead64704ad4056309 (patch) | |
tree | 40de7446e9ed5e6eef0ff355edee0b40591f0fef /include/osmocom | |
parent | ece46d2a43193505ca586c3a6d73c2c8aba87006 (diff) |
bits: Add left circular shift function
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'include/osmocom')
-rw-r--r-- | include/osmocom/core/bits.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index f3045e47..1587b050 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -77,4 +77,14 @@ uint32_t osmo_revbytebits_8(uint8_t x); /* \brief reverse the bits of each byte in a given buffer */ void osmo_revbytebits_buf(uint8_t *buf, int len); +/*! \brief left circular shift + * \param[in] in The 16 bit unsigned integer to be rotated + * \param[in] shift Number of bits to shift \a in to, [0;16] bits + * \returns shifted value + */ +static inline uint16_t osmo_rol16(uint16_t in, unsigned shift) +{ + return (in << shift) | (in >> (16 - shift)); +} + /*! @} */ |