From nobody Sat Feb 17 21:32:52 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 4Tchq91Q4Mz59lC5; Sat, 17 Feb 2024 21:32:53 +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 4Tchq862NKz4hFg; Sat, 17 Feb 2024 21:32:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205572; 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=dZNN1HyHO7bANCBAMK2x96I1KwMau8IkMeC0uV4KVy0=; b=vW4WmAG1keR1AXbiqZ/bF87hICGSXCPzXpW23o0V3jkXWWiV4UIsake2lU6X9gTlWFO41O GW6itQey57v5kxArycw6gDsdYrR4mnIqUiaHGoCmawyhWL6fBryBHizs/IqI3kgXORfx2Z tqxdCvKJU8j+QZY+ShW3EycKwAGFtyrDRn65h6T6SLaheRo1dT3zH8CttFyW97dfmlkknd OXFDLCrHnPheJXzNTreYHR9tFUtlRGNKUT0BdqKrY8QoxltZWKzh3BFU9U2swSlp0HB3Ic HFZgUY+Jz0ye13hHF41BSzcsO2tEFLjWp88V9mj3lqHZmBB+dglArbiONkN0mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205572; 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=dZNN1HyHO7bANCBAMK2x96I1KwMau8IkMeC0uV4KVy0=; b=viNMGgIeeqVYbMYWgFrcAiE8iEJaWy/yUwI49irrJCoX2cSj6sGIWAQ9c+RV74wNJVIREe p7h8jDq0I38vM7tXKOgTWfSHllIA9b6t4OWE7SzjF0Ucc2J0hPjqerubr7om8DBkv2r5hV 2q6QSEC11ApWRA6Z0M2BL/gIq6cjZ8ZVX5D5lZ9DalE3uV3DtsbusWnFzxe2SozbVFH34n K0qKSMLLlU07ddrppxZlUEatuKbE90HIHwzXjzYf9DO01eu/DBmwEkFPe6TLPgs5aJDCk9 3/74liwKIwXp02qjXyNv8oo0vLVhYbcd2ySpX3cH1P128oqwDqorhdcDFfIxjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708205572; a=rsa-sha256; cv=none; b=tbONWC1Ktvp80BgmjIkeuYuNPCzie9ELGi3DE8hmn/Gze+A30kJfYlpjVhaMcD1b9ozHek dZNxdi1Rn68G+zhzWm4ySgzcyUMcG5zbV5+3x5W9F4da76Z/LgWaJUaJ+3qydDvmwaKpP4 gghDUnKNyjI0Vf6H8accu2fhjDs3va9osYK4luN7eB5LD5FVwjm/2SAzS8ZlIIr8zz41h5 +znmEqYs8YXEBOutVejSKDro4pLGO0jbWkHBjjVlZZbqOTg4aMJMZ2frYDBNgYpElSxC/0 xGa5NXbgFG4QCkNmn2f//KsYoz2iAVlp1sEpGrjRpLvyc0zha6dTOjlF0e9k9w== 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 4Tchq857rZzPJl; Sat, 17 Feb 2024 21:32:52 +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 41HLWqrn020487; Sat, 17 Feb 2024 21:32:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41HLWqnR020484; Sat, 17 Feb 2024 21:32:52 GMT (envelope-from git) Date: Sat, 17 Feb 2024 21:32:52 GMT Message-Id: <202402172132.41HLWqnR020484@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 21d85c41bbbb - stable/14 - LinuxKPI: Split linux/container_of.h off from linux/kernel.h 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/14 X-Git-Reftype: branch X-Git-Commit: 21d85c41bbbb22cbb49b85fb759e2b3d5a9cadd4 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=21d85c41bbbb22cbb49b85fb759e2b3d5a9cadd4 commit 21d85c41bbbb22cbb49b85fb759e2b3d5a9cadd4 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-02-17 20:58:36 +0000 LinuxKPI: Split linux/container_of.h off from linux/kernel.h Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42796 (cherry picked from commit fa862482fb0a8759984437d71221b17377625491) --- .../linuxkpi/common/include/linux/container_of.h | 46 ++++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/kernel.h | 9 +---- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/container_of.h b/sys/compat/linuxkpi/common/include/linux/container_of.h new file mode 100644 index 000000000000..449507fcf9c1 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/container_of.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2010 iX Systems, Inc. + * Copyright (c) 2010 Panasas, Inc. + * Copyright (c) 2017 Matt Macy + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_LINUX_CONTAINER_OF_H +#define _LINUXKPI_LINUX_CONTAINER_OF_H + +#include + +#include +#include + +#define container_of(ptr, type, member) \ +({ \ + const __typeof(((type *)0)->member) *__p = (ptr); \ + (type *)((uintptr_t)__p - offsetof(type, member)); \ +}) + +#define typeof_member(type, member) __typeof(((type *)0)->member) + +#endif diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index fe844777e469..c8fbacedc561 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -274,12 +275,6 @@ extern int linuxkpi_debug; }) #endif -#define container_of(ptr, type, member) \ -({ \ - const __typeof(((type *)0)->member) *__p = (ptr); \ - (type *)((uintptr_t)__p - offsetof(type, member)); \ -}) - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define u64_to_user_ptr(val) ((void *)(uintptr_t)(val)) @@ -552,8 +547,6 @@ kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, #define offsetofend(t, m) \ (offsetof(t, m) + sizeof((((t *)0)->m))) -#define typeof_member(s, e) typeof(((s *)0)->e) - #define clamp_t(type, _x, min, max) min_t(type, max_t(type, _x, min), max) #define clamp(x, lo, hi) min( max(x,lo), hi) #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)