From nobody Sun Dec 24 08:22:58 2023 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 4SyYv73LSlz54H7Z; Sun, 24 Dec 2023 08:22:59 +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 4SyYv70S4hz4Xfm; Sun, 24 Dec 2023 08:22:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703406179; 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=GzJ6gfRL9wSbZ3Y7Y+riVTnuZrfcPrGzeQ87Z9ax+vY=; b=pmKPsKhaUr/U10rmMCI4uQUkdRh3KZaworhCIsavLu70eeGGa1SybBMFDZoGwlMdxPF/Gz 1UBiqCLVyx/m3FEEvOhn/ZJPXv1j3Nx5lUKoFeaZicwWzdXWxh3bV0xMrVZkl4mI7o662s bLshGdyQ3vptygYPn4l6SfOfMzRSU5rA4BzNTl9pw0lGAOjCFTfYxRW0FCzD0/4JYyJCLB nXTIdhgyKs/GLdBTQIxAQFBw6XIUFe6E/WrgC4QiTOp1oEyKCsvUbjcU1/0r4LKMahW/97 olMRYpjYSm2PN9O67fWv91TFCC4kElpTf/UXvTkSCSDXET/PJMhTTxbJ4XTL0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703406179; a=rsa-sha256; cv=none; b=Owsns82aj18KjYrmzdepesTDucnvH4GmQyce0IH/nK1zX/lWU0COkKi22wIL1qW8WrfmIP WztAsRSSRQF3RjU2YxKob2UzvCl4F2TbXWrO5tFBoIk+JkPOddHtuRXAEAgi8Lho9rh2tY 8wwVGeGwllzx2obrzSIx1pNfWf/e4VQ7Pplv6/+oR3EmhjCDD3+ETP3R8FAb3QE34CDXLx nu4GDIP4ZT9B5l9BN54cmggle2LRu2otmVrUBoNhtThPsfX9sKz4WVZztvkVr25u4VKjL5 Gk8sioGzegNK9c0yhf13YpQS8ZPwOITPJ+wMxi9qV0aeFK0wA/lAuc+mkSs5oQ== 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=1703406179; 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=GzJ6gfRL9wSbZ3Y7Y+riVTnuZrfcPrGzeQ87Z9ax+vY=; b=onRFRQpgkD/PjwJM13rfSLGtrtBAbUy6PjKCVSWf3Z1hJhtFPi8vZsUjEkdzQRFgge2Xhn 0skUgYlfXbpJ/DaYGtkcZV7Vlb70Qf3NPaokmHPA+7I5e3zy2AdMhqyR2YQ9cDnMaHPXXT sQFChtYNESXSSVtRrZI8jKAQqK3hLOtcRrgk1MNIjGnSv9+GctksiSvpRVISATOmaAFr1Y MLSfsDJGrEcpUcDzNPi7rG7HwNclTiyA2FafwLiwmL39o4UwNUbgeHKU/RCMF26YIPGgQo DYfX2uMU87bpm22JkdNxvu/wjs3D0R05JQ37/HHbj1ahk/kVlGhtVb+m2Snedw== 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 4SyYv66Lnhz5tH; Sun, 24 Dec 2023 08:22:58 +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 3BO8MwcF086652; Sun, 24 Dec 2023 08:22:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO8Mwgn086649; Sun, 24 Dec 2023 08:22:58 GMT (envelope-from git) Date: Sun, 24 Dec 2023 08:22:58 GMT Message-Id: <202312240822.3BO8Mwgn086649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: fa862482fb0a - main - 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/main X-Git-Reftype: branch X-Git-Commit: fa862482fb0a8759984437d71221b17377625491 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fa862482fb0a8759984437d71221b17377625491 commit fa862482fb0a8759984437d71221b17377625491 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2023-12-24 08:19:58 +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 --- .../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 097e22e5d8ea..99ba19e9e25c 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -273,12 +274,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)) @@ -551,8 +546,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)