From nobody Tue Aug 27 01:06:39 2024 X-Original-To: dev-commits-src-all@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 4Wt8Wg5PXTz5Thsn; Tue, 27 Aug 2024 01:06:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wt8Wg2wlPz4m0Z; Tue, 27 Aug 2024 01:06:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l4/jgTntAC2T/G55ZVE3COTKzl1RhBLxQufTgClb9bs=; b=ULvTBtR+3cPseaZY0V4nIACL+1bh3mLt+6WR2y31QFuK7jREVEL20mVPBbz6mkwLCrzgla ndrJQ+IHdXySz29R0ad0xNWQn5xlGjEIJrzQ6sgeyEbvW1gFLG/8/wE7CFNV+0jt3hLE8t ZQLtn/Xjuvhatd/G7F91lN8TfgEf1ZuOKTYSss+UPPrZqOPpNlenCYixIfQkyN5jzvcnR2 4DAXH49r8tN2KLvbdccQQBeoxYrUEaUTQFcPR7P07XszR7VWnwhonyh22fV+8O9RoAe0k6 qA579P7rnXrMDEgOkk0q5hA/XD3EdtT/eEEccWDr1crZTOQghqu3giaE4XKN/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724720799; a=rsa-sha256; cv=none; b=J0155vAbWh5tdo4//QUUdFs5Re4iSd/FEZ0m8nIFJ4P4jShsAJyddxxF20jukH8waeJ/eK Toj2sSyBv/ZeQZT3/sw2JIyRJnWJlL5PT5al/zlm8aJbKdYe6eBtj5CHjNjkmWgnZJdB2Y hlY8OXp3dy0vgoHpHYidmJoS2lcanNrvhnxqSHtTeaEAYqL6si4/LdF7YuzG3qWbw+P1MQ fm61zhn2u6SOmtZ7bVyDQ737NuWxpvIgR97Q3e6XLlmLicErKTae6p7UQecjEG+Ezjqs+N 1WQC3f55v1Q1iV1d9OSIQmPMl3xdCfTj0RGQpx+P4+2eo/b11zsexp85LUe6qA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l4/jgTntAC2T/G55ZVE3COTKzl1RhBLxQufTgClb9bs=; b=YmFJe93zyDajhitnkyxB+JIA14TMNkqTzG+jXXEZPbznmW9EzuBz7bgqK1QK1XGA5B2IUq 038dwAmhQVwhwCuDz/uwaDtre1R1iUdoJ5Sx88l22vV9rvNNhcXPAAa7qLeZ1jS6v4x0zX IGiNVVBksws0Ovif5Nwbpu/aLSWopSpdul7f/0S3hc5byshWukSNEylYwiprLydLnGl4Z2 x8NTkWS0Ws9yHXfpQ1qDGfN+A+jMG9LKHZi2Z57+TPD8P4glETI3Of0/lFkOxVrSv2SRpW EClbBiauAnXTfSBXIB5rBlskYaxq5QwIIXNGbyZJPf+KiAWXWZcvveDTF/AJSQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wt8Wg257czTfg; Tue, 27 Aug 2024 01:06:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47R16dII057095; Tue, 27 Aug 2024 01:06:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47R16dwR057092; Tue, 27 Aug 2024 01:06:39 GMT (envelope-from git) Date: Tue, 27 Aug 2024 01:06:39 GMT Message-Id: <202408270106.47R16dwR057092@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 650c012e519f - stable/14 - nvmecontrol: Fix to128 for big endian targets List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 650c012e519fe027fdab6561d35380dcd0ac8e4b Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=650c012e519fe027fdab6561d35380dcd0ac8e4b commit 650c012e519fe027fdab6561d35380dcd0ac8e4b Author: Warner Losh AuthorDate: 2024-04-16 22:35:59 +0000 Commit: John Baldwin CommitDate: 2024-08-26 18:31:02 +0000 nvmecontrol: Fix to128 for big endian targets The source is always 128-bits in little endian format. For big endian hosts, we have to convert, or we print bogus numbers. Sponsored by: Netflix Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D44651 (cherry picked from commit 1c4b7effa7f9df64bf72c6291b4719cffb2ffe22) --- sbin/nvmecontrol/Makefile | 1 - sbin/nvmecontrol/nvmecontrol.h | 27 +++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/sbin/nvmecontrol/Makefile b/sbin/nvmecontrol/Makefile index facb5f09835d..e3d363b123ed 100644 --- a/sbin/nvmecontrol/Makefile +++ b/sbin/nvmecontrol/Makefile @@ -1,4 +1,3 @@ - .include PACKAGE=nvme-tools diff --git a/sbin/nvmecontrol/nvmecontrol.h b/sbin/nvmecontrol/nvmecontrol.h index ed331327ae9e..4187c9bee432 100644 --- a/sbin/nvmecontrol/nvmecontrol.h +++ b/sbin/nvmecontrol/nvmecontrol.h @@ -91,22 +91,33 @@ void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, vo /* Utility Routines */ /* - * 128-bit integer augments to standard values. On i386 this - * doesn't exist, so we use 64-bit values. So, on 32-bit systems, - * you'll get truncated values until someone implement 128bit - * ints in software. + * C23 supports 128-bit integers via _BitInt(128). clang 16 and gcc 13 support + * this. Older compilers will support 128-bit ints on 64-bit + * platforms. Otherwise we truncate this to 64-bit on 32-bit systems with older + * compilers. We also check for > C18 instead of >= C23 because clang 17 was + * released before the the __STDC_VERSION__ was defined. */ #define UINT128_DIG 39 -#ifdef __ILP32__ -typedef uint64_t uint128_t; -#else +#if __STDC_VERSION__ >= 202311L +typedef unsigned _BitInt(128) uint128_t; +#elif defined(__SIZEOF_INT128__) typedef __uint128_t uint128_t; +#else +typedef uint64_t uint128_t; #endif static __inline uint128_t to128(void *p) { - return *(uint128_t *)p; +#if __STDC_VERSION__ >= 202311L || defined(__SIZEOF_INT128__) + uint64_t lo, hi; + + lo = le64dec(p); + hi = le64dec((const char *)p + 8); + return ((uint128_t)hi << 64 | lo); +#else + return (le64dec(p)); +#endif } uint64_t le48dec(const void *pp);