Replace NN_C99_INLINE and VDDS_INLINE by OS_INLINE
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
parent
934ff535d6
commit
9475024a5f
15 changed files with 298 additions and 361 deletions
|
@ -98,7 +98,6 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/ddsi"
|
|||
q_gc.h
|
||||
q_globals.h
|
||||
q_hbcontrol.h
|
||||
q_inline.h
|
||||
q_lat_estim.h
|
||||
q_lease.h
|
||||
q_log.h
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ddsi/q_inline.h"
|
||||
#include "os/os_inline.h"
|
||||
|
||||
#if NN_HAVE_C99_INLINE && !defined SUPPRESS_BITSET_INLINES
|
||||
#if OS_HAVE_INLINE && !defined SUPPRESS_BITSET_INLINES
|
||||
#include "q_bitset_template.h"
|
||||
#else
|
||||
#if defined (__cplusplus)
|
||||
|
|
|
@ -13,34 +13,34 @@
|
|||
|
||||
#include "ddsi/q_unused.h"
|
||||
|
||||
#if defined SUPPRESS_BITSET_INLINES && defined NN_C99_INLINE
|
||||
#undef NN_C99_INLINE
|
||||
#define NN_C99_INLINE
|
||||
#if defined SUPPRESS_BITSET_INLINES && defined OS_INLINE
|
||||
#undef OS_INLINE
|
||||
#define OS_INLINE
|
||||
#endif
|
||||
|
||||
NN_C99_INLINE int nn_bitset_isset (unsigned numbits, const unsigned *bits, unsigned idx)
|
||||
OS_INLINE int nn_bitset_isset (unsigned numbits, const unsigned *bits, unsigned idx)
|
||||
{
|
||||
return idx < numbits && (bits[idx/32] & (1u << (31 - (idx%32))));
|
||||
}
|
||||
|
||||
NN_C99_INLINE void nn_bitset_set (UNUSED_ARG_NDEBUG (unsigned numbits), unsigned *bits, unsigned idx)
|
||||
OS_INLINE void nn_bitset_set (UNUSED_ARG_NDEBUG (unsigned numbits), unsigned *bits, unsigned idx)
|
||||
{
|
||||
assert (idx < numbits);
|
||||
bits[idx/32] |= 1u << (31 - (idx%32));
|
||||
}
|
||||
|
||||
NN_C99_INLINE void nn_bitset_clear (UNUSED_ARG_NDEBUG (unsigned numbits), unsigned *bits, unsigned idx)
|
||||
OS_INLINE void nn_bitset_clear (UNUSED_ARG_NDEBUG (unsigned numbits), unsigned *bits, unsigned idx)
|
||||
{
|
||||
assert (idx < numbits);
|
||||
bits[idx/32] &= ~(1u << (31 - (idx%32)));
|
||||
}
|
||||
|
||||
NN_C99_INLINE void nn_bitset_zero (unsigned numbits, unsigned *bits)
|
||||
OS_INLINE void nn_bitset_zero (unsigned numbits, unsigned *bits)
|
||||
{
|
||||
memset (bits, 0, 4 * ((numbits + 31) / 32));
|
||||
}
|
||||
|
||||
NN_C99_INLINE void nn_bitset_one (unsigned numbits, unsigned *bits)
|
||||
OS_INLINE void nn_bitset_one (unsigned numbits, unsigned *bits)
|
||||
{
|
||||
memset (bits, 0xff, 4 * ((numbits + 31) / 32));
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "ddsi/q_inline.h"
|
||||
#include "ddsi/q_rtps.h" /* for nn_guid_t, nn_guid_prefix_t */
|
||||
#include "ddsi/q_protocol.h" /* for nn_sequence_number_t */
|
||||
|
||||
|
|
|
@ -11,29 +11,29 @@
|
|||
*/
|
||||
/* -*- c -*- */
|
||||
|
||||
#if defined SUPPRESS_BSWAP_INLINES && defined VDDS_INLINE
|
||||
#undef VDDS_INLINE
|
||||
#define VDDS_INLINE
|
||||
#if defined SUPPRESS_BSWAP_INLINES && defined OS_INLINE
|
||||
#undef OS_INLINE
|
||||
#define OS_INLINE
|
||||
#endif
|
||||
|
||||
VDDS_INLINE uint16_t bswap2u (uint16_t x)
|
||||
OS_INLINE uint16_t bswap2u (uint16_t x)
|
||||
{
|
||||
return (unsigned short) ((x >> 8) | (x << 8));
|
||||
}
|
||||
|
||||
VDDS_INLINE uint32_t bswap4u (uint32_t x)
|
||||
OS_INLINE uint32_t bswap4u (uint32_t x)
|
||||
{
|
||||
return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
|
||||
}
|
||||
|
||||
VDDS_INLINE uint64_t bswap8u (uint64_t x)
|
||||
OS_INLINE uint64_t bswap8u (uint64_t x)
|
||||
{
|
||||
const uint32_t newhi = bswap4u ((uint32_t) x);
|
||||
const uint32_t newlo = bswap4u ((uint32_t) (x >> 32));
|
||||
return ((uint64_t) newhi << 32) | (uint64_t) newlo;
|
||||
}
|
||||
|
||||
VDDS_INLINE void bswapSN (nn_sequence_number_t *sn)
|
||||
OS_INLINE void bswapSN (nn_sequence_number_t *sn)
|
||||
{
|
||||
sn->high = bswap4 (sn->high);
|
||||
sn->low = bswap4u (sn->low);
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef NN_INLINE_H
|
||||
#define NN_INLINE_H
|
||||
|
||||
#ifdef NN_SUPPRESS_C99_INLINE
|
||||
|
||||
#define NN_HAVE_C99_INLINE 0
|
||||
|
||||
#else
|
||||
/* We want to inline these, but we don't want to emit an exernally
|
||||
visible symbol for them and we don't want warnings if we don't use
|
||||
them.
|
||||
|
||||
It appears as if a plain "inline" will do just that in C99.
|
||||
|
||||
In traditional GCC one had to use "extern inline" to achieve that
|
||||
effect, but that will cause an externally visible symbol to be
|
||||
emitted by a C99 compiler.
|
||||
|
||||
Starting with GCC 4.3, GCC conforms to the C99 standard if
|
||||
compiling in C99 mode, unless -fgnu89-inline is specified. It
|
||||
defines __GNUC_STDC_INLINE__ if "inline"/"extern inline" behaviour
|
||||
is conforming the C99 standard.
|
||||
|
||||
So: GCC >= 4.3: choose between "inline" & "extern inline" based
|
||||
upon __GNUC_STDC_INLINE__; for GCCs < 4.2, rely on the traditional
|
||||
GCC behaiour; and for other compilers assume they behave conforming
|
||||
the standard if they advertise themselves as C99 compliant (use
|
||||
"inline"), and assume they do not support the inline keywords
|
||||
otherwise.
|
||||
|
||||
GCC when not optimizing ignores "extern inline" functions. So we
|
||||
need to distinguish between optimizing & non-optimizing ... */
|
||||
#if __GNUC__
|
||||
# if __OPTIMIZE__
|
||||
# if 1 || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
# ifdef __GNUC_STDC_INLINE__
|
||||
# define NN_HAVE_C99_INLINE 1
|
||||
# define NN_C99_INLINE inline
|
||||
# else
|
||||
# define NN_HAVE_C99_INLINE 1
|
||||
# define NN_C99_INLINE extern inline
|
||||
# endif
|
||||
# else
|
||||
# define NN_HAVE_C99_INLINE 1
|
||||
# define NN_C99_INLINE extern inline
|
||||
# endif
|
||||
# endif
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
# define NN_HAVE_C99_INLINE 1
|
||||
# define NN_C99_INLINE inline
|
||||
#endif
|
||||
|
||||
#endif /* NN_SUPPRESS_C99_INLINE */
|
||||
|
||||
#if ! NN_HAVE_C99_INLINE
|
||||
#define NN_C99_INLINE
|
||||
#endif
|
||||
|
||||
#endif /* NN_INLINE_H */
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "ddsi/q_inline.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -15,28 +15,28 @@
|
|||
#include "os/os_atomics.h"
|
||||
#include "ddsi/q_static_assert.h"
|
||||
|
||||
#if defined SUPPRESS_THREAD_INLINES && defined NN_C99_INLINE
|
||||
#undef NN_C99_INLINE
|
||||
#define NN_C99_INLINE
|
||||
#if defined SUPPRESS_THREAD_INLINES && defined OS_INLINE
|
||||
#undef OS_INLINE
|
||||
#define OS_INLINE
|
||||
#endif
|
||||
|
||||
NN_C99_INLINE int vtime_awake_p (_In_ vtime_t vtime)
|
||||
OS_INLINE int vtime_awake_p (_In_ vtime_t vtime)
|
||||
{
|
||||
return (vtime % 2) == 0;
|
||||
}
|
||||
|
||||
NN_C99_INLINE int vtime_asleep_p (_In_ vtime_t vtime)
|
||||
OS_INLINE int vtime_asleep_p (_In_ vtime_t vtime)
|
||||
{
|
||||
return (vtime % 2) == 1;
|
||||
}
|
||||
|
||||
NN_C99_INLINE int vtime_gt (_In_ vtime_t vtime1, _In_ vtime_t vtime0)
|
||||
OS_INLINE int vtime_gt (_In_ vtime_t vtime1, _In_ vtime_t vtime0)
|
||||
{
|
||||
Q_STATIC_ASSERT_CODE (sizeof (vtime_t) == sizeof (svtime_t));
|
||||
return (svtime_t) (vtime1 - vtime0) > 0;
|
||||
}
|
||||
|
||||
NN_C99_INLINE void thread_state_asleep (_Inout_ struct thread_state1 *ts1)
|
||||
OS_INLINE void thread_state_asleep (_Inout_ struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t vt = ts1->vtime;
|
||||
vtime_t wd = ts1->watchdog;
|
||||
|
@ -59,7 +59,7 @@ NN_C99_INLINE void thread_state_asleep (_Inout_ struct thread_state1 *ts1)
|
|||
}
|
||||
}
|
||||
|
||||
NN_C99_INLINE void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
||||
OS_INLINE void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t vt = ts1->vtime;
|
||||
vtime_t wd = ts1->watchdog;
|
||||
|
@ -80,7 +80,7 @@ NN_C99_INLINE void thread_state_awake (_Inout_ struct thread_state1 *ts1)
|
|||
|
||||
}
|
||||
|
||||
NN_C99_INLINE void thread_state_blocked (_Inout_ struct thread_state1 *ts1)
|
||||
OS_INLINE void thread_state_blocked (_Inout_ struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t wd = ts1->watchdog;
|
||||
if ( wd % 2 ){
|
||||
|
@ -90,7 +90,7 @@ NN_C99_INLINE void thread_state_blocked (_Inout_ struct thread_state1 *ts1)
|
|||
}
|
||||
}
|
||||
|
||||
NN_C99_INLINE void thread_state_unblocked (_Inout_ struct thread_state1 *ts1)
|
||||
OS_INLINE void thread_state_unblocked (_Inout_ struct thread_state1 *ts1)
|
||||
{
|
||||
vtime_t wd = ts1->watchdog;
|
||||
if ( wd % 2 ){
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#include "os/os.h"
|
||||
|
||||
#include "ddsi/q_inline.h"
|
||||
|
||||
#ifndef os_sockECONNRESET
|
||||
#ifdef WSAECONNRESET
|
||||
#define os_sockECONNRESET WSAECONNRESET
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Note: os_atomics_inlines.c overrules OS_HAVE_INLINE, VDDS_INLINE and
|
||||
/* Note: os_atomics_inlines.c overrules OS_HAVE_INLINE, OS_INLINE and
|
||||
OS_ATOMICS_OMIT_FUNCTIONS */
|
||||
|
||||
#if ! OS_HAVE_INLINE && ! defined OS_ATOMICS_OMIT_FUNCTIONS
|
||||
|
@ -37,8 +37,8 @@ extern "C" {
|
|||
because you can't include only a subset and later include the rest
|
||||
*/
|
||||
#undef OS_HAVE_INLINE
|
||||
#undef VDDS_INLINE
|
||||
#define VDDS_INLINE
|
||||
#undef OS_INLINE
|
||||
#define OS_INLINE
|
||||
#include "os_atomics_win32.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,316 +30,316 @@
|
|||
/* Eliminate C warnings */
|
||||
|
||||
#if ! defined (__cplusplus)
|
||||
VDDS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x);
|
||||
VDDS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v);
|
||||
VDDS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x);
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x);
|
||||
VDDS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
VDDS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
VDDS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
VDDS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des);
|
||||
VDDS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des);
|
||||
VDDS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des);
|
||||
VDDS_INLINE void os_atomic_fence (void);
|
||||
VDDS_INLINE void os_atomic_fence_acq (void);
|
||||
VDDS_INLINE void os_atomic_fence_rel (void);
|
||||
OS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x);
|
||||
OS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v);
|
||||
OS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x);
|
||||
OS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x);
|
||||
OS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
OS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
OS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
OS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v);
|
||||
OS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v);
|
||||
OS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v);
|
||||
OS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des);
|
||||
OS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des);
|
||||
OS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des);
|
||||
OS_INLINE void os_atomic_fence (void);
|
||||
OS_INLINE void os_atomic_fence_acq (void);
|
||||
OS_INLINE void os_atomic_fence_rel (void);
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x);
|
||||
VDDS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
VDDS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des);
|
||||
OS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x);
|
||||
OS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v);
|
||||
OS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* LD, ST */
|
||||
|
||||
VDDS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x) { return x->v; }
|
||||
OS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x) { return x->v; }
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x) { return x->v; }
|
||||
OS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x) { return x->v; }
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x) { return x->v; }
|
||||
VDDS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x) { return (void *) os_atomic_ldptr (x); }
|
||||
OS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x) { return x->v; }
|
||||
OS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x) { return (void *) os_atomic_ldptr (x); }
|
||||
|
||||
VDDS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
VDDS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v) { os_atomic_stptr (x, (uintptr_t) v); }
|
||||
OS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v) { os_atomic_stptr (x, (uintptr_t) v); }
|
||||
|
||||
/* INC */
|
||||
|
||||
VDDS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
VDDS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
|
||||
/* ADD */
|
||||
|
||||
VDDS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
os_atomic_addptr ((volatile os_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
return (void *) os_atomic_addptr_nv ((volatile os_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
VDDS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
os_atomic_subptr ((volatile os_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
return (void *) os_atomic_subptr_nv ((volatile os_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
VDDS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
VDDS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* CAS */
|
||||
|
||||
VDDS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
OS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
#if OS_ATOMIC64_SUPPORT
|
||||
VDDS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
OS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
#endif
|
||||
VDDS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
OS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
VDDS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des) {
|
||||
OS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return os_atomic_casptr (x, (uintptr_t) exp, (uintptr_t) des);
|
||||
}
|
||||
|
||||
/* FENCES */
|
||||
|
||||
VDDS_INLINE void os_atomic_fence (void) {
|
||||
OS_INLINE void os_atomic_fence (void) {
|
||||
__sync_synchronize ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_ldld (void) {
|
||||
OS_INLINE void os_atomic_fence_ldld (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_acq (void) {
|
||||
OS_INLINE void os_atomic_fence_acq (void) {
|
||||
os_atomic_fence ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_rel (void) {
|
||||
OS_INLINE void os_atomic_fence_rel (void) {
|
||||
os_atomic_fence ();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,68 +17,68 @@
|
|||
|
||||
/* LD, ST */
|
||||
|
||||
VDDS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x) { return x->v; }
|
||||
VDDS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x) { return x->v; }
|
||||
VDDS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x) { return x->v; }
|
||||
VDDS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x) { return (void *) os_atomic_ldptr (x); }
|
||||
OS_INLINE uint32_t os_atomic_ld32 (const volatile os_atomic_uint32_t *x) { return x->v; }
|
||||
OS_INLINE uint64_t os_atomic_ld64 (const volatile os_atomic_uint64_t *x) { return x->v; }
|
||||
OS_INLINE uintptr_t os_atomic_ldptr (const volatile os_atomic_uintptr_t *x) { return x->v; }
|
||||
OS_INLINE void *os_atomic_ldvoidp (const volatile os_atomic_voidp_t *x) { return (void *) os_atomic_ldptr (x); }
|
||||
|
||||
VDDS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
VDDS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
VDDS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
VDDS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v) { os_atomic_stptr (x, (uintptr_t) v); }
|
||||
OS_INLINE void os_atomic_st32 (volatile os_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_st64 (volatile os_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_stptr (volatile os_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
OS_INLINE void os_atomic_stvoidp (volatile os_atomic_voidp_t *x, void *v) { os_atomic_stptr (x, (uintptr_t) v); }
|
||||
|
||||
/* INC */
|
||||
|
||||
VDDS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE void os_atomic_inc32 (volatile os_atomic_uint32_t *x) {
|
||||
atomic_inc_32 (&x->v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE void os_atomic_inc64 (volatile os_atomic_uint64_t *x) {
|
||||
atomic_inc_64 (&x->v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE void os_atomic_incptr (volatile os_atomic_uintptr_t *x) {
|
||||
atomic_inc_ulong (&x->v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_inc32_nv (volatile os_atomic_uint32_t *x) {
|
||||
return atomic_inc_32_nv (&x->v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_inc64_nv (volatile os_atomic_uint64_t *x) {
|
||||
return atomic_inc_64_nv (&x->v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_incptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
return atomic_inc_ulong_nv (&x->v);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
VDDS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE void os_atomic_dec32 (volatile os_atomic_uint32_t *x) {
|
||||
atomic_dec_32 (&x->v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE void os_atomic_dec64 (volatile os_atomic_uint64_t *x) {
|
||||
atomic_dec_64 (&x->v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE void os_atomic_decptr (volatile os_atomic_uintptr_t *x) {
|
||||
atomic_dec_ulong (&x->v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_dec32_nv (volatile os_atomic_uint32_t *x) {
|
||||
return atomic_dec_32_nv (&x->v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_dec64_nv (volatile os_atomic_uint64_t *x) {
|
||||
return atomic_dec_64_nv (&x->v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_decptr_nv (volatile os_atomic_uintptr_t *x) {
|
||||
return atomic_dec_ulong_nv (&x->v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x) {
|
||||
OS_INLINE uint32_t os_atomic_dec32_ov (volatile os_atomic_uint32_t *x) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval - 1; } while (atomic_cas_32 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x) {
|
||||
OS_INLINE uint64_t os_atomic_dec64_ov (volatile os_atomic_uint64_t *x) {
|
||||
uint64_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval - 1; } while (atomic_cas_64 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x) {
|
||||
OS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval - 1; } while (atomic_cas_64 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
|
@ -86,158 +86,158 @@ VDDS_INLINE uintptr_t os_atomic_decptr_ov (volatile os_atomic_uintptr_t *x) {
|
|||
|
||||
/* ADD */
|
||||
|
||||
VDDS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_add32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_add_32 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_add64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_add_64 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_addptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
atomic_add_long (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void os_atomic_addvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
atomic_add_ptr (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_add32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_add64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_add_64_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_addptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return atomic_add_long_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void *os_atomic_addvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
return atomic_add_ptr_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
VDDS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_sub32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_add_32 (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_sub64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_add_64 (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_subptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
atomic_add_long (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void os_atomic_subvoidp (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
atomic_add_ptr (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_sub32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_sub64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_add_64_nv (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_subptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return atomic_add_long_nv (&x->v, -v);
|
||||
}
|
||||
VDDS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
OS_INLINE void *os_atomic_subvoidp_nv (volatile os_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
return atomic_add_ptr_nv (&x->v, -v);
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
VDDS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_and32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_and_32 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_and64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_and_64 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_andptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
atomic_and_ulong (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_and32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (atomic_cas_32 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_and64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
uint64_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (atomic_cas_64 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_andptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (atomic_cas_ulong (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_and32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_and_32_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_and64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_and_64_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_andptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return atomic_and_ulong_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
VDDS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE void os_atomic_or32 (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_or_32 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE void os_atomic_or64 (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_or_64 (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE void os_atomic_orptr (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
atomic_or_ulong (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_or32_ov (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (atomic_cas_32 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_or64_ov (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
uint64_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (atomic_cas_64 (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_orptr_ov (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (atomic_cas_ulong (&x->v, oldval, newval) != oldval);
|
||||
return oldval;
|
||||
}
|
||||
VDDS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
OS_INLINE uint32_t os_atomic_or32_nv (volatile os_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_or_32_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
OS_INLINE uint64_t os_atomic_or64_nv (volatile os_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_or_64_nv (&x->v, v);
|
||||
}
|
||||
VDDS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
OS_INLINE uintptr_t os_atomic_orptr_nv (volatile os_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return atomic_or_ulong_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* CAS */
|
||||
|
||||
VDDS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
OS_INLINE int os_atomic_cas32 (volatile os_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
return atomic_cas_32 (&x->v, exp, des) == exp;
|
||||
}
|
||||
VDDS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
OS_INLINE int os_atomic_cas64 (volatile os_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
return atomic_cas_64 (&x->v, exp, des) == exp;
|
||||
}
|
||||
VDDS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
OS_INLINE int os_atomic_casptr (volatile os_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return atomic_cas_ulong (&x->v, exp, des) == exp;
|
||||
}
|
||||
VDDS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des) {
|
||||
OS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return atomic_cas_ptr (&x->v, exp, des) == exp;
|
||||
}
|
||||
|
||||
/* FENCES */
|
||||
|
||||
VDDS_INLINE void os_atomic_fence (void) {
|
||||
OS_INLINE void os_atomic_fence (void) {
|
||||
membar_exit ();
|
||||
membar_enter ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_ldld (void) {
|
||||
OS_INLINE void os_atomic_fence_ldld (void) {
|
||||
membar_enter ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_acq (void) {
|
||||
OS_INLINE void os_atomic_fence_acq (void) {
|
||||
membar_enter ();
|
||||
}
|
||||
VDDS_INLINE void os_atomic_fence_rel (void) {
|
||||
OS_INLINE void os_atomic_fence_rel (void) {
|
||||
membar_exit ();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#error "OS_ENDIANNESS not set correctly"
|
||||
#endif
|
||||
|
||||
#include "os/os_inline.h"
|
||||
#include "os/os_decl_attributes.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
@ -189,66 +190,6 @@ __pragma (warning(pop))
|
|||
os_resultFail
|
||||
} os_result;
|
||||
|
||||
/* We want to inline these, but we don't want to emit an exernally
|
||||
visible symbol for them and we don't want warnings if we don't use
|
||||
them.
|
||||
|
||||
It appears as if a plain "inline" will do just that in C99.
|
||||
|
||||
In traditional GCC one had to use "extern inline" to achieve that
|
||||
effect, but that will cause an externally visible symbol to be
|
||||
emitted by a C99 compiler.
|
||||
|
||||
Starting with GCC 4.3, GCC conforms to the C99 standard if
|
||||
compiling in C99 mode, unless -fgnu89-inline is specified. It
|
||||
defines __GNUC_STDC_INLINE__ if "inline"/"extern inline" behaviour
|
||||
is conforming the C99 standard.
|
||||
|
||||
So: GCC >= 4.3: choose between "inline" & "extern inline" based
|
||||
upon __GNUC_STDC_INLINE__; for GCCs < 4.2, rely on the traditional
|
||||
GCC behaiour; and for other compilers assume they behave conforming
|
||||
the standard if they advertise themselves as C99 compliant (use
|
||||
"inline"), and assume they do not support the inline keywords
|
||||
otherwise.
|
||||
|
||||
GCC when not optimizing ignores "extern inline" functions. So we
|
||||
need to distinguish between optimizing & non-optimizing ... */
|
||||
|
||||
/* Defining OS_HAVE_INLINE is a supported way of overruling this file */
|
||||
#ifndef OS_HAVE_INLINE
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
# /* C99, but old GCC nonetheless doesn't implement C99 semantics ... */
|
||||
# if __GNUC__ && ! defined __GNUC_STDC_INLINE__
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define VDDS_INLINE extern __inline__
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define VDDS_INLINE inline
|
||||
# endif
|
||||
#elif defined __STDC__ && defined __GNUC__ && ! defined __cplusplus
|
||||
# if __OPTIMIZE__
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
# ifdef __GNUC_STDC_INLINE__
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define VDDS_INLINE __inline__
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define VDDS_INLINE extern __inline__
|
||||
# endif
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define VDDS_INLINE extern __inline__
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ! OS_HAVE_INLINE
|
||||
#define VDDS_INLINE
|
||||
#endif
|
||||
|
||||
#endif /* not defined OS_HAVE_INLINE */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* Thread-local storage using __declspec(thread) on Windows versions before
|
||||
Vista and Server 2008 works in DLLs if they are bound to the executable,
|
||||
|
|
72
src/os/include/os/os_inline.h
Normal file
72
src/os/include/os/os_inline.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef OS_INLINE_H
|
||||
#define OS_INLINE_H
|
||||
|
||||
/* We want to inline these, but we don't want to emit an externally visible
|
||||
symbol for them and we don't want warnings if we don't use them.
|
||||
|
||||
It appears as if a plain "inline" will do just that in C99.
|
||||
|
||||
In traditional GCC one had to use "extern inline" to achieve that effect,
|
||||
but that will cause an externally visible symbol to be emitted by a C99
|
||||
compiler.
|
||||
|
||||
Starting with GCC 4.3, GCC conforms to the C99 standard if compiling in C99
|
||||
mode, unless -fgnu89-inline is specified. It defines __GNUC_STDC_INLINE__
|
||||
if "inline"/"extern inline" behaviour is conforming the C99 standard.
|
||||
|
||||
So: GCC >= 4.3: choose between "inline" & "extern inline" based upon
|
||||
__GNUC_STDC_INLINE__; for GCCs < 4.2, rely on the traditional GCC behaviour;
|
||||
and for other compilers assume they behave conforming the standard if they
|
||||
advertise themselves as C99 compliant (use "inline"), and assume they do not
|
||||
support the inline keywords otherwise.
|
||||
|
||||
GCC when not optimizing ignores "extern inline" functions. So we need to
|
||||
distinguish between optimizing & non-optimizing ... */
|
||||
|
||||
/* Defining OS_HAVE_INLINE is a supported way of overruling this file */
|
||||
#ifndef OS_HAVE_INLINE
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
# /* C99, but old GCC nonetheless doesn't implement C99 semantics ... */
|
||||
# if __GNUC__ && ! defined __GNUC_STDC_INLINE__
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define OS_INLINE extern __inline__
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define OS_INLINE inline
|
||||
# endif
|
||||
#elif defined __STDC__ && defined __GNUC__ && ! defined __cplusplus
|
||||
# if __OPTIMIZE__
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
# ifdef __GNUC_STDC_INLINE__
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define OS_INLINE __inline__
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define OS_INLINE extern __inline__
|
||||
# endif
|
||||
# else
|
||||
# define OS_HAVE_INLINE 1
|
||||
# define OS_INLINE extern __inline__
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ! OS_HAVE_INLINE
|
||||
#define OS_INLINE
|
||||
#endif
|
||||
|
||||
#endif /* not defined OS_HAVE_INLINE */
|
||||
|
||||
#endif /* OS_INLINE_H */
|
|
@ -10,7 +10,7 @@
|
|||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#define OS_HAVE_INLINE 0 /* override automatic determination of inlining */
|
||||
#define VDDS_INLINE /* no "inline" in function defs (not really needed) */
|
||||
#define OS_INLINE /* no "inline" in function defs (not really needed) */
|
||||
#define OS_ATOMICS_OMIT_FUNCTIONS 0 /* force inclusion of functions defs */
|
||||
|
||||
#include "os/os.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue