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 <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen 2025-04-22 11:11:20 +08:00 committed by GUIDINGLI
parent 57a12556d2
commit efa0ae5275
4 changed files with 83 additions and 16 deletions

View file

@ -48,6 +48,8 @@
#include <stddef.h>
#include <stdbool.h>
#include <nuttx/list_type.h>
/****************************************************************************
* 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
****************************************************************************/

74
include/nuttx/list_type.h Normal file
View file

@ -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 <geist@foobox.com>
*
* 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 <nuttx/compiler.h>
/****************************************************************************
* 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 */

View file

@ -29,6 +29,7 @@
#include <nuttx/config.h>
#include <nuttx/list_type.h>
#include <nuttx/compiler.h>
#include <nuttx/clock.h>
#include <nuttx/list.h>
@ -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 */
};
/****************************************************************************

View file

@ -32,8 +32,8 @@
#include <sys/types.h>
#include <stdint.h>
#include <nuttx/list_type.h>
#include <nuttx/clock.h>
#include <nuttx/list.h>
#include <nuttx/wdog.h>
/****************************************************************************