nuttx/atomic.h:replace ALL stdatomic.h with nuttx/stdatomic.h in nuttx/

Summary:
  1. Add nuttx/atomic.h in include
  2. Use nuttx/atomic.h instead of stdatomic.h in the nuttx directory

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-07-26 19:35:53 +08:00 committed by Xiang Xiao
parent 4c6f75d13c
commit 667e92390b
7 changed files with 73 additions and 31 deletions

View File

@ -27,10 +27,10 @@
#include <assert.h>
#include <debug.h>
#include <string.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <nuttx/arch.h>
#include <nuttx/atomic.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/mm/mm.h>

View File

@ -22,8 +22,7 @@
* Included Files
****************************************************************************/
#include <stdatomic.h>
#include <nuttx/atomic.h>
#include <nuttx/note/note_driver.h>
#include <nuttx/note/notesnap_driver.h>
#include <nuttx/panic_notifier.h>

View File

@ -23,10 +23,10 @@
****************************************************************************/
#include <debug.h>
#include <stdatomic.h>
#include <string.h>
#include <nuttx/kmalloc.h>
#include <nuttx/atomic.h>
#include <nuttx/net/snoop.h>
#include <nuttx/wireless/bluetooth/bt_bridge.h>

64
include/nuttx/atomic.h Normal file
View File

@ -0,0 +1,64 @@
/****************************************************************************
* include/nuttx/atomic.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_ATOMIC_H
#define __INCLUDE_NUTTX_ATOMIC_H
/****************************************************************************
* Included Files
****************************************************************************/
#if !defined(__cplusplus) || defined(__clang__)
# include <stdatomic.h>
#elif defined(__has_include) && __has_include(<atomic>)
extern "C++"
{
# include <atomic>
using std::atomic_int;
using std::atomic_uint;
using std::atomic_ushort;
using std::atomic_load;
using std::atomic_store;
using std::atomic_fetch_add;
using std::atomic_fetch_sub;
using std::atomic_compare_exchange_strong;
# define ATOMIC_VAR_INIT(value) (value)
}
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_ATOMIC_H */

View File

@ -26,9 +26,9 @@
****************************************************************************/
#include <sys/types.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <nuttx/atomic.h>
#include <nuttx/list.h>
/****************************************************************************

View File

@ -29,8 +29,8 @@
#ifdef CONFIG_RAM_UART
#include <stdatomic.h>
#include <stdbool.h>
#include <nuttx/atomic.h>
/****************************************************************************
* Pre-processor Definitions

View File

@ -31,31 +31,13 @@
#include <assert.h>
#include <stdint.h>
#if defined(CONFIG_TICKET_SPINLOCK) || defined(CONFIG_RW_SPINLOCK)
# if !defined(__cplusplus)
# include <stdatomic.h>
# define CONFIG_HAVE_INLINE_SPINLOCK
# elif defined(__has_include) && __has_include(<atomic>)
extern "C++"
{
# include <atomic>
# define CONFIG_HAVE_INLINE_SPINLOCK
using std::atomic_int;
using std::atomic_load;
using std::atomic_uint;
using std::atomic_ushort;
using std::atomic_fetch_add;
using std::atomic_fetch_sub;
using std::atomic_compare_exchange_strong;
}
# endif
#else
# define CONFIG_HAVE_INLINE_SPINLOCK
#endif
#include <nuttx/compiler.h>
#include <nuttx/irq.h>
#if defined(CONFIG_TICKET_SPINLOCK) || defined(CONFIG_RW_SPINLOCK)
# include <nuttx/atomic.h>
#endif
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
@ -232,8 +214,6 @@ static inline spinlock_t up_testset(FAR volatile spinlock_t *lock)
/* void spin_lock_init(FAR spinlock_t *lock); */
#define spin_lock_init(l) do { *(l) = SP_UNLOCKED; } while (0)
#ifdef CONFIG_HAVE_INLINE_SPINLOCK
/****************************************************************************
* Name: spin_lock_wo_note
*
@ -1172,7 +1152,6 @@ void write_unlock_irqrestore(FAR rwlock_t *lock, irqstate_t flags);
#endif
#endif /* CONFIG_RW_SPINLOCK */
#endif /* CONFIG_HAVE_INLINE_SPINLOCK */
#undef EXTERN
#if defined(__cplusplus)