]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Fix Endianness detection in utils.h for non-Linux
authorChristoph Moench-Tegeder <cmt@burggraben.net>
Sun, 19 Oct 2025 17:03:43 +0000 (19:03 +0200)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 30 Oct 2025 16:09:11 +0000 (16:09 +0000)
commit9bbb566df59d3e3692c11b94afcfe92024194e52
treeb4e518fffbcfad47b1130d3a1321e815d90982ea
parentb1a14698a78638f799168549572376f06ef1ec75
Fix Endianness detection in utils.h for non-Linux

Commit 43bf8a4ded7a65203b766b91eaf8331a600e9d8d introduced endian
dependend byte-swapping code in include/asterisk/utils.h, where the
endianness was detected using the __BYTE_ORDER macro. This macro
lives in endian.h, which on Linux is included implicitely (by the
network-related headers, I think), but on FreeBSD the headers are
laid out differently and we do not get __BYTE_ORDER the implicit way.

Instead, this makes the usage of endian.h explicit by including it
where we need it, and switches the BYTE_ORDER/*ENDIAN macros to the
POSIX-defined ones (see
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/endian.h.html
for standard compliance). Additionally, this adds a compile-time check
for the endianness-logic: compilation will fail if neither big nor
little endian can be detected.

Fixes: #1536
include/asterisk/utils.h