[PATCH 2/3] Add left circular shift function

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Max Suraev Max.Suraev at fairwaves.co
Wed Jun 4 17:07:42 UTC 2014


---
 include/osmocom/core/bits.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h
index 5c9c7a6..c2c4863 100644
--- a/include/osmocom/core/bits.h
+++ b/include/osmocom/core/bits.h
@@ -78,6 +78,16 @@ 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));
+}
+
 /*! @} */
 
 #endif /* _OSMO_BITS_H */
-- 
1.9.1





More information about the baseband-devel mailing list