embeddedartistry / libc

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
MIT License
524 stars 67 forks source link

Fix endianness declarations for ARM platform #160

Closed celskeggs closed 3 years ago

celskeggs commented 3 years ago

Pull Request Template

Description

The ARM platform references _LITTLE_ENDIAN and _BIG_ENDIAN instead of __LITTLE_ENDIAN and __BIG_ENDIAN (which are what is defined in endian.h and used for other platforms). Because the comparison performed in endian.h simply checks whether __BYTE_ORDER == __LITTLE_ENDIAN, this means that ARM platforms are treated as big-endian regardless of actual endianness.

This PR corrects the declarations to use the correct number of underscores, allowing little-endian ARM platforms to be correctly recognized as little-endian.

Please let me know if you believe I've misunderstood something or should have suggested a different fix for this problem.

Type of change

How Has This Been Tested?

I added this assertion: assert(htole32(123) == 123); to my project on a little-endian ARM platform. Upon running the code, it asserted. After applying this change, it no longer asserted.

Test Configuration:

Checklist: