BSON_ENDIANNESS(3)
π¦ BSON_ENDIANNESS π
okay bestie, welcome to the libbson manual page for BSON_ENDIANNESS β yes it's a whole page just about which way your bytes face, and honestly? iconic of us.
β¨ THE TEA β
so. the BSON spec is very clear on this one thing: the encoding format is little-endian. periodt. that's the rule, no cap.
and the way that so many implementations just... ignore endianness altogether and straight-up assume they're gonna be running on a little-endian machine? π bestie that's giving "i'll deal with it later" and later never comes.
but libbson said no ma'am, we're doing this properly. we support both Big and Little Endian systems π«Άβ¨
what that means in practice:
- we use
memcpy()when it's the appropriate move, instead of just dereferencing and hoping for the best π - we properly convert to and from the host endian format, like the well-behaved library we are π
and the fun part? we expect the compiler intrinsics to optimize all that into a plain dereference when it possibly can. so you get correctness and speed. we ate. π
ngl the whole vibe here is: portable code that doesn't make you think about endianness. iykyk.
π AUTHOR
MongoDB, Inc
π COPYRIGHT
2017-present, MongoDB, Inc
okay that's the whole page, love u, go write some endian-safe code πΈ
version 1.26.0 β¨ dated Mar 31, 2024 π mwah, catch u in the next manpage bestie π¦
π¦ where this page comes from
- ubuntu noble: libbson-doc 1.26.0-1.1ubuntu2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms