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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue