Skip to content

core/byteorder: add uint16 from/to buffer funcs#9301

Merged
miri64 merged 1 commit intoRIOT-OS:masterfrom
haukepetersen:add_core_byteorder_lebufs
Jun 7, 2018
Merged

core/byteorder: add uint16 from/to buffer funcs#9301
miri64 merged 1 commit intoRIOT-OS:masterfrom
haukepetersen:add_core_byteorder_lebufs

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

Contribution description

A typical use case when implementing network protocols or similar is to read/write integers from/to buffers while casting them between host and le/be byte orders. The problem here is, that the values in the target buffers are not aligned, so a simple casting of multiple byte values does lead to hard-faults on some platforms (e.g. cortex-m0).

This PR adds two byteorder functions that can read/write uint16_t vars from/to buffers with any alignment. So far I added only two functions for writing/reading little endian values. I think it makes most sense to add be and/or other bit width functions on demand later.

I found that I copied these function to multiple modules, so having them in one central place make probably the most sense, right?!

Issues/PRs references

none

@haukepetersen haukepetersen added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 6, 2018
Copy link
Copy Markdown
Member

@cgundogan cgundogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar problem in ccn-lite and fixed it almost the same way as presented here. So ACK from my side. I'd really like to see unit tests for these functions, though.

@miri64 miri64 merged commit baf9a62 into RIOT-OS:master Jun 7, 2018
@miri64 miri64 deleted the add_core_byteorder_lebufs branch June 7, 2018 09:24
@cladmi cladmi added this to the Release 2018.07 milestone Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants