From efa0ae5275f3586c4440fccf272fbead91b0816d Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Tue, 22 Apr 2025 11:11:20 +0800 Subject: [PATCH] list: Fix the list conflicts. This commit is workaround for the list conflicts introduced by the wqueue and wdog. By spliting the list type definition and the list implementation, we can avoid the list conflicts with user-defined lists. Signed-off-by: ouyangxiangzhen --- include/nuttx/list.h | 12 ++----- include/nuttx/list_type.h | 74 +++++++++++++++++++++++++++++++++++++++ include/nuttx/wdog.h | 11 +++--- include/nuttx/wqueue.h | 2 +- 4 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 include/nuttx/list_type.h diff --git a/include/nuttx/list.h b/include/nuttx/list.h index 5a832c3cb3a..286c055dd01 100644 --- a/include/nuttx/list.h +++ b/include/nuttx/list.h @@ -48,6 +48,8 @@ #include #include +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -315,16 +317,6 @@ &entry->member != (list); \ entry = list_container_of(entry->member.prev, type, member)) -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -struct list_node -{ - FAR struct list_node *next; - FAR struct list_node *prev; -}; - /**************************************************************************** * Inline Functions ****************************************************************************/ diff --git a/include/nuttx/list_type.h b/include/nuttx/list_type.h new file mode 100644 index 00000000000..b5be1d9c87b --- /dev/null +++ b/include/nuttx/list_type.h @@ -0,0 +1,74 @@ +/**************************************************************************** + * include/nuttx/list_type.h + * + * SPDX-License-Identifier: BSD-2-Clause + * SPDX-FileCopyrightText: 2008 Travis Geiselbrecht. All rights reserved. + * SPDX-FileContributor: Travis Geiselbrecht + * + * Extracted from logic originally written by Travis Geiselbrecht and + * released under a public domain license. Re-released here under the 3- + * clause BSD license by Pinecone, Inc. + * + * 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, 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT OWNER OR CONTRIBUTORS 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 __INCLUDE_NUTTX_LIST_TYPE_H +#define __INCLUDE_NUTTX_LIST_TYPE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +struct list_node +{ + FAR struct list_node *next; + FAR struct list_node *prev; +}; + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __INCLUDE_NUTTX_LIST_TYPE_H */ diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h index 931745ac2a2..f65f70aac5a 100644 --- a/include/nuttx/wdog.h +++ b/include/nuttx/wdog.h @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -83,13 +84,13 @@ typedef CODE void (*wdentry_t)(wdparm_t arg); struct wdog_s { - struct list_node node; /* Supports a doubly linked list */ - wdparm_t arg; /* Callback argument */ - wdentry_t func; /* Function to execute when delay expires */ + struct list_node node; /* Supports a doubly linked list */ + wdparm_t arg; /* Callback argument */ + wdentry_t func; /* Function to execute when delay expires */ #ifdef CONFIG_PIC - FAR void *picbase; /* PIC base address */ + FAR void *picbase; /* PIC base address */ #endif - clock_t expired; /* Timer associated with the absolute time */ + clock_t expired; /* Timer associated with the absolute time */ }; /**************************************************************************** diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index 73e8a0eb1e4..b38a8ce7ef7 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -32,8 +32,8 @@ #include #include +#include #include -#include #include /****************************************************************************