[PATCH] Fix bit reversion 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/OpenBSC@lists.osmocom.org/.

Holger Freyther holger at freyther.de
Thu Jan 21 20:50:45 UTC 2016


> On 21 Jan 2016, at 17:16, suraev at alumni.ntnu.no wrote:
> 
> 
> -void osmo_revbytebits_buf(uint8_t *buf, int len);
> +void osmo_revbytebits_buf(uint8_t *buf, unsigned int len);

yes that makes sense but please do not mix bugfix and API
change in one (unless the API change is the bugfix). E.g.
2/3 of the change is "noise"


> @@ -221,8 +220,7 @@ void osmo_revbytebits_buf(uint8_t *buf, int len)
> 	}
> 
> 	for (i = unaligned_cnt; i + 3 < len; i += 4) {
> -		uint32_t *cur = (uint32_t *) (buf + i);
> -		*cur = osmo_revbytebits_32(*cur);
> +		osmo_store32be(osmo_revbytebits_32(osmo_load32be(buf + i)), buf + i);

		 uint32_t cur;
		 memcpy(&cur, buf + 1, sizeof(cur));
		 cur = osmo_revbytebits_32(cur);
		 memcpy(buf + 1, &cur, sizeof(cur));


would be my approach. So let's compare it. Your code without the loop
is here https://goo.gl/vD3kqQ and the memcpy variant is https://goo.gl/5kzTmx
now if there would be a cloud microbenchmark we could resolve that once and
for all.



More information about the OpenBSC mailing list