From nobody Wed Apr 17 03:33:40 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 4VK62F1SXKz5Hj0v; Wed, 17 Apr 2024 03:33:41 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VK62D6mqvz4Qff; Wed, 17 Apr 2024 03:33:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713324821; 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=qA2waD1z4c6h9aEnSso9+KRX1khpF2YRX9rujIHwMGU=; b=qhUf8MUUioXoRfRSGakQVCz0+mL/kxMQpg5klEVLaMyc8Oz+kVnG6CtyfvGxPazhLNeDUJ JlEcYNr2mgZBuGQANrsU4rkaRTXUfUnKWoOEBaEAqtPTd7XFlCqTtRvDCvvROVl+C349tn sOLAOYFuqjCh+HnBT7cif5My7gJ1qJHvjpuEGddRzUvhfFO17tgrrXODSI1er0x39YlU4T U8AxLHF1oKm+4SCcGpvLbDSBlpJ666REDSLdwWtrkZL3Zbv2umMFtF7h9HCgzDsT7AR9Vn T2hsYzqFRUsv/gvXD0bZoChyP6pW0n8ojIU54QZCI31iAkvWhLFcYNnoclN/pg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713324821; a=rsa-sha256; cv=none; b=A3RIS8uvUUlwCn2wBtpCMZBjH5L7NjZhLtdmsV7XIhHC6V14XptgjDXHdagj6Mtyd2f/TP oQ4PcH5aNRw4C9QcSFWr0+f7MMVUQuNZRB5TBQxlqdY1N4v4YYg6PhiWivpsTbeO9Illg9 VSwYkJOSEPESZPj0uCs1XuReOMIrD0gD8hyL3v0Qew1qBKkcCGSFsDlL1h/4/y7HQ5dV7r EQGNodtq9TPlO/SeuF4MYSdlVQ2DQfyzYz3GSNIC9vxkAC5Xt0Xj8Ui8iVTtagguEspxNP PrBU3W6HKdm2zk3y6mD4Qz88eEEvi4K94jfeHfVyLQ6YZ1z1MvHQHjO+fvYFxQ== 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=1713324820; 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=qA2waD1z4c6h9aEnSso9+KRX1khpF2YRX9rujIHwMGU=; b=JyDqjb2Af+Id3EDdjPmAdWNAt5gPoFWaNlS+xPvknLwgbqa1ibOMgJX8dJC5cuShYCHDI0 Pw5YTbmI0TFi/VnMYuRMzfL+lO6gIiEe4QiAIZSLNQxQvNI0teOWvMs3OisPgWurNyHdOj WA82OATfQlqBOY5LWiv1TUnO52enAjfgP2z9s3+TcPHwS6RlMd/yFS4DUCjCJy5W+o7sDs O+37SmLjgqO4Md/X3ghyWfOelV4Iz5JrStYreJNpvtzCM6z14pkvOkPx1ASgkXzWDu8pf0 y3gH5NFsDtHVeyQYL4UN1Hyi3XKL61mORXBhLtE6N8PKWKcNUyQT4/Pk6eGTFQ== 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 4VK62D6Mcrz19WQ; Wed, 17 Apr 2024 03:33:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43H3Xe4L086602; Wed, 17 Apr 2024 03:33:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43H3Xe86086599; Wed, 17 Apr 2024 03:33:40 GMT (envelope-from git) Date: Wed, 17 Apr 2024 03:33:40 GMT Message-Id: <202404170333.43H3Xe86086599@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 67163bc485a5 - main - 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 67163bc485a56d960b72fb26f19685682b92dd6b Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=67163bc485a56d960b72fb26f19685682b92dd6b commit 67163bc485a56d960b72fb26f19685682b92dd6b Author: Warner Losh AuthorDate: 2024-04-16 22:35:33 +0000 Commit: Warner Losh CommitDate: 2024-04-17 03:30:17 +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 --- 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);