libc/machine: split atomic into header, arch_atomic_irq.c, arch_atomic64.c

Split the atomic implementation into three files:
- arch_atomic.h: Shared macros (STORE, LOAD, etc.) using atomic_lock()/
  atomic_unlock() abstraction
- arch_atomic_irq.c: 32-bit atomic functions using IRQ disable (conditional
  on CONFIG_LIBC_ATOMIC_IRQ via Make.defs)
- arch_atomic64.c: 64-bit atomic functions using spinlock (always compiled,
  multi-core safe). The __atomic_* functions are always provided (GCC
  runtime helpers), while nx_atomic_* functions are conditional on
  !CONFIG_LIBC_ATOMIC_TOOLCHAIN.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
This commit is contained in:
zhangyu117 2026-08-21 10:58:23 +08:00 committed by Xiang Xiao
parent 5ff4bdde65
commit 2f46ced5c7
5 changed files with 547 additions and 403 deletions

View file

@ -22,7 +22,11 @@
add_subdirectory(${CONFIG_ARCH})
target_sources(c PRIVATE arch_atomic_irq.c)
if(CONFIG_LIBC_ATOMIC_IRQ)
target_sources(c PRIVATE arch_atomic_irq.c)
endif()
target_sources(c PRIVATE arch_atomic64.c)
if(CONFIG_MM_KASAN)
target_sources(c PRIVATE arch_libc.c)

View file

@ -20,7 +20,11 @@
#
############################################################################
CSRCS += arch_atomic_irq.c
ifeq ($(CONFIG_LIBC_ATOMIC_IRQ),y)
CSRCS += arch_atomic_irq.c
endif
CSRCS += arch_atomic64.c
ifeq ($(CONFIG_MM_KASAN),y)
CSRCS += arch_libc.c

View file

@ -0,0 +1,320 @@
/****************************************************************************
* libs/libc/machine/arch_atomic.h
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 __LIBS_LIBC_MACHINE_ARCH_ATOMIC_H
#define __LIBS_LIBC_MACHINE_ARCH_ATOMIC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
#include <nuttx/irq.h>
#include <nuttx/macro.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define STORE(fn, n, type) \
\
void weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
\
*(FAR type *)ptr = value; \
\
atomic_unlock(irqstate); \
}
#define LOAD(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR const volatile void *ptr, \
int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
\
type ret = *(FAR type *)ptr; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define EXCHANGE(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
type ret = *tmp; \
*tmp = value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define CMP_EXCHANGE(fn, n, type) \
\
bool weak_function CONCATENATE(fn, n)(FAR volatile void *mem, \
FAR volatile void *expect, \
type desired, bool weak, \
int success, int failure) \
{ \
bool ret = false; \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmpmem = (FAR type *)mem; \
FAR type *tmpexp = (FAR type *)expect; \
\
if (*tmpmem == *tmpexp) \
{ \
ret = true; \
*tmpmem = desired; \
} \
else \
{ \
*tmpexp = *tmpmem; \
} \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FLAG_TEST_AND_SET(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*(FAR type *)ptr = 1; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FETCH_ADD(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp + value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FETCH_SUB(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp - value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FETCH_AND(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp & value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FETCH_OR(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp | value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define FETCH_XOR(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp ^ value; \
\
atomic_unlock(irqstate); \
return ret; \
}
#define SYNC_ADD_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp + value; \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_SUB_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp - value; \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_OR_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp | value; \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_AND_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp & value; \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_XOR_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp ^ value; \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_NAND_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = ~(*tmp & value); \
\
atomic_unlock(irqstate); \
return *tmp; \
}
#define SYNC_BOOL_CMP_SWAP(fn, n, type) \
\
bool weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type oldvalue, \
type newvalue) \
{ \
bool ret = false; \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
\
if (*tmp == oldvalue) \
{ \
ret = true; \
*tmp = newvalue; \
} \
\
atomic_unlock(irqstate); \
return ret; \
}
#define SYNC_VAL_CMP_SWAP(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type oldvalue, \
type newvalue) \
{ \
irqstate_t irqstate = atomic_lock(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
if (*tmp == oldvalue) \
{ \
*tmp = newvalue; \
} \
\
atomic_unlock(irqstate); \
return ret; \
}
#endif /* __LIBS_LIBC_MACHINE_ARCH_ATOMIC_H */

View file

@ -0,0 +1,201 @@
/****************************************************************************
* libs/libc/machine/arch_atomic64.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/spinlock.h>
#include "arch_atomic.h"
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_atomic_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
static inline irqstate_t atomic_lock(void)
{
return spin_lock_irqsave(&g_atomic_lock);
}
static inline void atomic_unlock(irqstate_t flags)
{
spin_unlock_irqrestore(&g_atomic_lock, flags);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: __atomic_store_8
****************************************************************************/
STORE(__atomic_store_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
STORE(nx_atomic_store_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_load_8
****************************************************************************/
LOAD(__atomic_load_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
LOAD(nx_atomic_load_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_exchange_8
****************************************************************************/
EXCHANGE(__atomic_exchange_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
EXCHANGE(nx_atomic_exchange_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_compare_exchange_8
****************************************************************************/
CMP_EXCHANGE(__atomic_compare_exchange_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
CMP_EXCHANGE(nx_atomic_compare_exchange_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_flag_test_and_set_8
****************************************************************************/
FLAG_TEST_AND_SET(__atomic_flags_test_and_set_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FLAG_TEST_AND_SET(nx_atomic_flags_test_and_set_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_fetch_add_8
****************************************************************************/
FETCH_ADD(__atomic_fetch_add_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FETCH_ADD(nx_atomic_fetch_add_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_fetch_sub_8
****************************************************************************/
FETCH_SUB(__atomic_fetch_sub_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FETCH_SUB(nx_atomic_fetch_sub_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_fetch_and_8
****************************************************************************/
FETCH_AND(__atomic_fetch_and_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FETCH_AND(nx_atomic_fetch_and_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_fetch_or_8
****************************************************************************/
FETCH_OR(__atomic_fetch_or_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FETCH_OR(nx_atomic_fetch_or_, 8, int64_t)
#endif
/****************************************************************************
* Name: __atomic_fetch_xor_8
****************************************************************************/
FETCH_XOR(__atomic_fetch_xor_, 8, uint64_t)
#ifndef CONFIG_LIBC_ATOMIC_TOOLCHAIN
FETCH_XOR(nx_atomic_fetch_xor_, 8, int64_t)
#endif
/* Clang define the __sync builtins, add #ifndef to avoid
* redefined/redeclared problem.
*/
#ifndef __clang__
/****************************************************************************
* Name: __sync_add_and_fetch_8
****************************************************************************/
SYNC_ADD_FETCH(__sync_add_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_sub_and_fetch_8
****************************************************************************/
SYNC_SUB_FETCH(__sync_sub_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_or_and_fetch_8
****************************************************************************/
SYNC_OR_FETCH(__sync_or_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_and_and_fetch_8
****************************************************************************/
SYNC_AND_FETCH(__sync_and_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_xor_and_fetch_8
****************************************************************************/
SYNC_XOR_FETCH(__sync_xor_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_nand_and_fetch_8
****************************************************************************/
SYNC_NAND_FETCH(__sync_nand_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_bool_compare_and_swap_8
****************************************************************************/
SYNC_BOOL_CMP_SWAP(__sync_bool_compare_and_swap_, 8, uint64_t)
/****************************************************************************
* Name: __sync_val_compare_and_swap_8
****************************************************************************/
SYNC_VAL_CMP_SWAP(__sync_val_compare_and_swap_, 8, uint64_t)
#endif /* __clang__ */

View file

@ -28,291 +28,24 @@
#include <stdbool.h>
#include <stdint.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/macro.h>
#include "arch_atomic.h"
/****************************************************************************
* Pre-processor Definitions
* Private Functions
****************************************************************************/
#define STORE(fn, n, type) \
\
void weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
\
*(FAR type *)ptr = value; \
\
up_irq_restore(irqstate); \
}
static inline irqstate_t atomic_lock(void)
{
return up_irq_save();
}
#define LOAD(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR const volatile void *ptr, \
int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
\
type ret = *(FAR type *)ptr; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define EXCHANGE(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
type ret = *tmp; \
*tmp = value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define CMP_EXCHANGE(fn, n, type) \
\
bool weak_function CONCATENATE(fn, n)(FAR volatile void *mem, \
FAR volatile void *expect, \
type desired, bool weak, \
int success, int failure) \
{ \
bool ret = false; \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmpmem = (FAR type *)mem; \
FAR type *tmpexp = (FAR type *)expect; \
\
if (*tmpmem == *tmpexp) \
{ \
ret = true; \
*tmpmem = desired; \
} \
else \
{ \
*tmpexp = *tmpmem; \
} \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FLAG_TEST_AND_SET(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*(FAR type *)ptr = 1; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FETCH_ADD(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp + value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FETCH_SUB(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp - value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FETCH_AND(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp & value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FETCH_OR(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp | value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define FETCH_XOR(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value, int memorder) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
*tmp = *tmp ^ value; \
\
up_irq_restore(irqstate); \
return ret; \
}
#define SYNC_ADD_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp + value; \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_SUB_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp - value; \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_OR_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp | value; \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_AND_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp & value; \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_XOR_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = *tmp ^ value; \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_NAND_FETCH(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type value) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
*tmp = ~(*tmp & value); \
\
up_irq_restore(irqstate); \
return *tmp; \
}
#define SYNC_BOOL_CMP_SWAP(fn, n, type) \
\
bool weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type oldvalue, \
type newvalue) \
{ \
bool ret = false; \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
\
if (*tmp == oldvalue) \
{ \
ret = true; \
*tmp = newvalue; \
} \
\
up_irq_restore(irqstate); \
return ret; \
}
#define SYNC_VAL_CMP_SWAP(fn, n, type) \
\
type weak_function CONCATENATE(fn, n)(FAR volatile void *ptr, \
type oldvalue, \
type newvalue) \
{ \
irqstate_t irqstate = up_irq_save(); \
FAR type *tmp = (FAR type *)ptr; \
type ret = *tmp; \
\
if (*tmp == oldvalue) \
{ \
*tmp = newvalue; \
} \
\
up_irq_restore(irqstate); \
return ret; \
}
static inline void atomic_unlock(irqstate_t flags)
{
up_irq_restore(flags);
}
/****************************************************************************
* Public Functions
@ -337,13 +70,6 @@ STORE(__atomic_store_, 2, uint16_t)
STORE(__atomic_store_, 4, uint32_t)
STORE(nx_atomic_store_, 4, int32_t)
/****************************************************************************
* Name: __atomic_store_8
****************************************************************************/
STORE(__atomic_store_, 8, uint64_t)
STORE(nx_atomic_store_, 8, int64_t)
/****************************************************************************
* Name: __atomic_load_1
****************************************************************************/
@ -351,25 +77,18 @@ STORE(nx_atomic_store_, 8, int64_t)
LOAD(__atomic_load_, 1, uint8_t)
/****************************************************************************
* Name: __atomic_load__2
* Name: __atomic_load_2
****************************************************************************/
LOAD(__atomic_load_, 2, uint16_t)
/****************************************************************************
* Name: __atomic_load__4
* Name: __atomic_load_4
****************************************************************************/
LOAD(__atomic_load_, 4, uint32_t)
LOAD(nx_atomic_load_, 4, int32_t)
/****************************************************************************
* Name: __atomic_load__8
****************************************************************************/
LOAD(__atomic_load_, 8, uint64_t)
LOAD(nx_atomic_load_, 8, int64_t)
/****************************************************************************
* Name: __atomic_exchange_1
****************************************************************************/
@ -377,25 +96,18 @@ LOAD(nx_atomic_load_, 8, int64_t)
EXCHANGE(__atomic_exchange_, 1, uint8_t)
/****************************************************************************
* Name: __atomic_exchange__2
* Name: __atomic_exchange_2
****************************************************************************/
EXCHANGE(__atomic_exchange_, 2, uint16_t)
/****************************************************************************
* Name: __atomic_exchange__4
* Name: __atomic_exchange_4
****************************************************************************/
EXCHANGE(__atomic_exchange_, 4, uint32_t)
EXCHANGE(nx_atomic_exchange_, 4, int32_t)
/****************************************************************************
* Name: __atomic_exchange__8
****************************************************************************/
EXCHANGE(__atomic_exchange_, 8, uint64_t)
EXCHANGE(nx_atomic_exchange_, 8, int64_t)
/****************************************************************************
* Name: __atomic_compare_exchange_1
****************************************************************************/
@ -415,13 +127,6 @@ CMP_EXCHANGE(__atomic_compare_exchange_, 2, uint16_t)
CMP_EXCHANGE(__atomic_compare_exchange_, 4, uint32_t)
CMP_EXCHANGE(nx_atomic_compare_exchange_, 4, int32_t)
/****************************************************************************
* Name: __atomic_compare_exchange_8
****************************************************************************/
CMP_EXCHANGE(__atomic_compare_exchange_, 8, uint64_t)
CMP_EXCHANGE(nx_atomic_compare_exchange_, 8, int64_t)
/****************************************************************************
* Name: __atomic_flag_test_and_set_1
****************************************************************************/
@ -441,13 +146,6 @@ FLAG_TEST_AND_SET(__atomic_flags_test_and_set_, 2, uint16_t)
FLAG_TEST_AND_SET(__atomic_flags_test_and_set_, 4, uint32_t)
FLAG_TEST_AND_SET(nx_atomic_flags_test_and_set_, 4, int32_t)
/****************************************************************************
* Name: __atomic_flag_test_and_set_8
****************************************************************************/
FLAG_TEST_AND_SET(__atomic_flags_test_and_set_, 8, uint64_t)
FLAG_TEST_AND_SET(nx_atomic_flags_test_and_set_, 8, int64_t)
/****************************************************************************
* Name: __atomic_fetch_add_1
****************************************************************************/
@ -467,13 +165,6 @@ FETCH_ADD(__atomic_fetch_add_, 2, uint16_t)
FETCH_ADD(__atomic_fetch_add_, 4, uint32_t)
FETCH_ADD(nx_atomic_fetch_add_, 4, int32_t)
/****************************************************************************
* Name: __atomic_fetch_add_8
****************************************************************************/
FETCH_ADD(__atomic_fetch_add_, 8, uint64_t)
FETCH_ADD(nx_atomic_fetch_add_, 8, int64_t)
/****************************************************************************
* Name: __atomic_fetch_sub_1
****************************************************************************/
@ -493,13 +184,6 @@ FETCH_SUB(__atomic_fetch_sub_, 2, uint16_t)
FETCH_SUB(__atomic_fetch_sub_, 4, uint32_t)
FETCH_SUB(nx_atomic_fetch_sub_, 4, int32_t)
/****************************************************************************
* Name: __atomic_fetch_sub_8
****************************************************************************/
FETCH_SUB(__atomic_fetch_sub_, 8, uint64_t)
FETCH_SUB(nx_atomic_fetch_sub_, 8, int64_t)
/****************************************************************************
* Name: __atomic_fetch_and_1
****************************************************************************/
@ -519,13 +203,6 @@ FETCH_AND(__atomic_fetch_and_, 2, uint16_t)
FETCH_AND(__atomic_fetch_and_, 4, uint32_t)
FETCH_AND(nx_atomic_fetch_and_, 4, int32_t)
/****************************************************************************
* Name: __atomic_fetch_and_8
****************************************************************************/
FETCH_AND(__atomic_fetch_and_, 8, uint64_t)
FETCH_AND(nx_atomic_fetch_and_, 8, int64_t)
/****************************************************************************
* Name: __atomic_fetch_or_1
****************************************************************************/
@ -545,13 +222,6 @@ FETCH_OR(__atomic_fetch_or_, 2, uint16_t)
FETCH_OR(__atomic_fetch_or_, 4, uint32_t)
FETCH_OR(nx_atomic_fetch_or_, 4, int32_t)
/****************************************************************************
* Name: __atomic_fetch_or_4
****************************************************************************/
FETCH_OR(__atomic_fetch_or_, 8, uint64_t)
FETCH_OR(nx_atomic_fetch_or_, 8, int64_t)
/****************************************************************************
* Name: __atomic_fetch_xor_1
****************************************************************************/
@ -571,13 +241,6 @@ FETCH_XOR(__atomic_fetch_xor_, 2, uint16_t)
FETCH_XOR(__atomic_fetch_xor_, 4, uint32_t)
FETCH_XOR(nx_atomic_fetch_xor_, 4, int32_t)
/****************************************************************************
* Name: __atomic_fetch_xor_8
****************************************************************************/
FETCH_XOR(__atomic_fetch_xor_, 8, uint64_t)
FETCH_XOR(nx_atomic_fetch_xor_, 8, int64_t)
/* Clang define the __sync builtins, add #ifndef to avoid
* redefined/redeclared problem.
*/
@ -602,12 +265,6 @@ SYNC_ADD_FETCH(__sync_add_and_fetch_, 2, uint16_t)
SYNC_ADD_FETCH(__sync_add_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_add_and_fetch_8
****************************************************************************/
SYNC_ADD_FETCH(__sync_add_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_sub_and_fetch_1
****************************************************************************/
@ -626,12 +283,6 @@ SYNC_SUB_FETCH(__sync_sub_and_fetch_, 2, uint16_t)
SYNC_SUB_FETCH(__sync_sub_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_sub_and_fetch_8
****************************************************************************/
SYNC_SUB_FETCH(__sync_sub_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_or_and_fetch_1
****************************************************************************/
@ -650,12 +301,6 @@ SYNC_OR_FETCH(__sync_or_and_fetch_, 2, uint16_t)
SYNC_OR_FETCH(__sync_or_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_or_and_fetch_8
****************************************************************************/
SYNC_OR_FETCH(__sync_or_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_and_and_fetch_1
****************************************************************************/
@ -674,12 +319,6 @@ SYNC_AND_FETCH(__sync_and_and_fetch_, 2, uint16_t)
SYNC_AND_FETCH(__sync_and_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_and_and_fetch_8
****************************************************************************/
SYNC_AND_FETCH(__sync_and_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_xor_and_fetch_1
****************************************************************************/
@ -698,12 +337,6 @@ SYNC_XOR_FETCH(__sync_xor_and_fetch_, 2, uint16_t)
SYNC_XOR_FETCH(__sync_xor_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_xor_and_fetch_8
****************************************************************************/
SYNC_XOR_FETCH(__sync_xor_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_nand_and_fetch_1
****************************************************************************/
@ -722,12 +355,6 @@ SYNC_NAND_FETCH(__sync_nand_and_fetch_, 2, uint16_t)
SYNC_NAND_FETCH(__sync_nand_and_fetch_, 4, uint32_t)
/****************************************************************************
* Name: __sync_nand_and_fetch_8
****************************************************************************/
SYNC_NAND_FETCH(__sync_nand_and_fetch_, 8, uint64_t)
/****************************************************************************
* Name: __sync_bool_compare_and_swap_1
****************************************************************************/
@ -746,12 +373,6 @@ SYNC_BOOL_CMP_SWAP(__sync_bool_compare_and_swap_, 2, uint16_t)
SYNC_BOOL_CMP_SWAP(__sync_bool_compare_and_swap_, 4, uint32_t)
/****************************************************************************
* Name: __sync_bool_compare_and_swap_8
****************************************************************************/
SYNC_BOOL_CMP_SWAP(__sync_bool_compare_and_swap_, 8, uint64_t)
/****************************************************************************
* Name: __sync_val_compare_and_swap_1
****************************************************************************/
@ -770,12 +391,6 @@ SYNC_VAL_CMP_SWAP(__sync_val_compare_and_swap_, 2, uint16_t)
SYNC_VAL_CMP_SWAP(__sync_val_compare_and_swap_, 4, uint32_t)
/****************************************************************************
* Name: __sync_val_compare_and_swap_8
****************************************************************************/
SYNC_VAL_CMP_SWAP(__sync_val_compare_and_swap_, 8, uint64_t)
/****************************************************************************
* Name: __sync_synchronize
****************************************************************************/