Re: Canonical way / best practice for 128-bit integers

From: Marc Veldman <marc_at_bumblingdork.com>
Date: Sun, 10 Jul 2022 03:09:03 UTC
Hello Eugene,

> On 9 Jul 2022, at 21:27, Eugene Grosbein <eugen@grosbein.net> wrote:
> 
> 09.07.2022 23:26, Marc Veldman wrote:
>> Hello,
>> 
>> I’m working on some bluetooth code, and that involves handling 128-bit uuids.
>> There are various ways to handle in the FreeBSD codebase, like in sdp.h:
>> Is there any recommended / standard way to handle 128 bit integers in a portable way?
> 
> UUIDs are not integer numbers with arithmetic, so you should not look for 128 bit ints, if you need portability.

In Bluetooth, not quite. Bluetooth also has 32-bit and 16-bit “UUID aliases”, which can require some
arithmetic/bitshifting.

> For example, 32 bit i386 arch lacks hardware support for 128 bit ints,
> so FreeBSD does not support 128 bit ints with arithmetic for i386
> but it does not mean that you cannot use 128 bit UUIDs there.
> 
> We have uuid(3) manual for DCE 1.1 compliant UUID type uuid_t and functions.

That looks like a good candidate to have a look at.
Thanks!

Best regards,

Marc Veldman