From patchwork Sun Aug 20 22:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 136306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2727214vqi; Sun, 20 Aug 2023 18:20:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcxbn3Br3idqX9AjOg8cAWTMEf7KMAYZW9ViKOyXextx6tbUuxspbo05DtGiSEihlMavpO X-Received: by 2002:a05:6358:419f:b0:135:4003:784a with SMTP id w31-20020a056358419f00b001354003784amr5105961rwc.19.1692580822499; Sun, 20 Aug 2023 18:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692580822; cv=none; d=google.com; s=arc-20160816; b=aLL3rwGuhQgiIzt87gaaD5Y8MUEV6HAhLGWAGAgf0mlzeKwufUaAhrilxtmHGa2jjW NnsC64WDKtCwD8UxBFohvkkT584HxkEV2UYZHmB/gym1SxNb4jUXztmk6q4IFTov083I sxB2kvzQPFDT0SziiCr0oQX3NrnfMusu3gyiJOedToxLOtEPJ2qScqLovMM4vkP/GsLM t8u7W5bgzSI90HR/Se9lBvxP/yJJ5Sb9VNxfIwY3fopk6h72uZJm1UfAHFbnHrsIkLYS UseIMBFfRs7SEnxBD4aHfJOBe3InHFGvdCTVPWdPrCwMAX2cwp9zE9n0aceu6vhec/nz 0lfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yBSJoma1HoAuQ67nv0dAC+7MJTPU6zgJNMt+9n2PX/g=; fh=rliOZr6Fz5JmnSfKOt6v3ZHxXv/lQ1TnqU77+ZCO3og=; b=h2ww5hEpWzWoyuWKpBSbOKx1Jh1mRe6QzHrVceriTrf2H2Q8UnevT8gUk7D58/wpKs ZXu3FwDvsED1pUBlmIlXK3PKrM6Jw+MDrN8GezU23qstOjIi891B5C+I7nNn29GtgOQi MJJa7oNfBpfbOc4pOjExjCIepn+8K7v3L/5yiX2o1v3DbzB9uzldSUBFdip1bhXW8/Mz bHSbkr2qmEsJ6CJGG3SImjkfuLeZ2jv9uiJztmjUx+HZn1VXM7GALtspl4a+UqDOPJIX sJ9DMNdfm3hkdgIq1fhf3ddm6hv0jMRJdQRpjmSjjyJzrsOS+J2V+oExlPunfOOq4sjU +dGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AzSnGIZm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a633c4c000000b0056a95d13778si2869844pgn.293.2023.08.20.18.20.08; Sun, 20 Aug 2023 18:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AzSnGIZm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbjHTWsI (ORCPT + 99 others); Sun, 20 Aug 2023 18:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjHTWsH (ORCPT ); Sun, 20 Aug 2023 18:48:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB389D; Sun, 20 Aug 2023 15:48:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7D6960AF2; Sun, 20 Aug 2023 22:48:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF7F0C433C7; Sun, 20 Aug 2023 22:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692571685; bh=JN73pTS3ZRKgTEIXsF+IbODrn07EawwkrFb8emYRdrA=; h=From:To:Cc:Subject:Date:From; b=AzSnGIZmmkbQrOAXXHRqm4C+jft4uCeqWQr/R0PAn8gfxGvjmvrztg4/YFxFMkaX8 sp5n2CVE4+4hmTF69WpCE3adbfxAa/RGqDoutRLWgZ2WcRQYlc57um4lim4iyLv4Wt P+VqVxwRBPNKZ2vSVmgTCksdZT3YQpHIZDVf4gVl9uiVJAJNGTXM0JNjUX0NaQYvT4 Un9arLhGUvYUXMwi+ajXSb2fT7AGudGlOwPftugV5D8gMV/rU2twRUAPQRYIuNgPwm BerTeAIMf/j9N2PvegbV0Qtaw0FOMhxz8tgXHg8LznVWK+K+VYdkPfaYVKwW5UqCj6 yi/s36qbPpYBw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH] kbuild: merge list.h in modpost and kconfig Date: Mon, 21 Aug 2023 07:48:00 +0900 Message-Id: <20230820224800.3905291-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774799628066092373 X-GMAIL-MSGID: 1774799628066092373 Move scripts/mod/list.h to scripts/include/list.h and remove scripts/kconfig/list.h. This removes the code duplication between scripts/mod/list.h and scripts/kconfig/list.h. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/{mod => include}/list.h | 0 scripts/kconfig/expr.h | 3 +- scripts/kconfig/list.h | 132 -------------------------------- scripts/kconfig/preprocess.c | 2 +- scripts/mod/modpost.h | 2 +- 6 files changed, 5 insertions(+), 136 deletions(-) rename scripts/{mod => include}/list.h (100%) delete mode 100644 scripts/kconfig/list.h diff --git a/Makefile b/Makefile index 4382cdb38fba..5434e093d086 100644 --- a/Makefile +++ b/Makefile @@ -469,7 +469,7 @@ export rust_common_flags := --edition=2021 \ -Dclippy::needless_continue \ -Wclippy::dbg_macro -KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) +KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) -I $(srctree)/scripts/include KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ -Zallow-features= $(HOSTRUSTFLAGS) diff --git a/scripts/mod/list.h b/scripts/include/list.h similarity index 100% rename from scripts/mod/list.h rename to scripts/include/list.h diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 4a9a23b1b7e1..8f46c079fa98 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -12,11 +12,12 @@ extern "C" { #include #include -#include "list.h" #ifndef __cplusplus #include #endif +#include + struct file { struct file *next; struct file *parent; diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h deleted file mode 100644 index 45cb237ab7ef..000000000000 --- a/scripts/kconfig/list.h +++ /dev/null @@ -1,132 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef LIST_H -#define LIST_H - -/* - * Copied from include/linux/... - */ - -#undef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -/** - * container_of - cast a member of a structure out to the containing structure - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - - -struct list_head { - struct list_head *next, *prev; -}; - - -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) \ - struct list_head name = LIST_HEAD_INIT(name) - -/** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_head within the struct. - */ -#define list_entry(ptr, type, member) \ - container_of(ptr, type, member) - -/** - * list_for_each_entry - iterate over list of given type - * @pos: the type * to use as a loop cursor. - * @head: the head for your list. - * @member: the name of the list_head within the struct. - */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) - -/** - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_head within the struct. - */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -/** - * list_empty - tests whether a list is empty - * @head: the list to test. - */ -static inline int list_empty(const struct list_head *head) -{ - return head->next == head; -} - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_add(struct list_head *_new, - struct list_head *prev, - struct list_head *next) -{ - next->prev = _new; - _new->next = next; - _new->prev = prev; - prev->next = _new; -} - -/** - * list_add_tail - add a new entry - * @new: new entry to be added - * @head: list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static inline void list_add_tail(struct list_head *_new, struct list_head *head) -{ - __list_add(_new, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static inline void __list_del(struct list_head *prev, struct list_head *next) -{ - next->prev = prev; - prev->next = next; -} - -#define LIST_POISON1 ((void *) 0x00100100) -#define LIST_POISON2 ((void *) 0x00200200) -/** - * list_del - deletes entry from list. - * @entry: the element to delete from the list. - * Note: list_empty() on entry does not return true after this, the entry is - * in an undefined state. - */ -static inline void list_del(struct list_head *entry) -{ - __list_del(entry->prev, entry->next); - entry->next = (struct list_head*)LIST_POISON1; - entry->prev = (struct list_head*)LIST_POISON2; -} -#endif diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 748da578b418..cc2d5d26185d 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -9,7 +9,7 @@ #include #include -#include "list.h" +#include #include "lkc.h" #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 5f94c2c9f2d9..4ebc053cc68f 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -11,7 +11,7 @@ #include #include -#include "list.h" +#include #include "elfconfig.h" /* On BSD-alike OSes elf.h defines these according to host's word size */