From nobody Thu Oct 17 09:16:50 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 4XThzl28tvz5YlvG; Thu, 17 Oct 2024 09:16:51 +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 4XThzk6qrtz4HQ1; Thu, 17 Oct 2024 09:16:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729156611; 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=pSaWGixFIJcNIGHtck1jlVQn1l2CxGcJWNETGcLpUso=; b=VbTAXtAeK13qKDIZjPsx9VlYkPB4+KC1cZhTTWMhcZSNK8Bfh1dfMoBZNJBj5IPijvpm8p sLWdx2IQ8pD+hvTIAi1IUAAs60pZKDWBpD62PIVQG+09jqozPRxkw/bfjpSN/2noZb0RQe TKcdBx0ijn8TGUTl01VYHHJmw1hOqEHis3lec8so9YZha0Zp6+0RQemM6kV29p/rFI23Xd IRpqRV+IGJ2haNaMIVcGpGQIDd7W1UeBXlE/+E5o8gbq0hSxrYFPY9K2+iwVnxJ1V1Tep+ bcoPM6c8CsED1IMULO3qhb8ELrz8cwOJBWVKkeCn/5DACcyNNyea9o2UWzwA0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729156611; 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=pSaWGixFIJcNIGHtck1jlVQn1l2CxGcJWNETGcLpUso=; b=P/+Hhg8pEjedDYPZyIyTPOFunJP//mREplNxXBJ7Pq7wBKq8Zsyw3nnJkvGX6ZZG/n3lFa CQvcyGfiFppEDjrUF4eqoM++6TAhyML7N3BZIaQ/qhaVvqkij/VPSKr8eQNqSD44SwrABl UOBA4OfrV3euvsFkIdhCUYGjfjpPrMS6jbxbwqROePr8Vmk3CBBKw9Vj6BYzZHdX/1CRht VjTNnfp0fIFdPTSPBHje8SwHCAImyNIg/A2PeMjYNVKHNUumnLI0MI+mlIJ1siZw4runk1 YWtzEScAlYkpz8y4x6C7wGxgBo8rC2MCaOpXUZpqWajLTfJTrZ7X1uoEwpjcNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729156611; a=rsa-sha256; cv=none; b=JFzqmLQcKoKHCdqfjkAHW7+15rrUkOJ1IeP5xIgGQMW2e5ZOAm1DCyDwEP6KQNQ/AUJc/x 8hGhaDMkxPw6GdwhuHsano49mZTMIZOzZkjRoUNsMGSCLqTtMNOe6G3Djb7cS4BxyykZCS n+yBCOL6uQmxoAMG1gKKd59wFJQlZV7qG6cns+f+kNceKB1wblEw1alPM5wvbEwJazf+dm fc00DWeVkPo0xostkPT8iMdJAlsk4ZD0nx1RqK9q/GvAg4LnuDt08uMhHVFkO/To6/dAw6 S/ZNqvkY4atHU1LvUtEw5U2q0iL3mCoQEFCRk+xlOv1DXZ7NA4sZlc3Hqh0pZA== 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 4XThzk6N1kzkZQ; Thu, 17 Oct 2024 09:16:50 +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 49H9GoiJ087888; Thu, 17 Oct 2024 09:16:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49H9Go20087885; Thu, 17 Oct 2024 09:16:50 GMT (envelope-from git) Date: Thu, 17 Oct 2024 09:16:50 GMT Message-Id: <202410170916.49H9Go20087885@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 75ac24a7dfeb - stable/14 - LinuxKPI: add cleanup.h for guard DEFINE_GUARD/guard. 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 75ac24a7dfeb93301d4bb8b0118e2c98cc201f5e Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=75ac24a7dfeb93301d4bb8b0118e2c98cc201f5e commit 75ac24a7dfeb93301d4bb8b0118e2c98cc201f5e Author: Bjoern A. Zeeb AuthorDate: 2024-09-28 22:38:03 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-10-16 21:50:37 +0000 LinuxKPI: add cleanup.h for guard DEFINE_GUARD/guard. iwlwifi v6.11 started to use guard(). _T in the implementation needs to be exposed to the driver which uses it in DEFINE_GUARD(). Given this is the first instance of attribute(cleanup) in the tree: - gcc has support for it since at least 2003-06-04 (0bfa5f65bfb186f10d43304946fd7fcd69988732) - llvm gained support on 2009-01-31 (d277d790e0f6f23043397ba919619b5c3e157ff3, llvm-svn 63462). Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D46843 (cherry picked from commit fa81baa307da9a0055d7d08f6d141ea310f067ed) --- sys/compat/linuxkpi/common/include/linux/cleanup.h | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/cleanup.h b/sys/compat/linuxkpi/common/include/linux/cleanup.h new file mode 100644 index 000000000000..01f234f0cbe7 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/cleanup.h @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 The FreeBSD Foundation + * + * This software was developed by Björn Zeeb under sponsorship from + * the FreeBSD Foundation. + */ + +#ifndef _LINUXKPI_LINUX_CLEANUP_H +#define _LINUXKPI_LINUX_CLEANUP_H + +#define __cleanup(_f) __attribute__((__cleanup__(_f))) + +/* + * Note: "_T" are special as they are exposed into common code for + * statements. Extra care should be taken when changing the code. + */ +#define DEFINE_GUARD(_n, _dt, _lock, _unlock) \ + \ + typedef _dt guard_ ## _n ## _t; \ + \ + static inline _dt \ + guard_ ## _n ## _create( _dt _T) \ + { \ + _dt c; \ + \ + c = ({ _lock; _T; }); \ + return (c); \ + } \ + \ + static inline void \ + guard_ ## _n ## _destroy(_dt *t) \ + { \ + _dt _T; \ + \ + _T = *t; \ + if (_T) { _unlock; }; \ + } + +/* We need to keep these calls unique. */ +#define guard(_n) \ + guard_ ## _n ## _t guard_ ## _n ## _ ## __COUNTER__ \ + __cleanup(guard_ ## _n ## _destroy) = guard_ ## _n ## _create + +#endif /* _LINUXKPI_LINUX_CLEANUP_H */