From nobody Sun Jul 10 03:09:03 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EA98217FA649 for ; Sun, 10 Jul 2022 03:09:06 +0000 (UTC) (envelope-from marc@bumblingdork.com) Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LgX6T5yq3z3v3Q for ; Sun, 10 Jul 2022 03:09:05 +0000 (UTC) (envelope-from marc@bumblingdork.com) Received: by mail-ed1-x529.google.com with SMTP id e15so2692869edj.2 for ; Sat, 09 Jul 2022 20:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bumblingdork.com; s=google; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=vy4ABm7em5Y/Zx2A54lYg07W/z9PCesI6UoBULPSFbw=; b=AdPCi0jh4M295jb9ULQI2w6rRHsN/vgNS7VQWawA4VObvNEeRI4DDO0bcpkKmArE+/ LmzpOkswBLQmPFjkaVD0c0Zek/cdy0vurZFyK21vrZJOOa56OFOLJ90HRlIB0EskwxVu B+g/5UlGYjoKme6rszP2NF3KAtNLEWgx3BRKnTh74A/E7nUe97vQCbAL3jTeTZlBUFnt kKxnkfP0ZmB92v3llv+NmSrQsGh2/RJfoWIsRHjHx1s5/xo5KPa+Qr5exDETV2Y7djBY 2BqpawjPQnnZtZj8qkO1+oNlJqY0rj99wxuvzjmZGmFVk97RFr3spYpzE4m9QmOms+XW nd1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=vy4ABm7em5Y/Zx2A54lYg07W/z9PCesI6UoBULPSFbw=; b=DCwuRLzbUPyQDZRnyZpkjT7Cstp6mAzI37YGPMN6TrgkCIl0BfyxVulVSP/bBZH6pV yn/3LbcXFjv4zm0dp+6Cn08wQIWJvHvJL7rkfC6vOSUmTs5da5TLML8al/9ZboE1Cg2f t9x93Fg0oVOG8D5iYvhSBwPtVSASaA6J+oFAK5ZyVNRNEoBZzKwigkkhqxU9PRbRsk+l QcQtK34NJvpg6PKBb1Z28omQ/UaAYMH251zk3mtJ7W14WwCdbEJ9hablSFRqINwmd6qs xBApy1WZ8fUe58cOfR72pa7B8/LafsZ2RXh4kT4r4n2UCQP2CWQ0JwxTUFHxqJEql9/g tGsw== X-Gm-Message-State: AJIora9V+RB1ZqF2h4ywrbjn2rbo6IXklQNvCXma1PJ9N6II+rJMWjyy gP8j+qsJFAPwd6ZRphmQcgzm2jU7H0BI1g== X-Google-Smtp-Source: AGRyM1uuhisRbgw+6OX9R+mSYAREOBrSaPkbBbYPPmrFylYp4F7ZKoIFOu/uZ8b4Q+QSm/USjb+sxg== X-Received: by 2002:aa7:c0c4:0:b0:43a:20cf:3c68 with SMTP id j4-20020aa7c0c4000000b0043a20cf3c68mr15648889edp.172.1657422544429; Sat, 09 Jul 2022 20:09:04 -0700 (PDT) Received: from smtpclient.apple (2a02-a467-ec-1-1d41-7a05-7ac8-4c9f.fixed6.kpn.net. [2a02:a467:ec:1:1d41:7a05:7ac8:4c9f]) by smtp.gmail.com with ESMTPSA id ec10-20020a0564020d4a00b0043a45dc7158sm1962448edb.72.2022.07.09.20.09.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jul 2022 20:09:04 -0700 (PDT) From: Marc Veldman Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Canonical way / best practice for 128-bit integers Date: Sun, 10 Jul 2022 05:09:03 +0200 References: <86CB4C22-9CAB-4578-8F11-962B4B08F756@bumblingdork.com> To: Eugene Grosbein , freebsd-hackers@freebsd.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4LgX6T5yq3z3v3Q X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bumblingdork.com header.s=google header.b=AdPCi0jh; dmarc=pass (policy=none) header.from=bumblingdork.com; spf=pass (mx1.freebsd.org: domain of marc@bumblingdork.com designates 2a00:1450:4864:20::529 as permitted sender) smtp.mailfrom=marc@bumblingdork.com X-Spamd-Result: default: False [-3.50 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[bumblingdork.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; R_DKIM_ALLOW(-0.20)[bumblingdork.com:s=google]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MLMMJ_DEST(0.00)[freebsd-hackers]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::529:from]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FREEFALL_USER(0.00)[marc]; ARC_NA(0.00)[]; DKIM_TRACE(0.00)[bumblingdork.com:+]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_DN_SOME(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Hello Eugene, > On 9 Jul 2022, at 21:27, Eugene Grosbein wrote: >=20 > 09.07.2022 23:26, Marc Veldman wrote: >> Hello, >>=20 >> I=E2=80=99m 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? >=20 > 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 =E2=80=9CUUI= D aliases=E2=80=9D, 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. >=20 > 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