From nobody Tue Aug 27 01:06:35 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 4Wt8Wc3lYKz5TjHC; Tue, 27 Aug 2024 01:06:36 +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 4Wt8Wb6qv4z4lgT; Tue, 27 Aug 2024 01:06:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720796; 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=yDwXvOgRHPVKjvPw0UVhFXlzdfNFXJE8RuyNc/6WmVE=; b=m3Vu5av7639xD7qiZ0oTOUZB0TyES/+UIZZ0lBuPM/+n1uxiC7TwuoFhUvgYgCkdFDVUqT Q6LIA+PPwWkSWhqyZkfkr9yCkOiMNuGfbLrjdJiSkaRZ/oKvfY0xM+ck2cvBempEQRTzuH 4qv7E9jOgXDyMuuOqsr50yQ0dxJ4ezVIBzf1vdGx4RqcBe/S6rTv8r7mFn/wEc9udQFLYz 5ZuhbgabypYVmdoSrh2NDHeeZASSKXC/sbavmAzJJSO0j7WO7/1PhnTZov09pDwIVQa61w TMwgVy6i0T1G8PXjBojQ+ck/q3ydvXksFYS4It0OBmXy0NkfbtuUhH010+hEnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724720796; a=rsa-sha256; cv=none; b=ms5zMP02j6J3zKCNzxgkLiNo3tLlssDYMNffdAxsKI00yCmOfiNhwD1dGAZ7bgup/lSW24 uX2mv1slNX7mVlTtGutmp4XXl2kjsxx2Ya/J6FQaSNTtXvP/B4wS4VldAa8czxVeCEzS6Z JSSxtlHP7DhTnrD6HUMBi3gx/LxD40lRFUBWcfwMtRA1BFJIXJ4utKwGlK/o2BZT2ttpUM DGHnju5gZjLtNCndXK9tlVh/i4odZCTj/FHwHZyMaM5+X8TzxrNLXv21MwtqAFQ91Qz7JR pIkz1Ys/ULIFAgUsZFIZbXQ+ybzYkLmM0zUUOLcfjQftKSE60FpZfhNvueJ35A== 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=1724720796; 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=yDwXvOgRHPVKjvPw0UVhFXlzdfNFXJE8RuyNc/6WmVE=; b=TTOig3pTJmHlHz81BVTBCWgcZ+sfNm9wCEv8igr3eswCYBwHS5M1plssQpvM9RbfQjazYE 2iQAgxMerJXJUnxcV/FsS9KQhSNwmYTZTG2O0A2PrgaVhCNCRE62KKE99dE/b/UPcpGqfF 4OUlAPgf6/jJllVr+o5yLWgUYYa0kZY+8yKFPgm0+mDsgyla8qqX/rjFy6x6A/KRjMmf37 /ifsjUEnbNKAqkrDx1Zu/SV7TxWIokbiS/xMb9rlSsNVu62INi/BAUvWacenjXs18NMZhG 4Qf9LfThKZigA2BnkALDj7p5RDGG3Tcs2uAzJJvtO2vYrJu2CtdrocJP4rvOoQ== 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 4Wt8Wb6R0mzTdx; Tue, 27 Aug 2024 01:06:35 +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 47R16ZQa056930; Tue, 27 Aug 2024 01:06:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47R16Z3P056927; Tue, 27 Aug 2024 01:06:35 GMT (envelope-from git) Date: Tue, 27 Aug 2024 01:06:35 GMT Message-Id: <202408270106.47R16Z3P056927@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: 05fe0588432a - stable/14 - nvmecontrol: Create letoh to generically convert to host order 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: 05fe0588432aaf74077bc23b0db29889b49a3e40 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=05fe0588432aaf74077bc23b0db29889b49a3e40 commit 05fe0588432aaf74077bc23b0db29889b49a3e40 Author: Warner Losh AuthorDate: 2024-04-16 22:35:33 +0000 Commit: John Baldwin CommitDate: 2024-08-26 18:31:02 +0000 nvmecontrol: Create letoh to generically convert to host order Using _Generic, create letoh which will generically convert uintXX_t types from little endian to host, regardless of the size. This name has been floated as a possible addition to endian.h. Sponsored by: Netflix Discussed with: jhb Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D44649 (cherry picked from commit 67163bc485a56d960b72fb26f19685682b92dd6b) --- sbin/nvmecontrol/nvmecontrol.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sbin/nvmecontrol/nvmecontrol.h b/sbin/nvmecontrol/nvmecontrol.h index ce717e5732c3..a098da4c9c45 100644 --- a/sbin/nvmecontrol/nvmecontrol.h +++ b/sbin/nvmecontrol/nvmecontrol.h @@ -60,6 +60,17 @@ struct kv_name { const char *name; }; +/* + * Generically convert little endian to host endian, based on the type of the thing + * being converted. Use the proposed name for future changes to endian.h. + */ +#define letoh(x) \ + _Generic(x, \ + uint8_t: (x), \ + uint16_t: le16toh(x), \ + uint32_t: le32toh(x), \ + uint64_t: le64toh(x)) + const char *kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key); void logpage_register(struct logpage_function *p);