From nobody Tue Sep 22 15:48:50 2026 X-Original-To: dev-commits-src-branches@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 4hq4Jm5wQVz6sPlc for ; Tue, 22 Sep 2026 15:48:56 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hq4Jm2WKVz50YX for ; Tue, 22 Sep 2026 15:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790092136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8k294Rm0ctdTmE0i4zr0IWwnb1XnC4gztux3E1sdR6w=; b=AJwllnEhHVUpDOBJY84br21pNB9sdJiIlvgiVreRAnFBv8eU+CSPHhm9j/vDyPqCOOmkkc qoDhKwiZwoyCLyCl5l68AkIbrb1JTBbS66Z7n4pOhGYJaK4MiPQqoWOLMubqFVtYZeOCj1 tK06r6ONiq/IqIkBeMTNsnGXiT6PafFJMxHbfI5vyRhoFokyHH5Yg8Vl9E3vA4/bRukNG2 HBF3AgAiDurGK7L65mBHStYhb0vhaYGMPpV/Cr/i+VELauVTgoGKvAR91Y5uAyxfK/ZrkN 8WnL6s5U6l1mlWoVJ9CAd8pPRCHmTBl6pHtkCJNyOUdnpFVIQVjRD0miaglrVA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790092136; b=fcF4X8tvezL06l3/K+d8iORKH5TaMERbHBaRXEaYQfkjNM8vfb59Bjj7He7TUpXt9n5Wd+ 1zG3wWRuCVXGcZejSwlVjfLk5Q6i+tRtAPHTy0SIZWTO9TTtAHTdWfHaXajJ56e5m/spf8 PNq7Yx/4os25Cq+ECBD96UsTGkuD9X52Ee4IBxmDeu6Uth8oMivQiZ5Oh8T5NGSS8RRqIU xD1kq+2qQSr1wX2tBM1Aj3ME7F+Mr/fOVUN/5DU4o8hUgDHc1UhX1Ms/CLdrYcU4rpoM0f GsrHzAgB5FuWKxr2y/SLRyTO2DM1DC4019nzFPkcPCCwgf4YwGlymEIUu2c5MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790092136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8k294Rm0ctdTmE0i4zr0IWwnb1XnC4gztux3E1sdR6w=; b=p2sCbZHF9Tw/xu7xuUhOGL6kmiBTBYA5vl5SlXgxLQGMLsET1IBSa3gzq8PYFro8ZlXQff WHhsKlE3dhL7EKvQUgH+0hNpg0Z/FGzyx6wt0BoXtM9P/JdnDdr9WvWoVuSfBfk8Is2kTV xKrfIVKRqyrz+wLBIekAYX+8O2bosnC59X1kaKxF3XgR34eBk3/dqkiS/cWR8vrlIMoN4E aPvcxEZ6ODW0czWEJgHTXWmia/iY3W4GrsjnOMmOVA05q64xDcoGkvUT+0tY+JmCBMsRWF qf0TL1XQ9nArZMp1KavF76uXHDl7hcbd20cIv9y3wLO6e6TCwtWgKXnycmRCzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hq4Jm1bH8z1CLn for ; Tue, 22 Sep 2026 15:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3455d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 22 Sep 2026 15:48:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron From: Vladimir Kondratyev Subject: git: 7710a16e9847 - stable/15 - linuxkpi: Define `DEFINE_CLASS()` and `CLASS()` List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 7710a16e9847149882fd87769540d669592d4278 Auto-Submitted: auto-generated Date: Tue, 22 Sep 2026 15:48:50 +0000 Message-Id: <6ab2a362.3455d.1a99c1f6@gitrepo.freebsd.org> The branch stable/15 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=7710a16e9847149882fd87769540d669592d4278 commit 7710a16e9847149882fd87769540d669592d4278 Author: Jean-Sébastien Pédron AuthorDate: 2026-06-12 17:56:35 +0000 Commit: Vladimir Kondratyev CommitDate: 2026-09-22 15:47:03 +0000 linuxkpi: Define `DEFINE_CLASS()` and `CLASS()` `DEFINE_CLASS()` is in fact named `LINUXKPI_DEFINE_CLASS()` because it conflicts with `DEFINE_CLASS()` defined in . This macro defines a type and a pair of constructor/destructor functions. They are to be used by `CLASS()`: this one declares a variable, initialise it with the constructor and set the `__cleanup()` attribute to call the destructor once the variable goes out of scope. The DRM drivers generic code started to use `CLASS()` in Linux 6.13. It requires the `fd` class to be defined in . Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57583 (cherry picked from commit f2a2e02ae54b836d1e23648756a050406f65111e) --- sys/compat/linuxkpi/common/include/linux/cleanup.h | 26 ++++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/file.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/cleanup.h b/sys/compat/linuxkpi/common/include/linux/cleanup.h index fb21a81f121b..815cdc37a956 100644 --- a/sys/compat/linuxkpi/common/include/linux/cleanup.h +++ b/sys/compat/linuxkpi/common/include/linux/cleanup.h @@ -20,6 +20,32 @@ CLEANUP_NAME(_n, _t) _x __cleanup(CLEANUP_NAME(_n, _destroy)) = \ CLEANUP_NAME(_n, _create) +/* + * On Linux, the following macro is called `DEFINE_CLASS()`. However it + * conflicts with FreeBSD's macro defined in . + * + * Note: "_T" are special as they are exposed into common code for + * statements. Extra care should be taken when changing the code. + */ +#define LINUXKPI_DEFINE_CLASS(_name, _type, _exit, _init, _init_args...)\ + typedef _type class_##_name##_t; \ + \ + static inline _type class_##_name##_constructor(_init_args) \ + { \ + _type v = _init; \ + return (v); \ + } \ + \ + static inline void class_##_name##_destructor(_type *p) \ + { \ + _type _T = *p; \ + _exit; \ + } + +#define CLASS(_name, _var) \ + class_##_name##_t _var __cleanup(class_##_name##_destructor) = \ + class_##_name##_constructor + /* * Note: "_T" are special as they are exposed into common code for * statements. Extra care should be taken when changing the code. diff --git a/sys/compat/linuxkpi/common/include/linux/file.h b/sys/compat/linuxkpi/common/include/linux/file.h index 4d8f8fba7fab..8a589bd2021b 100644 --- a/sys/compat/linuxkpi/common/include/linux/file.h +++ b/sys/compat/linuxkpi/common/include/linux/file.h @@ -184,6 +184,8 @@ static inline struct fd fdget(unsigned int fd) return (struct fd){f}; } +LINUXKPI_DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd) + #define fd_file(fd) ((fd).linux_file) #define file linux_file