On 29.09.2020 10:58, Peter Maydell wrote: > On Mon, 28 Sep 2020 at 23:02, Kamil Rytarowski <ka...@netbsd.org> wrote: >> >> Personally, I prefer using the system headers. but if you want to use >> the GCC builtins, please go for it. > > I'd agree if the system header approach was cross-platform > or if this was a BSD-only program or if we were aiming for > complete compiler-implementation independence, but since we > rely on GCC/clang all over the place already it seems nicer to > avoid all the machinery for identifying which of the multiple > different system header implementations is present, and > instead just have a single implementation that works on > all the hosts we care about... >
This is already a part of POSIX: https://www.austingroupbugs.net/view.php?id=162 We have got everything needed from the standard now to implement bswap without relying on compiler builtins. Every modern enough POSIX-like OS already ships with <endian.h>. > thanks > -- PMM >