Adds further ext deps as-is binaries copies from customers env.
Qt6 Migration CI / migrate (push) Canceled after 0s
Qt6 Migration CI / migrate (push) Canceled after 0s
This commit is contained in:
3700 files changed
+2132394
No files matched your search
+287
@@ -0,0 +1,287 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDS_CDRSTREAM_H
|
||||
#define DDS_CDRSTREAM_H
|
||||
|
||||
#include "dds/ddsrt/bswap.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsc/dds_data_type_properties.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDS_CDRSTREAM_MAX_NESTING_DEPTH 32 /* maximum level of nesting for key extraction */
|
||||
|
||||
/*
|
||||
Encoding version to be used for serialization. Encoding version 1
|
||||
represents the XCDR1 format as defined in the DDS XTypes specification,
|
||||
with PLAIN_CDR(1) that is backwards compatible with the CDR encoding
|
||||
used by non-XTypes enabled nodes.
|
||||
*/
|
||||
#define DDSI_RTPS_CDR_ENC_VERSION_UNDEF 0
|
||||
#define DDSI_RTPS_CDR_ENC_VERSION_1 1
|
||||
#define DDSI_RTPS_CDR_ENC_VERSION_2 2
|
||||
|
||||
#define DDSI_RTPS_CDR_ENC_FORMAT_PLAIN 0
|
||||
#define DDSI_RTPS_CDR_ENC_FORMAT_DELIMITED 1
|
||||
#define DDSI_RTPS_CDR_ENC_FORMAT_PL 2
|
||||
|
||||
/* X-Types spec 7.6.3.1.2: Implementations of this specification shall set the
|
||||
least significant two bits in the second byte of the options field to a value
|
||||
that encodes the number of padding bytes needed after the end of the serialized
|
||||
payload in order to reach the next 4-byte aligned offset. */
|
||||
#define DDS_CDR_HDR_PADDING_MASK 0x3
|
||||
|
||||
|
||||
#define DDS_CDR_CALCULATED_FLAGS (DDS_TOPIC_FIXED_KEY | DDS_TOPIC_FIXED_KEY_XCDR2 | DDS_TOPIC_FIXED_KEY_XCDR2_KEYHASH | DDS_TOPIC_KEY_APPENDABLE | DDS_TOPIC_KEY_MUTABLE)
|
||||
|
||||
struct dds_cdr_header {
|
||||
unsigned short identifier;
|
||||
unsigned short options;
|
||||
};
|
||||
|
||||
enum dds_cdr_type_extensibility
|
||||
{
|
||||
DDS_CDR_TYPE_EXT_FINAL = 0,
|
||||
DDS_CDR_TYPE_EXT_APPENDABLE = 1,
|
||||
DDS_CDR_TYPE_EXT_MUTABLE = 2
|
||||
};
|
||||
|
||||
enum dds_cdr_key_serialization_kind
|
||||
{
|
||||
DDS_CDR_KEY_SERIALIZATION_SAMPLE,
|
||||
DDS_CDR_KEY_SERIALIZATION_KEYHASH
|
||||
};
|
||||
|
||||
typedef struct dds_istream {
|
||||
const unsigned char *m_buffer;
|
||||
uint32_t m_size; /* Buffer size */
|
||||
uint32_t m_index; /* Read/write offset from start of buffer */
|
||||
uint32_t m_xcdr_version; /* XCDR version of the data */
|
||||
} dds_istream_t;
|
||||
|
||||
typedef struct dds_ostream {
|
||||
unsigned char *m_buffer;
|
||||
uint32_t m_size; /* Buffer size */
|
||||
uint32_t m_index; /* Read/write offset from start of buffer */
|
||||
uint32_t m_xcdr_version; /* XCDR version to use for serializing data */
|
||||
} dds_ostream_t;
|
||||
|
||||
typedef struct dds_ostreamBE {
|
||||
dds_ostream_t x;
|
||||
} dds_ostreamBE_t;
|
||||
|
||||
typedef struct dds_ostreamLE {
|
||||
dds_ostream_t x;
|
||||
} dds_ostreamLE_t;
|
||||
|
||||
typedef struct dds_cdrstream_allocator {
|
||||
void* (*malloc) (size_t size);
|
||||
void* (*realloc) (void *ptr, size_t new_size);
|
||||
void (*free) (void *pt);
|
||||
/* In a future version, a void ptr may be needed here as a parameter for
|
||||
custom allocator implementations. */
|
||||
} dds_cdrstream_allocator_t;
|
||||
|
||||
typedef struct dds_cdrstream_desc_key {
|
||||
uint32_t ops_offs; /* Offset for key ops */
|
||||
uint32_t idx; /* Key index in containing type (definition order) */
|
||||
} dds_cdrstream_desc_key_t;
|
||||
|
||||
typedef struct dds_cdrstream_desc_keys {
|
||||
uint32_t nkeys;
|
||||
struct dds_cdrstream_desc_key *keys; // keys in member-id order
|
||||
struct dds_cdrstream_desc_key *keys_definition_order;
|
||||
} dds_cdrstream_desc_keys_t;
|
||||
|
||||
typedef struct dds_cdrstream_desc_op_seq {
|
||||
uint32_t nops; /* Number of words in ops (which >= number of ops stored in preproc output) */
|
||||
uint32_t *ops; /* Marshalling meta data */
|
||||
} dds_cdrstream_desc_op_seq_t;
|
||||
|
||||
struct dds_cdrstream_desc {
|
||||
uint32_t size; /* Size of type */
|
||||
uint32_t align; /* Alignment of top-level type */
|
||||
uint32_t flagset; /* Flags */
|
||||
struct dds_cdrstream_desc_keys keys;
|
||||
dds_cdrstream_desc_op_seq_t ops;
|
||||
size_t opt_size_xcdr1;
|
||||
size_t opt_size_xcdr2;
|
||||
};
|
||||
|
||||
|
||||
DDSRT_STATIC_ASSERT (offsetof (dds_ostreamLE_t, x) == 0);
|
||||
DDSRT_STATIC_ASSERT (offsetof (dds_ostreamBE_t, x) == 0);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
uint32_t dds_cdr_alignto4_clear_and_resize (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_istream_init (dds_istream_t *is, uint32_t size, const void *input, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_istream_fini (dds_istream_t *is);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostream_init (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, uint32_t size, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostream_fini (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostreamLE_init (dds_ostreamLE_t *os, const struct dds_cdrstream_allocator *allocator, uint32_t size, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostreamLE_fini (dds_ostreamLE_t *os, const struct dds_cdrstream_allocator *allocator);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostreamBE_init (dds_ostreamBE_t *os, const struct dds_cdrstream_allocator *allocator, uint32_t size, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_ostreamBE_fini (dds_ostreamBE_t *os, const struct dds_cdrstream_allocator *allocator);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
dds_ostream_t dds_ostream_from_buffer(void *buffer, size_t size, uint16_t write_encoding_version);
|
||||
|
||||
/**
|
||||
* @brief Normalized and validates CDR data
|
||||
* @component cdr_serializer
|
||||
*
|
||||
* @param data data sample
|
||||
* @param size size of the data
|
||||
* @param bswap byte-swapping required
|
||||
* @param xcdr_version XCDR version of the CDR data
|
||||
* @param desc type descriptor
|
||||
* @param just_key indicates if the data is a serialized key or a complete sample
|
||||
* @param actual_size is set to the actual size of the data (*actual_size <= size) on successful return
|
||||
* @returns True iff validation and normalization succeeded
|
||||
*/
|
||||
DDS_EXPORT bool dds_stream_normalize (void *data, uint32_t size, bool bswap, uint32_t xcdr_version, const struct dds_cdrstream_desc *desc, bool just_key, uint32_t *actual_size)
|
||||
ddsrt_attribute_warn_unused_result ddsrt_nonnull_all;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t *dds_stream_normalize_data (char *data, uint32_t *off, uint32_t size, bool bswap, uint32_t xcdr_version, const uint32_t *ops)
|
||||
ddsrt_attribute_warn_unused_result ddsrt_nonnull_all;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t *dds_stream_write (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, const char *data, const uint32_t *ops)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t *dds_stream_writeLE (dds_ostreamLE_t *os, const struct dds_cdrstream_allocator *allocator, const char *data, const uint32_t *ops)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t *dds_stream_writeBE (dds_ostreamBE_t *os, const struct dds_cdrstream_allocator *allocator, const char *data, const uint32_t *ops)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t * dds_stream_write_with_byte_order (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, const char *data, const uint32_t *ops, enum ddsrt_byte_order_selector bo)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT bool dds_stream_write_sample (dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, const void *data, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT bool dds_stream_write_sampleLE (dds_ostreamLE_t *os, const struct dds_cdrstream_allocator *allocator, const void *data, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT bool dds_stream_write_sampleBE (dds_ostreamBE_t *os, const struct dds_cdrstream_allocator *allocator, const void *data, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_stream_read_sample (dds_istream_t *is, void *data, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_stream_free_sample (void *data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT uint32_t dds_stream_countops (const uint32_t *ops, uint32_t nkeys, const dds_key_descriptor_t *keys);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
size_t dds_stream_check_optimize (const struct dds_cdrstream_desc *desc, uint32_t xcdr_version);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
bool dds_stream_write_key (dds_ostream_t *os, enum dds_cdr_key_serialization_kind ser_kind, const struct dds_cdrstream_allocator *allocator, const char *sample, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
bool dds_stream_write_keyBE (dds_ostreamBE_t *os, enum dds_cdr_key_serialization_kind ser_kind, const struct dds_cdrstream_allocator *allocator, const char *sample, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT bool dds_stream_extract_key_from_data (dds_istream_t *is, dds_ostream_t *os, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_stream_extract_key_from_key (dds_istream_t *is, dds_ostream_t *os, enum dds_cdr_key_serialization_kind ser_kind, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT bool dds_stream_extract_keyBE_from_data (dds_istream_t *is, dds_ostreamBE_t *os, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_stream_extract_keyBE_from_key (dds_istream_t *is, dds_ostreamBE_t *os, enum dds_cdr_key_serialization_kind ser_kind, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT const uint32_t *dds_stream_read (dds_istream_t *is, char *data, const struct dds_cdrstream_allocator *allocator, const uint32_t *ops);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_stream_read_key (dds_istream_t *is, char *sample, const struct dds_cdrstream_allocator *allocator, const struct dds_cdrstream_desc *desc);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT size_t dds_stream_print_key (dds_istream_t *is, const struct dds_cdrstream_desc *desc, char *buf, size_t size);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT size_t dds_stream_print_sample (dds_istream_t *is, const struct dds_cdrstream_desc *desc, char *buf, size_t size);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT size_t dds_stream_getsize_sample (const char *data, const struct dds_cdrstream_desc *desc, uint32_t xcdr_version)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT size_t dds_stream_getsize_key (enum dds_cdr_key_serialization_kind ser_kind, const char *sample, const struct dds_cdrstream_desc *desc, uint32_t xcdr_version)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @component cdr_serializer */
|
||||
uint16_t dds_stream_minimum_xcdr_version (const uint32_t *ops);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
uint32_t dds_stream_type_nesting_depth (const uint32_t *ops);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
uint32_t dds_stream_key_flags (struct dds_cdrstream_desc *desc, uint32_t *keysz_xcdrv1, uint32_t *keysz_xcdrv2);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
bool dds_stream_extensibility (const uint32_t *ops, enum dds_cdr_type_extensibility *ext);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
dds_data_type_properties_t dds_stream_data_types (const uint32_t *ops);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_cdrstream_desc_init (struct dds_cdrstream_desc *desc, const struct dds_cdrstream_allocator *allocator,
|
||||
uint32_t size, uint32_t align, uint32_t flagset, const uint32_t *ops, const dds_key_descriptor_t *keys, uint32_t nkeys);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_cdrstream_desc_fini (struct dds_cdrstream_desc *desc, const struct dds_cdrstream_allocator *allocator);
|
||||
|
||||
/** @component cdr_serializer */
|
||||
DDS_EXPORT void dds_cdrstream_desc_from_topic_desc (struct dds_cdrstream_desc *desc, const dds_topic_descriptor_t *topic_desc);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Copyright(c) 2022 ZettaScale Technology 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 DDS_CONFIG_H
|
||||
#define DDS_CONFIG_H
|
||||
|
||||
/* #undef DDSRT_WITH_LWIP */
|
||||
/* #undef DDSRT_WITH_FREERTOS */
|
||||
|
||||
#define DDSRT_HAVE_DYNLIB 1
|
||||
#define DDSRT_HAVE_FILESYSTEM 1
|
||||
#define DDSRT_HAVE_NETSTAT 1
|
||||
#define DDSRT_HAVE_RUSAGE 1
|
||||
|
||||
#define DDSRT_HAVE_IPV6 1
|
||||
#define DDSRT_HAVE_SSM 1
|
||||
#define DDSRT_HAVE_DNS 1
|
||||
#define DDSRT_HAVE_GETADDRINFO 1
|
||||
#define DDSRT_HAVE_GETHOSTBYNAME_R 1
|
||||
#define DDSRT_HAVE_GETHOSTNAME 1
|
||||
#define DDSRT_HAVE_INET_NTOP 1
|
||||
#define DDSRT_HAVE_INET_PTON 1
|
||||
|
||||
#endif
|
||||
Vendored
+5183
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,64 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology and others
|
||||
// Copyright(c) 2021 Apex.AI, Inc
|
||||
//
|
||||
// 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 _DDS_BASIC_TYPES_H_
|
||||
#define _DDS_BASIC_TYPES_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Handle to an entity
|
||||
* @ingroup entity
|
||||
*
|
||||
* A valid entity handle will always have a positive integer value.
|
||||
* Should the value be negative, it is one of the DDS_RETCODE_*
|
||||
* error codes.
|
||||
*/
|
||||
typedef int32_t dds_entity_t;
|
||||
|
||||
/**
|
||||
* @anchor DDS_MIN_PSEUDO_HANDLE
|
||||
* @ingroup internal
|
||||
* @brief Pseudo Handle origin
|
||||
*
|
||||
* Some handles in CycloneDDS are 'fake', most importantly the builtin topic handles.
|
||||
* These handles are derived from this constant.
|
||||
*/
|
||||
#define DDS_MIN_PSEUDO_HANDLE ((dds_entity_t)0x7fff0000)
|
||||
|
||||
/**
|
||||
* @anchor DDS_CYCLONEDDS_HANDLE
|
||||
* @ingroup internal
|
||||
* @brief Special handle representing the entity corresponding to the CycloneDDS library itself
|
||||
*/
|
||||
#define DDS_CYCLONEDDS_HANDLE ((dds_entity_t)(DDS_MIN_PSEUDO_HANDLE + 256))
|
||||
|
||||
/**
|
||||
* @brief Structure of a GUID in any builtin topic sample.
|
||||
* @ingroup builtintopic
|
||||
*/
|
||||
typedef struct dds_builtintopic_guid
|
||||
{
|
||||
uint8_t v[16]; /**< 16-byte unique identifier */
|
||||
}
|
||||
dds_builtintopic_guid_t;
|
||||
|
||||
/**
|
||||
* @brief Structure of a GUID in any builtin topic sample.
|
||||
* @ingroup builtintopic
|
||||
* @ref dds_builtintopic_guid_t is a bit of a weird name for what everyone just calls a GUID,
|
||||
* so let us try and switch to using the more logical one.
|
||||
*/
|
||||
typedef struct dds_builtintopic_guid dds_guid_t;
|
||||
|
||||
#endif /*_DDS_PUBLIC_TYPES_H_*/
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright(c) 2023 ZettaScale Technology 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 DDS_DATA_TYPE_PROPERTIES_H
|
||||
#define DDS_DATA_TYPE_PROPERTIES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Flags that are used to indicate the types used in a data type
|
||||
*/
|
||||
#define DDS_DATA_TYPE_CONTAINS_UNION (0x1ull << 0)
|
||||
#define DDS_DATA_TYPE_CONTAINS_BITMASK (0x1ull << 1)
|
||||
#define DDS_DATA_TYPE_CONTAINS_ENUM (0x1ull << 2)
|
||||
#define DDS_DATA_TYPE_CONTAINS_STRUCT (0x1ull << 3)
|
||||
#define DDS_DATA_TYPE_CONTAINS_STRING (0x1ull << 4)
|
||||
#define DDS_DATA_TYPE_CONTAINS_BSTRING (0x1ull << 5)
|
||||
#define DDS_DATA_TYPE_CONTAINS_WSTRING (0x1ull << 6)
|
||||
#define DDS_DATA_TYPE_CONTAINS_SEQUENCE (0x1ull << 7)
|
||||
#define DDS_DATA_TYPE_CONTAINS_BSEQUENCE (0x1ull << 8)
|
||||
#define DDS_DATA_TYPE_CONTAINS_ARRAY (0x1ull << 9)
|
||||
#define DDS_DATA_TYPE_CONTAINS_OPTIONAL (0x1ull << 10)
|
||||
#define DDS_DATA_TYPE_CONTAINS_EXTERNAL (0x1ull << 11)
|
||||
#define DDS_DATA_TYPE_CONTAINS_KEY (0x1ull << 12)
|
||||
#define DDS_DATA_TYPE_CONTAINS_BWSTRING (0x1ull << 13)
|
||||
#define DDS_DATA_TYPE_CONTAINS_WCHAR (0x1ull << 14)
|
||||
|
||||
#define DDS_DATA_TYPE_IS_MEMCPY_SAFE (0x1ull << 63)
|
||||
|
||||
typedef uint64_t dds_data_type_properties_t;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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
|
||||
|
||||
// WARNING This file is only needed for the work around for https://github.com/eclipse-cyclonedds/cyclonedds/issues/74
|
||||
// Do not include this file in an application! Once issue #74 is solved this header file should be removed.
|
||||
|
||||
#ifndef DDS_INTERNAL_API_H
|
||||
#define DDS_INTERNAL_API_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/dds.h"
|
||||
#include "dds/cdr/dds_cdrstream.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Magic numbers match the set of internal flags we want to use but do not want to expose in the API.
|
||||
// The implementation contains static assert to ensure this is kept in sync.
|
||||
#define DDS_PARTICIPANT_FLAGS_NO_DISCOVERY (1u | 2u | 32u)
|
||||
|
||||
/**
|
||||
* @ingroup internal
|
||||
* @component topic
|
||||
* @unstable
|
||||
* @brief Gets a CDR stream serializer type descriptor from a topic descriptor
|
||||
*
|
||||
* @param[out] desc Pointer to the target struct that can be filled with the CDR stream topic descriptor
|
||||
* @param[in] topic_desc The source topic descriptor
|
||||
*
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
dds_cdrstream_desc_from_topic_desc (struct dds_cdrstream_desc *desc, const dds_topic_descriptor_t *topic_desc);
|
||||
|
||||
/**
|
||||
* @ingroup internal
|
||||
* @component participant
|
||||
* @unstable
|
||||
* @brief Create a participant with the specified GUID
|
||||
*
|
||||
* @param[in] domain The domain in which to create the participant (can be DDS_DOMAIN_DEFAULT). DDS_DOMAIN_DEFAULT is for using the domain in the configuration.
|
||||
* @param[in] qos The QoS to set on the new participant (can be NULL).
|
||||
* @param[in] listener Any listener functions associated with the new participant (can be NULL).
|
||||
* @param[in] flags The flags to be used when creating the participant
|
||||
* @param[in] guid The GUID for the new participant
|
||||
*
|
||||
* @returns A valid participant handle or an error code. @see dds_create_participant for details
|
||||
*/
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_participant_guid (const dds_domainid_t domain, const dds_qos_t *qos, const dds_listener_t *listener, uint32_t flags, const dds_guid_t *guid);
|
||||
|
||||
/**
|
||||
* @ingroup internal
|
||||
* @component writer
|
||||
* @unstable
|
||||
* @brief Create a writer with the specified GUID
|
||||
*
|
||||
* @param[in] participant_or_publisher The participant or publisher on which the writer is being created.
|
||||
* @param[in] topic The topic to write.
|
||||
* @param[in] qos The QoS to set on the new writer (can be NULL).
|
||||
* @param[in] listener Any listener functions associated with the new writer (can be NULL).
|
||||
* @param[in] guid The GUID for the new writer
|
||||
*
|
||||
* @returns A valid writer handle or an error code. @see dds_create_writer for details
|
||||
*/
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_writer_guid (dds_entity_t participant_or_publisher, dds_entity_t topic, const dds_qos_t *qos, const dds_listener_t *listener, dds_guid_t *guid);
|
||||
|
||||
/**
|
||||
* @ingroup internal
|
||||
* @component reader
|
||||
* @unstable
|
||||
* @brief Create a reader with the specified GUID
|
||||
*
|
||||
* @param[in] participant_or_subscriber The participant or subscriber on which the reader is being created.
|
||||
* @param[in] topic The topic to read.
|
||||
* @param[in] qos The QoS to set on the new reader (can be NULL).
|
||||
* @param[in] listener Any listener functions associated with the new reader (can be NULL).
|
||||
* @param[in] guid The GUID for the new reader
|
||||
*
|
||||
* @returns A valid reader handle or an error code. @see dds_create_reader for details
|
||||
*/
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_reader_guid (dds_entity_t participant_or_subscriber, dds_entity_t topic, const dds_qos_t *qos, const dds_listener_t *listener, dds_guid_t *guid);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
// Copyright(c) 2021 to 2023 ZettaScale Technology
|
||||
// Copyright(c) 2021 Apex.AI, Inc
|
||||
//
|
||||
// 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
|
||||
|
||||
/**
|
||||
* @defgroup loaned_sample (Loaned samples)
|
||||
* @ingroup dds
|
||||
*/
|
||||
|
||||
#ifndef DDS_LOANED_SAMPLE_H
|
||||
#define DDS_LOANED_SAMPLE_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
#include "dds/ddsc/dds_basic_types.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_loan_pool;
|
||||
struct dds_loaned_sample;
|
||||
struct dds_psmx_endpoint;
|
||||
|
||||
/**
|
||||
* @brief State of the data contained in a Loaned Sample
|
||||
* @ingroup loaned_sample
|
||||
*
|
||||
*/
|
||||
typedef enum dds_loaned_sample_state {
|
||||
DDS_LOANED_SAMPLE_STATE_UNITIALIZED, //!< state not set yet; not passed through PSMX interface
|
||||
DDS_LOANED_SAMPLE_STATE_RAW_KEY, //!< application representation, only key fields initialized
|
||||
DDS_LOANED_SAMPLE_STATE_RAW_DATA, //!< application representation, full sample initialized
|
||||
DDS_LOANED_SAMPLE_STATE_SERIALIZED_KEY, //!< CDR/XCDR1/XCDR2-serialized key value serialized
|
||||
DDS_LOANED_SAMPLE_STATE_SERIALIZED_DATA //!< CDR/XCDR1/XCDR2-serialized sample value serialized
|
||||
} dds_loaned_sample_state_t;
|
||||
|
||||
/**
|
||||
* @brief Identifier used to distinguish between raw data types (C/C++/Python/...) in a Loaned Sample
|
||||
* @ingroup loaned_sample
|
||||
*/
|
||||
typedef uint32_t dds_loan_data_type_t;
|
||||
|
||||
/**
|
||||
* @brief Definition for function to free a Loaned Sample
|
||||
* @ingroup loaned_sample
|
||||
*
|
||||
* @param[in] loaned_sample A loaned sample
|
||||
*/
|
||||
typedef void (*dds_loaned_sample_free_f) (struct dds_loaned_sample *loaned_sample)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Container for implementation specific operations
|
||||
* @ingroup loaned_sample
|
||||
*/
|
||||
typedef struct dds_loaned_sample_ops {
|
||||
dds_loaned_sample_free_f free;
|
||||
} dds_loaned_sample_ops_t;
|
||||
|
||||
typedef enum dds_loaned_sample_origin_kind {
|
||||
DDS_LOAN_ORIGIN_KIND_HEAP, //!< Loaned sample allocated on the heap (and owned by Cyclone DDS)
|
||||
DDS_LOAN_ORIGIN_KIND_PSMX //!< Loaned sample owned by a PSMX Endpoint
|
||||
} dds_loaned_sample_origin_kind_t;
|
||||
|
||||
typedef struct dds_loaned_sample_origin {
|
||||
enum dds_loaned_sample_origin_kind origin_kind; //!< Whether on the HEAP or provided by a PSMX Endpoint
|
||||
struct dds_psmx_endpoint *psmx_endpoint; //!< Owning PSMX Endpoint, null if KIND_HEAP
|
||||
} dds_loaned_sample_origin_t;
|
||||
|
||||
/**
|
||||
* @brief The definition of a Loaned Sample
|
||||
* @ingroup loaned_sample
|
||||
*/
|
||||
typedef struct dds_loaned_sample {
|
||||
dds_loaned_sample_ops_t ops; //!< the implementation specific ops for this sample
|
||||
struct dds_loaned_sample_origin loan_origin; //!< the origin of the loan
|
||||
struct dds_psmx_metadata * metadata; //!< pointer to the associated metadata
|
||||
void * sample_ptr; //!< pointer to the loaned sample
|
||||
ddsrt_atomic_uint32_t refc; //!< the number of references to this loan
|
||||
} dds_loaned_sample_t;
|
||||
|
||||
/**
|
||||
* @brief Generic function to increase the refcount for a loaned sample
|
||||
* @ingroup loaned_sample
|
||||
*
|
||||
* @param[in] loaned_sample A loaned sample
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_nonnull_all dds_loaned_sample_ref (dds_loaned_sample_t *loaned_sample) {
|
||||
ddsrt_atomic_inc32 (&loaned_sample->refc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generic function to decrease the refcount for a loaned sample
|
||||
* @ingroup loaned_sample
|
||||
*
|
||||
* Calls the PSMX plugin specific free function once the reference count reaches 0.
|
||||
*
|
||||
* Loaned Samples are freed in the order in which their reference counts drop to 0.
|
||||
*
|
||||
* On the writing side, writing (or "returning") Loaned Samples in the order in which they
|
||||
* were requested will ensure that the "free" operations is also invoked in the that
|
||||
* order.
|
||||
*
|
||||
* On the reading side, the `serdata` constructed by `dds_reader_store_loaned_sample` may
|
||||
* or may not reference the Loaned Sample, and if not the Loaned Sample will be dropped
|
||||
* once the PSMX Plugin invokes `dds_loaned_sample_unref` on it.
|
||||
*
|
||||
* Otherwise, the Loaned Sample will be referenced by a sample in the reader history cache
|
||||
* and stay there until it gets dropped (and the PSMX Plugin also invokes
|
||||
* `dds_loaned_sample_unref` on it). If the reading application does not use loans in the
|
||||
* reads/takes, that will be once it is pushed out of the history or taken. If the
|
||||
* application uses `takecdr` or `take_with_collector`, then it is dependent on when the
|
||||
* application logic drops the serdata via `ddsi_serdata_unref`.
|
||||
*
|
||||
* If the application does use loans in reads/takes, and Cyclone DDS decides to hand the
|
||||
* data in the Loaned Sample to the application, the earliest time at which it can be
|
||||
* dropped is when it is removed from the reader history cache *and* the loan is returned
|
||||
* by the application using `dds_return_loan`.
|
||||
*
|
||||
* @param[in] loaned_sample A loaned sample
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_nonnull_all dds_loaned_sample_unref (dds_loaned_sample_t *loaned_sample) {
|
||||
if (ddsrt_atomic_dec32_ov (&loaned_sample->refc) == 1)
|
||||
loaned_sample->ops.free (loaned_sample);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert data from a loaned sample into the reader history cache
|
||||
* @ingroup reading
|
||||
*
|
||||
* Constructs a serdata of the reader's type from the loaned sample and stores it in the
|
||||
* reader's history cache. If the serdata references the loan, `dds_loaned_sample_ref` is
|
||||
* used to increment its reference count.
|
||||
*
|
||||
* If data is not from a known writer, this is a no-op.
|
||||
*
|
||||
* @param[in] reader The reader entity.
|
||||
* @param[in] data Pointer to the loaned sample of the entity received
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The operation was successful.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more parameters are invalid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The reader entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_reader_store_loaned_sample (dds_entity_t reader, dds_loaned_sample_t *data)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief insert data from a loaned sample into the reader history cache using the provided writer meta-data
|
||||
* @ingroup reading
|
||||
*
|
||||
* Constructs a serdata of the reader's type from the loaned sample and stores it in the
|
||||
* reader's history cache. If the serdata references the loan, `dds_loaned_sample_ref` is
|
||||
* used to increment its reference count.
|
||||
*
|
||||
* It is equivalent to `dds_reader_store_loaned_sample`, except that for this function no
|
||||
* writer look-up takes place (it doesn't need to because the required information is
|
||||
* passed in directly) and data unknown writers is accepted.
|
||||
|
||||
* @param[in] reader The reader entity.
|
||||
* @param[in] data Pointer to the loaned sample of the entity received
|
||||
* @param[in] ownership_strength The ownership strength of the writer
|
||||
* @param[in] autodispose_unregistered_instances Writer setting for auto-disposing unregistered entities
|
||||
* @param[in] lifespan_duration Lifespan duration value configured for the writer
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The operation was successful.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more parameters are invalid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The reader entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_reader_store_loaned_sample_wr_metadata (dds_entity_t reader, dds_loaned_sample_t *data, int32_t ownership_strength, bool autodispose_unregistered_instances, dds_duration_t lifespan_duration)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDS_LOANED_SAMPLE_H */
|
||||
+676
@@ -0,0 +1,676 @@
|
||||
// Copyright(c) 2021 to 2022 ZettaScale Technology 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 DDS_OPCODES_H
|
||||
#define DDS_OPCODES_H
|
||||
|
||||
#include "dds/ddsrt/align.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup serialization (Serialization)
|
||||
* @ingroup dds
|
||||
*
|
||||
* Opcodes for (de)serialization of types generated by idlc. Isolated in a
|
||||
* separate header to share with idlc without the need to pull in the entire
|
||||
* Eclipse Cyclone DDS C language binding.
|
||||
*
|
||||
* One opcode is a uint32 and depending on which code it is can contain several uint32 arguments.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP
|
||||
*/
|
||||
#define DDS_OP_MASK 0xff000000
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_TYPE_FLAGS_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP type flags
|
||||
*/
|
||||
#define DDS_OP_TYPE_FLAGS_MASK 0x00800000
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_TYPE_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP type
|
||||
*/
|
||||
#define DDS_OP_TYPE_MASK 0x007f0000
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_SUBTYPE_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP subtype
|
||||
*/
|
||||
#define DDS_OP_SUBTYPE_MASK 0x0000ff00
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_JMP_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP jump
|
||||
*/
|
||||
#define DDS_OP_JMP_MASK 0x0000ffff
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAGS_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the OP flags
|
||||
*/
|
||||
#define DDS_OP_FLAGS_MASK 0x000000ff
|
||||
|
||||
/**
|
||||
* @anchor DDS_JEQ_TYPE_FLAGS_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the JEQ type flags
|
||||
*/
|
||||
#define DDS_JEQ_TYPE_FLAGS_MASK 0x00800000
|
||||
|
||||
/**
|
||||
* @anchor DDS_JEQ_TYPE_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the JEQ type
|
||||
*/
|
||||
#define DDS_JEQ_TYPE_MASK 0x007f0000
|
||||
|
||||
/**
|
||||
* @anchor DDS_PLM_FLAGS_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the PLM flags
|
||||
*/
|
||||
#define DDS_PLM_FLAGS_MASK 0x00ff0000
|
||||
|
||||
/**
|
||||
* @anchor DDS_KOF_OFFSET_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Mask for the KOF offset
|
||||
*/
|
||||
#define DDS_KOF_OFFSET_MASK 0x0000ffff
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP
|
||||
* @ingroup serialization
|
||||
* @brief Extract the DDS OP from a uint32 as a \ref dds_stream_opcode
|
||||
*/
|
||||
#define DDS_OP(o) ((enum dds_stream_opcode) ((o) & DDS_OP_MASK))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_TYPE
|
||||
* @ingroup serialization
|
||||
* @brief Extract the DDS OP_TYPE from a uint32 as a \ref dds_stream_typecode
|
||||
*/
|
||||
#define DDS_OP_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_TYPE_MASK) >> 16))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_TYPE_FLAGS
|
||||
* @ingroup serialization
|
||||
* @brief Extract the DDS OP_TYPE_FLAGS from a uint32
|
||||
* DOC_TODO: possible values?
|
||||
*/
|
||||
#define DDS_OP_TYPE_FLAGS(o) ((o) & DDS_OP_TYPE_FLAGS_MASK)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_SUBTYPE
|
||||
* @ingroup serialization
|
||||
* @brief Extract the DDS OP_SUBTYPE from a uint32 as a \ref dds_stream_typecode
|
||||
* Used for collections, the OP_TYPE is array/sequence
|
||||
*/
|
||||
#define DDS_OP_SUBTYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_SUBTYPE_MASK) >> 8))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAGS
|
||||
* @ingroup serialization
|
||||
* @brief Extract the DDS OP_FLAGS from a uint32
|
||||
* DOC_TODO: possible values?
|
||||
*/
|
||||
#define DDS_OP_FLAGS(o) ((o) & DDS_OP_FLAGS_MASK)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_ADR_JSR
|
||||
* @ingroup serialization
|
||||
* @brief Extract the ADR JSR from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_OP_ADR_JSR(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_ADR_PLM
|
||||
* @ingroup serialization
|
||||
* @brief Extract the ADR PLM from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_OP_ADR_PLM(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_LENGTH
|
||||
* @ingroup serialization
|
||||
* @brief Extract the LENGTH from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_OP_LENGTH(o) ((uint16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_JUMP
|
||||
* @ingroup serialization
|
||||
* @brief Extract the JUMP from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_OP_JUMP(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_ADR_JMP
|
||||
* @ingroup serialization
|
||||
* @brief Extract the ADR_JMP from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_OP_ADR_JMP(o) ((o) >> 16)
|
||||
|
||||
/**
|
||||
* @anchor DDS_JEQ_TYPE
|
||||
* @ingroup serialization
|
||||
* @brief Extract the JEQ_TYPE from a uint32 as a \ref dds_stream_typecode
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_JEQ_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_JEQ_TYPE_MASK) >> 16))
|
||||
|
||||
/**
|
||||
* @anchor DDS_JEQ_TYPE_FLAGS
|
||||
* @ingroup serialization
|
||||
* @brief Extract the JEQ_TYPE_FLAGS from a uint32
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_JEQ_TYPE_FLAGS(o) ((o) & DDS_JEQ_TYPE_FLAGS_MASK)
|
||||
|
||||
/**
|
||||
* @anchor DDS_PLM_FLAGS
|
||||
* @ingroup serialization
|
||||
* @brief Extract the PLM_FLAGS from a uint32 as a \ref dds_stream_typecode
|
||||
* DOC_TODO: meaning?
|
||||
*/
|
||||
#define DDS_PLM_FLAGS(o) ((enum dds_stream_typecode) (((o) & DDS_PLM_FLAGS_MASK) >> 16))
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup serialization
|
||||
* @brief Topic encoding instruction types
|
||||
*/
|
||||
enum dds_stream_opcode {
|
||||
/** return from subroutine, exits top-level
|
||||
[RTS, 0, 0, 0] */
|
||||
DDS_OP_RTS = 0x00 << 24,
|
||||
|
||||
/** data field
|
||||
[ADR, nBY, 0, f] [offset]
|
||||
[ADR, BLN, 0, f] [offset]
|
||||
[ADR, WCHAR, 0, f] [offset]
|
||||
[ADR, ENU, 0, f] [offset] [max]
|
||||
[ADR, BMK, 0, f] [offset] [bits-high] [bits-low]
|
||||
[ADR, STR, 0, f] [offset]
|
||||
[ADR, WSTR, 0, f] [offset]
|
||||
[ADR, BST, 0, f] [offset] [max-size]
|
||||
[ADR, BWSTR, 0, f] [offset] [max-size]
|
||||
|
||||
[ADR, SEQ, nBY, f] [offset]
|
||||
[ADR, SEQ, BLN, f] [offset]
|
||||
[ADR, SEQ, WCHAR, f] [offset]
|
||||
[ADR, SEQ, ENU, f] [offset] [max]
|
||||
[ADR, SEQ, BMK, f] [offset] [bits-high] [bits-low]
|
||||
[ADR, SEQ, STR, f] [offset]
|
||||
[ADR, SEQ, WSTR, f] [offset]
|
||||
[ADR, SEQ, BST, f] [offset] [max-size]
|
||||
[ADR, SEQ, BWSTR, f] [offset] [max-size]
|
||||
[ADR, SEQ, s, f] [offset] [elem-size] [next-insn, elem-insn]
|
||||
where s = {SEQ,ARR,UNI,STU,BSQ}
|
||||
[ADR, SEQ, EXT, f] *** not supported
|
||||
|
||||
[ADR, BSQ, nBY, f] [offset] [sbound]
|
||||
[ADR, BSQ, BLN, f] [offset] [sbound]
|
||||
[ADR, BSQ, WCHAR, f] [offset] [sbound]
|
||||
[ADR, BSQ, ENU, f] [offset] [sbound] [max]
|
||||
[ADR, BSQ, BMK, f] [offset] [sbound] [bits-high] [bits-low]
|
||||
[ADR, BSQ, STR, f] [offset] [sbound]
|
||||
[ADR, BSQ, WSTR, f] [offset] [sbound]
|
||||
[ADR, BSQ, BST, f] [offset] [sbound] [max-size]
|
||||
[ADR, BSQ, BWSTR, f] [offset] [sbound] [max-size]
|
||||
[ADR, BSQ, s, f] [offset] [sbound] [elem-size] [next-insn, elem-insn]
|
||||
where s = {SEQ,ARR,UNI,STU,BSQ}
|
||||
[ADR, BSQ, EXT, f] *** not supported
|
||||
|
||||
[ADR, ARR, nBY, f] [offset] [alen]
|
||||
[ADR, ARR, BLN, f] [offset] [alen]
|
||||
[ADR, ARR, WCHAR, f] [offset] [alen]
|
||||
[ADR, ARR, ENU, f] [offset] [alen] [max]
|
||||
[ADR, ARR, BMK, f] [offset] [alen] [bits-high] [bits-low]
|
||||
[ADR, ARR, STR, f] [offset] [alen]
|
||||
[ADR, ARR, WSTR, f] [offset] [alen]
|
||||
[ADR, ARR, BST, f] [offset] [alen] [0] [max-size]
|
||||
[ADR, ARR, BWSTR, f] [offset] [alen] [0] [max-size]
|
||||
[ADR, ARR, s, f] [offset] [alen] [next-insn, elem-insn] [elem-size]
|
||||
where s = {SEQ,ARR,UNI,STU,BSQ}
|
||||
[ADR, ARR, EXT, f] *** not supported
|
||||
|
||||
[ADR, UNI, d, z] [offset] [alen] [next-insn, cases]
|
||||
[ADR, UNI, ENU, z] [offset] [alen] [next-insn, cases] [max]
|
||||
[ADR, UNI, EXT, f] *** not supported
|
||||
where
|
||||
d = discriminant type of {1BY,2BY,4BY,BLN}
|
||||
z = default present/not present (DDS_OP_FLAG_DEF)
|
||||
offset = discriminant offset
|
||||
max = max enum value
|
||||
followed by alen case labels: in JEQ format
|
||||
|
||||
[ADR, e | EXT, 0, f] [offset] [next-insn, elem-insn] [elem-size iff "external" flag e is set, or flag f has DDS_OP_FLAG_OPT]
|
||||
[ADR, STU, 0, f] *** not supported
|
||||
where
|
||||
s = subtype
|
||||
e = external: stored as external data (pointer) (DDS_OP_FLAG_EXT)
|
||||
f = flags:
|
||||
- key/not key (DDS_OP_FLAG_KEY)
|
||||
- base type member, used with EXT type (DDS_OP_FLAG_BASE)
|
||||
- optional (DDS_OP_FLAG_OPT)
|
||||
- must-understand (DDS_OP_FLAG_MU)
|
||||
- storage size, only for ENU and BMK (n << DDS_OP_FLAG_SZ_SHIFT)
|
||||
[offset] = field offset from start of element in memory
|
||||
[elem-size] = element size in memory (elem-size is only included in case 'external' flag is set)
|
||||
[max-size] = string bound + 1
|
||||
[max] = max enum value
|
||||
[bits-..] = identified bits in the bitmask, split into high and low 32 bits
|
||||
[alen] = array length, number of cases
|
||||
[sbound] = bounded sequence maximum number of elements
|
||||
[next-insn] = (unsigned 16 bits) offset to instruction for next field, from start of insn
|
||||
[elem-insn] = (unsigned 16 bits) offset to first instruction for element, from start of insn
|
||||
[cases] = (unsigned 16 bits) offset to first case label, from start of insn
|
||||
*/
|
||||
DDS_OP_ADR = 0x01 << 24,
|
||||
|
||||
/** jump-to-subroutine (e.g. used for recursive types and appendable unions)
|
||||
[JSR, 0, e]
|
||||
where
|
||||
e = (signed 16 bits) offset to first instruction in subroutine, from start of insn
|
||||
instruction sequence must end in RTS, execution resumes at instruction
|
||||
following JSR */
|
||||
DDS_OP_JSR = 0x02 << 24,
|
||||
|
||||
/** jump-if-equal, used for union cases:
|
||||
[JEQ, nBY, 0] [disc] [offset]
|
||||
[JEQ, BLN, 0] [disc] [offset]
|
||||
[JEQ, STR, 0] [disc] [offset]
|
||||
[JEQ, s, i] [disc] [offset]
|
||||
[JEQ4, e | nBY, 0] [disc] [offset] 0
|
||||
[JEQ4, e | STR, 0] [disc] [offset] 0
|
||||
[JEQ4, e | ENU, f] [disc] [offset] [max]
|
||||
[JEQ4, EXT, 0] *** not supported, use STU/UNI for external defined types
|
||||
[JEQ4, e | s, i] [disc] [offset] [elem-size iff "external" flag e is set, else 0]
|
||||
where
|
||||
e = external: stored as external data (pointer) (DDS_OP_FLAG_EXT)
|
||||
s = subtype other than {nBY,STR} for JEQ and {nBY,STR,ENU,EXT} for JEQ4
|
||||
(note that BMK cannot be inline, because it needs 2 additional instructions
|
||||
for the bits that are identified in the bitmask type)
|
||||
i = (unsigned 16 bits) offset to first instruction for case, from start of insn
|
||||
instruction sequence must end in RTS, at which point executes continues
|
||||
at the next field's instruction as specified by the union
|
||||
f = size flags for ENU instruction
|
||||
|
||||
Note that the JEQ instruction is deprecated and replaced by the JEQ4 instruction. The
|
||||
IDL compiler only generates JEQ4 for union cases, the JEQ instruction is included here
|
||||
for backwards compatibility (topic descriptors generated with a previous version of IDLC)
|
||||
*/
|
||||
DDS_OP_JEQ = 0x03 << 24,
|
||||
|
||||
/** XCDR2 delimited CDR (inserts DHEADER before type)
|
||||
[DLC, 0, 0]
|
||||
*/
|
||||
DDS_OP_DLC = 0x04 << 24,
|
||||
|
||||
/** XCDR2 parameter list CDR (inserts DHEADER before type and EMHEADER before each member)
|
||||
[PLC, 0, 0]
|
||||
followed by a list of JEQ instructions
|
||||
*/
|
||||
DDS_OP_PLC = 0x05 << 24,
|
||||
|
||||
/**
|
||||
[PLM, f, elem-insn] [member id]
|
||||
for members of aggregated mutable types (pl-cdr):
|
||||
where
|
||||
f = flags:
|
||||
- jump to base type (DDS_OP_FLAG_BASE)
|
||||
[elem-insn] = (unsigned 16 bits) offset to instruction for element, from start of insn
|
||||
when FLAG_BASE is set, this is the offset of the PLM list of the base type
|
||||
[member id] = id for this member (0 in case FLAG_BASE is set)
|
||||
*/
|
||||
DDS_OP_PLM = 0x06 << 24,
|
||||
|
||||
/** Key offset list
|
||||
[KOF, 0, n] [offset-1] ... [offset-n]
|
||||
where
|
||||
n = number of key offsets in following ops
|
||||
offset = Offset of the key field relative to the previous offset, repeated n times when key is
|
||||
in a nested struct. In case of inheritance of mutable structs, a single offset of
|
||||
the key member relative to the first op of the top-level type (index 0).
|
||||
*/
|
||||
DDS_OP_KOF = 0x07 << 24,
|
||||
|
||||
/** see comment for JEQ/JEQ4 above */
|
||||
DDS_OP_JEQ4 = 0x08 << 24
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup serialization
|
||||
* @brief datatypes as recognized by serialization VM.
|
||||
*/
|
||||
enum dds_stream_typecode {
|
||||
DDS_OP_VAL_1BY = 0x01, /**< one byte simple type (char, octet) */
|
||||
DDS_OP_VAL_2BY = 0x02, /**< two byte simple type ((unsigned) short) */
|
||||
DDS_OP_VAL_4BY = 0x03, /**< four byte simple type ((unsigned) long, float) */
|
||||
DDS_OP_VAL_8BY = 0x04, /**< eight byte simple type ((unsigned) long long, double) */
|
||||
DDS_OP_VAL_STR = 0x05, /**< string */
|
||||
DDS_OP_VAL_BST = 0x06, /**< bounded string */
|
||||
DDS_OP_VAL_SEQ = 0x07, /**< sequence */
|
||||
DDS_OP_VAL_ARR = 0x08, /**< array */
|
||||
DDS_OP_VAL_UNI = 0x09, /**< union */
|
||||
DDS_OP_VAL_STU = 0x0a, /**< struct */
|
||||
DDS_OP_VAL_BSQ = 0x0b, /**< bounded sequence */
|
||||
DDS_OP_VAL_ENU = 0x0c, /**< enumerated value (long) */
|
||||
DDS_OP_VAL_EXT = 0x0d, /**< field with external definition */
|
||||
DDS_OP_VAL_BLN = 0x0e, /**< boolean */
|
||||
DDS_OP_VAL_BMK = 0x0f, /**< bitmask */
|
||||
DDS_OP_VAL_WSTR = 0x10, /**< wstring (UTF-16) */
|
||||
DDS_OP_VAL_BWSTR = 0x11, /**< bounded wstring (UTF-16) */
|
||||
DDS_OP_VAL_WCHAR = 0x12 /**< wchar: UTF-16, no surrogates allowed */
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup serialization
|
||||
* @brief primary type code for DDS_OP_ADR, DDS_OP_JEQ
|
||||
* Convinience pre-bitshifted values.
|
||||
*/
|
||||
enum dds_stream_typecode_primary {
|
||||
DDS_OP_TYPE_1BY = DDS_OP_VAL_1BY << 16, /**< one byte simple type (char, octet) */
|
||||
DDS_OP_TYPE_2BY = DDS_OP_VAL_2BY << 16, /**< two byte simple type ((unsigned) short) */
|
||||
DDS_OP_TYPE_4BY = DDS_OP_VAL_4BY << 16, /**< four byte simple type ((unsigned) long, float) */
|
||||
DDS_OP_TYPE_8BY = DDS_OP_VAL_8BY << 16, /**< eight byte simple type ((unsigned) long long, double) */
|
||||
DDS_OP_TYPE_STR = DDS_OP_VAL_STR << 16, /**< string */
|
||||
DDS_OP_TYPE_BST = DDS_OP_VAL_BST << 16, /**< bounded string */
|
||||
DDS_OP_TYPE_SEQ = DDS_OP_VAL_SEQ << 16, /**< sequence */
|
||||
DDS_OP_TYPE_ARR = DDS_OP_VAL_ARR << 16, /**< array */
|
||||
DDS_OP_TYPE_UNI = DDS_OP_VAL_UNI << 16, /**< union */
|
||||
DDS_OP_TYPE_STU = DDS_OP_VAL_STU << 16, /**< struct */
|
||||
DDS_OP_TYPE_BSQ = DDS_OP_VAL_BSQ << 16, /**< bounded sequence */
|
||||
DDS_OP_TYPE_ENU = DDS_OP_VAL_ENU << 16, /**< enumerated value (long) */
|
||||
DDS_OP_TYPE_EXT = DDS_OP_VAL_EXT << 16, /**< field with external definition */
|
||||
DDS_OP_TYPE_BLN = DDS_OP_VAL_BLN << 16, /**< boolean */
|
||||
DDS_OP_TYPE_BMK = DDS_OP_VAL_BMK << 16, /**< bitmask */
|
||||
DDS_OP_TYPE_WSTR = DDS_OP_VAL_WSTR << 16, /**< wstring (UTF-16) */
|
||||
DDS_OP_TYPE_BWSTR = DDS_OP_VAL_BWSTR << 16, /**< bounded wstring (UTF-16) */
|
||||
DDS_OP_TYPE_WCHAR = DDS_OP_VAL_WCHAR << 16 /**< wchar: UTF-16, no surrogates allowed */
|
||||
};
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_EXT
|
||||
* @ingroup serialization
|
||||
* @brief This flag indicates that the type has external data
|
||||
* (i.e. a mapped to a pointer type), which can be the case because of (1) the \@external annotation
|
||||
* in idl or (2) the \@optional annotation (optional fields are also mapped to pointer types as described
|
||||
* in the XTypes spec). This flag is stored in the most-significant bit of the 'type' part of the
|
||||
* serializer instruction.
|
||||
*/
|
||||
#define DDS_OP_FLAG_EXT (1u << 23)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup serialization
|
||||
* @brief sub-type code
|
||||
* - encodes element type for DDS_OP_TYPE_{SEQ,ARR},
|
||||
* - discriminant type for DDS_OP_TYPE_UNI
|
||||
* Convinience pre-bitshifted values.
|
||||
*/
|
||||
enum dds_stream_typecode_subtype {
|
||||
DDS_OP_SUBTYPE_1BY = DDS_OP_VAL_1BY << 8, /**< one byte simple type (char, octet) */
|
||||
DDS_OP_SUBTYPE_2BY = DDS_OP_VAL_2BY << 8, /**< two byte simple type ((unsigned) short) */
|
||||
DDS_OP_SUBTYPE_4BY = DDS_OP_VAL_4BY << 8, /**< four byte simple type ((unsigned) long, float) */
|
||||
DDS_OP_SUBTYPE_8BY = DDS_OP_VAL_8BY << 8, /**< eight byte simple type ((unsigned) long long, double) */
|
||||
DDS_OP_SUBTYPE_STR = DDS_OP_VAL_STR << 8, /**< string */
|
||||
DDS_OP_SUBTYPE_BST = DDS_OP_VAL_BST << 8, /**< bounded string */
|
||||
DDS_OP_SUBTYPE_SEQ = DDS_OP_VAL_SEQ << 8, /**< sequence */
|
||||
DDS_OP_SUBTYPE_ARR = DDS_OP_VAL_ARR << 8, /**< array */
|
||||
DDS_OP_SUBTYPE_UNI = DDS_OP_VAL_UNI << 8, /**< union */
|
||||
DDS_OP_SUBTYPE_STU = DDS_OP_VAL_STU << 8, /**< struct */
|
||||
DDS_OP_SUBTYPE_BSQ = DDS_OP_VAL_BSQ << 8, /**< bounded sequence */
|
||||
DDS_OP_SUBTYPE_ENU = DDS_OP_VAL_ENU << 8, /**< enumerated value (long) */
|
||||
DDS_OP_SUBTYPE_BLN = DDS_OP_VAL_BLN << 8, /**< boolean */
|
||||
DDS_OP_SUBTYPE_BMK = DDS_OP_VAL_BMK << 8, /**< bitmask */
|
||||
DDS_OP_SUBTYPE_WSTR = DDS_OP_VAL_WSTR << 8, /**< wstring */
|
||||
DDS_OP_SUBTYPE_BWSTR = DDS_OP_VAL_BWSTR << 8, /**< bounded wstring */
|
||||
DDS_OP_SUBTYPE_WCHAR = DDS_OP_VAL_WCHAR << 8 /**< wchar: UTF-16, no surrogates allowed */
|
||||
};
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_KEY
|
||||
* @ingroup serialization
|
||||
* @brief mark field as key
|
||||
* applicable to {1,2,4,8}BY, STR, BST, ARR-of-{1,2,4,8}BY.
|
||||
* Note that when defining keys in nested types, the key flag should be set
|
||||
* on both the field(s) in the subtype and on the enclosing STU/EXT field.
|
||||
*/
|
||||
#define DDS_OP_FLAG_KEY (1u << 0)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_DEF
|
||||
* @ingroup serialization
|
||||
* @brief For a union:
|
||||
* -# the discriminator may be a key field;
|
||||
* -# there may be a default value;
|
||||
* -# and the discriminator can be an integral type (or enumerated - here treated as equivalent).
|
||||
* What it can't be is a floating-point type. So DEF and FP need never be set at the same time.
|
||||
* There are only a few flag bits, so saving one is not such a bad idea.
|
||||
*
|
||||
* union has a default case (for DDS_OP_ADR | DDS_OP_TYPE_UNI)
|
||||
*/
|
||||
#define DDS_OP_FLAG_DEF (1u << 1)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_FP
|
||||
* @ingroup serialization
|
||||
* @brief floating-point,
|
||||
* applicable to {4,8}BY and arrays, sequences of them
|
||||
*/
|
||||
#define DDS_OP_FLAG_FP (1u << 1)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_SGN
|
||||
* @ingroup serialization
|
||||
* @brief signed,
|
||||
* applicable to {1,2,4,8}BY and arrays, sequences of them
|
||||
*/
|
||||
#define DDS_OP_FLAG_SGN (1u << 2)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_MU
|
||||
* @ingroup serialization
|
||||
* @brief must-understand flag,
|
||||
* as defined by the XTypes spec.
|
||||
*/
|
||||
#define DDS_OP_FLAG_MU (1u << 3)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_BASE
|
||||
* @ingroup serialization
|
||||
* @brief jump to base type,
|
||||
* used with PLM in mutable types and for the TYPE_EXT 'parent' member
|
||||
* in final and appendable types
|
||||
*/
|
||||
#define DDS_OP_FLAG_BASE (1u << 4)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_OPT
|
||||
* @ingroup serialization
|
||||
* @brief optional flag,
|
||||
* used with struct members. For non-string types, an optional member
|
||||
* also gets the FLAG_EXT, see above.
|
||||
*/
|
||||
#define DDS_OP_FLAG_OPT (1u << 5)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_SZ_SHIFT
|
||||
* @ingroup serialization
|
||||
* @brief Enum and bitmask storage size (shift amount)
|
||||
*/
|
||||
#define DDS_OP_FLAG_SZ_SHIFT (6)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAG_SZ_MASK
|
||||
* @ingroup serialization
|
||||
* @brief Enum and bitmask storage size
|
||||
* -# 00 = 1 byte,
|
||||
* -# 01 = 2 bytes,
|
||||
* -# 10 = 4 bytes,
|
||||
* -# 11 = 8 bytes (bitmask only)
|
||||
*/
|
||||
#define DDS_OP_FLAG_SZ_MASK (3u << DDS_OP_FLAG_SZ_SHIFT)
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_FLAGS_SZ
|
||||
* @ingroup serialization
|
||||
* @brief Extract the Enum and Bitmask storage size from flags
|
||||
*/
|
||||
#define DDS_OP_FLAGS_SZ(f) (1u << (((f) & DDS_OP_FLAG_SZ_MASK) >> DDS_OP_FLAG_SZ_SHIFT))
|
||||
|
||||
/**
|
||||
* @anchor DDS_OP_TYPE_SZ
|
||||
* @ingroup serialization
|
||||
* @brief Extract the Enum and Bitmask storage size from an uint32
|
||||
*/
|
||||
#define DDS_OP_TYPE_SZ(o) DDS_OP_FLAGS_SZ(DDS_OP_FLAGS(o))
|
||||
|
||||
/**
|
||||
* @defgroup topic_flags (Topic flags)
|
||||
* @ingroup serialization
|
||||
* There are several flags that can be added to dds_topic_descriptor_t by the IDL compiler.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_NO_OPTIMIZE
|
||||
* @ingroup topic_flags
|
||||
* @brief Don't optimize the opcodes to quick memcpy's.
|
||||
* If a topic includes only plain types and directly nested structs,
|
||||
* it can be that a simple copy+optional byteswap can produce the right
|
||||
* C memory layout straight from CDR. If this flag is added it means that
|
||||
* there is pointer 'magic' involved in decoding the type and no shortcuts should be taken.
|
||||
* @deprecated Optimizability is determined runtime when creating the sertype_default
|
||||
* for the type, this flag is not used.
|
||||
*/
|
||||
#define DDS_TOPIC_NO_OPTIMIZE (1u << 0)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_FIXED_KEY
|
||||
* @ingroup topic_flags
|
||||
* @brief The XCDRV1 serialized key fits in 16 bytes.
|
||||
* If statically determined that a key always fits in 16 bytes
|
||||
* the spec specifies that the key of a sample is the resulting CDR.
|
||||
* If it is longer we must use MD5 to hash the resultant key CDR.
|
||||
*/
|
||||
#define DDS_TOPIC_FIXED_KEY (1u << 1)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_CONTAINS_UNION
|
||||
* @ingroup topic_flags
|
||||
* @deprecated reserved for backward compatibility
|
||||
* @brief ignored
|
||||
*/
|
||||
#define DDS_TOPIC_CONTAINS_UNION (1u << 2)
|
||||
|
||||
|
||||
// (1u << 3) unused, was used for DDS_TOPIC_DISABLE_TYPECHECK
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_FIXED_SIZE
|
||||
* @ingroup topic_flags
|
||||
* @brief The size in memory of a sample of this topic type is fully fixed.
|
||||
*/
|
||||
#define DDS_TOPIC_FIXED_SIZE (1u << 4)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_FIXED_KEY_XCDR2
|
||||
* @ingroup topic_flags
|
||||
* @brief The XCDRV2 serialized key fits in 16 bytes.
|
||||
* If statically determined that a key always fits in 16 bytes
|
||||
* the spec specifies that the key of a sample is the resulting CDR.
|
||||
* If it is longer we must use MD5 to hash the resultant key CDR.
|
||||
*
|
||||
* This is separate from the XCDRV1 version because it can differ due
|
||||
* to the change in alignment of 8byte types.
|
||||
*/
|
||||
#define DDS_TOPIC_FIXED_KEY_XCDR2 (1u << 5)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_XTYPES_METADATA
|
||||
* @ingroup topic_flags
|
||||
* @brief Set if XTypes meta-data is present for this topic
|
||||
*/
|
||||
#define DDS_TOPIC_XTYPES_METADATA (1u << 6)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_RESTRICT_DATA_REPRESENTATION
|
||||
* @ingroup topic_flags
|
||||
* @brief Set if data representation restrictions for the top-level type are present in the topic descriptor
|
||||
*/
|
||||
#define DDS_TOPIC_RESTRICT_DATA_REPRESENTATION (1u << 7)
|
||||
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_KEY_MUTABLE
|
||||
* @ingroup topic_flags
|
||||
* @brief Set if any of the key fields of a type is in a mutable aggregated type.
|
||||
*/
|
||||
#define DDS_TOPIC_KEY_MUTABLE (1u << 8)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_KEY_APPENDABLE
|
||||
* @ingroup topic_flags
|
||||
* @brief Set if any of the key fields of a type is in an appendable aggregated type.
|
||||
*/
|
||||
#define DDS_TOPIC_KEY_APPENDABLE (1u << 9)
|
||||
|
||||
/**
|
||||
* @anchor DDS_TOPIC_FIXED_KEY_XCDR2_KEYHASH
|
||||
* @ingroup topic_flags
|
||||
* @brief The XCDRV2 serialized key with field in member-id order fits
|
||||
* in 16 bytes. If statically determined that a serialized key that is
|
||||
* used to get the keyhash always fits in 16 bytes, the spec specifies
|
||||
* that the keyhash of a sample is the resulting CDR. If it is longer
|
||||
* we must use MD5 to hash the resultant key CDR.
|
||||
*
|
||||
* The XCDRV1 key-hash is calculated from the serialized key with the
|
||||
* fields in definition order, so DDS_TOPIC_FIXED_KEY can also be used
|
||||
* for key-hash for XCDR1.
|
||||
*/
|
||||
#define DDS_TOPIC_FIXED_KEY_XCDR2_KEYHASH (1u << 10)
|
||||
|
||||
/**
|
||||
* @anchor DDS_FIXED_KEY_MAX_SIZE
|
||||
* @ingroup topic_flags
|
||||
* @brief Max size of fixed key
|
||||
*/
|
||||
#define DDS_FIXED_KEY_MAX_SIZE (16)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDS_OPCODES_H */
|
||||
+690
@@ -0,0 +1,690 @@
|
||||
// Copyright(c) 2023 ZettaScale Technology 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
|
||||
|
||||
/**
|
||||
* @defgroup psmx (Publish Subscribe Message Exchange)
|
||||
* @ingroup dds
|
||||
*
|
||||
* OVERVIEW
|
||||
* ========
|
||||
*
|
||||
* The Publish Subscribe Message Exchange (PSMX) interface provides support for
|
||||
* off-loading data communication from the network stack of Cyclone to arbitrary pub-sub
|
||||
* transport implementations.[^1] This section provides an overview of the structure and
|
||||
* introduces some terminology, details on specific operations are provided at the
|
||||
* definitions of those operations.
|
||||
*
|
||||
* A Cyclone DDS Domain consists of a plurality of DDS Domain Entities, which are the
|
||||
* representations of the DDS Domain in a specific process.
|
||||
*
|
||||
* A PSMX Plugin provides an implementation of the PSMX interface, allowing the
|
||||
* instantiation of a PSMX Instance to establish a connection between a DDS Domain Entity
|
||||
* and a PSMX Domain. The PSMX Plugin is specified as a library and a PSMX Instance Name.
|
||||
* The library is loaded in the process and a constructor function provided by the library
|
||||
* is invoked to create and initialize a PSMX Instance given the PSMX Instance Name (and a
|
||||
* configuration string). In principle a specific library may be configured multiple
|
||||
* times in a single DDS Domain.
|
||||
*
|
||||
* The PSMX Instance Name is assumed to uniquely identify the PSMX Domain in the DDS
|
||||
* Domain. From the PSMX Instance Name, a numeric PSMX Instance ID is derived that
|
||||
* uniquely identifies the PSMX Domain within the DDS Domain Entity and is assumed to
|
||||
* uniquely identify the PSMX Domain in the DDS Domain.[^2]
|
||||
*
|
||||
* Each PSMX Instance chooses a 16-byte PSMX Locator[^3] such that any pair of instances
|
||||
* with the same PSMX Locator communicate, and any pair with different locators do not
|
||||
* communicate.[^4]
|
||||
*
|
||||
* DDS Topics, DDS Readers and DDS Writers are mapped to corresponding objects in PSMX
|
||||
* Instances. For DDS Readers and DDS Writers, the application can restrict the set of
|
||||
* PSMX Instances for which the mapping is created using the "PSMX Instances" QoS setting,
|
||||
* and the PSMX Instances can refuse mapping based on type and QoS information.
|
||||
*
|
||||
* DDS Topic Entities are representations of the topics in the DDS Domain, such that two
|
||||
* identical definitions of a topic in a DDS Domain Entity give rise to two
|
||||
* application-level DDS Topic Entities, but only to a single topic in the DDS Domain
|
||||
* Entity and thus also only one PSMX Topic object per PSMX Instance.
|
||||
*
|
||||
* Each DDS Reader/Writer is mapped to a set of PSMX Reader/Writer Endpoints, one for each
|
||||
* PSMX Instance in the "PSMX Instances" QoS that accepts the type and reader/writer QoS.
|
||||
* An associated set of PSMX Domains consisting of the PSMX Domains for which PSMX
|
||||
* Reader/Writer Endpoints have been created is assumed to exist.
|
||||
*
|
||||
* The PSMX Domain is assumed to deliver data published by the PSMX Writer associated with
|
||||
* DDS Writer X to all PSMX Readers associated with the DDS Readers Ys that match X[^5],
|
||||
* optionally excluding DDS Readers in the same Domain Entity as X. It is assumed to not
|
||||
* deliver data to other DDS Readers in the DDS Domain. It is assumed to do this with a
|
||||
* quality of service compatible with the DDS QoS.
|
||||
*
|
||||
* Readers associated with DDS Readers in the same DDS Domain Entity.
|
||||
*
|
||||
* If the intersection of the sets of PSMX Domains of a DDS Reader and a DDS Writer in a
|
||||
* DDS Domain:
|
||||
*
|
||||
* - is empty, off-loading data transfer to PSMX (for this pair) is not possible;
|
||||
*
|
||||
* - contains one instance, that PSMX Domain is eligible for off-loading data transfer;
|
||||
*
|
||||
* - contains multiple instances, the configuration is invalid.
|
||||
*
|
||||
* If an eligible PSMX Domain exists and the PSMX Locators for the corresponding two PSMX
|
||||
* Instances are the same, then PSMX is used to transfer data.
|
||||
*
|
||||
* The PSMX objects are represented in the interface as pointers to "dds_psmx",
|
||||
* "dds_psmx_topic", "dds_psmx_endpoint". The PSMX Plugin is responsible for allocating
|
||||
* and freeing these. It is expected that the PSMX Plugin internally uses an extended
|
||||
* version of these types to store any additional data it needs. E.g., a hypothetical
|
||||
* "weed" PSMX Plugin could do:
|
||||
*
|
||||
* struct psmx_weed {
|
||||
* struct dds_psmx c;
|
||||
* weed_root *x;
|
||||
* };
|
||||
*
|
||||
* The creator function mentioned above is required to be called NAME_create_psmx, where
|
||||
* NAME is the value of the "name" attribute of the PubSubMessageExchange interface
|
||||
* configuration element. It must have the following signature:
|
||||
*
|
||||
* dds_return_t NAME_create_psmx (
|
||||
* struct dds_psmx **psmx_instance,
|
||||
* dds_psmx_instance_id_t identifier,
|
||||
* const char *config)
|
||||
*
|
||||
* Where
|
||||
*
|
||||
* *psmx_instance must be set point to a new PSMX Instance on success and may be left
|
||||
* undefined on error
|
||||
* identifier contains the numeric PSMX Instance ID
|
||||
* config the PSMX configuration from the "config" attribute of the
|
||||
* PubSubMessageExchange interface configuration element.
|
||||
*
|
||||
* The "config" argument is a contiguous sequence of characters terminated by the first
|
||||
* double-\0. Each \0-terminated character sequence is a string that consists of
|
||||
* KEY=VALUE pairs, where each K-V pair is terminated by a semicolon.
|
||||
*
|
||||
* If the configuration string as set in Cyclone DDS configuration contains a
|
||||
* "INSTANCE_NAME" key, its value is used as the PSMX Instance Name. If the key is not
|
||||
* included, the value of the "name" attribute of the corresponding PubSubMessageExchange
|
||||
* element in configuration is used as the PSMX Instance Name. In all cases, looking up
|
||||
* the "INSTANCE_NAME" key in the configuration string using @ref
|
||||
* dds_psmx_get_config_option_value will return the PSMX Instance Name as its value.
|
||||
*
|
||||
* The behaviour of the constructor function is dependent on the interface version it
|
||||
* implements:
|
||||
*
|
||||
* - For version 0, it is responsible for setting:
|
||||
*
|
||||
* - ops to the addresses of the various functions implementing the operations
|
||||
* - instance_name to a "dds_alloc" allocated string
|
||||
* - instance_id to the "identifier" argument
|
||||
*
|
||||
* and for zero-initializing the other fields. At some point after this initialization,
|
||||
* and once it is prepared to handle the "get_node_id" operation, it must invoke the
|
||||
* "dds_psmx_init_generic" to complete the initialization.
|
||||
*
|
||||
* - For version 1, it is responsible for setting:
|
||||
*
|
||||
* - ops
|
||||
*
|
||||
* All other fields will be initialized by the Cyclone DDS after succesful return and
|
||||
* the "get_node_id" operation also will be invoked after the constructor returned.
|
||||
*
|
||||
* Whether the plugin implements version 0 or version 1 of the interface is controlled by
|
||||
* the function pointers in "dds_psmx_ops_t". If "create_topic" and "deinit" are
|
||||
* non-null, it is version 0; if both are null it is version 1. Neither
|
||||
* "create_topic_type" nor "delete_psmx" is touched by Cyclone DDS if the interface is
|
||||
* version 0, allowing for binary backwards compatibility.
|
||||
*
|
||||
* -- Footnotes: --
|
||||
*
|
||||
* [^1]: In particular including shared-memory based mechanisms.
|
||||
*
|
||||
* [^2]: Internally, the name is not used for anything other than the generation of the
|
||||
* numeric id.
|
||||
*
|
||||
* [^3]: Confusingly named "node identifier" in the interface, even though it has nothing
|
||||
* to do with the numeric PSMX Domain identifier.
|
||||
*
|
||||
* [^4]: This typically matches a machine when the transport is shared memory.
|
||||
*
|
||||
* [^5]: That is, the matching rules between Readers and Writers defined in the DDS
|
||||
* specification.
|
||||
*/
|
||||
#ifndef DDS_PSMX_H
|
||||
#define DDS_PSMX_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/dds.h"
|
||||
#include "dds/ddsc/dds_loaned_sample.h"
|
||||
#include "dds/ddsc/dds_data_type_properties.h"
|
||||
#include "dds/ddsrt/dynlib.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDS_MAX_PSMX_INSTANCES 8 // No particular reason for this specific number, except that it's probably enough, usually.
|
||||
|
||||
struct dds_psmx;
|
||||
struct dds_psmx_topic;
|
||||
struct dds_psmx_endpoint;
|
||||
struct ddsi_type;
|
||||
|
||||
/** @brief Type of the PSMX endpoint
|
||||
* @ingroup psmx
|
||||
*
|
||||
* The PSMX interface distinguishes between readers and writers, and in some cases needs
|
||||
* to specify that an operation applies to both or neither (depending on context).
|
||||
* "Reader" and "writer" here are used as in DDS, outside the DDS context these often are
|
||||
* known as subscribers and publishers.
|
||||
*/
|
||||
typedef enum dds_psmx_endpoint_type {
|
||||
DDS_PSMX_ENDPOINT_TYPE_UNSET, /**< inapplicable or applies to both */
|
||||
DDS_PSMX_ENDPOINT_TYPE_READER, /**< applies to reader only */
|
||||
DDS_PSMX_ENDPOINT_TYPE_WRITER /**< applies to writer only */
|
||||
} dds_psmx_endpoint_type_t;
|
||||
|
||||
/** @brief The numeric PSMX Instance ID
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef uint32_t dds_psmx_instance_id_t;
|
||||
|
||||
/**
|
||||
* @brief Flags for identifying features supported by a PSMX implementation
|
||||
*/
|
||||
#define DDS_PSMX_FEATURE_SHARED_MEMORY 1ul << 0 /**< Uses shared memory */
|
||||
#define DDS_PSMX_FEATURE_ZERO_COPY 1ul << 1 /**< Supports zero-copy */
|
||||
typedef uint32_t dds_psmx_features_t;
|
||||
|
||||
/**
|
||||
* @brief Describes the data which is transferred in addition to the application data
|
||||
* @ingroup psmx
|
||||
*
|
||||
* All fields are filled in by Cyclone DDS during the write prior to handing it to the
|
||||
* PSMX plug-in. The plug-in is only required to pass the contents to Cyclone DDS on the
|
||||
* receiving side.
|
||||
*/
|
||||
typedef struct dds_psmx_metadata {
|
||||
dds_loaned_sample_state_t sample_state; /**< Representation of this sample/key */
|
||||
dds_loan_data_type_t data_type; /**< Reserved, must be 0 */
|
||||
dds_psmx_instance_id_t instance_id; /**< PSMX instance id for this sample */
|
||||
uint32_t sample_size; /**< Size of payload */
|
||||
dds_guid_t guid; /**< GUID of original writer */
|
||||
dds_time_t timestamp; /**< Source timestamp of DDS sample */
|
||||
uint32_t statusinfo; /**< DDSI status info (write/dispose/unregister) */
|
||||
uint16_t cdr_identifier; /**< CDR encoding (DDSI_RTPS_SAMPLE_NATIVE if not serialized) */
|
||||
uint16_t cdr_options; /**< CDR options field (0 if not serialized) */
|
||||
} dds_psmx_metadata_t;
|
||||
|
||||
/**
|
||||
* @brief PSMX Locator
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_node_identifier {
|
||||
uint8_t x[16];
|
||||
} dds_psmx_node_identifier_t;
|
||||
|
||||
/**
|
||||
* @brief Definition of the function checking support for type and QoS
|
||||
* @ingroup psmx
|
||||
*
|
||||
* A PSMX Instance in the "PSMX Instances" QoS may accept or reject a given DDS
|
||||
* Topic/Reader/Writer based on information on the type and the QoS settings. PSMX
|
||||
* Instances not in the "PSMX Instances" QoS setting are not asked.
|
||||
*
|
||||
* @param[in] psmx_instance The PSMX Instance
|
||||
* @param[in] forwhat Whether for a topic/writer/reader (UNSET if topic)
|
||||
* @param[in] data_type_props Data type properties (see there)
|
||||
* @param[in] qos QoS of the DDS topic
|
||||
* @returns True if the PSMX Instance is willing to handle this DDS entity, false otherwise
|
||||
*/
|
||||
typedef bool (*dds_psmx_type_qos_supported_fn) (struct dds_psmx *psmx_instance, dds_psmx_endpoint_type_t forwhat, dds_data_type_properties_t data_type_props, const struct dds_qos *qos);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for creating a PSMX Topic (interface version 1)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Definition for a function that is called to construct a new PSMX Topic in a PSMX Instance
|
||||
* representing a new topic in the DDS Domain Entity.
|
||||
*
|
||||
* The PSMX Plugin is expected to represent a PSMX Topic using an extended version of the
|
||||
* `dds_psmx_topic` structure.
|
||||
*
|
||||
* If `type_definition` is not a null pointer, it points into the Cyclone type library. A
|
||||
* (default, C) serializer can be constructed using `ddsi_topic_descriptor_from_type`,
|
||||
* an XTypes TypeObject using `ddsi_type_get_typeobj`.
|
||||
*
|
||||
* If the function returns failure, creation of the DDS Entity fails.
|
||||
*
|
||||
* @param[in] psmx_instance The PSMX instance.
|
||||
* @param[in] topic_name The name of the topic to create
|
||||
* @param[in] type_name The name of the DDS data type for this topic
|
||||
* @param[in] data_type_props The data type properties for the topic's data type.
|
||||
* @param[in] type_definition Optional pointer to type definition in type library.
|
||||
* @param[in] sizeof_type In-memory size of a single instance of the type, 0 if unknown.
|
||||
* @returns A new PSMX Topic structure, or NULL on error
|
||||
*/
|
||||
typedef struct dds_psmx_topic * (*dds_psmx_create_topic_with_type_fn) (
|
||||
struct dds_psmx *psmx_instance,
|
||||
const char *topic_name,
|
||||
const char *type_name,
|
||||
dds_data_type_properties_t data_type_props,
|
||||
const struct ddsi_type *type_definition,
|
||||
uint32_t sizeof_type);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for destructing and freeing a PSMX Topic
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Definition for a function that is called on deleting the topic in the DDS Domain.
|
||||
* Called exactly once for each successful invocation of `dds_psmx_create_topic`/
|
||||
* `dds_psmx_create_topic_with_type`, all PSMX Endpoints related to this PSMX Topic will have
|
||||
* been destructed prior to calling this function.
|
||||
*
|
||||
* If the PSMX Topic was created using `dds_psmx_create_topic`, the PSMX Plugin is
|
||||
* required to call `dds_psmx_cleanup_topic_generic` and to do so prior to invalidating
|
||||
* the memory associated with the PSMX Topic and releasing any memory allocated for it
|
||||
* during construction.
|
||||
*
|
||||
* @param[in] psmx_topic The PSMX Topic to destruct
|
||||
* @returns A DDS return code, should be DDS_RETCODE_OK.
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_delete_topic_fn) (struct dds_psmx_topic *psmx_topic);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for creating a PSMX Topic (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Equivalent to `dds_psmx_create_topic_type` with `type_definition` and `sizeof_type`
|
||||
* a null pointer and 0, respectively. It is required to initialize the generic fields using
|
||||
* `dds_psmx_topic_init_generic`.
|
||||
*
|
||||
* @param[in] psmx_instance The PSMX instance.
|
||||
* @param[in] topic_name The name of the topic to create
|
||||
* @param[in] type_name The name of the DDS data type for this topic
|
||||
* @param[in] data_type_props The data type properties for the topic's data type.
|
||||
* @returns A new PSMX Topic structure, or NULL on error
|
||||
*/
|
||||
typedef struct dds_psmx_topic * (*dds_psmx_create_topic_fn) (
|
||||
struct dds_psmx * psmx_instance,
|
||||
const char * topic_name,
|
||||
const char * type_name,
|
||||
dds_data_type_properties_t data_type_props);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for destructing and freeing a PSMX Instance (interface version 1)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Function called on shutdown of a DDS Domain Entity, before unloading the PSMX Plugin
|
||||
* and after all other operations have completed and all objects created in the PSMX
|
||||
* Instance have been destructed using the various "delete" functions.
|
||||
*
|
||||
* The PSMX Plugin is required to call `dds_psmx_fini` and to do so prior to
|
||||
* invalidating the memory associated with the PSMX Instance and releasing any memory
|
||||
* allocated for it during construction.
|
||||
*
|
||||
* @param[in] psmx_instance The PSMX Instance to de-initialize
|
||||
*/
|
||||
typedef void (*dds_psmx_delete_fn) (struct dds_psmx *psmx_instance);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for destructing and freeing a PSMX Instance (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Function called on shutdown of a DDS Domain Entity, before unloading the PSMX Plugin
|
||||
* and after all other operations have completed and all objects created in the PSMX
|
||||
* Instance have been destructed using the various "delete" functions.
|
||||
*
|
||||
* The PSMX Plugin is required to call `dds_psmx_cleanup_generic` and to do so prior to
|
||||
* invalidating the memory associated with the PSMX Instance and releasing any memory
|
||||
* allocated for it during construction.
|
||||
*
|
||||
* @param[in] psmx_instance The PSMX Instance to de-initialize
|
||||
* @returns A DDS return code, should be DDS_RETCODE_OK.
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_deinit_fn) (struct dds_psmx *psmx_instance);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function returning the PSMX Locator
|
||||
* @ingroup psmx
|
||||
*
|
||||
* All PSMX Instances that can communicate must return the same PSMX Locator, PSMX
|
||||
* Instances that do not communicate must return different PSMX Locators.
|
||||
*
|
||||
* The function may be called by `dds_psmx_init_generic`.
|
||||
*
|
||||
* @param[in] psmx_instance A PSMX Instance
|
||||
* @returns The PSMX Locator for this PSMX Instance
|
||||
*/
|
||||
typedef dds_psmx_node_identifier_t (*dds_psmx_get_node_identifier_fn) (const struct dds_psmx *psmx_instance);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function to query the features supported by the PSMX Instance
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Returns an integer with the flags set for the features that are supported by the
|
||||
* provided PSMX Instance.
|
||||
*
|
||||
* @param[in] psmx_instance A PSMX instance
|
||||
* @returns The set of features supported by this PSMX instance
|
||||
*/
|
||||
typedef dds_psmx_features_t (*dds_psmx_supported_features_fn) (const struct dds_psmx *psmx_instance);
|
||||
|
||||
/**
|
||||
* @brief Table of pointers to functions operating on a PSMX Instance
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_ops {
|
||||
dds_psmx_type_qos_supported_fn type_qos_supported;
|
||||
dds_psmx_create_topic_fn create_topic; /**< non-null for interface version 0, null for version 1 */
|
||||
dds_psmx_delete_topic_fn delete_topic;
|
||||
dds_psmx_deinit_fn deinit; /**< non-null for interface version 0, null for version 1 */
|
||||
dds_psmx_get_node_identifier_fn get_node_id;
|
||||
dds_psmx_supported_features_fn supported_features;
|
||||
dds_psmx_create_topic_with_type_fn create_topic_with_type; /**< undefined for interface version 0, non-null for version 1 */
|
||||
dds_psmx_delete_fn delete_psmx; /**< undefined for interface version 0, non-null for version 1 */
|
||||
} dds_psmx_ops_t;
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for constructing a PSMX Endpoint for a PSMX Topic
|
||||
* @ingroup psmx
|
||||
*
|
||||
* @param[in] psmx_topic The PSMX Topic to create the PSMX Endpoint for
|
||||
* @param[in] qos QoS of the corresponding DDS endpoint
|
||||
* @param[in] endpoint_type The type of endpoint to create, either READER or WRITER
|
||||
* @returns A new PSMX Endpoint or a null pointer on error
|
||||
*/
|
||||
typedef struct dds_psmx_endpoint * (*dds_psmx_create_endpoint_fn) (struct dds_psmx_topic *psmx_topic, const struct dds_qos *qos, dds_psmx_endpoint_type_t endpoint_type);
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for destructing a PSMX Endpoint
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Called after the last operation on the PSMX Endpoint has completed and no further
|
||||
* operations will be invoked; called prior to destructing the PSMX Topic.
|
||||
*
|
||||
* @param[in] psmx_endpoint The PSMX Endpoint to be destructed
|
||||
* @returns a DDS return code, should be DDS_RETCODE_OK
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_delete_endpoint_fn) (struct dds_psmx_endpoint *psmx_endpoint);
|
||||
|
||||
/**
|
||||
* @brief Table of pointers to functions operating on a PSMX Topic
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_topic_ops {
|
||||
dds_psmx_create_endpoint_fn create_endpoint;
|
||||
dds_psmx_delete_endpoint_fn delete_endpoint;
|
||||
} dds_psmx_topic_ops_t;
|
||||
|
||||
/**
|
||||
* @brief Definition of the function for requesting a loan from a PSMX Writer
|
||||
* @ingroup psmx
|
||||
*
|
||||
* The PSMX Instance is the owner of the loan and implements the allocation and the
|
||||
* freeing of the memory for the `dds_loaned_sample_t`, the `dds_psmx_metadata_t` it
|
||||
* references and the payload it references.
|
||||
*
|
||||
* The `dds_loaned_sample_t` is reference counted and the free function referenced through
|
||||
* the "ops" table is invoked once the reference count drops to 0.
|
||||
*
|
||||
* The PSMX Plugin is required to properly initialize all fields:
|
||||
*
|
||||
* - ops
|
||||
* - metadata, the contents of the memory it points to may be undefined
|
||||
* - sample_ptr, the contents of the memory it points to may be undefined
|
||||
*
|
||||
* The loan_origin and refc fields are set by Cyclone DDS following a succesful return.
|
||||
*
|
||||
* The `sample_ptr` in the Loaned Sample must point to a unique memory block of at least
|
||||
* `size_requested` bytes and be suitably aligned to directly store any of the types in
|
||||
* application-representation to which the various supported IDL types map.
|
||||
*
|
||||
* `size_requested` is equal to `sizeof_type` in the PSMX create topic call if:
|
||||
* - the loan is to be used for a raw sample (implies `IS_MEMCPY_SAFE` set in the type properties)
|
||||
* - `sizeof_type` was non-0 in the call to create the PSMX Topic
|
||||
*
|
||||
* @param[in] psmx_endpoint The PSMX Writer to borrow from
|
||||
* @param[in] size_requested The size of the loan requested in bytes
|
||||
* @returns A pointer to the Loaned Sample on success or a null pointer on failure
|
||||
*/
|
||||
typedef dds_loaned_sample_t * (*dds_psmx_endpoint_request_loan_fn) (struct dds_psmx_endpoint *psmx_endpoint, uint32_t size_requested);
|
||||
|
||||
/**
|
||||
* @brief Definition of function for writing data via a PSMX Writer
|
||||
* @ingroup psmx
|
||||
*
|
||||
* The PSMX Plugin is expected to publish the payload and the metadata of the Loaned
|
||||
* Sample via the PSMX Instance to its subscribers as described in the overview. The
|
||||
* Loaned Sample:
|
||||
*
|
||||
* - originated in a successful request for a loan from this PSMX Instance;
|
||||
* - has the metadata and payload set correctly;
|
||||
* - has a metadata state that is not `UNINITIALIZED`.
|
||||
*
|
||||
* Cyclone DDS assumes:
|
||||
*
|
||||
* - that the `dds_loaned_sample_t` outlives the PSMX write operation
|
||||
* - that the `sample_ptr` and `metadata` are invalidated by the PSMX write operation
|
||||
*
|
||||
* and will consequently not touch the `sample_ptr` and `metadata` after the operation and
|
||||
* only invoke the Loaned Sample's `free` function.
|
||||
*
|
||||
* If the operations fails and returns an error, the DDS write (or write-like) operation
|
||||
* that caused it will report an error to the application. It is unspecified whether or
|
||||
* not any other deliver paths may or may not have been provided with the data when this
|
||||
* happens.
|
||||
*
|
||||
* @param[in] psmx_endpoint The PSMX Writer to publish the data on
|
||||
* @param[in] data The Loaned Sample containing the data to publish
|
||||
* @param[in] keysz The size of the serialized key blob, 0 for keyless topics
|
||||
* @param[in] key The serialized key, a null pointer for keyless topics
|
||||
* @returns A DDS return code
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_endpoint_write_with_key_fn) (struct dds_psmx_endpoint *psmx_endpoint, dds_loaned_sample_t *data, size_t keysz, const void *key);
|
||||
|
||||
/**
|
||||
* @brief Definition of function for writing data via a PSMX Writer
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Equivalent to `dds_psmx_endpoint_write_with_key_fn` with `keysz` = 0 and `key` = NULL
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_endpoint_write_fn) (struct dds_psmx_endpoint *psmx_endpoint, dds_loaned_sample_t *data);
|
||||
|
||||
/**
|
||||
* @brief Definition of function for taking data from a PSMX Reader
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Return an unread sample available to the PSMX Reader and remove it from the set of
|
||||
* samples available to the PSMX Reader. It should ensure, firstly, that a sample for
|
||||
* each key value for which data is available shall eventually be returned, and, secondly,
|
||||
* that samples for a given key value are returned in the order of publication.
|
||||
*
|
||||
* The Loaned Sample shall be fully initialized on return, with a metadata sample state
|
||||
* different from `UNINITIALIZED`.
|
||||
*
|
||||
* (Currently not called.)
|
||||
*
|
||||
* @param[in] psmx_endpoint The PSMX Reader to take the data from
|
||||
* @returns a Loaned Sample for an unread sample, or a null pointer if none is available
|
||||
*/
|
||||
typedef dds_loaned_sample_t * (*dds_psmx_endpoint_take_fn) (struct dds_psmx_endpoint *psmx_endpoint);
|
||||
|
||||
/**
|
||||
* @brief Definition of function to request asynchronous delivery of new data by a PSMX Reader
|
||||
* @ingroup psmx
|
||||
*
|
||||
* The PSMX Plugin is requested to arrange for data arriving at the PSMX Reader to be
|
||||
* delivered to Cyclone DDS as if a background thread exists that contains a loop body:
|
||||
* ```
|
||||
* dds_loaned_sample_t *ls = dds_psmx_endpoint_ops.take(psmx_endpoint)
|
||||
* if (ls != NULL) {
|
||||
* dds_reader_store_loaned_sample(reader, ls);
|
||||
* }
|
||||
* dds_loaned_sample_unref(data)
|
||||
* ```
|
||||
* (alternatively calling `dds_reader_store_loaned_sample_wr_metadata` for each sample)
|
||||
*
|
||||
* @param[in] psmx_endpoint The PSMX Reader on which to enable asynchronous delivery
|
||||
* @param[in] reader The DDS Reader to which the data is to be delivered
|
||||
* @returns a DDS return code
|
||||
*/
|
||||
typedef dds_return_t (*dds_psmx_endpoint_on_data_available_fn) (struct dds_psmx_endpoint *psmx_endpoint, dds_entity_t reader);
|
||||
|
||||
/**
|
||||
* @brief Table of pointers to functions that are used on a PSMX Endpoint
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_endpoint_ops {
|
||||
dds_psmx_endpoint_request_loan_fn request_loan;
|
||||
dds_psmx_endpoint_write_fn write; /**< write, not required if `write_key` is defined */
|
||||
dds_psmx_endpoint_take_fn take;
|
||||
dds_psmx_endpoint_on_data_available_fn on_data_available;
|
||||
dds_psmx_endpoint_write_with_key_fn write_with_key; /**< may be null for backwards compatibility if `write` is defined */
|
||||
} dds_psmx_endpoint_ops_t;
|
||||
|
||||
/**
|
||||
* @brief Type representing a PSMX Instance in a DDS Domain Entity
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Each PSMX Instance is represented in a DDS Domain Entity by a pointer to a `struct dds_psmx`.
|
||||
* The PSMX Plugin is responsible for allocating and constructing it on initialization in a constructor
|
||||
* as described in the overview.
|
||||
*/
|
||||
typedef struct dds_psmx {
|
||||
dds_psmx_ops_t ops; /**< operations on the PSMX Instance */
|
||||
const char *instance_name; /**< name of this PSMX Instance */
|
||||
int32_t priority; /**< priority for this interface */
|
||||
const struct ddsi_locator *locator; /**< PSMX Locator for this PSMX Instance */
|
||||
dds_psmx_instance_id_t instance_id; /**< Numeric PSMX Instance ID for this PSMX Instance */
|
||||
void *psmx_topics; /**< Reserved, must be 0 */
|
||||
} dds_psmx_t;
|
||||
|
||||
/**
|
||||
* @brief Type representing a PSMX Topic in a DDS Domain Entity
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_topic {
|
||||
dds_psmx_topic_ops_t ops; /**< operations on the PSMX Topic */
|
||||
struct dds_psmx *psmx_instance; /**< PSMX Instance which created this PSMX Topic */
|
||||
const char *topic_name; /**< Topic name */
|
||||
const char *type_name; /**< Type name */
|
||||
dds_loan_data_type_t data_type; /**< Reserved, must be 0 */
|
||||
void *psmx_endpoints; /**< Reserved, must be 0 */
|
||||
dds_data_type_properties_t data_type_props; /**< Properties of the data type associated with this topic */
|
||||
} dds_psmx_topic_t;
|
||||
|
||||
/**
|
||||
* @brief Type representing a PSMX Endpoint in a DDS Domain Entity
|
||||
* @ingroup psmx
|
||||
*/
|
||||
typedef struct dds_psmx_endpoint {
|
||||
dds_psmx_endpoint_ops_t ops; /**< operations on the PSMX Endpoint */
|
||||
struct dds_psmx_topic *psmx_topic; /**< PSMX Topic for this endpoint */
|
||||
dds_psmx_endpoint_type_t endpoint_type; /**< Type of endpoint (READER or WRITER) */
|
||||
} dds_psmx_endpoint_t;
|
||||
|
||||
/**
|
||||
* @brief nop
|
||||
* @ingroup psmx
|
||||
*
|
||||
* does nothing, exists for backwards compatibility only
|
||||
*
|
||||
* @param[in] psmx_topic ignored
|
||||
* @param[in,out] list ignored
|
||||
* @return `DDS_RETCODE_OK`
|
||||
*/
|
||||
DDS_DEPRECATED_EXPORT dds_return_t dds_add_psmx_topic_to_list (struct dds_psmx_topic *psmx_topic, void **list);
|
||||
|
||||
/**
|
||||
* @brief nop
|
||||
* @ingroup psmx
|
||||
*
|
||||
* does nothing, exists for backwards compatibility only
|
||||
*
|
||||
* @param[in] psmx_endpoint ignored
|
||||
* @param[in,out] list ignored
|
||||
* @return `DDS_RETCODE_OK`
|
||||
*/
|
||||
DDS_DEPRECATED_EXPORT dds_return_t dds_add_psmx_endpoint_to_list (struct dds_psmx_endpoint *psmx_endpoint, void **list);
|
||||
|
||||
/**
|
||||
* @brief initialization function for PSMX instance (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Shall be called by a constructor function for a PSMX Plugin implementing interface
|
||||
* version 0 as described in the overview.
|
||||
*
|
||||
* @param[in] psmx The PSMX instance to initialize
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_psmx_init_generic (struct dds_psmx *psmx);
|
||||
|
||||
/**
|
||||
* @brief cleanup function for a PSMX instance (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Shall be called by the destructor function of PSMX Plugin implementing interface
|
||||
* version 0 as described in the documentation of "dds_psmx_deinit_fn".
|
||||
*
|
||||
* @param[in] psmx the PSMX instance to cleanup
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_psmx_cleanup_generic (struct dds_psmx *psmx);
|
||||
|
||||
/**
|
||||
* @brief init function for topic (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Shall be called by de topic constructor function for a PSMX Plugin implementing
|
||||
* interface version 0.
|
||||
*
|
||||
* @param[in] psmx_topic the topic to initialize
|
||||
* @param[in] ops vtable for this psmx_topic
|
||||
* @param[in] psmx the PSMX instance
|
||||
* @param[in] topic_name the topic name
|
||||
* @param[in] type_name the DDS type name for this topic
|
||||
* @param[in] data_type_props the data type's properties
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_psmx_topic_init_generic (struct dds_psmx_topic *psmx_topic, const dds_psmx_topic_ops_t *ops, const struct dds_psmx *psmx, const char *topic_name, const char *type_name, dds_data_type_properties_t data_type_props);
|
||||
|
||||
/**
|
||||
* @brief cleanup function for a topic (interface version 0)
|
||||
* @ingroup psmx
|
||||
*
|
||||
* Shall be called by de topic destructor function for a PSMX Plugin implementing
|
||||
* interface version 0 as described in the documentation of "dds_psmx_delete_topic_fn".
|
||||
*
|
||||
* @param[in] psmx_topic the topic to de-initialize
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_psmx_topic_cleanup_generic (struct dds_psmx_topic *psmx_topic);
|
||||
|
||||
/**
|
||||
* @brief Returns the string associated with the option_name in the PSMX config string.
|
||||
* @ingroup psmx
|
||||
*
|
||||
* The C string returned from this function should be freed by the user using `ddsrt_free`.
|
||||
*
|
||||
* The option "SERVICE_NAME" is treated as an alias for "INSTANCE_NAME".
|
||||
*
|
||||
* @param[in] conf a double-\0 terminated configuration string in the
|
||||
* same format as that passed to the PSMX Plugin's constructor
|
||||
* function (see the overview).
|
||||
* @param[in] option_name the option to look up
|
||||
* @return pointer to a newly allocated string on the heap if found, NULL if not found or out of memory.
|
||||
*/
|
||||
DDS_EXPORT char *dds_psmx_get_config_option_value (const char *conf, const char *option_name);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDS_PSMX_H */
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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
|
||||
|
||||
/* TODO: do we really need to expose this as an API? */
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @brief DDS C Allocation API
|
||||
*
|
||||
* This header file defines the public API of allocation convenience functions
|
||||
* in the Eclipse Cyclone DDS C language binding.
|
||||
*/
|
||||
#ifndef DDS_ALLOC_H
|
||||
#define DDS_ALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_topic_descriptor;
|
||||
struct dds_sequence;
|
||||
|
||||
DDS_EXPORT extern const struct dds_cdrstream_allocator dds_cdrstream_default_allocator;
|
||||
|
||||
/**
|
||||
* @anchor DDS_FREE_KEY_BIT
|
||||
* @ingroup alloc
|
||||
* @brief Instruction to free all keyfields in sample
|
||||
*/
|
||||
#define DDS_FREE_KEY_BIT 0x01
|
||||
|
||||
/**
|
||||
* @anchor DDS_FREE_CONTENTS_BIT
|
||||
* @ingroup alloc
|
||||
* @brief Instruction to free all non-keyfields in sample
|
||||
*/
|
||||
#define DDS_FREE_CONTENTS_BIT 0x02
|
||||
|
||||
/**
|
||||
* @anchor DDS_FREE_ALL_BIT
|
||||
* @ingroup alloc
|
||||
* @brief Instruction to free outer sample
|
||||
*/
|
||||
#define DDS_FREE_ALL_BIT 0x04
|
||||
|
||||
/**
|
||||
* @brief Freeing operation type
|
||||
* @ingroup alloc
|
||||
* What part of a sample to free
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DDS_FREE_ALL = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT | DDS_FREE_ALL_BIT, /**< free full sample */
|
||||
DDS_FREE_CONTENTS = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT, /**< free all sample contents, but leave sample pointer intact */
|
||||
DDS_FREE_KEY = DDS_FREE_KEY_BIT /**< free only the keyfields in a sample */
|
||||
}
|
||||
dds_free_op_t;
|
||||
|
||||
/**
|
||||
* @brief DDS Allocator
|
||||
* @ingroup alloc
|
||||
* C-Style allocator API
|
||||
*/
|
||||
typedef struct dds_allocator
|
||||
{
|
||||
void * (*malloc) (size_t size); /**< behave like C malloc */
|
||||
void * (*realloc) (void *ptr, size_t size); /**< behave like C realloc, may be null */
|
||||
void (*free) (void *ptr); /**< behave like C free */
|
||||
}
|
||||
dds_allocator_t;
|
||||
|
||||
/**
|
||||
* @brief Perform an alloc() with the default allocator.
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] size number of bytes
|
||||
* @returns new pointer or NULL if out of memory
|
||||
*/
|
||||
DDS_EXPORT void * dds_alloc (size_t size);
|
||||
|
||||
/**
|
||||
* @brief Perform a realloc() with the default allocator.
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] ptr previously alloc()'ed pointer
|
||||
* @param[in] size new size
|
||||
* @return new pointer or NULL if out of memory
|
||||
*/
|
||||
DDS_EXPORT void * dds_realloc (void * ptr, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Perform a realloc() with the default allocator. Zero out memory.
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] ptr previously alloc()'ed pointer
|
||||
* @param[in] size new size
|
||||
* @return new pointer or NULL if out of memory
|
||||
*/
|
||||
DDS_EXPORT void * dds_realloc_zero (void * ptr, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Perform a free() on a memory fragment allocated with the default allocator.
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] ptr previously alloc()'ed pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_free (void * ptr);
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
typedef void * (*dds_alloc_fn_t) (size_t p);
|
||||
typedef void * (*dds_realloc_fn_t) (void * a, size_t b);
|
||||
typedef void (*dds_free_fn_t) (void *p);
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
/**
|
||||
* @brief Allocated a string with size, accounting for the null terminator.
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] size number of characters
|
||||
* @returns newly allocated string or NULL if out of memory
|
||||
*/
|
||||
DDS_EXPORT char * dds_string_alloc (size_t size);
|
||||
|
||||
/**
|
||||
* @brief Duplicate a null-terminated string
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] str string to duplicate
|
||||
* @returns newly allocated duplicate string, or NULL if out of memory
|
||||
*/
|
||||
DDS_EXPORT char * dds_string_dup (const char * str);
|
||||
|
||||
/**
|
||||
* @brief Free a string, equivalent to dds_free
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] str string to free
|
||||
*/
|
||||
DDS_EXPORT void dds_string_free (char * str);
|
||||
|
||||
/**
|
||||
* @brief Free (parts of) a sample according to the \ref dds_free_op_t
|
||||
* @component memory_alloc
|
||||
*
|
||||
* @param[in] sample sample to free
|
||||
* @param[in] desc topic descriptor of the type this sample was created from.
|
||||
* @param[in] op Which parts of the sample to free.
|
||||
*/
|
||||
DDS_EXPORT void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,635 @@
|
||||
// Copyright(c) 2023 ZettaScale Technology 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 DDS_DYNAMIC_TYPE_H
|
||||
#define DDS_DYNAMIC_TYPE_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
struct ddsi_typeinfo;
|
||||
|
||||
/**
|
||||
* @defgroup dynamic_type (Dynamic Type API)
|
||||
* @ingroup dds
|
||||
* The Dynamic Type API to construct and manipulate data types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Representation of a dynamically created type. This struct has an opaque pointer
|
||||
* to the type in the type system. During construction of the type (setting properties
|
||||
* and adding members), the internal type has the state 'CONSTRUCTION'. Once the type
|
||||
* is registered, the state is updated to 'RESOLVED' and the type cannot be modified.
|
||||
*
|
||||
* The 'ret' member of this struct holds the return code of operations performed on
|
||||
* this type. In case this value is not DDS_RETCODE_OK, the type cannot be used for
|
||||
* further processing (e.g. adding members, registering the type, etc.).
|
||||
*
|
||||
*/
|
||||
typedef struct dds_dynamic_type {
|
||||
void * x[2];
|
||||
dds_return_t ret;
|
||||
} dds_dynamic_type_t;
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Invalid member ID: used when adding a member, to indicate that the member should get
|
||||
* the id (m+1) where m is the highest member id in the current set of members. A valid
|
||||
* member id has the 4 most significant bits set to 0 (because of usage in the EMHEADER),
|
||||
* so also when hashed-id are used, the hash member id will never be set to the invalid
|
||||
* member id.
|
||||
*/
|
||||
#define DDS_DYNAMIC_MEMBER_ID_INVALID 0xf000000u
|
||||
#define DDS_DYNAMIC_MEMBER_ID_AUTO DDS_DYNAMIC_MEMBER_ID_INVALID
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* When adding members, index 0 is used to indicate that a member should be inserted as
|
||||
* the first member. A value higher than the current maximum index can be used to indicate
|
||||
* that the member should be added after the other members
|
||||
*/
|
||||
#define DDS_DYNAMIC_MEMBER_INDEX_START 0u
|
||||
#define DDS_DYNAMIC_MEMBER_INDEX_END UINT32_MAX
|
||||
|
||||
/**
|
||||
* @brief Dynamic Type Kind
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Enumeration with the type kind values that can be used to create a dynamic type.
|
||||
*/
|
||||
typedef enum dds_dynamic_type_kind
|
||||
{
|
||||
DDS_DYNAMIC_NONE,
|
||||
DDS_DYNAMIC_BOOLEAN,
|
||||
DDS_DYNAMIC_BYTE,
|
||||
DDS_DYNAMIC_INT16,
|
||||
DDS_DYNAMIC_INT32,
|
||||
DDS_DYNAMIC_INT64,
|
||||
DDS_DYNAMIC_UINT16,
|
||||
DDS_DYNAMIC_UINT32,
|
||||
DDS_DYNAMIC_UINT64,
|
||||
DDS_DYNAMIC_FLOAT32,
|
||||
DDS_DYNAMIC_FLOAT64,
|
||||
DDS_DYNAMIC_FLOAT128,
|
||||
DDS_DYNAMIC_INT8,
|
||||
DDS_DYNAMIC_UINT8,
|
||||
DDS_DYNAMIC_CHAR8,
|
||||
DDS_DYNAMIC_CHAR16,
|
||||
DDS_DYNAMIC_STRING8,
|
||||
DDS_DYNAMIC_STRING16,
|
||||
DDS_DYNAMIC_ENUMERATION,
|
||||
DDS_DYNAMIC_BITMASK,
|
||||
DDS_DYNAMIC_ALIAS,
|
||||
DDS_DYNAMIC_ARRAY,
|
||||
DDS_DYNAMIC_SEQUENCE,
|
||||
DDS_DYNAMIC_MAP,
|
||||
DDS_DYNAMIC_STRUCTURE,
|
||||
DDS_DYNAMIC_UNION,
|
||||
DDS_DYNAMIC_BITSET
|
||||
} dds_dynamic_type_kind_t;
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Short notation for initializer of a dynamic type spec for non-primitive and primitive types.
|
||||
*/
|
||||
#define DDS_DYNAMIC_TYPE_SPEC(t) ((dds_dynamic_type_spec_t) { .kind = DDS_DYNAMIC_TYPE_KIND_DEFINITION, .type = { .type = (t) } })
|
||||
#define DDS_DYNAMIC_TYPE_SPEC_PRIM(p) ((dds_dynamic_type_spec_t) { .kind = DDS_DYNAMIC_TYPE_KIND_PRIMITIVE, .type = { .primitive = (p) } })
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Short notation for struct member descriptor with different sets of commonly used properties
|
||||
*/
|
||||
#define DDS_DYNAMIC_MEMBER_(member_type_spec,member_name,member_id,member_index) \
|
||||
((dds_dynamic_member_descriptor_t) { \
|
||||
.name = (member_name), \
|
||||
.id = (member_id), \
|
||||
.type = (member_type_spec), \
|
||||
.index = (member_index) \
|
||||
})
|
||||
#define DDS_DYNAMIC_MEMBER_ID(member_type,member_name,member_id) \
|
||||
DDS_DYNAMIC_MEMBER_ (DDS_DYNAMIC_TYPE_SPEC((member_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END)
|
||||
#define DDS_DYNAMIC_MEMBER_ID_PRIM(member_prim_type,member_name,member_id) \
|
||||
DDS_DYNAMIC_MEMBER_(DDS_DYNAMIC_TYPE_SPEC_PRIM((member_prim_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END)
|
||||
#define DDS_DYNAMIC_MEMBER(member_type,member_name) \
|
||||
DDS_DYNAMIC_MEMBER_ID((member_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID)
|
||||
#define DDS_DYNAMIC_MEMBER_PRIM(member_prim_type,member_name) \
|
||||
DDS_DYNAMIC_MEMBER_ID_PRIM((member_prim_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID)
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Short notation for union member descriptor with different sets of commonly used properties
|
||||
*/
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_(member_type_spec,member_name,member_id,member_index,member_num_labels,member_labels,member_is_default) \
|
||||
((dds_dynamic_member_descriptor_t) { \
|
||||
.name = (member_name), \
|
||||
.id = (member_id), \
|
||||
.type = (member_type_spec), \
|
||||
.index = (member_index), \
|
||||
.num_labels = (member_num_labels), \
|
||||
.labels = (member_labels), \
|
||||
.default_label = (member_is_default) \
|
||||
})
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_ID(member_type,member_name,member_id,member_num_labels,member_labels) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_(DDS_DYNAMIC_TYPE_SPEC((member_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END,(member_num_labels),(member_labels),false)
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_ID_PRIM(member_prim_type,member_name,member_id,member_num_labels,member_labels) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_(DDS_DYNAMIC_TYPE_SPEC_PRIM((member_prim_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END,(member_num_labels),(member_labels),false)
|
||||
#define DDS_DYNAMIC_UNION_MEMBER(member_type,member_name,member_num_labels,member_labels) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_ID((member_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID,(member_num_labels),(member_labels))
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_PRIM(member_prim_type,member_name,member_num_labels,member_labels) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_ID_PRIM((member_prim_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID,(member_num_labels),(member_labels))
|
||||
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_DEFAULT_ID(member_type,member_name,member_id) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_(DDS_DYNAMIC_TYPE_SPEC((member_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END,0,NULL,true)
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_DEFAULT_ID_PRIM(member_prim_type,member_name,member_id) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_(DDS_DYNAMIC_TYPE_SPEC_PRIM((member_prim_type)),(member_name),(member_id),DDS_DYNAMIC_MEMBER_INDEX_END,0,NULL,true)
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_DEFAULT(member_type,member_name) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_DEFAULT_ID((member_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID)
|
||||
#define DDS_DYNAMIC_UNION_MEMBER_DEFAULT_PRIM(member_prim_type,member_name) \
|
||||
DDS_DYNAMIC_UNION_MEMBER_DEFAULT_ID_PRIM((member_prim_type),(member_name),DDS_DYNAMIC_MEMBER_ID_INVALID)
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Dynamic Type specification kind
|
||||
*/
|
||||
typedef enum dds_dynamic_type_spec_kind {
|
||||
DDS_DYNAMIC_TYPE_KIND_UNSET,
|
||||
DDS_DYNAMIC_TYPE_KIND_DEFINITION,
|
||||
DDS_DYNAMIC_TYPE_KIND_PRIMITIVE
|
||||
} dds_dynamic_type_spec_kind_t;
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Dynamic Type specification: a reference to dynamic type, which can be a primitive type
|
||||
* kind (just the type kind enumeration value), or a (primitive or non-primitive) dynamic
|
||||
* type reference.
|
||||
*/
|
||||
typedef struct dds_dynamic_type_spec {
|
||||
dds_dynamic_type_spec_kind_t kind;
|
||||
union {
|
||||
dds_dynamic_type_t type;
|
||||
dds_dynamic_type_kind_t primitive;
|
||||
} type;
|
||||
} dds_dynamic_type_spec_t;
|
||||
|
||||
/**
|
||||
* @brief Dynamic Type descriptor
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Structure that holds the properties for creating a Dynamic Type. For each type kind,
|
||||
* specific member fields are applicable and/or required.
|
||||
*/
|
||||
typedef struct dds_dynamic_type_descriptor {
|
||||
dds_dynamic_type_kind_t kind; /**< Type kind. Required for all types. */
|
||||
const char * name; /**< Type name. Required for struct, union, alias, enum, bitmask, array, sequence. */
|
||||
dds_dynamic_type_spec_t base_type; /**< Option base type for a struct, or (required) aliased type in case of an alias type. */
|
||||
dds_dynamic_type_spec_t discriminator_type; /**< Discriminator type for a union (required). */
|
||||
uint32_t num_bounds; /**< Number of bounds for array and sequence types. In case of sequence, this can be 0 (unbounded) or 1. */
|
||||
const uint32_t *bounds; /**< Bounds for array (0..num_bounds) and sequence (single value) */
|
||||
dds_dynamic_type_spec_t element_type; /**< Element type for array and sequence, required. */
|
||||
dds_dynamic_type_spec_t key_element_type; /**< Key element type for map type */
|
||||
} dds_dynamic_type_descriptor_t;
|
||||
|
||||
/**
|
||||
* @brief Dynamic Type Member descriptor
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Structure that holds the properities for adding a member to a dynamic type. Depending on
|
||||
* the member type, different fields apply and are required.
|
||||
*/
|
||||
typedef struct dds_dynamic_member_descriptor {
|
||||
const char * name; /**< Name of the member, required */
|
||||
uint32_t id; /**< Identifier of the member, applicable for struct and union members. DDS_DYNAMIC_MEMBER_ID_AUTO can be used to indicate the next available id (current max + 1) should be used. */
|
||||
dds_dynamic_type_spec_t type; /**< Member type, required for struct and union members. */
|
||||
char *default_value; /**< Default value for the member */
|
||||
uint32_t index; /**< Member index, applicable for struct and union members. DDS_DYNAMIC_MEMBER_INDEX_START and DDS_DYNAMIC_MEMBER_INDEX_END can be used to add a member as first or last member in the parent type. */
|
||||
uint32_t num_labels; /**< Number of labels, required for union members in case not default_label */
|
||||
int32_t *labels; /**< Labels for a union member, 1..n required for union members in case not default_label */
|
||||
bool default_label; /**< Is default union member */
|
||||
} dds_dynamic_member_descriptor_t;
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Dynamic Type extensibility
|
||||
*/
|
||||
enum dds_dynamic_type_extensibility {
|
||||
DDS_DYNAMIC_TYPE_EXT_FINAL,
|
||||
DDS_DYNAMIC_TYPE_EXT_APPENDABLE,
|
||||
DDS_DYNAMIC_TYPE_EXT_MUTABLE
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Dynamic Type automatic member ID kind
|
||||
*/
|
||||
enum dds_dynamic_type_autoid {
|
||||
DDS_DYNAMIC_TYPE_AUTOID_SEQUENTIAL, /**< The member ID are assigned sequential */
|
||||
DDS_DYNAMIC_TYPE_AUTOID_HASH /**< The member ID is the hash of the member's name */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enum value kind
|
||||
*
|
||||
* see @ref dds_dynamic_enum_literal_value
|
||||
*/
|
||||
enum dds_dynamic_type_enum_value_kind {
|
||||
DDS_DYNAMIC_ENUM_LITERAL_VALUE_NEXT_AVAIL,
|
||||
DDS_DYNAMIC_ENUM_LITERAL_VALUE_EXPLICIT
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Dynamic Enumeration type literal value kind and value. Can be set to NEXT_AVAIL to indicate
|
||||
* that the current max value + 1 should be used for this member, or an explicit value can be
|
||||
* provided.
|
||||
*/
|
||||
typedef struct dds_dynamic_enum_literal_value {
|
||||
enum dds_dynamic_type_enum_value_kind value_kind;
|
||||
int32_t value;
|
||||
} dds_dynamic_enum_literal_value_t;
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Short notation for initializing a Dynamic Enum value struct.
|
||||
*/
|
||||
#define DDS_DYNAMIC_ENUM_LITERAL_VALUE_AUTO ((dds_dynamic_enum_literal_value_t) { DDS_DYNAMIC_ENUM_LITERAL_VALUE_NEXT_AVAIL, 0 })
|
||||
#define DDS_DYNAMIC_ENUM_LITERAL_VALUE(v) ((dds_dynamic_enum_literal_value_t) { DDS_DYNAMIC_ENUM_LITERAL_VALUE_EXPLICIT, (v) })
|
||||
|
||||
/**
|
||||
* @ingroup dynamic_type
|
||||
*
|
||||
* Used to indicate that the bitmask field should get the next available position (current maximum + 1)
|
||||
*/
|
||||
#define DDS_DYNAMIC_BITMASK_POSITION_AUTO (UINT16_MAX)
|
||||
|
||||
/**
|
||||
* @brief Create a new Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* Creates a new Dynamic Type, using the properties that are set in the type descriptor.
|
||||
* In case these properties include a base-type, element-type or discriminator type, the
|
||||
* ownership of these types is transferred to the newly created type.
|
||||
*
|
||||
* @param[in] entity A DDS entity (any entity, except the pseudo root entity identified by DDS_CYCLONEDDS_HANDLE). This entity is used to get the type library of the entity's domain, to add the type to.
|
||||
* @param[in] descriptor The Dynamic Type descriptor.
|
||||
*
|
||||
* @return dds_dynamic_type_t A Dynamic Type reference for the created type.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The type is created successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_UNSUPPORTED
|
||||
* The provided type kind is not supported.
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* Not enough resources to create the type.
|
||||
*/
|
||||
DDS_EXPORT dds_dynamic_type_t dds_dynamic_type_create (dds_entity_t entity, dds_dynamic_type_descriptor_t descriptor);
|
||||
|
||||
/**
|
||||
* @brief Set the extensibility of a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type to set the extensibility for. This can be a structure, union, bitmask or enum type. This type must be in the CONSTRUCTING state and have no members added.
|
||||
* @param[in] extensibility The extensibility to set (@ref dds_dynamic_type_extensibility).
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The extensibility is set successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_set_extensibility (dds_dynamic_type_t *type, enum dds_dynamic_type_extensibility extensibility);
|
||||
|
||||
/**
|
||||
* @brief Set the bit-bound of a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type to set the bit-bound for. This can be a bitmask or enum type.
|
||||
* @param[in] bit_bound The bit-bound value to set, in the (including) range 1..32 for enum and 1..64 for bitmask.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The bit-bound is set successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_set_bit_bound (dds_dynamic_type_t *type, uint16_t bit_bound);
|
||||
|
||||
/**
|
||||
* @brief Set the nested flag of a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type to set the nested flag for. This can be a structure or union type.
|
||||
* @param[in] is_nested Whether the nested flag is set.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is set successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_set_nested (dds_dynamic_type_t *type, bool is_nested);
|
||||
|
||||
/**
|
||||
* @brief Set the auto-id kind of a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type to set the auto-id kind for. This can be a structure or union type.
|
||||
* @param[in] value The auto-id kind, see @ref dds_dynamic_type_autoid.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The value is set successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_set_autoid (dds_dynamic_type_t *type, enum dds_dynamic_type_autoid value);
|
||||
|
||||
/**
|
||||
* @brief Add a member to a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* This function is used to add a member to a Dynamic Type. The parent type can be a structure,
|
||||
* union, enumeration or bitmask type. The parent type the member is added to takes over the
|
||||
* ownership of the member type and dereferences the member type when it is deleted.
|
||||
* (@see dds_dynamic_type_ref for re-using a type)
|
||||
*
|
||||
* @param[in,out] type The Dynamic type to add the member to.
|
||||
* @param[in] member_descriptor The member descriptor that has the properties of the member to add, @see dds_dynamic_member_descriptor.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The member is added successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type (non the member type) is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_add_member (dds_dynamic_type_t *type, dds_dynamic_member_descriptor_t member_descriptor);
|
||||
|
||||
/**
|
||||
* @brief Add a literal to a Dynamic Enum Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* This function is used to add a literal to a Dynamic Enum Type.
|
||||
*
|
||||
* @param[in,out] type The Dynamic enum type to add the member to.
|
||||
* @param[in] name The name of the literal to add.
|
||||
* @param[in] value The value for the literal (@see dds_dynamic_enum_literal_value).
|
||||
* @param[in] is_default Indicates if the literal if default for the enum.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The member is added successfully
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_add_enum_literal (dds_dynamic_type_t *type, const char *name, dds_dynamic_enum_literal_value_t value, bool is_default);
|
||||
|
||||
/**
|
||||
* @brief Add a field to a Dynamic bitmask Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* This function is used to add a field to a Dynamic bitmask Type.
|
||||
*
|
||||
* @param[in,out] type The Dynamic bitmask type to add the field to.
|
||||
* @param[in] name The name of the field to add.
|
||||
* @param[in] position The position for the field (@see DDS_DYNAMIC_BITMASK_POSITION_AUTO).
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The member is added successfully
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_add_bitmask_field (dds_dynamic_type_t *type, const char *name, uint16_t position);
|
||||
|
||||
/**
|
||||
* @brief Set the key flag for a Dynamic Type member
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type that contains the member to set the key flag for (must be a structure type).
|
||||
* @param[in] member_id The ID of the member to set the flag for.
|
||||
* @param[in] is_key Indicates whether the key flag should be set or cleared.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is updated successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_member_set_key (dds_dynamic_type_t *type, uint32_t member_id, bool is_key);
|
||||
|
||||
/**
|
||||
* @brief Set the optional flag for a Dynamic Type member
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type that contains the member to set the optional flag for (must be a structure type).
|
||||
* @param[in] member_id The ID of the member to set the flag for.
|
||||
* @param[in] is_optional Indicates whether the optional flag should be set or cleared.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is updated successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_member_set_optional (dds_dynamic_type_t *type, uint32_t member_id, bool is_optional);
|
||||
|
||||
/**
|
||||
* @brief Set the external flag for a Dynamic Type member
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type that contains the member to set the external flag for (must be a structure or union type).
|
||||
* @param[in] member_id The ID of the member to set the flag for.
|
||||
* @param[in] is_external Indicates whether the external flag should be set or cleared.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is updated successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_member_set_external (dds_dynamic_type_t *type, uint32_t member_id, bool is_external);
|
||||
|
||||
/**
|
||||
* @brief Set the hash ID flag and hash field name for a Dynamic Type member
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type that contains the member to set the flag and hash-name for (must be a structure or union type).
|
||||
* @param[in] member_id The ID of the member to set the flag and hash-name for.
|
||||
* @param[in] hash_member_name The hash-name that should be used for calculating the member ID.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is updated successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_member_set_hashid (dds_dynamic_type_t *type, uint32_t member_id, const char *hash_member_name);
|
||||
|
||||
/**
|
||||
* @brief Set the must-understand flag for a Dynamic Type member
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* @param[in,out] type Dynamic Type that contains the member to set the must-understand flag for (must be a structure type).
|
||||
* @param[in] member_id The ID of the member to set the flag for.
|
||||
* @param[in] is_must_understand Indicates whether the must-understand flag should be set or cleared.
|
||||
*
|
||||
* @return dds_return_t Return code. In case of an error, the return code field in the provided type is also set to this value.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The flag is updated successfully.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_member_set_must_understand (dds_dynamic_type_t *type, uint32_t member_id, bool is_must_understand);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Registers a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* This function registers a dynamic type, making it immutable and finalizing
|
||||
* its definition. A type that is registered, get the state 'RESOLVED' and is
|
||||
* stored in the type library.
|
||||
*
|
||||
* @param[in] type A pointer to the dynamic type to be registered.
|
||||
* @param[out] type_info A pointer to a pointer to a ddsi_typeinfo structure that holds information about the registered type.
|
||||
*
|
||||
* @return dds_return_t Return code.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The type was successfully registered.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* Not enough resources to create the type.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_register (dds_dynamic_type_t *type, struct ddsi_typeinfo **type_info);
|
||||
|
||||
/**
|
||||
* @brief Reference a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* References a Dynamic Type and increases the ref-count of the type. This
|
||||
* can e.g. be used to re-use a subtype when constructing a type.
|
||||
*
|
||||
* @param type Dynamic Type to reference
|
||||
*
|
||||
* @return dds_dynamic_type_t Dynamic Type with increased ref-count
|
||||
*/
|
||||
DDS_EXPORT dds_dynamic_type_t dds_dynamic_type_ref (dds_dynamic_type_t *type);
|
||||
|
||||
/**
|
||||
* @brief Unref a Dynamic Type
|
||||
*
|
||||
* @param type The Dynamic Type to dereference.
|
||||
*
|
||||
* @return dds_return_t Return code.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The type was successfully registered.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more of the provided parameters are invalid.
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* The provided type is not in the CONSTRUCTING state.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_dynamic_type_unref (dds_dynamic_type_t *type);
|
||||
|
||||
/**
|
||||
* @brief Duplicate a Dynamic Type
|
||||
* @ingroup dynamic_type
|
||||
* @component dynamic_type_api
|
||||
*
|
||||
* Duplicates a Dynamic Type. Dependencies of the type are not duplicated,
|
||||
* but their ref-count is increased.
|
||||
*
|
||||
* @param src The type to duplicate.
|
||||
*
|
||||
* @return dds_dynamic_type_t A duplicate of the source type.
|
||||
*/
|
||||
DDS_EXPORT dds_dynamic_type_t dds_dynamic_type_dup (const dds_dynamic_type_t *src);
|
||||
|
||||
|
||||
#endif /* DDS_HAS_TYPELIB */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DDS_DYNAMIC_TYPE_H
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @brief DDS C Error API
|
||||
*
|
||||
* This header file defines the public API of error values and convenience
|
||||
* functions in the CycloneDDS C language binding.
|
||||
*/
|
||||
#ifndef DDS_ERROR_H
|
||||
#define DDS_ERROR_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ** DEPRECATED ** */
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
/* Error masks for returned status values */
|
||||
|
||||
#define DDS_ERR_NR_MASK 0x000000ff
|
||||
#define DDS_ERR_LINE_MASK 0x003fff00
|
||||
#define DDS_ERR_FILE_ID_MASK 0x7fc00000
|
||||
|
||||
/* Error code handling functions */
|
||||
|
||||
/** Macro to extract error number */
|
||||
#define dds_err_nr(e) (e)
|
||||
|
||||
/** Macro to extract line number */
|
||||
#define dds_err_line(e) (0)
|
||||
|
||||
/** Macro to extract file identifier */
|
||||
#define dds_err_file_id(e) (0)
|
||||
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+351
@@ -0,0 +1,351 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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
|
||||
|
||||
/* TODO: do we really need to expose all of this as an API? maybe some, but all? */
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @brief DDS C Implementation API
|
||||
*
|
||||
* This header file defines the public API for all kinds of things in the
|
||||
* Eclipse Cyclone DDS C language binding.
|
||||
*/
|
||||
#ifndef DDS_IMPL_H
|
||||
#define DDS_IMPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/align.h"
|
||||
#include "dds/ddsc/dds_public_alloc.h"
|
||||
#include "dds/ddsc/dds_opcodes.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup implementation (Public Implementation Details)
|
||||
* @ingroup dds
|
||||
* Miscellaneous types and functions that are required to be public, since they are
|
||||
* in the output of the IDL compiler, but are not intended for direct use.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup implementation
|
||||
* @brief Datastructure of a Sequence type
|
||||
* Container for a sequence of bytes. The general model of this type is also used in IDL output,
|
||||
* where the uint8_t * _buffer is replaced by the appropriate subtype of what is contained.
|
||||
*/
|
||||
typedef struct dds_sequence
|
||||
{
|
||||
uint32_t _maximum; /**< Allocated space in _buffer */
|
||||
uint32_t _length; /**< Used space in _buffer */
|
||||
uint8_t * _buffer; /**< Sequence of bytes */
|
||||
bool _release; /**< Whether a CycloneDDS _free method should free the contained buffer.
|
||||
if you put in your own allocated _buffer set this to false to avoid
|
||||
CycloneDDS calling free() on it. */
|
||||
}
|
||||
dds_sequence_t;
|
||||
|
||||
/**
|
||||
* @ingroup implementation
|
||||
* @brief Key Descriptor
|
||||
* Used to describe a named key field in a type with the offset from the start of a struct.
|
||||
*/
|
||||
typedef struct dds_key_descriptor
|
||||
{
|
||||
const char * m_name; /**< name of keyfield */
|
||||
uint32_t m_offset; /**< offset from pointer */
|
||||
uint32_t m_idx; /**< m_idx'th key of type */
|
||||
}
|
||||
dds_key_descriptor_t;
|
||||
|
||||
/**
|
||||
* @defgroup topic_definition (Topic Definition)
|
||||
* @ingroup implementation
|
||||
* Topic definitions are output by the IDL compiler and have an
|
||||
* implementation-private definition. The only thing exposed on the
|
||||
* API is a pointer to the "dds_topic_descriptor_t" struct type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup topic_definition
|
||||
* @brief Simple sized byte container to hold serialized type info
|
||||
* Holds XTypes information (TypeInformation, TypeMapping) for a
|
||||
* type
|
||||
*/
|
||||
struct dds_type_meta_ser
|
||||
{
|
||||
const unsigned char * data; /**< data pointer */
|
||||
uint32_t sz; /**< data size */
|
||||
};
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_XCDR1
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XCDR1
|
||||
* Type can be represented using XCDR1
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_XCDR1 0
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_XML
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XML
|
||||
* Type can be represented using XML
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_XML 1
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_XCDR2
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XCDR2
|
||||
* Type can be represented using XCDR2
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_XCDR2 2
|
||||
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_FLAG_XCDR1
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XCDR1 flag
|
||||
* Type can be represented using XCDR1, preshifted
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_FLAG_XCDR1 (1u << DDS_DATA_REPRESENTATION_XCDR1)
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_FLAG_XML
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XML flag
|
||||
* Type can be represented using XML, preshifted
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_FLAG_XML (1u << DDS_DATA_REPRESENTATION_XML)
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_FLAG_XCDR2
|
||||
* @ingroup topic_definition
|
||||
* @brief Data representation XCDR2 flag
|
||||
* Type can be represented using XCDR2, preshifted
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_FLAG_XCDR2 (1u << DDS_DATA_REPRESENTATION_XCDR2)
|
||||
|
||||
/**
|
||||
* @anchor DDS_DATA_REPRESENTATION_RESTRICT_DEFAULT
|
||||
* @ingroup topic_definition
|
||||
* @brief Default datarepresentation flag, XCDR1 and XCDR2 flags
|
||||
*/
|
||||
#define DDS_DATA_REPRESENTATION_RESTRICT_DEFAULT (DDS_DATA_REPRESENTATION_FLAG_XCDR1 | DDS_DATA_REPRESENTATION_FLAG_XCDR2)
|
||||
|
||||
/**
|
||||
* @brief Topic Descriptor
|
||||
* @ingroup topic_definition
|
||||
* @warning Unstable/Private API
|
||||
* Contains all meta information about a type, usually produced by the IDL compiler
|
||||
* Since this type is not intended for public consumption it can change without warning.
|
||||
*/
|
||||
typedef struct dds_topic_descriptor
|
||||
{
|
||||
const uint32_t m_size; /**< Size of topic type */
|
||||
const uint32_t m_align; /**< Alignment of topic type */
|
||||
const uint32_t m_flagset; /**< Flags */
|
||||
const uint32_t m_nkeys; /**< Number of keys (can be 0) */
|
||||
const char * m_typename; /**< Type name */
|
||||
const dds_key_descriptor_t * m_keys; /**< Key descriptors (NULL iff m_nkeys 0) */
|
||||
const uint32_t m_nops; /**< Number of ops in m_ops */
|
||||
const uint32_t * m_ops; /**< Marshalling meta data */
|
||||
const char * m_meta; /**< XML topic description meta data */
|
||||
struct dds_type_meta_ser type_information; /**< XCDR2 serialized TypeInformation, only present if flag DDS_TOPIC_XTYPES_METADATA is set */
|
||||
struct dds_type_meta_ser type_mapping; /**< XCDR2 serialized TypeMapping: maps type-id to type object and minimal to complete type id,
|
||||
only present if flag DDS_TOPIC_XTYPES_METADATA is set */
|
||||
const uint32_t restrict_data_representation; /**< restrictions on the data representations allowed for the top-level type for this topic,
|
||||
only present if flag DDS_TOPIC_RESTRICT_DATA_REPRESENTATION */
|
||||
}
|
||||
dds_topic_descriptor_t;
|
||||
|
||||
/**
|
||||
* @defgroup reading_masks (Reading Masks)
|
||||
* @ingroup conditions
|
||||
* Masks for read condition, read, take: there is only one mask here,
|
||||
* which combines the sample, view and instance states.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @anchor DDS_READ_SAMPLE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that were already returned once by a read/take operation
|
||||
*/
|
||||
#define DDS_READ_SAMPLE_STATE 1u
|
||||
|
||||
/**
|
||||
* @anchor DDS_NOT_READ_SAMPLE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that have not been returned by a read/take operation yet
|
||||
*/
|
||||
#define DDS_NOT_READ_SAMPLE_STATE 2u
|
||||
|
||||
/**
|
||||
* @anchor DDS_ANY_SAMPLE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples \ref DDS_READ_SAMPLE_STATE or \ref DDS_NOT_READ_SAMPLE_STATE
|
||||
*/
|
||||
#define DDS_ANY_SAMPLE_STATE (1u | 2u)
|
||||
|
||||
|
||||
/**
|
||||
* @anchor DDS_NEW_VIEW_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that belong to a new instance (unique key value)
|
||||
*/
|
||||
#define DDS_NEW_VIEW_STATE 4u
|
||||
|
||||
/**
|
||||
* @anchor DDS_NOT_NEW_VIEW_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that belong to an existing instance (previously received key value)
|
||||
*/
|
||||
#define DDS_NOT_NEW_VIEW_STATE 8u
|
||||
|
||||
/**
|
||||
* @anchor DDS_ANY_VIEW_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples \ref DDS_NEW_VIEW_STATE or \ref DDS_NOT_NEW_VIEW_STATE
|
||||
*/
|
||||
#define DDS_ANY_VIEW_STATE (4u | 8u)
|
||||
|
||||
|
||||
/**
|
||||
* @anchor DDS_ALIVE_INSTANCE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that belong to a write
|
||||
*/
|
||||
#define DDS_ALIVE_INSTANCE_STATE 16u
|
||||
|
||||
/**
|
||||
* @anchor DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that belong to a (write)dispose
|
||||
*/
|
||||
#define DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE 32u
|
||||
|
||||
/**
|
||||
* @anchor DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples that belong a writer that is gone
|
||||
*/
|
||||
#define DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE 64u
|
||||
|
||||
/**
|
||||
* @anchor DDS_ANY_INSTANCE_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Samples \ref DDS_ALIVE_INSTANCE_STATE, \ref DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE or \ref DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
|
||||
*/
|
||||
#define DDS_ANY_INSTANCE_STATE (16u | 32u | 64u)
|
||||
|
||||
/**
|
||||
* @anchor DDS_ANY_STATE
|
||||
* @ingroup reading_masks
|
||||
* @brief Any and all samples
|
||||
* Equivalen to \ref DDS_ANY_SAMPLE_STATE | \ref DDS_ANY_VIEW_STATE | \ref DDS_ANY_INSTANCE_STATE
|
||||
*/
|
||||
#define DDS_ANY_STATE (DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE)
|
||||
|
||||
/**
|
||||
* @anchor DDS_DOMAIN_DEFAULT
|
||||
* @ingroup domain
|
||||
* @brief Select the default domain
|
||||
*/
|
||||
#define DDS_DOMAIN_DEFAULT ((uint32_t) 0xffffffffu)
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
#define DDS_HANDLE_NIL 0
|
||||
#define DDS_ENTITY_NIL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief DDS Entity Kind constants
|
||||
* @ingroup internal
|
||||
* @warning Unstable/Private API
|
||||
* Used throughout the library to indicate what entity is what.
|
||||
*/
|
||||
typedef enum dds_entity_kind
|
||||
{
|
||||
DDS_KIND_DONTCARE, /**< Retrieving any entity */
|
||||
DDS_KIND_TOPIC, /**< Topic entity */
|
||||
DDS_KIND_PARTICIPANT, /**< Domain Participant entity */
|
||||
DDS_KIND_READER, /**< Reader entity */
|
||||
DDS_KIND_WRITER, /**< Writer entity */
|
||||
DDS_KIND_SUBSCRIBER, /**< Subscriber entity */
|
||||
DDS_KIND_PUBLISHER, /**< Publisher entity */
|
||||
DDS_KIND_COND_READ, /**< ReadCondition entity */
|
||||
DDS_KIND_COND_QUERY, /**< QueryCondition entity */
|
||||
DDS_KIND_COND_GUARD, /**< GuardCondition entity */
|
||||
DDS_KIND_WAITSET, /**< WaitSet entity */
|
||||
DDS_KIND_DOMAIN, /**< Domain entity */
|
||||
DDS_KIND_CYCLONEDDS /**< CycloneDDS library entity */
|
||||
} dds_entity_kind_t;
|
||||
/**
|
||||
* @anchor DDS_KIND_MAX
|
||||
* @ingroup internal
|
||||
* @brief Max entity kind, used for loops.
|
||||
*/
|
||||
#define DDS_KIND_MAX DDS_KIND_CYCLONEDDS
|
||||
|
||||
/**
|
||||
* @ingroup internal
|
||||
* @warning Private API
|
||||
* @brief Instance handles are uint64_t behind the scenes
|
||||
*/
|
||||
typedef uint64_t dds_instance_handle_t;
|
||||
|
||||
/**
|
||||
* @ingroup domain
|
||||
* @brief Domain IDs are 32 bit unsigned integers.
|
||||
*/
|
||||
typedef uint32_t dds_domainid_t;
|
||||
|
||||
/**
|
||||
* @ingroup topic
|
||||
* @brief Scope for dds_find_topic()
|
||||
*/
|
||||
typedef enum dds_find_scope
|
||||
{
|
||||
DDS_FIND_SCOPE_GLOBAL, /**< locate the topic anywhere CycloneDDS knows about */
|
||||
DDS_FIND_SCOPE_LOCAL_DOMAIN, /**< locate the topic locally within domain boundaries */
|
||||
DDS_FIND_SCOPE_PARTICIPANT /**< locate the topic within the current participant */
|
||||
}
|
||||
dds_find_scope_t;
|
||||
|
||||
/**
|
||||
* @ingroup builtintopic
|
||||
* @brief Type identifier kind for getting endpoint type identifier
|
||||
*/
|
||||
typedef enum dds_typeid_kind
|
||||
{
|
||||
DDS_TYPEID_MINIMAL, /**< XTypes Minimal Type ID */
|
||||
DDS_TYPEID_COMPLETE /**< XTypes Complete Type ID */
|
||||
}
|
||||
dds_typeid_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Enable or disable write batching.
|
||||
* @component domain
|
||||
*
|
||||
* Overrides default configuration setting for write batching (Internal/WriteBatch).
|
||||
*
|
||||
* @param[in] enable Enables or disables write batching for all writers.
|
||||
*/
|
||||
DDS_DEPRECATED_EXPORT void dds_write_set_batch (bool enable);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,853 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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
|
||||
|
||||
/**
|
||||
* @defgroup listener (Listener API)
|
||||
* @ingroup dds
|
||||
*
|
||||
* This defines the public API of listeners in the
|
||||
* Eclipse Cyclone DDS C language binding.
|
||||
*/
|
||||
#ifndef _DDS_PUBLIC_LISTENER_H_
|
||||
#define _DDS_PUBLIC_LISTENER_H_
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsc/dds_public_impl.h"
|
||||
#include "dds/ddsc/dds_public_status.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Listener callbacks */
|
||||
typedef void (*dds_on_inconsistent_topic_fn) (dds_entity_t topic, const dds_inconsistent_topic_status_t status, void* arg);
|
||||
typedef void (*dds_on_liveliness_lost_fn) (dds_entity_t writer, const dds_liveliness_lost_status_t status, void* arg);
|
||||
typedef void (*dds_on_offered_deadline_missed_fn) (dds_entity_t writer, const dds_offered_deadline_missed_status_t status, void* arg);
|
||||
typedef void (*dds_on_offered_incompatible_qos_fn) (dds_entity_t writer, const dds_offered_incompatible_qos_status_t status, void* arg);
|
||||
typedef void (*dds_on_data_on_readers_fn) (dds_entity_t subscriber, void* arg);
|
||||
typedef void (*dds_on_sample_lost_fn) (dds_entity_t reader, const dds_sample_lost_status_t status, void* arg);
|
||||
typedef void (*dds_on_data_available_fn) (dds_entity_t reader, void* arg);
|
||||
typedef void (*dds_on_sample_rejected_fn) (dds_entity_t reader, const dds_sample_rejected_status_t status, void* arg);
|
||||
typedef void (*dds_on_liveliness_changed_fn) (dds_entity_t reader, const dds_liveliness_changed_status_t status, void* arg);
|
||||
typedef void (*dds_on_requested_deadline_missed_fn) (dds_entity_t reader, const dds_requested_deadline_missed_status_t status, void* arg);
|
||||
typedef void (*dds_on_requested_incompatible_qos_fn) (dds_entity_t reader, const dds_requested_incompatible_qos_status_t status, void* arg);
|
||||
typedef void (*dds_on_publication_matched_fn) (dds_entity_t writer, const dds_publication_matched_status_t status, void* arg);
|
||||
typedef void (*dds_on_subscription_matched_fn) (dds_entity_t reader, const dds_subscription_matched_status_t status, void* arg);
|
||||
|
||||
/**
|
||||
* @anchor DDS_LUNSET
|
||||
* @ingroup internal
|
||||
* @brief Default initial value (nullptr) for listener functions.
|
||||
*/
|
||||
#define DDS_LUNSET 0
|
||||
|
||||
/**
|
||||
* @brief DDS Listener struct (opaque)
|
||||
* @ingroup listener
|
||||
*/
|
||||
struct dds_listener;
|
||||
|
||||
/**
|
||||
* @brief DDS Listener type (opaque)
|
||||
* @ingroup listener
|
||||
*/
|
||||
typedef struct dds_listener dds_listener_t;
|
||||
|
||||
/**
|
||||
* @ingroup listener
|
||||
* @component listener_obj
|
||||
* @brief Allocate memory and initializes to default values (@ref DDS_LUNSET) of a listener
|
||||
*
|
||||
* @param[in] arg optional pointer that will be passed on to the listener callbacks
|
||||
*
|
||||
* @returns Returns a pointer to the allocated memory for dds_listener_t structure.
|
||||
*/
|
||||
DDS_EXPORT dds_listener_t* dds_create_listener(void* arg);
|
||||
|
||||
/**
|
||||
* @ingroup listener
|
||||
* @component listener_obj
|
||||
* @brief Delete the memory allocated to listener structure
|
||||
*
|
||||
* @param[in] listener pointer to the listener struct to delete
|
||||
*/
|
||||
DDS_EXPORT void dds_delete_listener (dds_listener_t *listener);
|
||||
|
||||
/**
|
||||
* @ingroup listener
|
||||
* @component listener_obj
|
||||
* @brief Reset the listener structure contents to @ref DDS_LUNSET
|
||||
*
|
||||
* @param[in,out] listener pointer to the listener struct to reset
|
||||
*/
|
||||
DDS_EXPORT void dds_reset_listener (dds_listener_t *listener);
|
||||
|
||||
/**
|
||||
* @ingroup listener
|
||||
* @component listener_obj
|
||||
* @brief Copy the listener callbacks from source to destination
|
||||
*
|
||||
* @param[in,out] dst The pointer to the destination listener structure, where the content is to copied
|
||||
* @param[in] src The pointer to the source listener structure to be copied
|
||||
*/
|
||||
DDS_EXPORT void dds_copy_listener (dds_listener_t *dst, const dds_listener_t *src);
|
||||
|
||||
/**
|
||||
* @ingroup listener
|
||||
* @component listener_obj
|
||||
* @brief Copy the listener callbacks from source to destination, unless already set
|
||||
*
|
||||
* Any listener callbacks already set in @p dst (including NULL) are skipped, only
|
||||
* those set to DDS_LUNSET are copied from @p src.
|
||||
*
|
||||
* @param[in,out] dst The pointer to the destination listener structure, where the content is merged
|
||||
* @param[in] src The pointer to the source listener structure to be copied
|
||||
*/
|
||||
DDS_EXPORT void dds_merge_listener (dds_listener_t *dst, const dds_listener_t *src);
|
||||
|
||||
/************************************************************************************************
|
||||
* Setters
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup listener_setters (Setters)
|
||||
* @ingroup listener
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the data_available callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_data_available_arg (dds_listener_t *listener, dds_on_data_available_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the data_on_readers callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_data_on_readers_arg (dds_listener_t *listener, dds_on_data_on_readers_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the inconsistent_topic callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_inconsistent_topic_arg (dds_listener_t *listener, dds_on_inconsistent_topic_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the liveliness_changed callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_liveliness_changed_arg (dds_listener_t *listener, dds_on_liveliness_changed_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the liveliness_lost callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_liveliness_lost_arg (dds_listener_t *listener, dds_on_liveliness_lost_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the offered_deadline_missed callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_offered_deadline_missed_arg (dds_listener_t *listener, dds_on_offered_deadline_missed_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the offered_incompatible_qos callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_offered_incompatible_qos_arg (dds_listener_t *listener, dds_on_offered_incompatible_qos_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the publication_matched callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_publication_matched_arg (dds_listener_t *listener, dds_on_publication_matched_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the requested_deadline_missed callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_requested_deadline_missed_arg (dds_listener_t *listener, dds_on_requested_deadline_missed_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the requested_incompatible_qos callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_requested_incompatible_qos_arg (dds_listener_t *listener, dds_on_requested_incompatible_qos_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the sample_lost callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_sample_lost_arg (dds_listener_t *listener, dds_on_sample_lost_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the sample_rejected callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_sample_rejected_arg (dds_listener_t *listener, dds_on_sample_rejected_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the subscription_matched callback and argument in the listener structure.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
* @param[in] arg callback argument that is passed uninterpreted to the callback function
|
||||
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
|
||||
*
|
||||
* @retval DDS_RETCODE_OK success
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lset_subscription_matched_arg (dds_listener_t *listener, dds_on_subscription_matched_fn callback, void *arg, bool reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the inconsistent_topic callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_inconsistent_topic_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_inconsistent_topic (dds_listener_t *listener, dds_on_inconsistent_topic_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the liveliness_lost callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_liveliness_lost_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_liveliness_lost (dds_listener_t *listener, dds_on_liveliness_lost_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the offered_deadline_missed callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_offered_deadline_missed_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_offered_deadline_missed (dds_listener_t *listener, dds_on_offered_deadline_missed_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the offered_incompatible_qos callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_offered_incompatible_qos_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_offered_incompatible_qos (dds_listener_t *listener, dds_on_offered_incompatible_qos_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the data_on_readers callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_data_on_readers_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_data_on_readers (dds_listener_t *listener, dds_on_data_on_readers_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the sample_lost callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_sample_lost_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_sample_lost (dds_listener_t *listener, dds_on_sample_lost_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the data_available callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_data_available_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_data_available (dds_listener_t *listener, dds_on_data_available_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the sample_rejected callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_sample_rejected_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_sample_rejected (dds_listener_t *listener, dds_on_sample_rejected_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the liveliness_changed callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_liveliness_changed_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_liveliness_changed (dds_listener_t *listener, dds_on_liveliness_changed_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the requested_deadline_missed callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_requested_deadline_missed_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_requested_deadline_missed (dds_listener_t *listener, dds_on_requested_deadline_missed_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the requested_incompatible_qos callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_requested_incompatible_qos_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_requested_incompatible_qos (dds_listener_t *listener, dds_on_requested_incompatible_qos_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the publication_matched callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_publication_matched_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_publication_matched (dds_listener_t *listener, dds_on_publication_matched_fn callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_setters
|
||||
* @component listener_obj
|
||||
* @brief Set the subscription_matched callback in the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lset_subscription_matched_arg with arg set to the argument passed in
|
||||
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
|
||||
*
|
||||
* @param[in,out] listener listener structure to update
|
||||
* @param[in] callback the callback to set or a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lset_subscription_matched (dds_listener_t *listener, dds_on_subscription_matched_fn callback);
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* Getters
|
||||
************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup listener_getters (Getters)
|
||||
* @ingroup listener
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the data_available callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_data_available_arg (const dds_listener_t *listener, dds_on_data_available_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the data_on_readers callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_data_on_readers_arg (const dds_listener_t *listener, dds_on_data_on_readers_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the inconsistent_topic callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_inconsistent_topic_arg (const dds_listener_t *listener, dds_on_inconsistent_topic_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the liveliness_changed callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_liveliness_changed_arg (const dds_listener_t *listener, dds_on_liveliness_changed_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the liveliness_lost callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_liveliness_lost_arg (const dds_listener_t *listener, dds_on_liveliness_lost_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the offered_deadline_missed callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_offered_deadline_missed_arg (const dds_listener_t *listener, dds_on_offered_deadline_missed_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the offered_incompatible_qos callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_offered_incompatible_qos_arg (const dds_listener_t *listener, dds_on_offered_incompatible_qos_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the publication_matched callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_publication_matched_arg (const dds_listener_t *listener, dds_on_publication_matched_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the subscription_matched callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_requested_deadline_missed_arg (const dds_listener_t *listener, dds_on_requested_deadline_missed_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the requested_incompatible_qos callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_requested_incompatible_qos_arg (const dds_listener_t *listener, dds_on_requested_incompatible_qos_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the sample_lost callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_sample_lost_arg (const dds_listener_t *listener, dds_on_sample_lost_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the sample_rejected callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_sample_rejected_arg (const dds_listener_t *listener, dds_on_sample_rejected_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the subscription_matched callback from the listener structure.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
* @param[out] arg Callback argument pointer; may be a null pointer
|
||||
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
|
||||
*
|
||||
* @retval DDS_RETCODE_OK if successful
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_lget_subscription_matched_arg (const dds_listener_t *listener, dds_on_subscription_matched_fn *callback, void **arg, bool *reset_on_invoke);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the inconsistent_topic callback from the listener structure
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_inconsistent_topic_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_inconsistent_topic (const dds_listener_t *listener, dds_on_inconsistent_topic_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the liveliness_lost callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_liveliness_lost_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_liveliness_lost (const dds_listener_t *listener, dds_on_liveliness_lost_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the offered_deadline_missed callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_offered_deadline_missed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_offered_deadline_missed (const dds_listener_t *listener, dds_on_offered_deadline_missed_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the offered_incompatible_qos callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_offered_incompatible_qos_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_offered_incompatible_qos (const dds_listener_t *listener, dds_on_offered_incompatible_qos_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the data_on_readers callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_data_on_readers_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_data_on_readers (const dds_listener_t *listener, dds_on_data_on_readers_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the sample_lost callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_sample_lost_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_sample_lost (const dds_listener_t *listener, dds_on_sample_lost_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the data_available callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_data_available_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_data_available (const dds_listener_t *listener, dds_on_data_available_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the sample_rejected callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_sample_rejected_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_sample_rejected (const dds_listener_t *listener, dds_on_sample_rejected_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the liveliness_changed callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_liveliness_changed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_liveliness_changed (const dds_listener_t *listener, dds_on_liveliness_changed_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the requested_deadline_missed callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_requested_deadline_missed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_requested_deadline_missed (const dds_listener_t *listener, dds_on_requested_deadline_missed_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the requested_incompatible_qos callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_requested_incompatible_qos_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_requested_incompatible_qos (const dds_listener_t *listener, dds_on_requested_incompatible_qos_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the publication_matched callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_publication_matched_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_publication_matched (const dds_listener_t *listener, dds_on_publication_matched_fn *callback);
|
||||
|
||||
/**
|
||||
* @ingroup listener_getters
|
||||
* @component listener_obj
|
||||
* @brief Get the subscription_matched callback from the listener structure.
|
||||
*
|
||||
* Equivalent to calling @ref dds_lget_subscription_matched_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
|
||||
*
|
||||
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
|
||||
* @param[out] callback Callback function; may be a null pointer
|
||||
*/
|
||||
DDS_EXPORT void dds_lget_subscription_matched (const dds_listener_t *listener, dds_on_subscription_matched_fn *callback);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_DDS_PUBLIC_LISTENER_H_*/
|
||||
@@ -0,0 +1,172 @@
|
||||
// Copyright(c) 2021 ZettaScale Technology
|
||||
// Copyright(c) 2021 Apex.AI, Inc
|
||||
//
|
||||
// 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
|
||||
|
||||
// API extension
|
||||
// defines functions needed for loaning and shared memory usage
|
||||
|
||||
#ifndef DDS_PUBLIC_LOAN_API_H
|
||||
#define DDS_PUBLIC_LOAN_API_H
|
||||
|
||||
#include "dds/ddsc/dds_basic_types.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup loan (Loans API)
|
||||
* @ingroup dds
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Request a loan from an entity.
|
||||
* @ingroup loan
|
||||
*
|
||||
* Borrow a sample from the entity, which currently must be a writer. This sample
|
||||
* can then be returned using @ref dds_return_loan or can be used to publish data
|
||||
* using @ref dds_write or @ref dds_writedispose.
|
||||
*
|
||||
* If the topic type has a fixed size (and so no internal pointers) and a PSMX interface is configured,
|
||||
* the memory will be borrowed from the PSMX implementation, which allows Cyclone to avoid copies
|
||||
* and/or serialization if there is no need for sending the data over a network interface or storing it
|
||||
* in the WHC.
|
||||
*
|
||||
* @param[in] entity The entity to request loans from.
|
||||
* @param[out] sample Where to store the address of the loaned sample.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* The operation was successful.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One or more parameters are invalid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An unfortunate incident occurred.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_request_loan (dds_entity_t entity, void **sample);
|
||||
|
||||
/**
|
||||
* @brief Return loaned samples to a reader or writer
|
||||
* @ingroup loan
|
||||
* @component read_data
|
||||
*
|
||||
* Used to release middleware-owned samples returned by a read/take operation and samples
|
||||
* borrowed from the writer using @ref dds_request_loan.
|
||||
*
|
||||
* For reader loans, the @ref dds_read and @ref dds_take operations implicitly return
|
||||
* outstanding loans referenced by the sample array passed in. Looping until no data is
|
||||
* returned therefore often eliminates the need for calling this function.
|
||||
*
|
||||
* For writer loans, a @ref dds_write operation takes over the loan. Consequently, this
|
||||
* function is only needed in the exceptional case where a loan is taken but ultimately
|
||||
* not used to publish data.
|
||||
*
|
||||
* @param[in] entity The entity that the loan(s) belong to. If a read or query condition is passed in for the entity, the reader for that condition is used.
|
||||
* @param[in,out] buf An array of (pointers to) samples, some or all of which will be set to null pointers.
|
||||
* @param[in] bufsz The size of the buffer.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure
|
||||
* @retval DDS_RETCODE_OK
|
||||
* - the operation was successful
|
||||
* - a no-op if bufsz <= 0, otherwise
|
||||
* - buf[0] .. buf[k-1] were successfully returned loans, k = bufsz or buf[k] = null
|
||||
* - buf[0] is set to a null pointer, buf[k > 0] undefined
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* - the entity parameter is not a valid parameter
|
||||
* - buf is null, or bufsz > 0 and buf[0] = null
|
||||
* - a non-loan was encountered (all loans are still returned)
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* - bufsz > 0 and buf[0] != null but not a loan, nothing done
|
||||
* @retval DDS_RETCODE_UNSUPPORTED
|
||||
* - (for writer loans) invoked on a writer not supporting loans.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* - the operation is invoked on an inappropriate object.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_return_loan (dds_entity_t entity, void **buf, int32_t bufsz);
|
||||
|
||||
/**
|
||||
* @ingroup loan
|
||||
* @component read_data
|
||||
* @brief Check if a shared memory is available to reader/writer.
|
||||
*
|
||||
* @note dds_request_loan_of_size can be used if and only if
|
||||
* dds_is_shared_memory_available returns true.
|
||||
*
|
||||
* @param[in] entity the handle of the entity
|
||||
*
|
||||
* @returns true if shared memory is available, false otherwise
|
||||
*/
|
||||
DDS_EXPORT bool dds_is_shared_memory_available (const dds_entity_t entity);
|
||||
|
||||
/**
|
||||
* @brief Request a loan of a specified size from an entity.
|
||||
* @ingroup loan
|
||||
*
|
||||
* Borrow a sample of a specified size from the entity, which currently must be a
|
||||
* writer. This sample can then be returned using @ref dds_return_loan or can be
|
||||
* used to publish data using @ref dds_write or @ref dds_writedispose.
|
||||
*
|
||||
* @note The function can only be used if dds_is_shared_memory_available is
|
||||
* true for the writer.
|
||||
*
|
||||
* @param[in] writer The entity to request loans from.
|
||||
* @param[in] size the requested loan size
|
||||
* @param[out] sample Where to store the address of the loaned sample.
|
||||
*
|
||||
* @returns DDS_RETCODE_OK if successful, DDS_RETCODE_ERROR otherwise
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_request_loan_of_size (dds_entity_t writer, size_t size, void **sample);
|
||||
|
||||
/**
|
||||
* @ingroup deprecated
|
||||
* @component read_data
|
||||
* @brief Check if a Loan is available to reader/writer
|
||||
* @deprecated Use @ref dds_request_loan instead, returns 0 if loan is not available
|
||||
*
|
||||
* The loan is available if the shared memory is enabled and all the constraints
|
||||
* to enable shared memory are met and the type is fixed
|
||||
* @note dds_loan_sample can be used if and only if
|
||||
* dds_is_loan_available returns true.
|
||||
*
|
||||
* @param[in] entity the handle of the entity
|
||||
*
|
||||
* @returns loan available or not
|
||||
*/
|
||||
DDS_DEPRECATED_EXPORT bool dds_is_loan_available (const dds_entity_t entity);
|
||||
|
||||
/**
|
||||
* @ingroup deprecated
|
||||
* @component read_data
|
||||
* @brief Loan a sample from the writer.
|
||||
* @deprecated Use @ref dds_request_loan
|
||||
* @note This function is to be used with dds_write to publish the loaned
|
||||
* sample.
|
||||
* @note The function can only be used if dds_is_loan_available is
|
||||
* true for the writer.
|
||||
*
|
||||
* @param[in] writer the writer to loan the buffer from
|
||||
* @param[out] sample the loaned sample
|
||||
*
|
||||
* @returns DDS_RETCODE_OK if successful, DDS_RETCODE_ERROR otherwise
|
||||
*/
|
||||
DDS_DEPRECATED_EXPORT dds_return_t dds_loan_sample (dds_entity_t writer, void **sample);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDS_PUBLIC_LOAN_API_H */
|
||||
+1133
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,121 @@
|
||||
// Copyright(c) 2024 ZettaScale Technology 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 DDS_QOS_PROVIDER_H
|
||||
#define DDS_QOS_PROVIDER_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsc/dds_public_qosdefs.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_QOS_PROVIDER
|
||||
|
||||
/**
|
||||
* @defgroup qos_provider (QosProvider)
|
||||
* @ingroup dds
|
||||
* The Qos Provider API.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief All kind of entities for which qos can be stored in Profile.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*/
|
||||
enum dds_qos_kind
|
||||
{
|
||||
DDS_PARTICIPANT_QOS,
|
||||
DDS_PUBLISHER_QOS,
|
||||
DDS_SUBSCRIBER_QOS,
|
||||
DDS_TOPIC_QOS,
|
||||
DDS_READER_QOS,
|
||||
DDS_WRITER_QOS
|
||||
};
|
||||
typedef enum dds_qos_kind dds_qos_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Sample structure of the Qos Provider.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*/
|
||||
struct dds_qos_provider;
|
||||
typedef struct dds_qos_provider dds_qos_provider_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize Qos Provider.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*
|
||||
* Create dds_qos_provider with provided system definition file path.
|
||||
*
|
||||
* @param[in] path - String that contains system definition inself or path to system defenition file.
|
||||
* @param[in,out] provider - Pointer to the Qos Provider structure.
|
||||
*
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_create_qos_provider (const char *path, dds_qos_provider_t **provider);
|
||||
|
||||
/**
|
||||
* @brief Initialize Qos Provider with certain scope.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*
|
||||
* Create dds_qos_provider with provided system definition file path and scope.
|
||||
*
|
||||
* @param[in] path - String that contains system definition inself or path to system defenition file.
|
||||
* @param[in,out] provider - Pointer to the Qos Provider structure.
|
||||
* @param[in] key - String that contains pattern of interested qos from `path` in format '<library name>::<profile name>::<entity name>'.
|
||||
*
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_create_qos_provider_scope (const char *path, dds_qos_provider_t **provider,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* @brief Get Qos from Qos Provider.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*
|
||||
* Provide access to dds_qos_t from dds_qos_provider by full key and type of qos entity.
|
||||
*
|
||||
* @param[in] provider - Pointer to the Qos Provider structure.
|
||||
* @param[in] type - Type of entity which Qos to get.
|
||||
* @param[in] key - Full qualify name of Qos to get in format '<library name>::<profile name>::<entity name>'.
|
||||
* @param[in,out] qos - Pointer to the Qos structure.
|
||||
*
|
||||
* @return a DDS return code
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_qos_provider_get_qos (const dds_qos_provider_t *provider, dds_qos_kind_t type,
|
||||
const char *key, const dds_qos_t **qos);
|
||||
|
||||
/**
|
||||
* @brief Finalize Qos Provider.
|
||||
* @ingroup qos_provider
|
||||
* @component qos_provider_api
|
||||
*
|
||||
* Release resources allocated by dds_qos_provider.
|
||||
*
|
||||
* @param[in] provider - Pointer to the Qos Provider structure.
|
||||
*/
|
||||
DDS_EXPORT void
|
||||
dds_delete_qos_provider (dds_qos_provider_t *provider);
|
||||
|
||||
#endif /* DDS_HAS_QOS_PROVIDER */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DDS_QOS_PROVIDER_H
|
||||
@@ -0,0 +1,182 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDS_QOSDEFS_H
|
||||
#define DDS_QOSDEFS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @anchor DDS_LENGTH_UNLIMITED
|
||||
* @ingroup qos
|
||||
* @brief Used for indicating unlimited length in dds_qset_resource_limits()
|
||||
*/
|
||||
#define DDS_LENGTH_UNLIMITED -1
|
||||
|
||||
/**
|
||||
* @brief Qos Policy IDs
|
||||
* @ingroup internal
|
||||
* Used internally to mark the QoS policy type
|
||||
*/
|
||||
typedef enum dds_qos_policy_id {
|
||||
DDS_INVALID_QOS_POLICY_ID, /**< Invalid Policy */
|
||||
DDS_USERDATA_QOS_POLICY_ID, /**< Userdata policy dds_qset_userdata() */
|
||||
DDS_DURABILITY_QOS_POLICY_ID, /**< Durability policy dds_qset_durability() */
|
||||
DDS_PRESENTATION_QOS_POLICY_ID, /**< Presentation policy dds_qset_presentation() */
|
||||
DDS_DEADLINE_QOS_POLICY_ID, /**< Deadline policy dds_qset_deadline() */
|
||||
DDS_LATENCYBUDGET_QOS_POLICY_ID, /**< LatencyBudget policy dds_qset_latency_budget() */
|
||||
DDS_OWNERSHIP_QOS_POLICY_ID, /**< Ownership policy dds_qset_ownership() */
|
||||
DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID, /**< OwnershipStrength policy dds_qset_ownership_strength() */
|
||||
DDS_LIVELINESS_QOS_POLICY_ID, /**< Liveliness policy dds_qset_liveliness() */
|
||||
DDS_TIMEBASEDFILTER_QOS_POLICY_ID, /**< TimeBasedFilter policy dds_qset_time_based_filter() */
|
||||
DDS_PARTITION_QOS_POLICY_ID, /**< Partition policy dds_qset_partition() */
|
||||
DDS_RELIABILITY_QOS_POLICY_ID, /**< Reliability policy dds_qset_reliability() */
|
||||
DDS_DESTINATIONORDER_QOS_POLICY_ID, /**< DestinationOrder policy dds_qset_destination_order() */
|
||||
DDS_HISTORY_QOS_POLICY_ID, /**< History policy dds_qset_history() */
|
||||
DDS_RESOURCELIMITS_QOS_POLICY_ID, /**< ResourceLimits policy dds_qset_resource_limits() */
|
||||
DDS_ENTITYFACTORY_QOS_POLICY_ID, /**< EntityFactory policy */
|
||||
DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID, /**< WriterDataLifecycle policy dds_qset_writer_data_lifecycle() */
|
||||
DDS_READERDATALIFECYCLE_QOS_POLICY_ID, /**< ReaderDataLifecycle policy dds_qset_reader_data_lifecycle() */
|
||||
DDS_TOPICDATA_QOS_POLICY_ID, /**< Topicdata policy dds_qset_topicdata() */
|
||||
DDS_GROUPDATA_QOS_POLICY_ID, /**< Groupdata policy dds_qset_groupdata() */
|
||||
DDS_TRANSPORTPRIORITY_QOS_POLICY_ID, /**< TransportPriority policy dds_qset_transport_priority() */
|
||||
DDS_LIFESPAN_QOS_POLICY_ID, /**< Livespan policy dds_qset_lifespan() */
|
||||
DDS_DURABILITYSERVICE_QOS_POLICY_ID, /**< DurabilityService policy dds_qset_durability_service() */
|
||||
DDS_PROPERTY_QOS_POLICY_ID, /**< Property policy dds_qset_property() */
|
||||
DDS_TYPE_CONSISTENCY_ENFORCEMENT_QOS_POLICY_ID, /**< TypeConsistencyEnforcement policy dds_qset_type_consistency_enforcements() */
|
||||
DDS_DATA_REPRESENTATION_QOS_POLICY_ID /**< DataRepresentation policy dds_qset_data_representation() */
|
||||
} dds_qos_policy_id_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief QoS datatype
|
||||
* @ingroup qos
|
||||
* QoS structure is opaque
|
||||
*/
|
||||
typedef struct dds_qos dds_qos_t;
|
||||
|
||||
/**
|
||||
* @brief Durability QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_durability_kind
|
||||
{
|
||||
DDS_DURABILITY_VOLATILE, /**< Volatile durability */
|
||||
DDS_DURABILITY_TRANSIENT_LOCAL, /**< Transient Local durability */
|
||||
DDS_DURABILITY_TRANSIENT, /**< Transient durability */
|
||||
DDS_DURABILITY_PERSISTENT /**< Persistent durability */
|
||||
}
|
||||
dds_durability_kind_t;
|
||||
|
||||
/**
|
||||
* @brief History QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_history_kind
|
||||
{
|
||||
DDS_HISTORY_KEEP_LAST, /**< Keep Last history */
|
||||
DDS_HISTORY_KEEP_ALL /**< Keep All history */
|
||||
}
|
||||
dds_history_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Ownership QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_ownership_kind
|
||||
{
|
||||
DDS_OWNERSHIP_SHARED, /**< Shared Ownership */
|
||||
DDS_OWNERSHIP_EXCLUSIVE /**< Exclusive Ownership */
|
||||
}
|
||||
dds_ownership_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Liveliness QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_liveliness_kind
|
||||
{
|
||||
DDS_LIVELINESS_AUTOMATIC, /**< Automatic liveliness */
|
||||
DDS_LIVELINESS_MANUAL_BY_PARTICIPANT, /**< Manual by Participant liveliness */
|
||||
DDS_LIVELINESS_MANUAL_BY_TOPIC /**< Manual by Topic liveliness */
|
||||
}
|
||||
dds_liveliness_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Reliability QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_reliability_kind
|
||||
{
|
||||
DDS_RELIABILITY_BEST_EFFORT, /**< Best Effort reliability */
|
||||
DDS_RELIABILITY_RELIABLE /**< Reliable reliability */
|
||||
}
|
||||
dds_reliability_kind_t;
|
||||
|
||||
/**
|
||||
* @brief DestinationOrder QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_destination_order_kind
|
||||
{
|
||||
DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP, /**< order by reception timestamp */
|
||||
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP /**< order by source timestamp */
|
||||
}
|
||||
dds_destination_order_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Presentation QoS: Applies to Publisher, Subscriber
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_presentation_access_scope_kind
|
||||
{
|
||||
DDS_PRESENTATION_INSTANCE, /**< presentation scope per instance */
|
||||
DDS_PRESENTATION_TOPIC, /**< presentation scope per topic */
|
||||
DDS_PRESENTATION_GROUP /**< presentation scope per group */
|
||||
}
|
||||
dds_presentation_access_scope_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Ignore-local QoS: Applies to DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_ignorelocal_kind
|
||||
{
|
||||
DDS_IGNORELOCAL_NONE, /**< Don't ignore local data */
|
||||
DDS_IGNORELOCAL_PARTICIPANT, /**< Ignore local data from same participant */
|
||||
DDS_IGNORELOCAL_PROCESS /**< Ignore local data from same process */
|
||||
}
|
||||
dds_ignorelocal_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Type-consistency QoS: Applies to DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef enum dds_type_consistency_kind
|
||||
{
|
||||
DDS_TYPE_CONSISTENCY_DISALLOW_TYPE_COERCION, /**< Do not allow type coercion */
|
||||
DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION /**< Allow type coercion */
|
||||
}
|
||||
dds_type_consistency_kind_t;
|
||||
|
||||
/**
|
||||
* @brief Data Representation QoS: Applies to Topic, DataReader, DataWriter
|
||||
* @ingroup qos
|
||||
*/
|
||||
typedef int16_t dds_data_representation_id_t;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+521
@@ -0,0 +1,521 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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
|
||||
|
||||
/**
|
||||
* @defgroup dcps_status (DDS C Communication Status API)
|
||||
* @ingroup dds
|
||||
* This defines the public API of the Communication Status in the
|
||||
* Eclipse Cyclone DDS C language binding. Listeners are implemented
|
||||
* as structs containing callback functions that take listener status types
|
||||
* as arguments.
|
||||
*/
|
||||
#ifndef DDS_STATUS_H
|
||||
#define DDS_STATUS_H
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_OfferedDeadlineMissed
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_offered_deadline_missed_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_offered_deadline_missed_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_OfferedIncompatibleQoS
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_offered_incompatible_qos_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
uint32_t last_policy_id; /**< DOC_TODO */
|
||||
}
|
||||
dds_offered_incompatible_qos_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_PublicationMatched
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_publication_matched_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
uint32_t current_count; /**< DOC_TODO */
|
||||
int32_t current_count_change; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_subscription_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_publication_matched_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_LivelinessLost
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_liveliness_lost_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
}
|
||||
dds_liveliness_lost_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_SubscriptionMatched
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_subscription_matched_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
uint32_t current_count; /**< DOC_TODO */
|
||||
int32_t current_count_change; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_publication_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_subscription_matched_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief Rejected Status
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DDS_NOT_REJECTED, /**< DOC_TODO */
|
||||
DDS_REJECTED_BY_INSTANCES_LIMIT, /**< DOC_TODO */
|
||||
DDS_REJECTED_BY_SAMPLES_LIMIT, /**< DOC_TODO */
|
||||
DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT /**< DOC_TODO */
|
||||
}
|
||||
dds_sample_rejected_status_kind;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_SampleRejected
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_sample_rejected_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
dds_sample_rejected_status_kind last_reason; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_sample_rejected_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_LivelinessChanged
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_liveliness_changed_status
|
||||
{
|
||||
uint32_t alive_count; /**< DOC_TODO */
|
||||
uint32_t not_alive_count; /**< DOC_TODO */
|
||||
int32_t alive_count_change; /**< DOC_TODO */
|
||||
int32_t not_alive_count_change; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_publication_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_liveliness_changed_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_RequestedDeadlineMissed
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_requested_deadline_missed_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
|
||||
}
|
||||
dds_requested_deadline_missed_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_RequestedIncompatibleQoS
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_requested_incompatible_qos_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
uint32_t last_policy_id; /**< DOC_TODO */
|
||||
}
|
||||
dds_requested_incompatible_qos_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_SampleLost
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_sample_lost_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
}
|
||||
dds_sample_lost_status_t;
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status
|
||||
* @brief DCPS_Status_InconsistentTopic
|
||||
* DOC_TODO
|
||||
*/
|
||||
typedef struct dds_inconsistent_topic_status
|
||||
{
|
||||
uint32_t total_count; /**< DOC_TODO */
|
||||
int32_t total_count_change; /**< DOC_TODO */
|
||||
}
|
||||
dds_inconsistent_topic_status_t;
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup dcps_status_getters (DCPS Status Getters)
|
||||
* @ingroup dcps_status
|
||||
* get_<status> APIs return the status of an entity and resets the status
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get INCONSISTENT_TOPIC status
|
||||
*
|
||||
* This operation gets the status value corresponding to INCONSISTENT_TOPIC
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] topic The topic entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_inconsistent_topic_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_inconsistent_topic_status (
|
||||
dds_entity_t topic,
|
||||
dds_inconsistent_topic_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get PUBLICATION_MATCHED status
|
||||
*
|
||||
* This operation gets the status value corresponding to PUBLICATION_MATCHED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] writer The writer entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_publication_matched_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_publication_matched_status (
|
||||
dds_entity_t writer,
|
||||
dds_publication_matched_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get LIVELINESS_LOST status
|
||||
*
|
||||
* This operation gets the status value corresponding to LIVELINESS_LOST
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] writer The writer entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_liveliness_lost_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_liveliness_lost_status (
|
||||
dds_entity_t writer,
|
||||
dds_liveliness_lost_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get OFFERED_DEADLINE_MISSED status
|
||||
*
|
||||
* This operation gets the status value corresponding to OFFERED_DEADLINE_MISSED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] writer The writer entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_offered_deadline_missed_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_offered_deadline_missed_status(
|
||||
dds_entity_t writer,
|
||||
dds_offered_deadline_missed_status_t *status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get OFFERED_INCOMPATIBLE_QOS status
|
||||
*
|
||||
* This operation gets the status value corresponding to OFFERED_INCOMPATIBLE_QOS
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] writer The writer entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_offered_incompatible_qos_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_offered_incompatible_qos_status (
|
||||
dds_entity_t writer,
|
||||
dds_offered_incompatible_qos_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get SUBSCRIPTION_MATCHED status
|
||||
*
|
||||
* This operation gets the status value corresponding to SUBSCRIPTION_MATCHED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_subscription_matched_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_subscription_matched_status (
|
||||
dds_entity_t reader,
|
||||
dds_subscription_matched_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get LIVELINESS_CHANGED status
|
||||
*
|
||||
* This operation gets the status value corresponding to LIVELINESS_CHANGED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_liveliness_changed_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_liveliness_changed_status (
|
||||
dds_entity_t reader,
|
||||
dds_liveliness_changed_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get SAMPLE_REJECTED status
|
||||
*
|
||||
* This operation gets the status value corresponding to SAMPLE_REJECTED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_sample_rejected_status_t to get the status
|
||||
*
|
||||
* @returns 0 - Success
|
||||
* @returns <0 - Failure
|
||||
*
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_sample_rejected_status (
|
||||
dds_entity_t reader,
|
||||
dds_sample_rejected_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get SAMPLE_LOST status
|
||||
*
|
||||
* This operation gets the status value corresponding to SAMPLE_LOST
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_sample_lost_status_t to get the status
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Success
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_sample_lost_status (
|
||||
dds_entity_t reader,
|
||||
dds_sample_lost_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get REQUESTED_DEADLINE_MISSED status
|
||||
*
|
||||
* This operation gets the status value corresponding to REQUESTED_DEADLINE_MISSED
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_requested_deadline_missed_status_t to get the status
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Success
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_requested_deadline_missed_status (
|
||||
dds_entity_t reader,
|
||||
dds_requested_deadline_missed_status_t * status);
|
||||
|
||||
/**
|
||||
* @ingroup dcps_status_getters
|
||||
* @component entity_status
|
||||
* @brief Get REQUESTED_INCOMPATIBLE_QOS status
|
||||
*
|
||||
* This operation gets the status value corresponding to REQUESTED_INCOMPATIBLE_QOS
|
||||
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
|
||||
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
|
||||
*
|
||||
* @param[in] reader The reader entity to get the status
|
||||
* @param[out] status The pointer to @ref dds_requested_incompatible_qos_status_t to get the status
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Success
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error has occurred.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* One of the given arguments is not valid.
|
||||
* @retval DDS_RETCODE_ILLEGAL_OPERATION
|
||||
* The operation is invoked on an inappropriate object.
|
||||
* @retval DDS_RETCODE_ALREADY_DELETED
|
||||
* The entity has already been deleted.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
dds_get_requested_incompatible_qos_status (
|
||||
dds_entity_t reader,
|
||||
dds_requested_incompatible_qos_status_t * status);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 _DDS_RHC_H_
|
||||
#define _DDS_RHC_H_
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsi/ddsi_rhc.h"
|
||||
|
||||
#define DDS_RHC_NO_STATE_MASK_SET (DDS_ANY_STATE + 1)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_rhc;
|
||||
struct dds_readcond;
|
||||
struct dds_reader;
|
||||
struct ddsi_tkmap;
|
||||
|
||||
typedef dds_return_t (*dds_rhc_associate_t) (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertype *type, struct ddsi_tkmap *tkmap);
|
||||
typedef int32_t (*dds_rhc_read_take_t) (struct dds_rhc *rhc, int32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond, dds_read_with_collector_fn_t collect_sample, void *collect_sample_arg);
|
||||
|
||||
typedef bool (*dds_rhc_add_readcondition_t) (struct dds_rhc *rhc, struct dds_readcond *cond);
|
||||
typedef void (*dds_rhc_remove_readcondition_t) (struct dds_rhc *rhc, struct dds_readcond *cond);
|
||||
|
||||
struct dds_rhc_ops {
|
||||
/* A copy of DDSI rhc ops comes first so we can use either interface without
|
||||
additional indirections */
|
||||
struct ddsi_rhc_ops rhc_ops;
|
||||
dds_rhc_read_take_t peek;
|
||||
dds_rhc_read_take_t read;
|
||||
dds_rhc_read_take_t take;
|
||||
dds_rhc_add_readcondition_t add_readcondition;
|
||||
dds_rhc_remove_readcondition_t remove_readcondition;
|
||||
dds_rhc_associate_t associate;
|
||||
};
|
||||
|
||||
struct dds_rhc {
|
||||
union {
|
||||
const struct dds_rhc_ops *ops;
|
||||
struct ddsi_rhc rhc;
|
||||
} common;
|
||||
};
|
||||
|
||||
DDSRT_STATIC_ASSERT (offsetof (struct dds_rhc, common.ops) == offsetof (struct ddsi_rhc, ops));
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline dds_return_t dds_rhc_associate (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertype *type, struct ddsi_tkmap *tkmap) {
|
||||
return rhc->common.ops->associate (rhc, reader, type, tkmap);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline bool dds_rhc_store (struct dds_rhc *rhc, const struct ddsi_writer_info *wr_info, struct ddsi_serdata *sample, struct ddsi_tkmap_instance *tk) {
|
||||
return rhc->common.ops->rhc_ops.store (&rhc->common.rhc, wr_info, sample, tk);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline void dds_rhc_unregister_wr (struct dds_rhc *rhc, const struct ddsi_writer_info *wr_info) {
|
||||
rhc->common.ops->rhc_ops.unregister_wr (&rhc->common.rhc, wr_info);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline void dds_rhc_relinquish_ownership (struct dds_rhc *rhc, const uint64_t wr_iid) {
|
||||
rhc->common.ops->rhc_ops.relinquish_ownership (&rhc->common.rhc, wr_iid);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline void dds_rhc_set_qos (struct dds_rhc *rhc, const struct dds_qos *qos) {
|
||||
rhc->common.ops->rhc_ops.set_qos (&rhc->common.rhc, qos);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline void dds_rhc_free (struct dds_rhc *rhc) {
|
||||
rhc->common.ops->rhc_ops.free (&rhc->common.rhc);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline int32_t dds_rhc_peek (struct dds_rhc *rhc, int32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond, dds_read_with_collector_fn_t collect_sample, void *collect_sample_arg) {
|
||||
return (rhc->common.ops->peek) (rhc, max_samples, mask, handle, cond, collect_sample, collect_sample_arg);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline int32_t dds_rhc_read (struct dds_rhc *rhc, int32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond, dds_read_with_collector_fn_t collect_sample, void *collect_sample_arg) {
|
||||
return (rhc->common.ops->read) (rhc, max_samples, mask, handle, cond, collect_sample, collect_sample_arg);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline int32_t dds_rhc_take (struct dds_rhc *rhc, int32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond, dds_read_with_collector_fn_t collect_sample, void *collect_sample_arg) {
|
||||
return rhc->common.ops->take (rhc, max_samples, mask, handle, cond, collect_sample, collect_sample_arg);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline bool dds_rhc_add_readcondition (struct dds_rhc *rhc, struct dds_readcond *cond) {
|
||||
return rhc->common.ops->add_readcondition (rhc, cond);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_INLINE_EXPORT inline void dds_rhc_remove_readcondition (struct dds_rhc *rhc, struct dds_readcond *cond) {
|
||||
rhc->common.ops->remove_readcondition (rhc, cond);
|
||||
}
|
||||
|
||||
/** @component rhc */
|
||||
DDS_EXPORT void dds_reader_data_available_cb (struct dds_reader *rd);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
// Copyright(c) 2020 ZettaScale Technology 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 DDS_STATISTICS_H
|
||||
#define DDS_STATISTICS_H
|
||||
|
||||
/**
|
||||
* @defgroup statistics (DDS Statistics)
|
||||
* @ingroup dds
|
||||
* @warning Unstable API
|
||||
*
|
||||
* A quick-and-dirty provisional interface
|
||||
*/
|
||||
|
||||
#include "dds/dds.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Kind of statistical value
|
||||
* @ingroup statistics
|
||||
*/
|
||||
enum dds_stat_kind {
|
||||
DDS_STAT_KIND_UINT32, /**< value is a 32-bit unsigned integer */
|
||||
DDS_STAT_KIND_UINT64, /**< value is a 64-bit unsigned integer */
|
||||
DDS_STAT_KIND_LENGTHTIME /**< value is integral(length(t) dt) */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief KeyValue statistics entry
|
||||
* @ingroup statistics
|
||||
*/
|
||||
struct dds_stat_keyvalue {
|
||||
const char *name; /**< name, memory owned by library */
|
||||
enum dds_stat_kind kind; /**< value type */
|
||||
union {
|
||||
uint32_t u32; /**< used if kind == DDS_STAT_KIND_UINT32 */
|
||||
uint64_t u64; /**< used if kind == DDS_STAT_KIND_UINT64 */
|
||||
uint64_t lengthtime; /**< used if kind == DDS_STAT_KIND_LENGTHTIME */
|
||||
} u; /**< value */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Statistics container
|
||||
* @ingroup statistics
|
||||
*/
|
||||
struct dds_statistics {
|
||||
dds_entity_t entity; /**< handle of entity to which this set of values applies */
|
||||
uint64_t opaque; /**< internal data */
|
||||
dds_time_t time; /**< time stamp of latest call to dds_refresh_statistics() */
|
||||
size_t count; /**< number of key-value pairs */
|
||||
struct dds_stat_keyvalue kv[]; /**< data */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Allocate a new statistics object for entity
|
||||
* @ingroup statistics
|
||||
* @component statistics
|
||||
* @unstable
|
||||
*
|
||||
* This allocates and populates a newly allocated `struct dds_statistics` for the
|
||||
* specified entity.
|
||||
*
|
||||
* @param[in] entity the handle of the entity
|
||||
*
|
||||
* @returns a newly allocated and populated statistics structure or NULL if entity is
|
||||
* invalid or doesn't support any statistics.
|
||||
*/
|
||||
DDS_EXPORT struct dds_statistics *dds_create_statistics (dds_entity_t entity);
|
||||
|
||||
/**
|
||||
* @brief Update a previously created statistics structure with current values
|
||||
* @ingroup statistics
|
||||
* @component statistics
|
||||
* @unstable
|
||||
*
|
||||
* Only the time stamp and the values (and "opaque") may change. The set of keys and the
|
||||
* types of the values do not change.
|
||||
*
|
||||
* @param[in,out] stat statistics structure to update the values of
|
||||
*
|
||||
* @returns success or an error indication
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* the data was successfully updated
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* stats is a null pointer or the referenced entity no longer exists
|
||||
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
|
||||
* library was deinitialized
|
||||
*/
|
||||
DDS_EXPORT dds_return_t dds_refresh_statistics (struct dds_statistics *stat);
|
||||
|
||||
/**
|
||||
* @brief Free a previously created statistics object
|
||||
* @ingroup statistics
|
||||
* @component statistics
|
||||
* @unstable
|
||||
*
|
||||
* This frees the statistics object. Passing a null pointer is a no-op. The operation
|
||||
* succeeds also if the referenced entity no longer exists.
|
||||
*
|
||||
* @param[in] stat statistics object to free
|
||||
*/
|
||||
DDS_EXPORT void dds_delete_statistics (struct dds_statistics *stat);
|
||||
|
||||
/**
|
||||
* @brief Lookup a specific value by name
|
||||
* @ingroup statistics
|
||||
* @component statistics
|
||||
* @unstable
|
||||
*
|
||||
* This looks up the specified name in the list of keys in `stat` and returns the address
|
||||
* of the key-value pair if present, a null pointer if not. If `stat` is a null pointer,
|
||||
* it returns a null pointer.
|
||||
*
|
||||
* @param[in] stat statistics object to lookup a name in (or NULL)
|
||||
* @param[in] name name to look for
|
||||
*
|
||||
* @returns The address of the key-value pair inside `stat`, or NULL if `stat` is NULL or
|
||||
* `name` does not match a key in `stat.
|
||||
*/
|
||||
DDS_EXPORT const struct dds_stat_keyvalue *dds_lookup_statistic (const struct dds_statistics *stat, const char *name)
|
||||
ddsrt_nonnull ((2));
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_ADDRSET_H
|
||||
#define DDSI_ADDRSET_H
|
||||
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_addrset;
|
||||
struct ddsi_domaingv;
|
||||
|
||||
typedef void (*ddsi_addrset_forall_fun_t) (const ddsi_xlocator_t *loc, void *arg);
|
||||
|
||||
/** @component locators */
|
||||
bool ddsi_addrset_empty (const struct ddsi_addrset *as)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @component locators */
|
||||
void ddsi_addrset_forall (struct ddsi_addrset *as, ddsi_addrset_forall_fun_t f, void *arg)
|
||||
ddsrt_nonnull ((1,2));
|
||||
|
||||
/** @component locators */
|
||||
DDS_EXPORT struct ddsi_addrset *ddsi_ref_addrset (struct ddsi_addrset *as);
|
||||
|
||||
/** @component locators */
|
||||
DDS_EXPORT void ddsi_unref_addrset (struct ddsi_addrset *as);
|
||||
|
||||
/** @component locators */
|
||||
DDS_EXPORT struct ddsi_addrset *ddsi_new_addrset (void)
|
||||
ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component locators */
|
||||
DDS_EXPORT void ddsi_add_locator_to_addrset (const struct ddsi_domaingv *gv, struct ddsi_addrset *as, const ddsi_locator_t *loc)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* DDSI_ADDRSET_H */
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright(c) 2019 to 2021 ZettaScale Technology 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 DDSI_BUILTIN_TOPIC_IF_H
|
||||
#define DDSI_BUILTIN_TOPIC_IF_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_entity_common;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_sertype;
|
||||
struct ddsi_guid;
|
||||
struct ddsi_topic_definition;
|
||||
|
||||
struct ddsi_builtin_topic_interface {
|
||||
void *arg;
|
||||
|
||||
bool (*builtintopic_is_builtintopic) (const struct ddsi_sertype *type, void *arg);
|
||||
bool (*builtintopic_is_visible) (const struct ddsi_guid *guid, ddsi_vendorid_t vendorid, void *arg);
|
||||
struct ddsi_tkmap_instance * (*builtintopic_get_tkmap_entry) (const struct ddsi_guid *guid, void *arg);
|
||||
void (*builtintopic_write_endpoint) (const struct ddsi_entity_common *e, ddsrt_wctime_t timestamp, bool alive, void *arg);
|
||||
void (*builtintopic_write_topic) (const struct ddsi_topic_definition *tpd, ddsrt_wctime_t timestamp, bool alive, void *arg);
|
||||
};
|
||||
|
||||
/** @component builtintopic_if */
|
||||
inline bool ddsi_builtintopic_is_visible (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid, ddsi_vendorid_t vendorid) {
|
||||
return btif ? btif->builtintopic_is_visible (guid, vendorid, btif->arg) : false;
|
||||
}
|
||||
|
||||
/** @component builtintopic_if */
|
||||
inline bool ddsi_builtintopic_is_builtintopic (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_sertype *type) {
|
||||
return btif ? btif->builtintopic_is_builtintopic (type, btif->arg) : false;
|
||||
}
|
||||
|
||||
/** @component builtintopic_if */
|
||||
inline struct ddsi_tkmap_instance *ddsi_builtintopic_get_tkmap_entry (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_guid *guid) {
|
||||
return btif ? btif->builtintopic_get_tkmap_entry (guid, btif->arg) : NULL;
|
||||
}
|
||||
|
||||
/** @component builtintopic_if */
|
||||
inline void ddsi_builtintopic_write_endpoint (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_entity_common *e, ddsrt_wctime_t timestamp, bool alive) {
|
||||
if (btif) btif->builtintopic_write_endpoint (e, timestamp, alive, btif->arg);
|
||||
}
|
||||
|
||||
/** @component builtintopic_if */
|
||||
inline void ddsi_builtintopic_write_topic (const struct ddsi_builtin_topic_interface *btif, const struct ddsi_topic_definition *tpd, ddsrt_wctime_t timestamp, bool alive) {
|
||||
if (btif) btif->builtintopic_write_topic (tpd, timestamp, alive, btif->arg);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+464
@@ -0,0 +1,464 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_CONFIG_H
|
||||
#define DDSI_CONFIG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/sched.h"
|
||||
#include "dds/ddsrt/random.h"
|
||||
#include "dds/ddsi/ddsi_portmapping.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_config;
|
||||
|
||||
enum ddsi_standards_conformance {
|
||||
DDSI_SC_PEDANTIC,
|
||||
DDSI_SC_STRICT,
|
||||
DDSI_SC_LAX
|
||||
};
|
||||
|
||||
#define DDSI_SC_PEDANTIC_P(config) ((config).standards_conformance <= DDSI_SC_PEDANTIC)
|
||||
#define DDSI_SC_STRICT_P(config) ((config).standards_conformance <= DDSI_SC_STRICT)
|
||||
|
||||
enum ddsi_besmode {
|
||||
DDSI_BESMODE_FULL,
|
||||
DDSI_BESMODE_WRITERS,
|
||||
DDSI_BESMODE_MINIMAL
|
||||
};
|
||||
|
||||
enum ddsi_retransmit_merging {
|
||||
DDSI_REXMIT_MERGE_NEVER,
|
||||
DDSI_REXMIT_MERGE_ADAPTIVE,
|
||||
DDSI_REXMIT_MERGE_ALWAYS
|
||||
};
|
||||
|
||||
enum ddsi_boolean_default {
|
||||
DDSI_BOOLDEF_DEFAULT,
|
||||
DDSI_BOOLDEF_FALSE,
|
||||
DDSI_BOOLDEF_TRUE
|
||||
};
|
||||
|
||||
/* deprecated shm log level */
|
||||
enum ddsi_shm_loglevel {
|
||||
DDSI_SHM_OFF = 0,
|
||||
DDSI_SHM_FATAL,
|
||||
DDSI_SHM_ERROR,
|
||||
DDSI_SHM_WARN,
|
||||
DDSI_SHM_INFO,
|
||||
DDSI_SHM_DEBUG,
|
||||
DDSI_SHM_VERBOSE
|
||||
};
|
||||
|
||||
#define DDSI_PARTICIPANT_INDEX_AUTO -1
|
||||
#define DDSI_PARTICIPANT_INDEX_NONE -2
|
||||
#define DDSI_PARTICIPANT_INDEX_DEFAULT -3
|
||||
|
||||
/* ddsi_config_listelem must be an overlay for all used listelem types */
|
||||
struct ddsi_config_listelem {
|
||||
struct ddsi_config_listelem *next;
|
||||
};
|
||||
|
||||
#ifdef DDS_HAS_NETWORK_PARTITIONS
|
||||
struct ddsi_networkpartition_address {
|
||||
struct ddsi_networkpartition_address *next;
|
||||
ddsi_locator_t loc;
|
||||
};
|
||||
|
||||
struct ddsi_config_networkpartition_listelem {
|
||||
struct ddsi_config_networkpartition_listelem *next;
|
||||
char *name;
|
||||
char *address_string;
|
||||
char *interface_names;
|
||||
struct ddsi_networkpartition_address *uc_addresses;
|
||||
struct ddsi_networkpartition_address *asm_addresses;
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
struct ddsi_networkpartition_address *ssm_addresses;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ddsi_config_ignoredpartition_listelem {
|
||||
struct ddsi_config_ignoredpartition_listelem *next;
|
||||
char *DCPSPartitionTopic;
|
||||
};
|
||||
|
||||
struct ddsi_config_partitionmapping_listelem {
|
||||
struct ddsi_config_partitionmapping_listelem *next;
|
||||
char *networkPartition;
|
||||
char *DCPSPartitionTopic;
|
||||
struct ddsi_config_networkpartition_listelem *partition;
|
||||
};
|
||||
#endif /* DDS_HAS_NETWORK_PARTITIONS */
|
||||
|
||||
struct ddsi_config_maybe_int32 {
|
||||
int isdefault;
|
||||
int32_t value;
|
||||
};
|
||||
|
||||
struct ddsi_config_maybe_uint32 {
|
||||
int isdefault;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
struct ddsi_config_maybe_duration {
|
||||
int isdefault;
|
||||
dds_duration_t value;
|
||||
};
|
||||
|
||||
struct ddsi_config_uint32_array {
|
||||
uint32_t n;
|
||||
uint32_t *xs;
|
||||
};
|
||||
|
||||
struct ddsi_config_thread_properties_listelem {
|
||||
struct ddsi_config_thread_properties_listelem *next;
|
||||
char *name;
|
||||
ddsrt_sched_t sched_class;
|
||||
struct ddsi_config_maybe_int32 schedule_priority;
|
||||
struct ddsi_config_maybe_uint32 stack_size;
|
||||
struct ddsi_config_uint32_array affinity;
|
||||
};
|
||||
|
||||
struct ddsi_config_peer_listelem
|
||||
{
|
||||
struct ddsi_config_peer_listelem *next;
|
||||
char *peer;
|
||||
struct ddsi_config_maybe_duration prune_delay;
|
||||
};
|
||||
|
||||
struct ddsi_config_prune_deleted_ppant {
|
||||
int64_t delay;
|
||||
int enforce_delay;
|
||||
};
|
||||
|
||||
/* allow multicast bits (default depends on network type): */
|
||||
#define DDSI_AMC_FALSE 0u
|
||||
#define DDSI_AMC_SPDP 1u
|
||||
#define DDSI_AMC_ASM 2u
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
#define DDSI_AMC_SSM 4u
|
||||
#define DDSI_AMC_TRUE (DDSI_AMC_SPDP | DDSI_AMC_ASM | DDSI_AMC_SSM)
|
||||
#else
|
||||
#define DDSI_AMC_TRUE (DDSI_AMC_SPDP | DDSI_AMC_ASM)
|
||||
#endif
|
||||
#define DDSI_AMC_DEFAULT 0x80000000u
|
||||
|
||||
/* FIXME: this should be fully dynamic ... but this is easier for a quick hack */
|
||||
enum ddsi_transport_selector {
|
||||
DDSI_TRANS_DEFAULT, /* actually UDP, but this is so we can tell what has been set */
|
||||
DDSI_TRANS_UDP,
|
||||
DDSI_TRANS_UDP6,
|
||||
DDSI_TRANS_TCP,
|
||||
DDSI_TRANS_TCP6,
|
||||
DDSI_TRANS_RAWETH,
|
||||
DDSI_TRANS_NONE /* FIXME: see FIXME above ... :( */
|
||||
};
|
||||
|
||||
enum ddsi_many_sockets_mode {
|
||||
DDSI_MSM_NO_UNICAST,
|
||||
DDSI_MSM_SINGLE_UNICAST,
|
||||
DDSI_MSM_MANY_UNICAST
|
||||
};
|
||||
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_plugin_library_properties {
|
||||
char *library_path;
|
||||
char *library_init;
|
||||
char *library_finalize;
|
||||
};
|
||||
|
||||
struct ddsi_authentication_properties {
|
||||
char *identity_certificate;
|
||||
char *identity_ca;
|
||||
char *private_key;
|
||||
char *password;
|
||||
char *trusted_ca_dir;
|
||||
char *crl;
|
||||
int include_optional_fields;
|
||||
};
|
||||
|
||||
struct ddsi_access_control_properties {
|
||||
char *permissions;
|
||||
char *permissions_ca;
|
||||
char *governance;
|
||||
};
|
||||
|
||||
struct ddsi_config_omg_security {
|
||||
struct ddsi_authentication_properties authentication_properties;
|
||||
struct ddsi_access_control_properties access_control_properties;
|
||||
struct ddsi_plugin_library_properties authentication_plugin;
|
||||
struct ddsi_plugin_library_properties access_control_plugin;
|
||||
struct ddsi_plugin_library_properties cryptography_plugin;
|
||||
};
|
||||
|
||||
struct ddsi_config_omg_security_listelem {
|
||||
struct ddsi_config_omg_security_listelem *next;
|
||||
struct ddsi_config_omg_security cfg;
|
||||
};
|
||||
#endif /* DDS_HAS_SECURITY */
|
||||
|
||||
#ifdef DDS_HAS_TCP_TLS
|
||||
struct ddsi_config_ssl_min_version {
|
||||
int major;
|
||||
int minor;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct ddsi_config_socket_buf_size {
|
||||
struct ddsi_config_maybe_uint32 min, max;
|
||||
};
|
||||
|
||||
struct ddsi_config_network_interface {
|
||||
int automatic;
|
||||
char *name;
|
||||
char *address;
|
||||
int prefer_multicast;
|
||||
int presence_required;
|
||||
enum ddsi_boolean_default multicast;
|
||||
struct ddsi_config_maybe_int32 priority;
|
||||
uint32_t allow_multicast; // no need for a "maybe" type: DDSI_AMC_DEFAULT takes care of that
|
||||
};
|
||||
|
||||
struct ddsi_config_network_interface_listelem {
|
||||
struct ddsi_config_network_interface_listelem *next;
|
||||
struct ddsi_config_network_interface cfg;
|
||||
};
|
||||
|
||||
enum ddsi_config_entity_naming_mode {
|
||||
DDSI_ENTITY_NAMING_DEFAULT_EMPTY,
|
||||
DDSI_ENTITY_NAMING_DEFAULT_FANCY
|
||||
};
|
||||
|
||||
struct ddsi_config_psmx {
|
||||
char *type;
|
||||
char *library;
|
||||
char *config;
|
||||
struct ddsi_config_maybe_int32 priority;
|
||||
};
|
||||
|
||||
struct ddsi_config_psmx_listelem {
|
||||
struct ddsi_config_psmx_listelem *next;
|
||||
struct ddsi_config_psmx cfg;
|
||||
};
|
||||
|
||||
/* Expensive checks (compiled in when NDEBUG not defined, enabled only if flag set in xchecks) */
|
||||
#define DDSI_XCHECK_WHC 1u
|
||||
#define DDSI_XCHECK_RHC 2u
|
||||
#define DDSI_XCHECK_XEV 4u
|
||||
|
||||
/**
|
||||
* @brief Default-initialize a configuration (unstable)
|
||||
* @component config
|
||||
*
|
||||
* @param[out] cfg The configuration struct to be initialized.
|
||||
*/
|
||||
DDS_EXPORT void ddsi_config_init_default (struct ddsi_config *cfg);
|
||||
|
||||
struct ddsi_config
|
||||
{
|
||||
int valid;
|
||||
uint32_t tracemask;
|
||||
uint32_t enabled_xchecks;
|
||||
char *pcap_file;
|
||||
|
||||
/* interfaces */
|
||||
struct ddsi_config_network_interface_listelem *network_interfaces;
|
||||
struct ddsi_config_psmx_listelem *psmx_instances;
|
||||
|
||||
/* deprecated interface support */
|
||||
char *depr_networkAddressString;
|
||||
int depr_prefer_multicast;
|
||||
char *depr_assumeMulticastCapable;
|
||||
|
||||
char **networkRecvAddressStrings;
|
||||
uint32_t allowMulticast;
|
||||
char *externalAddressString;
|
||||
char *externalMaskString;
|
||||
FILE *tracefp;
|
||||
char *tracefile;
|
||||
int tracingAppendToFile;
|
||||
enum ddsi_transport_selector transport_selector;
|
||||
enum ddsi_boolean_default compat_use_ipv6;
|
||||
enum ddsi_boolean_default compat_tcp_enable;
|
||||
int dontRoute;
|
||||
int enableMulticastLoopback;
|
||||
uint32_t domainId;
|
||||
struct ddsi_config_maybe_uint32 extDomainId; // domain id advertised in discovery
|
||||
char *domainTag;
|
||||
int participantIndex;
|
||||
int maxAutoParticipantIndex;
|
||||
char *spdpMulticastAddressString;
|
||||
char *defaultMulticastAddressString;
|
||||
struct ddsi_config_maybe_duration spdp_interval;
|
||||
int64_t spdp_response_delay_max;
|
||||
int64_t spdp_prune_delay_initial;
|
||||
int64_t spdp_prune_delay_discovered;
|
||||
int64_t lease_duration;
|
||||
int64_t const_hb_intv_sched;
|
||||
int64_t const_hb_intv_sched_min;
|
||||
int64_t const_hb_intv_sched_max;
|
||||
int64_t const_hb_intv_min;
|
||||
enum ddsi_retransmit_merging retransmit_merging;
|
||||
int64_t retransmit_merging_period;
|
||||
int squash_participants;
|
||||
int liveliness_monitoring;
|
||||
int noprogress_log_stacktraces;
|
||||
int64_t liveliness_monitoring_interval;
|
||||
int prioritize_retransmit;
|
||||
enum ddsi_boolean_default multiple_recv_threads;
|
||||
unsigned recv_thread_stop_maxretries;
|
||||
|
||||
unsigned primary_reorder_maxsamples;
|
||||
unsigned secondary_reorder_maxsamples;
|
||||
|
||||
unsigned delivery_queue_maxsamples;
|
||||
|
||||
uint16_t fragment_size;
|
||||
uint32_t max_msg_size;
|
||||
uint32_t max_rexmit_msg_size;
|
||||
uint32_t init_transmit_extra_pct;
|
||||
uint32_t max_rexmit_burst_size;
|
||||
uint32_t max_frags_in_rexmit_of_sample;
|
||||
|
||||
int publish_uc_locators; /* Publish discovery unicast locators */
|
||||
int enable_uc_locators; /* If false, don't even try to create a unicast socket */
|
||||
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
int enable_topic_discovery_endpoints;
|
||||
#endif
|
||||
|
||||
/* TCP transport configuration */
|
||||
int tcp_nodelay;
|
||||
int tcp_port;
|
||||
int64_t tcp_read_timeout;
|
||||
int64_t tcp_write_timeout;
|
||||
int tcp_use_peeraddr_for_unicast;
|
||||
|
||||
#ifdef DDS_HAS_TCP_TLS
|
||||
/* SSL support for TCP */
|
||||
int ssl_enable;
|
||||
int ssl_verify;
|
||||
int ssl_verify_client;
|
||||
int ssl_self_signed;
|
||||
char * ssl_keystore;
|
||||
char * ssl_rand_file;
|
||||
char * ssl_key_pass;
|
||||
char * ssl_ciphers;
|
||||
struct ddsi_config_ssl_min_version ssl_min_version;
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_NETWORK_PARTITIONS
|
||||
struct ddsi_config_networkpartition_listelem *networkPartitions;
|
||||
unsigned nof_networkPartitions;
|
||||
struct ddsi_config_ignoredpartition_listelem *ignoredPartitions;
|
||||
struct ddsi_config_partitionmapping_listelem *partitionMappings;
|
||||
#endif /* DDS_HAS_NETWORK_PARTITIONS */
|
||||
enum ddsi_boolean_default add_localhost_to_peers;
|
||||
struct ddsi_config_peer_listelem *peers;
|
||||
struct ddsi_config_thread_properties_listelem *thread_properties;
|
||||
|
||||
/* debug/test/undoc features: */
|
||||
int xmit_lossiness; /**<< fraction of packets to drop on xmit, in units of 1e-3 */
|
||||
uint32_t rmsg_chunk_size; /**<< size of a chunk in the receive buffer */
|
||||
uint32_t rbuf_size; /* << size of a single receiver buffer */
|
||||
enum ddsi_besmode besmode;
|
||||
int meas_hb_to_ack_latency;
|
||||
int synchronous_delivery_priority_threshold;
|
||||
int64_t synchronous_delivery_latency_bound;
|
||||
|
||||
/* Write cache */
|
||||
|
||||
int whc_batch;
|
||||
uint32_t whc_lowwater_mark;
|
||||
uint32_t whc_highwater_mark;
|
||||
struct ddsi_config_maybe_uint32 whc_init_highwater_mark;
|
||||
int whc_adaptive;
|
||||
|
||||
unsigned defrag_unreliable_maxsamples;
|
||||
unsigned defrag_reliable_maxsamples;
|
||||
unsigned accelerate_rexmit_block_size;
|
||||
int64_t responsiveness_timeout;
|
||||
uint32_t max_participants;
|
||||
int64_t writer_linger_duration;
|
||||
int multicast_ttl;
|
||||
struct ddsi_config_socket_buf_size socket_rcvbuf_size;
|
||||
struct ddsi_config_socket_buf_size socket_sndbuf_size;
|
||||
int64_t ack_delay;
|
||||
int64_t nack_delay;
|
||||
int64_t preemptive_ack_delay;
|
||||
int64_t auto_resched_nack_delay;
|
||||
int64_t ds_grace_period;
|
||||
uint32_t max_queued_rexmit_bytes;
|
||||
unsigned max_queued_rexmit_msgs;
|
||||
int late_ack_mode;
|
||||
int retry_on_reject_besteffort;
|
||||
int generate_keyhash;
|
||||
uint32_t max_sample_size;
|
||||
int extended_packet_info;
|
||||
|
||||
/* compability options */
|
||||
enum ddsi_standards_conformance standards_conformance;
|
||||
int explicitly_publish_qos_set_to_default;
|
||||
enum ddsi_many_sockets_mode many_sockets_mode;
|
||||
int assume_rti_has_pmd_endpoints;
|
||||
|
||||
struct ddsi_portmapping ports;
|
||||
|
||||
int monitor_port;
|
||||
|
||||
int enable_control_topic;
|
||||
int initial_deaf;
|
||||
int initial_mute;
|
||||
int64_t initial_deaf_mute_reset;
|
||||
|
||||
int use_multicast_if_mreqn;
|
||||
struct ddsi_config_prune_deleted_ppant prune_deleted_ppant;
|
||||
int redundant_networking;
|
||||
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_config_omg_security_listelem *omg_security_configuration;
|
||||
#endif
|
||||
|
||||
/* deprecated shm options */
|
||||
int enable_shm;
|
||||
char *shm_locator;
|
||||
char *iceoryx_service;
|
||||
enum ddsi_shm_loglevel shm_log_lvl;
|
||||
|
||||
enum ddsi_config_entity_naming_mode entity_naming_mode;
|
||||
ddsrt_prng_seed_t entity_naming_seed;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
public:
|
||||
ddsi_config() {
|
||||
ddsi_config_init_default (this);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/** @component config */
|
||||
struct ddsi_cfgst *ddsi_config_init (const char *config, struct ddsi_config *cfg, uint32_t domid) ddsrt_nonnull((1,2));
|
||||
|
||||
/** @component config */
|
||||
DDS_EXPORT void ddsi_config_fini (struct ddsi_cfgst *cfgst);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_CONFIG_H */
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_DEADLINE_H
|
||||
#define DDSI_DEADLINE_H
|
||||
|
||||
#include "dds/ddsrt/circlist.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
#include "dds/ddsi/ddsi_xevent.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef ddsrt_mtime_t (*deadline_missed_cb_t)(void *hc, ddsrt_mtime_t tnow);
|
||||
|
||||
struct ddsi_deadline_adm {
|
||||
struct ddsrt_circlist list; /* linked list for deadline missed */
|
||||
struct ddsi_xevent *evt; /* xevent that triggers when deadline expires for an instance */
|
||||
deadline_missed_cb_t deadline_missed_cb; /* callback for deadline missed; this cb can use ddsi_deadline_next_missed_locked to get next instance that has a missed deadline */
|
||||
size_t list_offset; /* offset of deadline_adm element in whc or rhc */
|
||||
size_t elem_offset; /* offset of deadline_elem element in whc or rhc instance */
|
||||
dds_duration_t dur; /* deadline duration */
|
||||
};
|
||||
|
||||
struct deadline_elem {
|
||||
struct ddsrt_circlist_elem e;
|
||||
ddsrt_mtime_t t_deadline;
|
||||
ddsrt_mtime_t t_last_update;
|
||||
uint32_t deadlines_missed;
|
||||
};
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_init (const struct ddsi_domaingv *gv, struct ddsi_deadline_adm *deadline_adm, size_t list_offset, size_t elem_offset, deadline_missed_cb_t deadline_missed_cb);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_stop (const struct ddsi_deadline_adm *deadline_adm);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_clear (struct ddsi_deadline_adm *deadline_adm);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_fini (const struct ddsi_deadline_adm *deadline_adm);
|
||||
|
||||
/** @component deadline_qos */
|
||||
uint32_t ddsi_deadline_compute_deadlines_missed (ddsrt_mtime_t tnow, const struct deadline_elem *deadline_elem, dds_duration_t deadline_dur);
|
||||
|
||||
/** @component deadline_qos */
|
||||
ddsrt_mtime_t ddsi_deadline_next_missed_locked (struct ddsi_deadline_adm *deadline_adm, ddsrt_mtime_t tnow, void **instance);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_register_instance_real (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_reregister_instance_real (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tprev, ddsrt_mtime_t tnow);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_unregister_instance_real (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem);
|
||||
|
||||
/** @component deadline_qos */
|
||||
void ddsi_deadline_renew_instance_real (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem);
|
||||
|
||||
/** @component deadline_qos */
|
||||
inline void ddsi_deadline_register_instance_locked (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow)
|
||||
{
|
||||
if (deadline_adm->dur != DDS_INFINITY)
|
||||
ddsi_deadline_register_instance_real (deadline_adm, elem, tnow);
|
||||
}
|
||||
|
||||
/** @component deadline_qos */
|
||||
inline void ddsi_deadline_reregister_instance_locked (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem, ddsrt_mtime_t tnow)
|
||||
{
|
||||
if (deadline_adm->dur != DDS_INFINITY)
|
||||
ddsi_deadline_reregister_instance_real (deadline_adm, elem, elem->t_last_update, tnow);
|
||||
}
|
||||
|
||||
/** @component deadline_qos */
|
||||
inline void ddsi_deadline_unregister_instance_locked (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem)
|
||||
{
|
||||
if (deadline_adm->dur != DDS_INFINITY)
|
||||
{
|
||||
assert (elem->t_deadline.v != DDS_NEVER);
|
||||
ddsi_deadline_unregister_instance_real (deadline_adm, elem);
|
||||
}
|
||||
}
|
||||
|
||||
/** @component deadline_qos */
|
||||
inline void ddsi_deadline_renew_instance_locked (struct ddsi_deadline_adm *deadline_adm, struct deadline_elem *elem)
|
||||
{
|
||||
if (deadline_adm->dur != DDS_INFINITY)
|
||||
{
|
||||
assert (elem->t_deadline.v != DDS_NEVER);
|
||||
ddsi_deadline_renew_instance_real (deadline_adm, elem);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_DEADLINE_H */
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright(c) 2020 ZettaScale Technology 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 DDSI_DELIVER_LOCALLY_H
|
||||
#define DDSI_DELIVER_LOCALLY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_sertype;
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_entity_index;
|
||||
struct ddsi_reader;
|
||||
struct ddsi_entity_common;
|
||||
struct ddsi_writer_info;
|
||||
struct ddsi_local_reader_ary;
|
||||
|
||||
typedef struct ddsi_serdata * (*deliver_locally_makesample_t) (struct ddsi_tkmap_instance **tk, struct ddsi_domaingv *gv, struct ddsi_sertype const * const type, void *vsourceinfo);
|
||||
typedef struct ddsi_reader * (*deliver_locally_first_reader_t) (struct ddsi_entity_index *entity_index, struct ddsi_entity_common *source_entity, ddsrt_avl_iter_t *it);
|
||||
typedef struct ddsi_reader * (*deliver_locally_next_reader_t) (struct ddsi_entity_index *entity_index, ddsrt_avl_iter_t *it);
|
||||
|
||||
/** return:
|
||||
- DDS_RETCODE_OK to try again immediately
|
||||
- DDS_RETCODE_TRY_AGAIN to complete restart the operation later
|
||||
- anything else: error to be returned from deliver_locally_xxx */
|
||||
typedef dds_return_t (*deliver_locally_on_failure_fastpath_t) (struct ddsi_entity_common *source_entity, bool source_entity_locked, struct ddsi_local_reader_ary *fastpath_rdary, void *vsourceinfo);
|
||||
|
||||
struct ddsi_deliver_locally_ops {
|
||||
deliver_locally_makesample_t makesample;
|
||||
deliver_locally_first_reader_t first_reader;
|
||||
deliver_locally_next_reader_t next_reader;
|
||||
deliver_locally_on_failure_fastpath_t on_failure_fastpath;
|
||||
};
|
||||
|
||||
/** @component local_delivery */
|
||||
dds_return_t ddsi_deliver_locally_allinsync (struct ddsi_domaingv *gv, struct ddsi_entity_common *source_entity, bool source_entity_locked, struct ddsi_local_reader_ary *fastpath_rdary, const struct ddsi_writer_info *wrinfo, const struct ddsi_deliver_locally_ops *ops, void *vsourceinfo);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_DELIVER_LOCALLY_H */
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_DOMAINGV_H
|
||||
#define DDSI_DOMAINGV_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsrt/random.h"
|
||||
|
||||
#include "dds/ddsi/ddsi_plist.h"
|
||||
#include "dds/ddsi/ddsi_nwinterfaces.h"
|
||||
#include "dds/ddsi/ddsi_protocol.h"
|
||||
#include "dds/ddsi/ddsi_sockwaitset.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_xmsgpool;
|
||||
struct ddsi_dqueue;
|
||||
struct ddsi_reorder;
|
||||
struct ddsi_defrag;
|
||||
struct ddsi_addrset;
|
||||
struct ddsi_xeventq;
|
||||
struct ddsi_gcreq_queue;
|
||||
struct ddsi_entity_index;
|
||||
struct ddsi_lease;
|
||||
struct ddsi_tran_conn;
|
||||
struct ddsi_tran_listener;
|
||||
struct ddsi_tran_factory;
|
||||
struct ddsi_debug_monitor;
|
||||
struct ddsi_tkmap;
|
||||
struct dds_security_context;
|
||||
struct dds_security_match_index;
|
||||
struct ddsi_hsadmin;
|
||||
struct spdp_admin;
|
||||
|
||||
struct ddsi_config_in_addr_node {
|
||||
ddsi_locator_t loc;
|
||||
struct ddsi_config_in_addr_node *next;
|
||||
};
|
||||
|
||||
enum ddsi_recvips_mode {
|
||||
DDSI_RECVIPS_MODE_ALL, /* all MC capable interfaces */
|
||||
DDSI_RECVIPS_MODE_ANY, /* kernel-default interface */
|
||||
DDSI_RECVIPS_MODE_PREFERRED, /* selected interface only */
|
||||
DDSI_RECVIPS_MODE_NONE, /* no interfaces at all */
|
||||
DDSI_RECVIPS_MODE_SOME /* explicit list of interfaces; only one requiring recvips */
|
||||
};
|
||||
|
||||
enum ddsi_recv_thread_mode {
|
||||
DDSI_RTM_SINGLE,
|
||||
DDSI_RTM_MANY
|
||||
};
|
||||
|
||||
struct ddsi_recv_thread_arg {
|
||||
enum ddsi_recv_thread_mode mode;
|
||||
struct ddsi_rbufpool *rbpool;
|
||||
struct ddsi_domaingv *gv;
|
||||
union {
|
||||
struct {
|
||||
const ddsi_locator_t *loc;
|
||||
struct ddsi_tran_conn *conn;
|
||||
} single;
|
||||
struct {
|
||||
struct ddsi_sock_waitset *ws;
|
||||
} many;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct ddsi_deleted_participants_admin;
|
||||
|
||||
struct ddsi_domaingv {
|
||||
volatile int terminate;
|
||||
volatile int deaf;
|
||||
volatile int mute;
|
||||
|
||||
struct ddsrt_log_cfg logconfig;
|
||||
struct ddsi_config config;
|
||||
|
||||
struct ddsi_tkmap * m_tkmap;
|
||||
|
||||
/* Hash tables for participants, readers, writers, proxy
|
||||
participants, proxy readers and proxy writers by GUID. */
|
||||
struct ddsi_entity_index *entity_index;
|
||||
|
||||
/* Timed events admin */
|
||||
struct ddsi_xeventq *xevents;
|
||||
|
||||
/* Queue for garbage collection requests */
|
||||
struct ddsi_gcreq_queue *gcreq_queue;
|
||||
|
||||
/* Lease junk */
|
||||
ddsrt_mutex_t leaseheap_lock;
|
||||
ddsrt_fibheap_t leaseheap;
|
||||
|
||||
/* Transport factories & selected factory */
|
||||
struct ddsi_tran_factory *ddsi_tran_factories;
|
||||
struct ddsi_tran_factory *m_factory;
|
||||
|
||||
/* Connections for multicast discovery & data, and those that correspond
|
||||
to the one DDSI participant index that the DDSI service uses. The
|
||||
DCPS participant of DDSI itself will be mirrored in a DDSI
|
||||
participant, and in multi-socket mode that one gets its own
|
||||
socket. */
|
||||
struct ddsi_tran_conn * disc_conn_mc;
|
||||
struct ddsi_tran_conn * data_conn_mc;
|
||||
struct ddsi_tran_conn * disc_conn_uc;
|
||||
struct ddsi_tran_conn * data_conn_uc;
|
||||
|
||||
/* Connection used for all output (for connectionless transports), this
|
||||
used to simply be data_conn_uc, but:
|
||||
|
||||
- Windows has a quirk that makes multicast delivery within a machine
|
||||
utterly unreliable if the transmitting socket is bound to 0.0.0.0
|
||||
(despite all sockets having multicast interfaces set correctly),
|
||||
but apparently only in the presence of sockets transmitting to the
|
||||
same multicast group that have been bound to non-0.0.0.0 ...
|
||||
- At least Fast-RTPS and Connext fail to honour the set of advertised
|
||||
addresses and substitute 127.0.0.1 for the advertised IP address and
|
||||
expect it to work.
|
||||
- Fast-RTPS (at least) binds the socket it uses for transmitting
|
||||
multicasts to non-0.0.0.0
|
||||
|
||||
So binding to 0.0.0.0 means the unicasts from Fast-RTPS & Connext will
|
||||
arrive but the multicasts from Cyclone get dropped often on Windows
|
||||
when trying to interoperate; and binding to the IP address means
|
||||
unicast messages from the others fail to arrive (because they fail to
|
||||
arrive).
|
||||
|
||||
The only work around is to use a separate socket for sending. It is
|
||||
rather sad that Cyclone needs to work around the bugs of the others,
|
||||
but it seems the only way to get the users what they expect. */
|
||||
#define MAX_XMIT_CONNS 4
|
||||
struct ddsi_tran_conn * xmit_conns[MAX_XMIT_CONNS];
|
||||
ddsi_xlocator_t intf_xlocators[MAX_XMIT_CONNS];
|
||||
|
||||
/* TCP listener */
|
||||
struct ddsi_tran_listener * listener;
|
||||
|
||||
/* In many sockets mode, the receive threads maintain a local array
|
||||
with participant GUIDs and sockets, participant_set_generation is
|
||||
used to notify them. */
|
||||
ddsrt_atomic_uint32_t participant_set_generation;
|
||||
|
||||
/* nparticipants is used primarily for limiting the number of active
|
||||
participants, but also during shutdown to determine when it is
|
||||
safe to stop the GC thread. */
|
||||
ddsrt_mutex_t participant_set_lock;
|
||||
ddsrt_cond_t participant_set_cond;
|
||||
uint32_t nparticipants;
|
||||
|
||||
/* For participants without (some) built-in writers, we fall back to
|
||||
this participant, which is the first one created with all
|
||||
built-in writers present. It MUST be created before any in need
|
||||
of it pops up! */
|
||||
struct ddsi_participant *privileged_pp;
|
||||
ddsrt_mutex_t privileged_pp_lock;
|
||||
|
||||
/* For tracking (recently) deleted participants */
|
||||
struct ddsi_deleted_participants_admin *deleted_participants;
|
||||
|
||||
/* GUID to be used in next call to new_participant; also protected
|
||||
by privileged_pp_lock */
|
||||
struct ddsi_guid ppguid_base;
|
||||
|
||||
/* number of selected interfaces. */
|
||||
int n_interfaces;
|
||||
struct ddsi_network_interface interfaces[MAX_XMIT_CONNS];
|
||||
/* whether we're using a link-local address (and therefore
|
||||
only listening to multicasts on that interface) */
|
||||
int using_link_local_intf;
|
||||
|
||||
/* Addressing: actual own (preferred) IP address, IP address
|
||||
advertised in discovery messages (so that an external IP address on
|
||||
a NAT may be advertised), and the DDSI multi-cast address. */
|
||||
enum ddsi_recvips_mode recvips_mode;
|
||||
struct ddsi_config_in_addr_node *recvips;
|
||||
ddsi_locator_t extmask;
|
||||
|
||||
/* Locators */
|
||||
ddsi_locator_t loc_spdp_mc;
|
||||
ddsi_locator_t loc_meta_mc;
|
||||
ddsi_locator_t loc_meta_uc;
|
||||
ddsi_locator_t loc_default_mc;
|
||||
ddsi_locator_t loc_default_uc;
|
||||
|
||||
/*
|
||||
Initial discovery address set, and the current discovery address
|
||||
set. These are the addresses that SPDP pings get sent to.
|
||||
*/
|
||||
struct spdp_admin *spdp_schedule;
|
||||
|
||||
ddsrt_mutex_t lock;
|
||||
|
||||
/* Receive thread. (We can only has one for now, cos of the signal
|
||||
trigger socket.) Receive buffer pool is per receive thread,
|
||||
it is only a global variable because it needs to be freed way later
|
||||
than the receive thread itself terminates */
|
||||
#define MAX_RECV_THREADS 3
|
||||
uint32_t n_recv_threads;
|
||||
struct recv_thread {
|
||||
const char *name;
|
||||
struct ddsi_thread_state *thrst;
|
||||
struct ddsi_recv_thread_arg arg;
|
||||
} recv_threads[MAX_RECV_THREADS];
|
||||
|
||||
/* Listener thread for connection based transports */
|
||||
struct ddsi_thread_state *listen_ts;
|
||||
|
||||
/* Flag cleared when stopping (receive threads). FIXME. */
|
||||
ddsrt_atomic_uint32_t rtps_keepgoing;
|
||||
|
||||
/* Start time of the DDSI service, for logging relative time stamps,
|
||||
should I ever so desire. */
|
||||
ddsrt_wctime_t tstart;
|
||||
|
||||
/* Default QoSs for participant, readers and writers (needed for
|
||||
eliminating default values in outgoing discovery packets, and for
|
||||
supplying values for missing QoS settings in incoming discovery
|
||||
packets); plus the actual QoSs needed for the builtin
|
||||
endpoints. */
|
||||
dds_qos_t default_local_xqos_pp;
|
||||
dds_qos_t spdp_endpoint_xqos;
|
||||
dds_qos_t builtin_endpoint_xqos_rd;
|
||||
dds_qos_t builtin_endpoint_xqos_wr;
|
||||
#ifdef DDS_HAS_TYPE_DISCOVERY
|
||||
dds_qos_t builtin_volatile_xqos_rd;
|
||||
dds_qos_t builtin_volatile_xqos_wr;
|
||||
#endif
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
dds_qos_t builtin_secure_volatile_xqos_rd;
|
||||
dds_qos_t builtin_secure_volatile_xqos_wr;
|
||||
dds_qos_t builtin_stateless_xqos_rd;
|
||||
dds_qos_t builtin_stateless_xqos_wr;
|
||||
#endif
|
||||
|
||||
/* SPDP packets get very special treatment (they're the only packets
|
||||
we accept from writers we don't know) and have their very own
|
||||
do-nothing defragmentation and reordering thingummies, as well as a
|
||||
global mutex to in lieu of the proxy writer lock. */
|
||||
ddsrt_mutex_t spdp_lock;
|
||||
struct ddsi_defrag *spdp_defrag;
|
||||
struct ddsi_reorder *spdp_reorder;
|
||||
|
||||
/* Built-in stuff other than SPDP gets funneled through the builtins
|
||||
delivery queue; currently just SEDP and PMD */
|
||||
struct ddsi_dqueue *builtins_dqueue;
|
||||
|
||||
struct ddsi_debug_monitor *debmon;
|
||||
|
||||
uint32_t networkQueueId;
|
||||
struct ddsi_thread_state *channel_reader_thrst;
|
||||
|
||||
/* Application data gets its own delivery queue */
|
||||
struct ddsi_dqueue *user_dqueue;
|
||||
|
||||
/* Transmit side: pool for transmit queue*/
|
||||
struct ddsi_xmsgpool *xmsgpool;
|
||||
struct ddsi_sertype *spdp_type; /* key = participant GUID */
|
||||
struct ddsi_sertype *sedp_reader_type; /* key = endpoint GUID */
|
||||
struct ddsi_sertype *sedp_writer_type; /* key = endpoint GUID */
|
||||
struct ddsi_sertype *sedp_topic_type; /* key = topic GUID */
|
||||
struct ddsi_sertype *pmd_type; /* participant message data */
|
||||
#ifdef DDS_HAS_TYPE_DISCOVERY
|
||||
struct ddsi_sertype *tl_svc_request_type; /* TypeLookup service request, no key */
|
||||
struct ddsi_sertype *tl_svc_reply_type; /* TypeLookup service reply, no key */
|
||||
#endif
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_sertype *spdp_secure_type; /* key = participant GUID */
|
||||
struct ddsi_sertype *sedp_reader_secure_type; /* key = endpoint GUID */
|
||||
struct ddsi_sertype *sedp_writer_secure_type; /* key = endpoint GUID */
|
||||
struct ddsi_sertype *pmd_secure_type; /* participant message data */
|
||||
struct ddsi_sertype *pgm_stateless_type; /* participant generic message */
|
||||
struct ddsi_sertype *pgm_volatile_type; /* participant generic message */
|
||||
#endif
|
||||
|
||||
ddsrt_mutex_t sendq_lock;
|
||||
ddsrt_cond_t sendq_cond;
|
||||
unsigned sendq_length;
|
||||
struct ddsi_xpack *sendq_head;
|
||||
struct ddsi_xpack *sendq_tail;
|
||||
int sendq_stop;
|
||||
struct ddsi_thread_state *sendq_ts;
|
||||
bool sendq_running;
|
||||
ddsrt_mutex_t sendq_running_lock;
|
||||
|
||||
/* File for dumping captured packets, NULL if disabled */
|
||||
FILE *pcap_fp;
|
||||
ddsrt_mutex_t pcap_lock;
|
||||
|
||||
struct ddsi_builtin_topic_interface *builtin_topic_interface;
|
||||
|
||||
struct ddsi_mcgroup_membership *mship;
|
||||
|
||||
ddsrt_mutex_t sertypes_lock;
|
||||
struct ddsrt_hh *sertypes;
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
ddsrt_mutex_t typelib_lock;
|
||||
ddsrt_avl_tree_t typelib;
|
||||
ddsrt_avl_tree_t typedeps;
|
||||
ddsrt_avl_tree_t typedeps_reverse;
|
||||
ddsrt_cond_t typelib_resolved_cond;
|
||||
#endif
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
ddsrt_mutex_t topic_defs_lock;
|
||||
struct ddsrt_hh *topic_defs;
|
||||
#endif
|
||||
|
||||
ddsrt_mutex_t new_topic_lock;
|
||||
ddsrt_cond_t new_topic_cond;
|
||||
uint32_t new_topic_version;
|
||||
|
||||
/* security globals */
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct dds_security_context *security_context;
|
||||
struct ddsi_hsadmin *hsadmin;
|
||||
bool handshake_include_optional;
|
||||
#endif
|
||||
|
||||
/* naming */
|
||||
ddsrt_mutex_t naming_lock;
|
||||
ddsrt_prng_t naming_rng;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_DOMAINGV_H */
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
// Copyright(c) 2023 ZettaScale Technology 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 DDSI_DYNAMIC_TYPE_H
|
||||
#define DDSI_DYNAMIC_TYPE_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_typewrap.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
struct ddsi_dynamic_type_struct_member_param {
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
uint32_t index;
|
||||
bool is_key;
|
||||
};
|
||||
|
||||
struct ddsi_dynamic_type_union_member_param {
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
uint32_t index;
|
||||
bool is_default;
|
||||
uint32_t n_labels;
|
||||
int32_t *labels;
|
||||
};
|
||||
|
||||
struct ddsi_dynamic_type_enum_literal_param {
|
||||
const char *name;
|
||||
bool is_auto_value;
|
||||
int32_t value;
|
||||
bool is_default;
|
||||
};
|
||||
|
||||
struct ddsi_dynamic_type_bitmask_field_param {
|
||||
const char *name;
|
||||
bool is_auto_position;
|
||||
uint16_t position;
|
||||
};
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_struct (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name, struct ddsi_type **base_type);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_union (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name, struct ddsi_type **discriminant_type);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_sequence (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name, struct ddsi_type **element_type, uint32_t bound);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_array (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name, struct ddsi_type **element_type, uint32_t num_bounds, const uint32_t *bounds);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_enum (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_bitmask (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_alias (struct ddsi_domaingv *gv, struct ddsi_type **type, const char *type_name, struct ddsi_type **aliased_type);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_string8 (struct ddsi_domaingv *gv, struct ddsi_type **type, uint32_t bound);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_string16 (struct ddsi_domaingv *gv, struct ddsi_type **type, uint32_t bound);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_create_primitive (struct ddsi_domaingv *gv, struct ddsi_type **type, dds_dynamic_type_kind_t kind);
|
||||
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_set_extensibility (struct ddsi_type *type, enum dds_dynamic_type_extensibility extensibility);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_set_bitbound (struct ddsi_type *type, uint16_t bit_bound);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_set_nested (struct ddsi_type *type, bool is_nested);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_set_autoid (struct ddsi_type *type, enum dds_dynamic_type_autoid value);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_add_struct_member (struct ddsi_type *type, struct ddsi_type **member_type, struct ddsi_dynamic_type_struct_member_param params);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_add_union_member (struct ddsi_type *type, struct ddsi_type **member_type, struct ddsi_dynamic_type_union_member_param params);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_add_enum_literal (struct ddsi_type *type, struct ddsi_dynamic_type_enum_literal_param params);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_add_bitmask_field (struct ddsi_type *type, struct ddsi_dynamic_type_bitmask_field_param params);
|
||||
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_member_set_key (struct ddsi_type *type, uint32_t member_id, bool is_key);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_member_set_optional (struct ddsi_type *type, uint32_t member_id, bool is_optional);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_struct_member_set_external (struct ddsi_type *type, uint32_t member_id, bool is_external);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_union_member_set_external (struct ddsi_type *type, uint32_t member_id, bool is_external);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_member_set_must_understand (struct ddsi_type *type, uint32_t member_id, bool is_must_understand);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_member_set_hashid (struct ddsi_type *type, uint32_t member_id, const char *hash_member_name);
|
||||
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
dds_return_t ddsi_dynamic_type_register (struct ddsi_type **type_c, struct ddsi_type **type_m, ddsi_typeinfo_t **type_info);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
struct ddsi_type * ddsi_dynamic_type_dup (const struct ddsi_type *src);
|
||||
|
||||
/** @component dynamic_type_support */
|
||||
bool ddsi_dynamic_type_is_constructing (const struct ddsi_type *type);
|
||||
|
||||
#endif /* DDS_HAS_TYPELIB */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_DYNAMIC_TYPE_H */
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_ENDPOINT_H
|
||||
#define DDSI_ENDPOINT_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsi/ddsi_entity.h"
|
||||
#include "dds/ddsi/ddsi_hbcontrol.h"
|
||||
#include "dds/dds.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_participant;
|
||||
struct ddsi_type_pair;
|
||||
struct ddsi_writer_info;
|
||||
struct ddsi_entity_common;
|
||||
struct ddsi_endpoint_common;
|
||||
struct ddsi_ldur_fhnode;
|
||||
struct ddsi_entity_index;
|
||||
struct dds_qos;
|
||||
|
||||
/* Liveliness changed is more complicated than just add/remove. Encode the event
|
||||
in ddsi_status_cb_data_t::extra and ignore ddsi_status_cb_data_t::add */
|
||||
enum ddsi_liveliness_changed_data_extra {
|
||||
DDSI_LIVELINESS_CHANGED_ADD_ALIVE,
|
||||
DDSI_LIVELINESS_CHANGED_ADD_NOT_ALIVE,
|
||||
DDSI_LIVELINESS_CHANGED_REMOVE_NOT_ALIVE,
|
||||
DDSI_LIVELINESS_CHANGED_REMOVE_ALIVE,
|
||||
DDSI_LIVELINESS_CHANGED_ALIVE_TO_NOT_ALIVE,
|
||||
DDSI_LIVELINESS_CHANGED_NOT_ALIVE_TO_ALIVE
|
||||
};
|
||||
|
||||
struct ddsi_psmx_locators_set {
|
||||
uint32_t length;
|
||||
struct ddsi_locator *locators;
|
||||
};
|
||||
|
||||
struct ddsi_endpoint_common {
|
||||
struct ddsi_participant *pp;
|
||||
ddsi_guid_t group_guid;
|
||||
struct ddsi_psmx_locators_set psmx_locators;
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
struct ddsi_type_pair *type_pair;
|
||||
#endif
|
||||
};
|
||||
|
||||
enum ddsi_writer_state {
|
||||
WRST_OPERATIONAL, /* normal situation */
|
||||
WRST_INTERRUPT, /* will be deleted, unblock throttle_writer but do not do anything further */
|
||||
WRST_LINGERING, /* writer deletion has been requested but still has unack'd data */
|
||||
WRST_DELETING /* writer is actually being deleted (removed from hash table) */
|
||||
};
|
||||
|
||||
typedef ddsrt_atomic_uint64_t seq_xmit_t;
|
||||
|
||||
struct ddsi_writer
|
||||
{
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_endpoint_common c;
|
||||
ddsi_status_cb_t status_cb;
|
||||
void * status_cb_entity;
|
||||
ddsrt_cond_t throttle_cond; /* used to trigger a transmit thread blocked in throttle_writer() or wait_for_acks() */
|
||||
ddsi_seqno_t seq; /* last sequence number (transmitted seqs are 1 ... seq, 0 when nothing published yet) */
|
||||
seq_xmit_t seq_xmit; /* last sequence number actually transmitted */
|
||||
ddsi_seqno_t min_local_readers_reject_seq; /* mimum of local_readers->last_deliv_seq */
|
||||
ddsi_count_t hbcount; /* last hb seq number */
|
||||
ddsi_count_t hbfragcount; /* last hb frag seq number */
|
||||
int throttling; /* non-zero when some thread is waiting for the WHC to shrink */
|
||||
struct ddsi_hbcontrol hbcontrol; /* controls heartbeat timing, piggybacking */
|
||||
struct dds_qos *xqos;
|
||||
enum ddsi_writer_state state;
|
||||
unsigned reliable: 1; /* iff 1, writer is reliable <=> heartbeat_xevent != NULL */
|
||||
unsigned handle_as_transient_local: 1; /* controls whether data is retained in WHC */
|
||||
unsigned force_md5_keyhash: 1; /* iff 1, when keyhash has to be hashed, no matter the size */
|
||||
unsigned retransmitting: 1; /* iff 1, this writer is currently retransmitting */
|
||||
unsigned alive: 1; /* iff 1, the writer is alive (lease for this writer is not expired); field may be modified only when holding both wr->e.lock and wr->c.pp->e.lock */
|
||||
unsigned test_ignore_acknack : 1; /* iff 1, the writer ignores all arriving ACKNACK messages */
|
||||
unsigned test_suppress_retransmit : 1; /* iff 1, the writer does not respond to retransmit requests */
|
||||
unsigned test_suppress_heartbeat : 1; /* iff 1, the writer suppresses all periodic heartbeats */
|
||||
unsigned test_suppress_flush_on_sync_heartbeat : 1; /* iff 1, the writer never flushes because of a piggy-backed heartbeat */
|
||||
unsigned test_drop_outgoing_data : 1; /* iff 1, the writer drops outgoing data, forcing the readers to request a retransmit */
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
unsigned supports_ssm: 1;
|
||||
struct ddsi_addrset *ssm_as;
|
||||
#endif
|
||||
uint32_t alive_vclock; /* virtual clock counting transitions between alive/not-alive */
|
||||
const struct ddsi_sertype * type; /* type of the data written by this writer */
|
||||
struct ddsi_addrset *as; /* set of addresses to publish to */
|
||||
struct ddsi_xevent *heartbeat_xevent; /* timed event for "periodically" publishing heartbeats when unack'd data present, NULL <=> unreliable */
|
||||
struct ddsi_ldur_fhnode *lease_duration; /* fibheap node to keep lease duration for this writer, NULL in case of automatic liveliness with inifite duration */
|
||||
struct ddsi_whc *whc; /* WHC tracking history, T-L durability service history + samples by sequence number for retransmit */
|
||||
uint32_t whc_low, whc_high; /* watermarks for WHC in bytes (counting only unack'd data) */
|
||||
ddsrt_etime_t t_rexmit_start;
|
||||
ddsrt_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
|
||||
ddsrt_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
|
||||
uint32_t init_burst_size_limit; /* derived from reader's receive_buffer_size */
|
||||
uint32_t rexmit_burst_size_limit; /* derived from reader's receive_buffer_size */
|
||||
uint32_t num_readers; /* total number of matching PROXY readers */
|
||||
uint32_t num_reliable_readers; /* number of matching reliable PROXY readers */
|
||||
uint32_t num_readers_requesting_keyhash; /* also +1 for protected keys and config override for generating keyhash */
|
||||
ddsrt_avl_tree_t readers; /* all matching PROXY readers, see struct ddsi_wr_prd_match */
|
||||
ddsrt_avl_tree_t local_readers; /* all matching LOCAL readers, see struct ddsi_wr_rd_match */
|
||||
#ifdef DDS_HAS_NETWORK_PARTITIONS
|
||||
const struct ddsi_config_networkpartition_listelem *network_partition;
|
||||
#endif
|
||||
uint32_t num_acks_received; /* cum received ACKNACKs with no request for retransmission */
|
||||
uint32_t num_nacks_received; /* cum received ACKNACKs that did request retransmission */
|
||||
uint32_t throttle_count; /* cum times transmitting was throttled (whc hitting high-level mark) */
|
||||
uint32_t throttle_tracing;
|
||||
uint32_t rexmit_count; /* cum samples retransmitted (counting events; 1 sample can be counted many times) */
|
||||
uint32_t rexmit_lost_count; /* cum samples lost but retransmit requested (also counting events) */
|
||||
uint64_t rexmit_bytes; /* cum bytes queued for retransmit */
|
||||
uint64_t time_throttled; /* cum time in throttled state */
|
||||
uint64_t time_retransmit; /* cum time in retransmitting state */
|
||||
struct ddsi_xeventq *evq; /* timed event queue to be used by this writer */
|
||||
struct ddsi_local_reader_ary rdary; /* LOCAL readers for fast-pathing; if not fast-pathed, fall back to scanning local_readers */
|
||||
struct ddsi_lease *lease; /* for liveliness administration (writer can only become inactive when using manual liveliness) */
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_writer_sec_attributes *sec_attr;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ddsi_local_orphan_writer {
|
||||
struct ddsi_writer wr;
|
||||
};
|
||||
|
||||
struct ddsi_reader
|
||||
{
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_endpoint_common c;
|
||||
ddsi_status_cb_t status_cb;
|
||||
void * status_cb_entity;
|
||||
struct ddsi_rhc * rhc; /* reader history, tracks registrations and data */
|
||||
struct dds_qos *xqos;
|
||||
unsigned reliable: 1; /* 1 iff reader is reliable */
|
||||
unsigned handle_as_transient_local: 1; /* 1 iff reader wants historical data from proxy writers */
|
||||
unsigned request_keyhash: 1; /* really controlled by the sertype */
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
unsigned favours_ssm: 1; /* iff 1, this reader favours SSM */
|
||||
#endif
|
||||
ddsi_count_t init_acknack_count; /* initial value for "count" (i.e. ACK seq num) for newly matched proxy writers */
|
||||
#ifdef DDS_HAS_NETWORK_PARTITIONS
|
||||
struct ddsi_networkpartition_address *uc_as;
|
||||
struct ddsi_networkpartition_address *mc_as;
|
||||
#endif
|
||||
const struct ddsi_sertype * type; /* type of the data read by this reader */
|
||||
uint32_t num_writers; /* total number of matching PROXY writers */
|
||||
ddsrt_avl_tree_t writers; /* all matching PROXY writers, see struct ddsi_rd_pwr_match */
|
||||
ddsrt_avl_tree_t local_writers; /* all matching LOCAL writers, see struct ddsi_rd_wr_match */
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_reader_sec_attributes *sec_attr;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ddsi_generic_endpoint
|
||||
{
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_endpoint_common c;
|
||||
};
|
||||
|
||||
DDS_EXPORT extern const ddsrt_avl_treedef_t ddsi_wr_readers_treedef;
|
||||
DDS_EXPORT extern const ddsrt_avl_treedef_t ddsi_wr_local_readers_treedef;
|
||||
DDS_EXPORT extern const ddsrt_avl_treedef_t ddsi_rd_writers_treedef;
|
||||
DDS_EXPORT extern const ddsrt_avl_treedef_t ddsi_rd_local_writers_treedef;
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
int ddsi_is_builtin_endpoint (ddsi_entityid_t id, ddsi_vendorid_t vendorid);
|
||||
|
||||
struct dds_ktopic;
|
||||
|
||||
// writer
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
struct ddsi_local_orphan_writer *ddsi_new_local_orphan_writer (struct ddsi_domaingv *gv, ddsi_entityid_t entityid, const char *topic_name, struct ddsi_sertype *type, const struct dds_qos *xqos, struct ddsi_whc *whc);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
void ddsi_delete_local_orphan_writer (struct ddsi_local_orphan_writer *wr);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_generate_writer_guid (struct ddsi_guid *wrguid, struct ddsi_participant *participant, const struct ddsi_sertype *sertype);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_new_writer (struct ddsi_writer **wr_out, const struct ddsi_guid *guid, const struct ddsi_guid *group_guid, struct ddsi_participant *pp, const char *topic_name, const struct ddsi_sertype *type, const struct dds_qos *xqos, struct ddsi_whc *whc, ddsi_status_cb_t status_cb, void *status_entity, struct ddsi_psmx_locators_set *psmx_locators);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
void ddsi_update_writer_qos (struct ddsi_writer *wr, const struct dds_qos *xqos);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
void ddsi_make_writer_info (struct ddsi_writer_info *wrinfo, const struct ddsi_entity_common *e, const struct dds_qos *xqos, uint32_t statusinfo);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
void ddsi_make_writer_info_params (struct ddsi_writer_info *wrinfo, const ddsi_guid_t *wr_guid, int32_t ownership_strength, bool autodispose_unregistered_instances, uint64_t iid, uint32_t statusinfo, dds_duration_t lifespan_duration);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_writer_wait_for_acks (struct ddsi_writer *wr, const ddsi_guid_t *rdguid, dds_time_t abstimeout);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_unblock_throttled_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_delete_writer (struct ddsi_domaingv *gv, const struct ddsi_guid *guid);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
struct ddsi_reader *ddsi_writer_first_in_sync_reader (struct ddsi_entity_index *entity_index, struct ddsi_entity_common *wrcmn, ddsrt_avl_iter_t *it);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
struct ddsi_reader *ddsi_writer_next_in_sync_reader (struct ddsi_entity_index *entity_index, ddsrt_avl_iter_t *it);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_generate_reader_guid (struct ddsi_guid *rdguid, struct ddsi_participant *participant, const struct ddsi_sertype *sertype);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_new_reader (struct ddsi_reader **rd_out, const struct ddsi_guid *guid, const struct ddsi_guid *group_guid, struct ddsi_participant *pp, const char *topic_name, const struct ddsi_sertype *type, const struct dds_qos *xqos, struct ddsi_rhc *rhc, ddsi_status_cb_t status_cb, void * status_entity, struct ddsi_psmx_locators_set *psmx_locators);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
void ddsi_update_reader_qos (struct ddsi_reader *rd, const struct dds_qos *xqos);
|
||||
|
||||
/** @component ddsi_endpoint */
|
||||
dds_return_t ddsi_delete_reader (struct ddsi_domaingv *gv, const struct ddsi_guid *guid);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_ENDPOINT_H */
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_ENDPOINT_MATCH_H
|
||||
#define DDSI_ENDPOINT_MATCH_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_lat_estim.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_writer;
|
||||
struct ddsi_reader;
|
||||
struct ddsi_entity_common;
|
||||
struct dds_qos;
|
||||
|
||||
/** @component endpoint_matching */
|
||||
dds_return_t ddsi_writer_get_matched_subscriptions (struct ddsi_writer *wr, uint64_t *rds, size_t nrds);
|
||||
|
||||
/** @component endpoint_matching */
|
||||
dds_return_t ddsi_reader_get_matched_publications (struct ddsi_reader *rd, uint64_t *wrs, size_t nwrs);
|
||||
|
||||
/** @brief Lookup the instance handle of a matching reader and return it, it's qos and participant
|
||||
* @component endpoint_matching
|
||||
*
|
||||
* @note Thread state must be "awake", returned pointers are aliases; lifetime ends on leaving the "awake" state; contents may not be modified.
|
||||
*
|
||||
* @param[in] wr writer for which to lookup ih in the setting of matching readers
|
||||
* @param[in] ih instance handle of a reader
|
||||
* @param[out] rdc pointer to the common entity data of the reader
|
||||
* @param[out] rdqos pointer to the QoS of the reader
|
||||
* @param[out] ppc participant, may be null for an orphan reader
|
||||
* @return true iff ih corresponds to a matched reader, output parameters are undefined if not
|
||||
*/
|
||||
bool ddsi_writer_find_matched_reader (struct ddsi_writer *wr, uint64_t ih, const struct ddsi_entity_common **rdc, const struct dds_qos **rdqos, const struct ddsi_entity_common **ppc);
|
||||
|
||||
/** @brief Lookup the instance handle of a matching writer and return it, it's qos and participant
|
||||
* @component endpoint_matching
|
||||
*
|
||||
* @note Thread state must be "awake", returned pointers are aliases; lifetime ends on leaving the "awake" state; contents may not be modified.
|
||||
*
|
||||
* @param[in] rd reader for which to lookup ih in the setting of matching writers
|
||||
* @param[in] ih instance handle of a writer
|
||||
* @param[out] wrc pointer to the common entity data of the writer
|
||||
* @param[out] wrqos pointer to the QoS of the writer
|
||||
* @param[out] ppc participant, may be null for an orphan writer
|
||||
* @return true iff ih corresponds to a matched writer, output parameters are undefined if not
|
||||
*/
|
||||
bool ddsi_reader_find_matched_writer (struct ddsi_reader *rd, uint64_t ih, const struct ddsi_entity_common **wrc, const struct dds_qos **wrqos, const struct ddsi_entity_common **ppc);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_ENDPOINT_MATCH_H */
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_ENTITY_H
|
||||
#define DDSI_ENTITY_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsi/ddsi_protocol.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_rsample_info;
|
||||
struct ddsi_rdata;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_local_reader_ary;
|
||||
|
||||
enum ddsi_entity_kind {
|
||||
DDSI_EK_PARTICIPANT,
|
||||
DDSI_EK_PROXY_PARTICIPANT,
|
||||
DDSI_EK_TOPIC,
|
||||
DDSI_EK_WRITER,
|
||||
DDSI_EK_PROXY_WRITER,
|
||||
DDSI_EK_READER,
|
||||
DDSI_EK_PROXY_READER
|
||||
};
|
||||
|
||||
typedef struct ddsi_status_cb_data
|
||||
{
|
||||
int raw_status_id;
|
||||
uint32_t extra;
|
||||
uint64_t handle;
|
||||
bool add;
|
||||
} ddsi_status_cb_data_t;
|
||||
|
||||
typedef void (*ddsi_status_cb_t) (void *entity, const ddsi_status_cb_data_t *data);
|
||||
|
||||
typedef struct ddsi_type_pair
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
{
|
||||
struct ddsi_type *minimal;
|
||||
struct ddsi_type *complete;
|
||||
}
|
||||
#endif
|
||||
ddsi_type_pair_t;
|
||||
|
||||
struct ddsi_entity_common {
|
||||
enum ddsi_entity_kind kind;
|
||||
ddsi_guid_t guid;
|
||||
ddsrt_wctime_t tupdate; /* timestamp of last update */
|
||||
uint64_t iid;
|
||||
struct ddsi_tkmap_instance *tk;
|
||||
ddsrt_mutex_t lock;
|
||||
bool onlylocal;
|
||||
struct ddsi_domaingv *gv;
|
||||
ddsrt_avl_node_t all_entities_avlnode;
|
||||
|
||||
/* QoS changes always lock the entity itself, and additionally
|
||||
(and within the scope of the entity lock) acquire qos_lock
|
||||
while manipulating the QoS. So any thread that needs to read
|
||||
the QoS without acquiring the entity's lock can still do so
|
||||
(e.g., the materialisation of samples for built-in topics
|
||||
when connecting a reader to a writer for a built-in topic).
|
||||
|
||||
qos_lock lock order across entities in is in increasing
|
||||
order of entity addresses cast to uintptr_t. */
|
||||
ddsrt_mutex_t qos_lock;
|
||||
};
|
||||
|
||||
struct ddsi_local_reader_ary {
|
||||
ddsrt_mutex_t rdary_lock; /* mutations only ever happen when (proxy) writer lock also held (excepting careful hacks in tests) */
|
||||
unsigned valid: 1; /* always true until (proxy-)writer is being deleted; !valid => !fastpath_ok */
|
||||
unsigned fastpath_ok: 1; /* if not ok, fall back to using GUIDs (gives access to the reader-writer match data for handling readers that bumped into resource limits, hence can flip-flop, unlike "valid") */
|
||||
uint32_t n_readers;
|
||||
struct ddsi_reader **rdary; /* for efficient delivery, null-pointer terminated, grouped by topic */
|
||||
};
|
||||
|
||||
/** @component ddsi_generic_entity */
|
||||
ddsi_entityid_t ddsi_to_entityid (unsigned u);
|
||||
|
||||
/** @component ddsi_generic_entity */
|
||||
ddsi_vendorid_t ddsi_get_entity_vendorid (const struct ddsi_entity_common *e);
|
||||
|
||||
/** @component ddsi_generic_entity */
|
||||
uint64_t ddsi_get_entity_instanceid (const struct ddsi_domaingv *gv, const struct ddsi_guid *guid);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_ENTITY_H */
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_ENTITY_INDEX_H
|
||||
#define DDSI_ENTITY_INDEX_H
|
||||
|
||||
#include "dds/ddsi/ddsi_thread.h"
|
||||
#include "dds/ddsi/ddsi_topic.h"
|
||||
#include "dds/ddsi/ddsi_entity.h"
|
||||
#include "dds/ddsi/ddsi_endpoint.h"
|
||||
#include "dds/ddsi/ddsi_proxy_endpoint.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_entity_index;
|
||||
struct ddsi_guid;
|
||||
struct ddsi_domaingv;
|
||||
|
||||
struct ddsi_entity_enum
|
||||
{
|
||||
struct ddsi_entity_index *entidx;
|
||||
enum ddsi_entity_kind kind;
|
||||
struct ddsi_entity_common *cur;
|
||||
#ifndef NDEBUG
|
||||
ddsi_vtime_t vtime;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Readers & writers are both in a GUID- and in a GID-keyed table. If
|
||||
they are in the GID-based one, they are also in the GUID-based one,
|
||||
but not the way around, for two reasons:
|
||||
|
||||
- firstly, there are readers & writers that do not have a GID
|
||||
(built-in endpoints, fictitious transient data readers),
|
||||
|
||||
- secondly, they are inserted first in the GUID-keyed one, and then
|
||||
in the GID-keyed one.
|
||||
|
||||
The GID is used solely for the interface with the OpenSplice
|
||||
kernel, all internal state and protocol handling is done using the
|
||||
GUID. So all this means is that, e.g., a writer being deleted
|
||||
becomes invisible to the network reader slightly before it
|
||||
disappears in the protocol handling, or that a writer might exist
|
||||
at the protocol level slightly before the network reader can use it
|
||||
to transmit data. */
|
||||
|
||||
|
||||
/** @component entity_index */
|
||||
void *ddsi_entidx_lookup_guid_untyped (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
void *ddsi_entidx_lookup_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid, enum ddsi_entity_kind kind) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
struct ddsi_participant *ddsi_entidx_lookup_participant_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
DDS_EXPORT struct ddsi_writer *ddsi_entidx_lookup_writer_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
struct ddsi_reader *ddsi_entidx_lookup_reader_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
struct ddsi_proxy_participant *ddsi_entidx_lookup_proxy_participant_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
struct ddsi_proxy_writer *ddsi_entidx_lookup_proxy_writer_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
struct ddsi_proxy_reader *ddsi_entidx_lookup_proxy_reader_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid) ddsrt_nonnull_all;
|
||||
|
||||
/* Enumeration of entries in the hash table:
|
||||
|
||||
- "next" visits at least all entries that were in the hash table at
|
||||
the time of calling init and that have not subsequently been
|
||||
removed;
|
||||
|
||||
- "next" may visit an entry more than once, but will do so only
|
||||
because of rare events (i.e., resize or so);
|
||||
|
||||
- the order in which entries are visited is arbitrary;
|
||||
|
||||
- the caller must call init() before it may call next(); it must
|
||||
call fini() before it may call init() again. */
|
||||
|
||||
/** @component entity_index */
|
||||
void ddsi_entidx_enum_init (struct ddsi_entity_enum *st, const struct ddsi_entity_index *ei, enum ddsi_entity_kind kind) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
void *ddsi_entidx_enum_next (struct ddsi_entity_enum *st) ddsrt_nonnull_all;
|
||||
|
||||
/** @component entity_index */
|
||||
void ddsi_entidx_enum_fini (struct ddsi_entity_enum *st) ddsrt_nonnull_all;
|
||||
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
/** @component entity_index */
|
||||
struct ddsi_topic *ddsi_entidx_lookup_topic_guid (const struct ddsi_entity_index *ei, const struct ddsi_guid *guid);
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_ENTITY_INDEX_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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
|
||||
|
||||
/* Feature macros:
|
||||
|
||||
- SSM: support for source-specific multicast
|
||||
requires: NETWORK_PARTIITONS
|
||||
also requires platform support; SSM is silently disabled if the
|
||||
platform doesn't support it
|
||||
|
||||
- IPV6: support for IPV6
|
||||
requires: platform support (which itself is not part of DDSI)
|
||||
|
||||
- NETWORK_PARTITIONS: support for multiple network partitions
|
||||
|
||||
*/
|
||||
#include "dds/features.h"
|
||||
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
#ifndef DDS_HAS_NETWORK_PARTITIONS
|
||||
#error "SSM requires NETWORK_PARTITIONS"
|
||||
#endif
|
||||
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#ifndef DDSRT_HAVE_SSM
|
||||
#error "DDSRT_HAVE_SSM should be defined"
|
||||
#elif ! DDSRT_HAVE_SSM
|
||||
#undef DDSRT_HAVE_SSM
|
||||
#endif
|
||||
#endif
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_FREELIST_H
|
||||
#define DDSI_FREELIST_H
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSI_FREELIST_NONE 1
|
||||
#define DDSI_FREELIST_ATOMIC_LIFO 2
|
||||
#define DDSI_FREELIST_DOUBLE 3
|
||||
|
||||
#define DDSI_FREELIST_TYPE DDSI_FREELIST_DOUBLE
|
||||
|
||||
#ifndef DDSI_FREELIST_TYPE
|
||||
#if DDSRT_HAVE_ATOMIC_LIFO
|
||||
#define DDSI_FREELIST_TYPE DDSI_FREELIST_ATOMIC_LIFO
|
||||
#else
|
||||
#define DDSI_FREELIST_TYPE DDSI_FREELIST_DOUBLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DDSI_FREELIST_TYPE == DDSI_FREELIST_NONE
|
||||
|
||||
struct ddsi_freelist {
|
||||
char dummy;
|
||||
};
|
||||
|
||||
#elif DDSI_FREELIST_TYPE == DDSI_FREELIST_ATOMIC_LIFO
|
||||
|
||||
struct ddsi_freelist {
|
||||
ddsrt_atomic_lifo_t x;
|
||||
ddsrt_atomic_uint32_t count;
|
||||
uint32_t max;
|
||||
size_t linkoff;
|
||||
};
|
||||
|
||||
#elif DDSI_FREELIST_TYPE == DDSI_FREELIST_DOUBLE
|
||||
|
||||
#define NN_FREELIST_NPAR 4
|
||||
#define NN_FREELIST_NPAR_LG2 2
|
||||
#define NN_FREELIST_MAGSIZE 256
|
||||
|
||||
struct ddsi_freelist_m {
|
||||
void *x[NN_FREELIST_MAGSIZE];
|
||||
void *next;
|
||||
};
|
||||
|
||||
struct ddsi_freelist1 {
|
||||
ddsrt_mutex_t lock;
|
||||
uint32_t count;
|
||||
struct ddsi_freelist_m *m;
|
||||
};
|
||||
|
||||
struct ddsi_freelist {
|
||||
struct ddsi_freelist1 inner[NN_FREELIST_NPAR];
|
||||
ddsrt_atomic_uint32_t cc;
|
||||
ddsrt_mutex_t lock;
|
||||
struct ddsi_freelist_m *mlist;
|
||||
struct ddsi_freelist_m *emlist;
|
||||
uint32_t count;
|
||||
uint32_t max;
|
||||
size_t linkoff;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/** @component ddsi_freelist */
|
||||
void ddsi_freelist_init (struct ddsi_freelist *fl, uint32_t max, size_t linkoff);
|
||||
|
||||
/** @component ddsi_freelist */
|
||||
void ddsi_freelist_fini (struct ddsi_freelist *fl, void (*free) (void *elem));
|
||||
|
||||
/** @component ddsi_freelist */
|
||||
bool ddsi_freelist_push (struct ddsi_freelist *fl, void *elem);
|
||||
|
||||
/** @component ddsi_freelist */
|
||||
void *ddsi_freelist_pushmany (struct ddsi_freelist *fl, void *first, void *last, uint32_t n);
|
||||
|
||||
/** @component ddsi_freelist */
|
||||
void *ddsi_freelist_pop (struct ddsi_freelist *fl);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_FREELIST_H */
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_GC_H
|
||||
#define DDSI_GC_H
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_gcreq;
|
||||
struct ddsi_gcreq_queue;
|
||||
|
||||
typedef void (*ddsi_gcreq_cb_t) (struct ddsi_gcreq *gcreq);
|
||||
|
||||
/** @component garbage_collector */
|
||||
DDS_EXPORT struct ddsi_gcreq *ddsi_gcreq_new (struct ddsi_gcreq_queue *gcreq_queue, ddsi_gcreq_cb_t cb);
|
||||
|
||||
/** @component garbage_collector */
|
||||
DDS_EXPORT void ddsi_gcreq_free (struct ddsi_gcreq *gcreq);
|
||||
|
||||
/** @component garbage_collector */
|
||||
DDS_EXPORT void ddsi_gcreq_enqueue (struct ddsi_gcreq *gcreq);
|
||||
|
||||
/** @component garbage_collector */
|
||||
DDS_EXPORT void * ddsi_gcreq_get_arg (struct ddsi_gcreq *gcreq);
|
||||
|
||||
/** @component garbage_collector */
|
||||
DDS_EXPORT void ddsi_gcreq_set_arg (struct ddsi_gcreq *gcreq, void *arg);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_GC_H */
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// Copyright(c) 2019 ZettaScale Technology 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 DDSI_GUID_H
|
||||
#define DDSI_GUID_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union ddsi_guid_prefix {
|
||||
unsigned char s[12];
|
||||
uint32_t u[3];
|
||||
} ddsi_guid_prefix_t;
|
||||
|
||||
typedef union ddsi_entityid {
|
||||
uint32_t u;
|
||||
} ddsi_entityid_t;
|
||||
|
||||
typedef struct ddsi_guid {
|
||||
ddsi_guid_prefix_t prefix;
|
||||
ddsi_entityid_t entityid;
|
||||
} ddsi_guid_t;
|
||||
|
||||
/** @component misc */
|
||||
DDS_EXPORT ddsi_guid_t ddsi_hton_guid (ddsi_guid_t g);
|
||||
|
||||
/** @component misc */
|
||||
DDS_EXPORT ddsi_guid_t ddsi_ntoh_guid (ddsi_guid_t g);
|
||||
|
||||
/** @component misc */
|
||||
ddsi_guid_prefix_t ddsi_hton_guid_prefix (ddsi_guid_prefix_t p);
|
||||
|
||||
/** @component misc */
|
||||
ddsi_guid_prefix_t ddsi_ntoh_guid_prefix (ddsi_guid_prefix_t p);
|
||||
|
||||
/** @component misc */
|
||||
ddsi_entityid_t ddsi_hton_entityid (ddsi_entityid_t e);
|
||||
|
||||
/** @component misc */
|
||||
ddsi_entityid_t ddsi_ntoh_entityid (ddsi_entityid_t e);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_HBCONTROL_H
|
||||
#define DDSI_HBCONTROL_H
|
||||
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// @brief State information used in deciding when/what kind of a heartbeat to send (per writer)
|
||||
///
|
||||
/// Heartbeats inform readers of the range of sequence numbers available from the writer and serve the dual
|
||||
/// purpose of (1) allowing the reader to detect message loss, and (2) allowing the reader to request a retransmit.
|
||||
///
|
||||
/// Because readers are not allowed to request a retransmit unless they received a heartbeat, we make an
|
||||
/// effort to a embed heartbeat in an outgoing RTPS message (~ a packet) if a preceding RTPS message
|
||||
/// also contained data from the writer. Its sole purpose is to allow it to request a retransmit.
|
||||
struct ddsi_hbcontrol {
|
||||
ddsrt_mtime_t t_of_last_write; ///< Time of most recent write
|
||||
ddsrt_mtime_t t_of_last_hb; ///< Time of last heartbeat sent
|
||||
ddsrt_mtime_t t_of_last_ackhb; ///< Time of last heartbeat sent that requires a response
|
||||
ddsrt_mtime_t tsched; ///< Time at which next asynchronous heartbeat is scheduled
|
||||
uint32_t hbs_since_last_write; ///< Number of heartbeats sent since last write
|
||||
uint32_t last_packetid; ///< Last RTPS message id containing a heartbeat from this writer
|
||||
};
|
||||
|
||||
/// @brief Encoding for possible ways of adding heartbeats to messages
|
||||
enum ddsi_hbcontrol_ack_required {
|
||||
DDSI_HBC_ACK_REQ_NO, ///< Heartbeat does not require a response (FINAL flag set)
|
||||
DDSI_HBC_ACK_REQ_YES, ///< Heartbeat requires a response, may continue packing
|
||||
DDSI_HBC_ACK_REQ_YES_AND_FLUSH ///< Heartbeat requires a response, must send immediately
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_HBCONTROL_H */
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 _DDS_IID_H_
|
||||
#define _DDS_IID_H_
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_iid {
|
||||
ddsrt_atomic_uint64_t counter;
|
||||
uint32_t key[4];
|
||||
};
|
||||
|
||||
/** @component instance_id */
|
||||
void ddsi_iid_init (void);
|
||||
|
||||
/** @component instance_id */
|
||||
void ddsi_iid_fini (void);
|
||||
|
||||
/** @component instance_id */
|
||||
uint64_t ddsi_iid_gen (void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_INIT_H
|
||||
#define DDSI_INIT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsi/ddsi_psmx.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_cfgst;
|
||||
struct ddsi_domaingv;
|
||||
|
||||
/** @component ddsi_init */
|
||||
int ddsi_config_prep (struct ddsi_domaingv *gv, struct ddsi_cfgst *cfgst);
|
||||
|
||||
/** @component ddsi_init */
|
||||
int ddsi_init (struct ddsi_domaingv *gv, struct ddsi_psmx_instance_locators *psmx_locators);
|
||||
|
||||
/** @component ddsi_init */
|
||||
int ddsi_start (struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component ddsi_init */
|
||||
void ddsi_stop (struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component ddsi_init */
|
||||
void ddsi_fini (struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component ddsi_generic_entity */
|
||||
void ddsi_set_deafmute (struct ddsi_domaingv *gv, bool deaf, bool mute, int64_t reset_after);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_INIT_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSI_INVERSE_UINT32_SET_H
|
||||
#define DDSI_INVERSE_UINT32_SET_H
|
||||
|
||||
#include "dds/ddsrt/avl.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_inverse_uint32_set {
|
||||
ddsrt_avl_tree_t ids;
|
||||
uint32_t cursor;
|
||||
uint32_t min, max;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_INVERSE_UINT32_SET_H */
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Copyright(c) 2020 ZettaScale Technology 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 DDSI_KEYHASH_H
|
||||
#define DDSI_KEYHASH_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ddsi_keyhash {
|
||||
unsigned char value[16];
|
||||
} ddsi_keyhash_t;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSI_LAT_ESTIM_H
|
||||
#define DDSI_LAT_ESTIM_H
|
||||
|
||||
#include "dds/ddsi/ddsi_log.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSI_LAT_ESTIM_MEDIAN_WINSZ 7
|
||||
|
||||
struct ddsi_lat_estim {
|
||||
/* median filtering with a small window in an attempt to remove the
|
||||
worst outliers */
|
||||
int index;
|
||||
float window[DDSI_LAT_ESTIM_MEDIAN_WINSZ];
|
||||
/* simple alpha filtering for smoothing */
|
||||
float smoothed;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_LAT_ESTIM_H */
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_LEASE_H
|
||||
#define DDSI_LEASE_H
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_entity_common;
|
||||
|
||||
struct ddsi_lease {
|
||||
ddsrt_fibheap_node_t heapnode;
|
||||
ddsrt_fibheap_node_t pp_heapnode;
|
||||
ddsrt_etime_t tsched; /* access guarded by leaseheap_lock */
|
||||
ddsrt_atomic_uint64_t tend; /* really an ddsrt_etime_t */
|
||||
dds_duration_t tdur; /* constant (renew depends on it) */
|
||||
struct ddsi_entity_common *entity; /* constant */
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_LEASE_H */
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_LIFESPAN_H
|
||||
#define DDSI_LIFESPAN_H
|
||||
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef ddsrt_mtime_t (*ddsi_sample_expired_cb_t)(void *hc, ddsrt_mtime_t tnow);
|
||||
|
||||
struct ddsi_lifespan_adm {
|
||||
ddsrt_fibheap_t ls_exp_heap; /* heap for sample expiration (lifespan) */
|
||||
struct ddsi_xevent *evt; /* xevent that triggers for sample with earliest expiration */
|
||||
ddsi_sample_expired_cb_t sample_expired_cb; /* callback for expired sample; this cb can use ddsi_lifespan_next_expired_locked to get next expired sample */
|
||||
size_t fh_offset; /* offset of lifespan_adm element in whc or rhc */
|
||||
size_t fhn_offset; /* offset of lifespan_fhnode element in whc or rhc node (sample) */
|
||||
};
|
||||
|
||||
struct ddsi_lifespan_fhnode {
|
||||
ddsrt_fibheap_node_t heapnode;
|
||||
ddsrt_mtime_t t_expire;
|
||||
};
|
||||
|
||||
/** @component lifespan_qos */
|
||||
void ddsi_lifespan_init (const struct ddsi_domaingv *gv, struct ddsi_lifespan_adm *lifespan_adm, size_t fh_offset, size_t fh_node_offset, ddsi_sample_expired_cb_t sample_expired_cb);
|
||||
|
||||
/** @component lifespan_qos */
|
||||
void ddsi_lifespan_fini (const struct ddsi_lifespan_adm *lifespan_adm);
|
||||
|
||||
/** @component lifespan_qos */
|
||||
ddsrt_mtime_t ddsi_lifespan_next_expired_locked (const struct ddsi_lifespan_adm *lifespan_adm, ddsrt_mtime_t tnow, void **sample);
|
||||
|
||||
/** @component lifespan_qos */
|
||||
void ddsi_lifespan_register_sample_real (struct ddsi_lifespan_adm *lifespan_adm, struct ddsi_lifespan_fhnode *node);
|
||||
|
||||
/** @component lifespan_qos */
|
||||
void ddsi_lifespan_unregister_sample_real (struct ddsi_lifespan_adm *lifespan_adm, struct ddsi_lifespan_fhnode *node);
|
||||
|
||||
/** @component lifespan_qos */
|
||||
inline void ddsi_lifespan_register_sample_locked (struct ddsi_lifespan_adm *lifespan_adm, struct ddsi_lifespan_fhnode *node)
|
||||
{
|
||||
if (node->t_expire.v != DDS_NEVER)
|
||||
ddsi_lifespan_register_sample_real (lifespan_adm, node);
|
||||
}
|
||||
|
||||
/** @component lifespan_qos */
|
||||
inline void ddsi_lifespan_unregister_sample_locked (struct ddsi_lifespan_adm *lifespan_adm, struct ddsi_lifespan_fhnode *node)
|
||||
{
|
||||
if (node->t_expire.v != DDS_NEVER)
|
||||
ddsi_lifespan_unregister_sample_real (lifespan_adm, node);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_LIFESPAN_H */
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_LOCATOR_H
|
||||
#define DDSI_LOCATOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_tran_factory;
|
||||
struct ddsi_tran_conn;
|
||||
|
||||
/* address field in locator maintained in network byte order, the rest in host */
|
||||
typedef struct ddsi_locator {
|
||||
int32_t kind;
|
||||
uint32_t port;
|
||||
unsigned char address[16];
|
||||
} ddsi_locator_t;
|
||||
|
||||
typedef struct ddsi_xlocator {
|
||||
ddsi_locator_t c;
|
||||
struct ddsi_tran_conn *conn;
|
||||
} ddsi_xlocator_t;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_LOCATOR_H */
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_LOG_H
|
||||
#define DDSI_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "dds/ddsrt/log.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GVTRACE(...) DDS_CTRACE (&gv->logconfig, __VA_ARGS__)
|
||||
#define GVLOG(cat, ...) DDS_CLOG ((cat), &gv->logconfig, __VA_ARGS__)
|
||||
#define GVWARNING(...) DDS_CLOG (DDS_LC_WARNING, &gv->logconfig, __VA_ARGS__)
|
||||
#define GVERROR(...) DDS_CLOG (DDS_LC_ERROR, &gv->logconfig, __VA_ARGS__)
|
||||
|
||||
#define RSTTRACE(...) DDS_CTRACE (&rst->gv->logconfig, __VA_ARGS__)
|
||||
|
||||
#define ETRACE(e_, ...) DDS_CTRACE (&(e_)->e.gv->logconfig, __VA_ARGS__)
|
||||
#define EETRACE(e_, ...) DDS_CTRACE (&(e_)->gv->logconfig, __VA_ARGS__)
|
||||
#define ELOG(cat, e_, ...) DDS_CLOG ((cat), &(e_)->e.gv->logconfig, __VA_ARGS__)
|
||||
#define EELOG(cat, e_, ...) DDS_CLOG ((cat), &(e_)->gv->logconfig, __VA_ARGS__)
|
||||
|
||||
/* There are quite a few places where discovery-related things are logged, so abbreviate those
|
||||
a bit */
|
||||
#define GVLOGDISC(...) DDS_CLOG (DDS_LC_DISCOVERY, &gv->logconfig, __VA_ARGS__)
|
||||
#define ELOGDISC(e_,...) DDS_CLOG (DDS_LC_DISCOVERY, &(e_)->e.gv->logconfig, __VA_ARGS__)
|
||||
#define EELOGDISC(e_, ...) DDS_CLOG (DDS_LC_DISCOVERY, &(e_)->gv->logconfig, __VA_ARGS__)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_LOG_H */
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright(c) 2006 to 2023 ZettaScale Technology 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 DDSI_NWINTERFACES_H
|
||||
#define DDSI_NWINTERFACES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dds/ddsrt/ifaddrs.h"
|
||||
#include "dds/ddsrt/sockets.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_network_interface {
|
||||
ddsi_locator_t loc; // actual interface address
|
||||
ddsi_locator_t extloc; // interface address to advertise in discovery
|
||||
ddsi_locator_t netmask;
|
||||
uint32_t if_index;
|
||||
unsigned mc_capable: 1;
|
||||
unsigned mc_flaky: 1;
|
||||
unsigned point_to_point: 1;
|
||||
unsigned loopback: 1;
|
||||
unsigned link_local: 1;
|
||||
unsigned prefer_multicast: 1;
|
||||
unsigned is_psmx: 1;
|
||||
uint32_t allow_multicast;
|
||||
int32_t priority;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_NWINTERFACES_H */
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_PARTICIPANT_H
|
||||
#define DDSI_PARTICIPANT_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/log.h"
|
||||
#include "dds/ddsi/ddsi_entity.h"
|
||||
#include "dds/ddsi/ddsi_inverse_uint32_set.h"
|
||||
#include "dds/ddsi/ddsi_plist.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set this flag in new_participant to prevent the creation SPDP, SEDP
|
||||
and PMD readers for that participant. It doesn't really need it,
|
||||
they all share the information anyway. But you do need it once. */
|
||||
#define RTPS_PF_NO_BUILTIN_READERS 1u
|
||||
/* Set this flag to prevent the creation of SPDP, SEDP and PMD
|
||||
writers. It will then rely on the "privileged participant", which
|
||||
must exist at the time of creation. It creates a reference to that
|
||||
"privileged participant" to ensure it won't disappear too early. */
|
||||
#define RTPS_PF_NO_BUILTIN_WRITERS 2u
|
||||
/* Set this flag to mark the participant as the "privileged
|
||||
participant", there can only be one of these. The privileged
|
||||
participant MUST have all builtin readers and writers. */
|
||||
#define RTPS_PF_PRIVILEGED_PP 4u
|
||||
/* Set this flag to mark the participant as is_ddsi2_pp. */
|
||||
#define RTPS_PF_IS_DDSI2_PP 8u
|
||||
/* Set this flag to mark the participant as an local entity only. */
|
||||
#define RTPS_PF_ONLY_LOCAL 16u
|
||||
/* Set this flag to mark that no privileged participant should be used
|
||||
for the built-in readers and writers. Can be used with NO_BUILTIN_READER and
|
||||
NO_BUILTIN_WRITER flag to avoid any communication for built-in topics. */
|
||||
#define RTPS_PF_NO_PRIVILEGED_PP 32u
|
||||
|
||||
struct ddsi_avail_entityid_set {
|
||||
struct ddsi_inverse_uint32_set x;
|
||||
};
|
||||
|
||||
enum ddsi_participant_state {
|
||||
DDSI_PARTICIPANT_STATE_INITIALIZING,
|
||||
DDSI_PARTICIPANT_STATE_OPERATIONAL,
|
||||
DDSI_PARTICIPANT_STATE_DELETE_STARTED,
|
||||
DDSI_PARTICIPANT_STATE_DELETING_BUILTINS
|
||||
};
|
||||
|
||||
struct ddsi_participant
|
||||
{
|
||||
struct ddsi_entity_common e;
|
||||
uint32_t bes; /* built-in endpoint set */
|
||||
unsigned is_ddsi2_pp: 1; /* true for the "federation leader", the ddsi2 participant itself in OSPL; FIXME: probably should use this for broker mode as well ... */
|
||||
uint32_t flags; /* flags used when creating this participant */
|
||||
struct ddsi_plist *plist; /* settings/QoS for this participant */
|
||||
struct ddsi_serdata *spdp_serdata; /* SPDP message: we no longer have a writer for it */
|
||||
ddsi_seqno_t spdp_seqno; /* sequence number of spdp_serdata; FIXME: move seqno into serdata and delete this */
|
||||
struct ddsi_xevent *pmd_update_xevent; /* timed event for periodically publishing ParticipantMessageData */
|
||||
ddsi_locator_t m_locator; /* this is always a unicast address, it is set if it is in the many unicast mode */
|
||||
struct ddsi_tran_conn * m_conn; /* this is connection to m_locator, if it is set, this is used */
|
||||
struct ddsi_avail_entityid_set avail_entityids; /* available entity ids [e.lock] */
|
||||
ddsrt_mutex_t refc_lock;
|
||||
int32_t user_refc; /* number of non-built-in endpoints in this participant [refc_lock] */
|
||||
int32_t builtin_refc; /* number of built-in endpoints in this participant [refc_lock] */
|
||||
enum ddsi_participant_state state; /* current state of this participant [refc_lock] */
|
||||
ddsrt_fibheap_t ldur_auto_wr; /* Heap that contains lease duration for writers with automatic liveliness in this participant */
|
||||
ddsrt_atomic_voidp_t minl_man; /* clone of min(leaseheap_man) */
|
||||
ddsrt_fibheap_t leaseheap_man; /* keeps leases for this participant's writers (with liveliness manual-by-participant) */
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
struct ddsi_participant_sec_attributes *sec_attr;
|
||||
ddsi_security_info_t security_info;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Generates a new participant GUID
|
||||
*
|
||||
* @param[out] ppguid The generated participant GUID
|
||||
* @param[in] gv Domain globals
|
||||
*/
|
||||
void ddsi_generate_participant_guid (ddsi_guid_t *ppguid, struct ddsi_domaingv *gv);
|
||||
|
||||
/**
|
||||
* @brief Create a new participant with a specified GUID
|
||||
* @component ddsi_participant
|
||||
*
|
||||
* @param[in] ppguid The GUID for the new participant
|
||||
* @param[in] gv Domain globals
|
||||
* @param[in] flags
|
||||
* Zero or more of:
|
||||
* - RTPS_PF_NO_BUILTIN_READERS do not create discovery readers in new ppant
|
||||
* - RTPS_PF_NO_BUILTIN_WRITERS do not create discvoery writers in new ppant
|
||||
* - RTPS_PF_PRIVILEGED_PP FIXME: figure out how to describe this ...
|
||||
* - RTPS_PF_IS_DDSI2_PP FIXME: OSPL holdover - there is no DDSI2E here
|
||||
* - RTPS_PF_ONLY_LOCAL FIXME: not used, it seems
|
||||
* @param[in] plist Parameters/QoS for this participant
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Success
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* The configured maximum number of participants has been reached.
|
||||
*/
|
||||
dds_return_t ddsi_new_participant (ddsi_guid_t *ppguid, struct ddsi_domaingv *gv, unsigned flags, const struct ddsi_plist *plist);
|
||||
|
||||
/**
|
||||
* @component ddsi_participant
|
||||
*
|
||||
* Initiate the deletion of the participant:
|
||||
* - dispose/unregister built-in topic
|
||||
* - list it as one of the recently deleted participants
|
||||
* - remote it from the GUID hash tables
|
||||
* - schedule the scare stuff to really delete it via the GC
|
||||
*
|
||||
* It is ok to call delete_participant without deleting all DDSI-level
|
||||
* readers/writers: those will simply be deleted. (New ones can't be
|
||||
* created anymore because the participant can no longer be located via
|
||||
* the hash tables).
|
||||
*
|
||||
* @param[in] ppguid
|
||||
* GUID of the participant to be deleted.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Success, it is no longer visible and GC events have
|
||||
* been scheduled for eventual deleting of all remaining
|
||||
* readers and writers and freeing of memory
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* ppguid lookup failed.
|
||||
*/
|
||||
dds_return_t ddsi_delete_participant (struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid);
|
||||
|
||||
/**
|
||||
* @brief Updates the parameters list for this participant and trigger sending an updated SPDP message.
|
||||
* @component ddsi_participant
|
||||
*
|
||||
* @param[in] pp The participant
|
||||
* @param[in] plist The new parameters
|
||||
*/
|
||||
void ddsi_update_participant_plist (struct ddsi_participant *pp, const struct ddsi_plist *plist);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PARTICIPANT_H */
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_PLIST_H
|
||||
#define DDSI_PLIST_H
|
||||
|
||||
#include "dds/ddsrt/bswap.h"
|
||||
#include "dds/ddsi/ddsi_feature_check.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
#include "dds/ddsi/ddsi_keyhash.h"
|
||||
#include "dds/ddsi/ddsi_tran.h" /* FIXME: eliminate */
|
||||
#include "dds/ddsi/ddsi_protocol.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For locators one could patch the received message data to create
|
||||
singly-linked lists (parameter header -> offset of next entry in
|
||||
list relative to current), allowing aliasing of the data. But that
|
||||
requires modifying the data. For string sequences the length does
|
||||
the same thing. */
|
||||
struct ddsi_locators_one {
|
||||
struct ddsi_locators_one *next;
|
||||
ddsi_locator_t loc;
|
||||
};
|
||||
|
||||
typedef struct ddsi_locators {
|
||||
uint32_t n;
|
||||
struct ddsi_locators_one *first;
|
||||
struct ddsi_locators_one *last;
|
||||
} ddsi_locators_t;
|
||||
|
||||
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
|
||||
typedef struct ddsi_tag {
|
||||
char *name;
|
||||
char *value;
|
||||
} ddsi_tag_t;
|
||||
|
||||
typedef struct ddsi_tagseq {
|
||||
uint32_t n;
|
||||
ddsi_tag_t *tags;
|
||||
} ddsi_tagseq_t;
|
||||
|
||||
typedef struct ddsi_datatags {
|
||||
ddsi_tagseq_t tags;
|
||||
} ddsi_datatags_t;
|
||||
|
||||
typedef struct ddsi_dataholder {
|
||||
char *class_id;
|
||||
dds_propertyseq_t properties;
|
||||
dds_binarypropertyseq_t binary_properties;
|
||||
} ddsi_dataholder_t;
|
||||
|
||||
typedef struct ddsi_dataholderseq {
|
||||
uint32_t n;
|
||||
ddsi_dataholder_t *tags;
|
||||
} ddsi_dataholderseq_t;
|
||||
|
||||
typedef ddsi_dataholder_t ddsi_token_t;
|
||||
|
||||
/* Used for both ddsi_participant_security_info and ddsi_endpoint_security_info. */
|
||||
typedef struct ddsi_security_info
|
||||
{
|
||||
uint32_t security_attributes;
|
||||
uint32_t plugin_security_attributes;
|
||||
} ddsi_security_info_t;
|
||||
|
||||
#else /* DDS_HAS_SECURITY */
|
||||
|
||||
struct ddsi_security_info;
|
||||
typedef struct ddsi_security_info ddsi_security_info_t;
|
||||
|
||||
#endif /* DDS_HAS_SECURITY */
|
||||
|
||||
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
|
||||
typedef struct ddsi_reader_favours_ssm {
|
||||
uint32_t state; /* default is false */
|
||||
} ddsi_reader_favours_ssm_t;
|
||||
|
||||
#endif /* DDSRT_HAVE_SSM */
|
||||
|
||||
|
||||
typedef struct ddsi_adlink_participant_version_info
|
||||
{
|
||||
uint32_t version;
|
||||
uint32_t flags;
|
||||
uint32_t unused[3];
|
||||
char *internals;
|
||||
} ddsi_adlink_participant_version_info_t;
|
||||
|
||||
typedef struct ddsi_plist {
|
||||
uint64_t present;
|
||||
uint64_t aliased;
|
||||
|
||||
dds_qos_t qos;
|
||||
|
||||
ddsi_protocol_version_t protocol_version;
|
||||
ddsi_vendorid_t vendorid;
|
||||
ddsi_locators_t unicast_locators;
|
||||
ddsi_locators_t multicast_locators;
|
||||
ddsi_locators_t default_unicast_locators;
|
||||
ddsi_locators_t default_multicast_locators;
|
||||
ddsi_locators_t metatraffic_unicast_locators;
|
||||
ddsi_locators_t metatraffic_multicast_locators;
|
||||
|
||||
unsigned char expects_inline_qos;
|
||||
ddsi_count_t participant_manual_liveliness_count;
|
||||
uint32_t participant_builtin_endpoints;
|
||||
/* ddsi_content_filter_property_t content_filter_property; */
|
||||
ddsi_guid_t participant_guid;
|
||||
ddsi_guid_t endpoint_guid;
|
||||
ddsi_guid_t group_guid;
|
||||
ddsi_guid_t topic_guid;
|
||||
#if 0 /* reserved, rather than NIY */
|
||||
ddsi_entityid_t participant_entityid;
|
||||
ddsi_entityid_t group_entityid;
|
||||
#endif
|
||||
uint32_t builtin_endpoint_set;
|
||||
/* int type_max_size_serialized; */
|
||||
ddsi_keyhash_t keyhash;
|
||||
uint32_t statusinfo;
|
||||
ddsi_adlink_participant_version_info_t adlink_participant_version_info;
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
ddsi_token_t identity_token;
|
||||
ddsi_token_t permissions_token;
|
||||
ddsi_security_info_t endpoint_security_info;
|
||||
ddsi_security_info_t participant_security_info;
|
||||
ddsi_token_t identity_status_token;
|
||||
ddsi_datatags_t data_tags;
|
||||
#endif
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
ddsi_reader_favours_ssm_t reader_favours_ssm;
|
||||
#endif
|
||||
uint32_t domain_id;
|
||||
char *domain_tag;
|
||||
uint32_t cyclone_receive_buffer_size;
|
||||
unsigned char cyclone_requests_keyhash;
|
||||
unsigned char cyclone_redundant_networking;
|
||||
} ddsi_plist_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize a ddsi_plist_t as an empty object
|
||||
* @component parameter_list
|
||||
*
|
||||
* In principle, this only clears the "present" and "aliased" bitmasks. A debug build
|
||||
* additionally initializes all other bytes to 0x55.
|
||||
*
|
||||
* @param[out] dest plist_t to be initialized.
|
||||
*/
|
||||
DDS_EXPORT void ddsi_plist_init_empty (ddsi_plist_t *dest);
|
||||
|
||||
/**
|
||||
* @brief Free memory owned by "ps"
|
||||
* @component parameter_list
|
||||
*
|
||||
* A ddsi_plist_t may own other allocated blocks of memory, depending on which fields are
|
||||
* set, their types and whether they are marked as "aliased". This function releases any
|
||||
* such memory owned by "ps", but not "ps" itself. Afterward, the contents of "ps" is
|
||||
* undefined and must not be used again without initialising it (either via
|
||||
* `ddsi_plist_init_empty`, `ddsi_plist_init_frommsg` or `ddsi_plist_copy`.
|
||||
*
|
||||
* @param[in] ps ddsi_plist_t for which to free memory
|
||||
*/
|
||||
DDS_EXPORT void ddsi_plist_fini (ddsi_plist_t *ps);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PLIST_H */
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_PMD_H
|
||||
#define DDSI_PMD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_guid;
|
||||
|
||||
/** @component pmd */
|
||||
void ddsi_write_pmd_message_guid (struct ddsi_domaingv * const gv, struct ddsi_guid *pp_guid, unsigned pmd_kind);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* DDSI_PMD_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright(c) 2019 to 2020 ZettaScale Technology 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 DDSI_PORTMAPPING_H
|
||||
#define DDSI_PORTMAPPING_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum ddsi_port {
|
||||
DDSI_PORT_MULTI_DISC,
|
||||
DDSI_PORT_MULTI_DATA,
|
||||
DDSI_PORT_UNI_DISC,
|
||||
DDSI_PORT_UNI_DATA
|
||||
};
|
||||
|
||||
struct ddsi_portmapping {
|
||||
uint32_t base;
|
||||
uint32_t dg;
|
||||
uint32_t pg;
|
||||
uint32_t d0;
|
||||
uint32_t d1;
|
||||
uint32_t d2;
|
||||
uint32_t d3;
|
||||
};
|
||||
|
||||
/** @component port_mapping */
|
||||
DDS_EXPORT bool ddsi_get_port_int (uint32_t *port, const struct ddsi_portmapping *map, enum ddsi_port which, uint32_t domain_id, int32_t participant_index, char *str_if_overflow, size_t strsize);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PORTMAPPING_H */
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_PROTOCOL_H
|
||||
#define DDSI_PROTOCOL_H
|
||||
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsi/ddsi_feature_check.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSI_STATUSINFO_DISPOSE 0x1u
|
||||
#define DDSI_STATUSINFO_UNREGISTER 0x2u
|
||||
#define DDSI_STATUSINFO_STANDARDIZED (DDSI_STATUSINFO_DISPOSE | DDSI_STATUSINFO_UNREGISTER)
|
||||
#define DDSI_STATUSINFO_OSPL_AUTO 0x10000000u /* OSPL extension, not on the wire */
|
||||
#define DDSI_STATUSINFOX_OSPL_AUTO 0x1 /* statusinfo word 2, OSPL L_AUTO flag on the wire */
|
||||
|
||||
#define DDSI_LOCATOR_KIND_INVALID -1
|
||||
#define DDSI_LOCATOR_KIND_RESERVED 0
|
||||
#define DDSI_LOCATOR_KIND_UDPv4 1
|
||||
#define DDSI_LOCATOR_KIND_UDPv6 2
|
||||
#define DDSI_LOCATOR_KIND_TCPv4 4
|
||||
#define DDSI_LOCATOR_KIND_TCPv6 8
|
||||
#define DDSI_LOCATOR_KIND_PSMX 16
|
||||
#define DDSI_LOCATOR_KIND_RAWETH 0x02000000
|
||||
#define DDSI_LOCATOR_KIND_UDPv4MCGEN 0x4fff0000
|
||||
#define DDSI_LOCATOR_PORT_INVALID 0
|
||||
|
||||
// The maximum size of the index in a MCGEN locator, so that it can be stored in a cover_info_t
|
||||
#define DDSI_LOCATOR_UDPv4MCGEN_INDEX_MASK_BITS 12
|
||||
|
||||
typedef uint32_t ddsi_count_t;
|
||||
|
||||
typedef struct ddsi_protocol_version {
|
||||
uint8_t major, minor;
|
||||
} ddsi_protocol_version_t;
|
||||
|
||||
typedef uint64_t ddsi_seqno_t;
|
||||
#define DDSI_MAX_SEQ_NUMBER INT64_MAX
|
||||
|
||||
#define PGUIDPREFIX(gp) (gp).u[0], (gp).u[1], (gp).u[2]
|
||||
#define PGUID(g) PGUIDPREFIX ((g).prefix), (g).entityid.u
|
||||
#define PGUIDPREFIXFMT "%" PRIx32 ":%" PRIx32 ":%" PRIx32
|
||||
#define PGUIDFMT PGUIDPREFIXFMT ":%" PRIx32
|
||||
|
||||
typedef struct {
|
||||
uint8_t id[2];
|
||||
} ddsi_vendorid_t;
|
||||
|
||||
typedef struct ddsi_protocolid {
|
||||
uint8_t id[4];
|
||||
} ddsi_protocolid_t;
|
||||
|
||||
typedef struct ddsi_rtps_header {
|
||||
ddsi_protocolid_t protocol;
|
||||
ddsi_protocol_version_t version;
|
||||
ddsi_vendorid_t vendorid;
|
||||
ddsi_guid_prefix_t guid_prefix;
|
||||
} ddsi_rtps_header_t;
|
||||
#define DDSI_RTPS_MESSAGE_HEADER_SIZE (sizeof (ddsi_rtps_header_t))
|
||||
|
||||
typedef struct ddsi_rtps_submessage_header {
|
||||
uint8_t submessageId;
|
||||
uint8_t flags;
|
||||
uint16_t octetsToNextHeader;
|
||||
} ddsi_rtps_submessage_header_t;
|
||||
#define DDSI_RTPS_SUBMESSAGE_HEADER_SIZE (sizeof (ddsi_rtps_submessage_header_t))
|
||||
#define DDSI_RTPS_SUBMESSAGE_FLAG_ENDIANNESS 0x01u
|
||||
|
||||
typedef enum ddsi_rtps_submessage_kind {
|
||||
DDSI_RTPS_SMID_PAD = 0x01,
|
||||
DDSI_RTPS_SMID_ACKNACK = 0x06,
|
||||
DDSI_RTPS_SMID_HEARTBEAT = 0x07,
|
||||
DDSI_RTPS_SMID_GAP = 0x08,
|
||||
DDSI_RTPS_SMID_INFO_TS = 0x09,
|
||||
DDSI_RTPS_SMID_INFO_SRC = 0x0c,
|
||||
DDSI_RTPS_SMID_INFO_REPLY_IP4 = 0x0d,
|
||||
DDSI_RTPS_SMID_INFO_DST = 0x0e,
|
||||
DDSI_RTPS_SMID_INFO_REPLY = 0x0f,
|
||||
DDSI_RTPS_SMID_NACK_FRAG = 0x12,
|
||||
DDSI_RTPS_SMID_HEARTBEAT_FRAG = 0x13,
|
||||
DDSI_RTPS_SMID_DATA = 0x15,
|
||||
DDSI_RTPS_SMID_DATA_FRAG = 0x16,
|
||||
/* security-specific sub messages */
|
||||
DDSI_RTPS_SMID_SEC_BODY = 0x30,
|
||||
DDSI_RTPS_SMID_SEC_PREFIX = 0x31,
|
||||
DDSI_RTPS_SMID_SEC_POSTFIX = 0x32,
|
||||
DDSI_RTPS_SMID_SRTPS_PREFIX = 0x33,
|
||||
DDSI_RTPS_SMID_SRTPS_POSTFIX = 0x34,
|
||||
/* vendor-specific sub messages (0x80 .. 0xff) */
|
||||
DDSI_RTPS_SMID_ADLINK_MSG_LEN = 0x81,
|
||||
DDSI_RTPS_SMID_ADLINK_ENTITY_ID = 0x82
|
||||
} ddsi_rtps_submessage_kind_t;
|
||||
|
||||
typedef struct ddsi_rtps_info_src {
|
||||
ddsi_rtps_submessage_header_t smhdr;
|
||||
unsigned unused;
|
||||
ddsi_protocol_version_t version;
|
||||
ddsi_vendorid_t vendorid;
|
||||
ddsi_guid_prefix_t guid_prefix;
|
||||
} ddsi_rtps_info_src_t;
|
||||
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
|
||||
#define DDSI_RTPS_CDR_BE 0x0000u
|
||||
#define DDSI_RTPS_CDR_LE 0x0100u
|
||||
#define DDSI_RTPS_PL_CDR_BE 0x0200u
|
||||
#define DDSI_RTPS_PL_CDR_LE 0x0300u
|
||||
#define DDSI_RTPS_CDR2_BE 0x0600u
|
||||
#define DDSI_RTPS_CDR2_LE 0x0700u
|
||||
#define DDSI_RTPS_D_CDR2_BE 0x0800u
|
||||
#define DDSI_RTPS_D_CDR2_LE 0x0900u
|
||||
#define DDSI_RTPS_PL_CDR2_BE 0x0a00u
|
||||
#define DDSI_RTPS_PL_CDR2_LE 0x0b00u
|
||||
#define DDSI_RTPS_SAMPLE_NATIVE 0x00c0u
|
||||
|
||||
#define DDSI_RTPS_CDR_ENC_LE(x) (assert((x) != DDSI_RTPS_SAMPLE_NATIVE), ((x) & 0x0100) == 0x0100)
|
||||
#define DDSI_RTPS_CDR_ENC_IS_NATIVE(x) (DDSI_RTPS_CDR_ENC_LE ((x)))
|
||||
#define DDSI_RTPS_CDR_ENC_IS_VALID(x) (!((x) > DDSI_RTPS_PL_CDR2_LE || (x) == DDSI_RTPS_SAMPLE_NATIVE || (x) == 0x0400 || (x) == 0x0500))
|
||||
#define DDSI_RTPS_CDR_ENC_TO_NATIVE(x) (assert((x) != DDSI_RTPS_SAMPLE_NATIVE), ((x) | 0x0100))
|
||||
|
||||
#else
|
||||
|
||||
#define DDSI_RTPS_CDR_BE 0x0000u
|
||||
#define DDSI_RTPS_CDR_LE 0x0001u
|
||||
#define DDSI_RTPS_PL_CDR_BE 0x0002u
|
||||
#define DDSI_RTPS_PL_CDR_LE 0x0003u
|
||||
#define DDSI_RTPS_CDR2_BE 0x0006u
|
||||
#define DDSI_RTPS_CDR2_LE 0x0007u
|
||||
#define DDSI_RTPS_D_CDR2_BE 0x0008u
|
||||
#define DDSI_RTPS_D_CDR2_LE 0x0009u
|
||||
#define DDSI_RTPS_PL_CDR2_BE 0x000au
|
||||
#define DDSI_RTPS_PL_CDR2_LE 0x000bu
|
||||
#define DDSI_RTPS_SAMPLE_NATIVE 0xc000u
|
||||
|
||||
#define DDSI_RTPS_CDR_ENC_LE(x) (assert((x) != DDSI_RTPS_SAMPLE_NATIVE), ((x) & 0x0001) == 0x0001)
|
||||
#define DDSI_RTPS_CDR_ENC_IS_NATIVE(x) (!DDSI_RTPS_CDR_ENC_LE ((x)))
|
||||
#define DDSI_RTPS_CDR_ENC_IS_VALID(x) (!((x) > DDSI_RTPS_PL_CDR2_LE || (x) == DDSI_RTPS_SAMPLE_NATIVE || (x) == 0x0004 || (x) == 0x0005))
|
||||
#define DDSI_RTPS_CDR_ENC_TO_NATIVE(x) (assert((x) != DDSI_RTPS_SAMPLE_NATIVE), ((x) & ~0x0001))
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct ddsi_rtps_msg_len {
|
||||
ddsi_rtps_submessage_header_t smhdr;
|
||||
uint32_t length;
|
||||
} ddsi_rtps_msg_len_t;
|
||||
|
||||
#define DDSI_PARTICIPANT_MESSAGE_DATA_KIND_UNKNOWN 0x0u
|
||||
#define DDSI_PARTICIPANT_MESSAGE_DATA_KIND_AUTOMATIC_LIVELINESS_UPDATE 0x1u
|
||||
#define DDSI_PARTICIPANT_MESSAGE_DATA_KIND_MANUAL_LIVELINESS_UPDATE 0x2u
|
||||
#define DDSI_PARTICIPANT_MESSAGE_DATA_VENDOR_SPECIFIC_KIND_FLAG 0x8000000u
|
||||
|
||||
/* predefined entity ids; here viewed as an unsigned int, on the
|
||||
network as four bytes corresponding to the integer in network byte
|
||||
order */
|
||||
#define DDSI_ENTITYID_UNKNOWN 0x0
|
||||
#define DDSI_ENTITYID_PARTICIPANT 0x1c1
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_TOPIC_WRITER 0x2c2
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_TOPIC_READER 0x2c7
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER 0x3c2
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER 0x3c7
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER 0x4c2
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER 0x4c7
|
||||
#define DDSI_ENTITYID_SPDP_BUILTIN_PARTICIPANT_WRITER 0x100c2
|
||||
#define DDSI_ENTITYID_SPDP_BUILTIN_PARTICIPANT_READER 0x100c7
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER 0x200c2
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER 0x200c7
|
||||
|
||||
#define DDSI_ENTITYID_TL_SVC_BUILTIN_REQUEST_WRITER 0x300c3
|
||||
#define DDSI_ENTITYID_TL_SVC_BUILTIN_REQUEST_READER 0x300c4
|
||||
#define DDSI_ENTITYID_TL_SVC_BUILTIN_REPLY_WRITER 0x301c3
|
||||
#define DDSI_ENTITYID_TL_SVC_BUILTIN_REPLY_READER 0x301c4
|
||||
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER 0xff0003c2
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_READER 0xff0003c7
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER 0xff0004c2
|
||||
#define DDSI_ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_READER 0xff0004c7
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_MESSAGE_WRITER 0x201c3
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_MESSAGE_READER 0x201c4
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER 0xff0200c2
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_READER 0xff0200c7
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_SECURE_WRITER 0xff0202c3
|
||||
#define DDSI_ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_SECURE_READER 0xff0202c4
|
||||
#define DDSI_ENTITYID_SPDP_RELIABLE_BUILTIN_PARTICIPANT_SECURE_WRITER 0xff0101c2
|
||||
#define DDSI_ENTITYID_SPDP_RELIABLE_BUILTIN_PARTICIPANT_SECURE_READER 0xff0101c7
|
||||
|
||||
#define DDSI_ENTITYID_SOURCE_MASK 0xc0
|
||||
#define DDSI_ENTITYID_SOURCE_USER 0x00
|
||||
#define DDSI_ENTITYID_SOURCE_BUILTIN 0xc0
|
||||
#define DDSI_ENTITYID_SOURCE_VENDOR 0x40
|
||||
#define DDSI_ENTITYID_KIND_MASK 0x3f
|
||||
#define DDSI_ENTITYID_KIND_WRITER_WITH_KEY 0x02
|
||||
#define DDSI_ENTITYID_KIND_WRITER_NO_KEY 0x03
|
||||
#define DDSI_ENTITYID_KIND_READER_NO_KEY 0x04
|
||||
#define DDSI_ENTITYID_KIND_READER_WITH_KEY 0x07
|
||||
/* Entity kind topic is not defined in the RTPS spec, so the following two
|
||||
should to be used as vendor specific entities using DDSI_ENTITYID_SOURCE_VENDOR.
|
||||
Two entity kinds for built-in and user topics are required, because the
|
||||
vendor and built-in flags cannot be combined. */
|
||||
#define DDSI_ENTITYID_KIND_CYCLONE_TOPIC_BUILTIN 0x0c
|
||||
#define DDSI_ENTITYID_KIND_CYCLONE_TOPIC_USER 0x0d
|
||||
|
||||
#define DDSI_ENTITYID_ALLOCSTEP 0x100
|
||||
|
||||
|
||||
/* Names of the built-in topics */
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_NAME "DCPSParticipant"
|
||||
#define DDS_BUILTIN_TOPIC_PUBLICATION_NAME "DCPSPublication"
|
||||
#define DDS_BUILTIN_TOPIC_SUBSCRIPTION_NAME "DCPSSubscription"
|
||||
#define DDS_BUILTIN_TOPIC_TOPIC_NAME "DCPSTopic"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_MESSAGE_NAME "DCPSParticipantMessage"
|
||||
#define DDS_BUILTIN_TOPIC_TYPELOOKUP_REQUEST_NAME "DCPSTypeLookupRequest"
|
||||
#define DDS_BUILTIN_TOPIC_TYPELOOKUP_REPLY_NAME "DCPSTypeLookupReply"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_SECURE_NAME "DCPSParticipantsSecure"
|
||||
#define DDS_BUILTIN_TOPIC_PUBLICATION_SECURE_NAME "DCPSPublicationsSecure"
|
||||
#define DDS_BUILTIN_TOPIC_SUBSCRIPTION_SECURE_NAME "DCPSSubscriptionsSecure"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_MESSAGE_SECURE_NAME "DCPSParticipantMessageSecure"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_STATELESS_MESSAGE_NAME "DCPSParticipantStatelessMessage"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_VOLATILE_MESSAGE_SECURE_NAME "DCPSParticipantVolatileMessageSecure"
|
||||
|
||||
/* Participant built-in topic qos properties */
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_PROPERTY_PROCESS_NAME "__ProcessName"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_PROPERTY_PID "__Pid"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_PROPERTY_HOSTNAME "__Hostname"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_PROPERTY_NETWORKADDRESSES "__NetworkAddresses"
|
||||
#define DDS_BUILTIN_TOPIC_PARTICIPANT_DEBUG_MONITOR "__DebugMonitor"
|
||||
#define DDS_BUILTIN_TOPIC_NULL_NAME NULL
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PROTOCOL_H */
|
||||
@@ -0,0 +1,151 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_PROXY_ENDPOINT_H
|
||||
#define DDSI_PROXY_ENDPOINT_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
#include "dds/ddsi/ddsi_entity.h"
|
||||
#include "dds/ddsi/ddsi_lease.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_proxy_participant;
|
||||
struct ddsi_proxy_reader;
|
||||
struct ddsi_writer;
|
||||
struct dds_qos;
|
||||
struct ddsi_addrset;
|
||||
struct ddsi_serdata;
|
||||
|
||||
struct ddsi_proxy_endpoint_common
|
||||
{
|
||||
struct ddsi_proxy_participant *proxypp; /* counted backref to proxy participant */
|
||||
struct ddsi_proxy_endpoint_common *next_ep; /* next \ endpoint belonging to this proxy participant */
|
||||
struct ddsi_proxy_endpoint_common *prev_ep; /* prev / -- this is in arbitrary ordering */
|
||||
struct dds_qos *xqos; /* proxy endpoint QoS lives here; FIXME: local ones should have it moved to common as well */
|
||||
struct ddsi_addrset *as; /* address set to use for communicating with this endpoint */
|
||||
ddsi_xlocator_t loc_uc; /* preferred address for sending unicast */
|
||||
ddsi_guid_t group_guid; /* 0:0:0:0 if not available */
|
||||
ddsi_vendorid_t vendor; /* cached from proxypp->vendor */
|
||||
ddsi_seqno_t seq; /* sequence number of most recent SEDP message */
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
struct ddsi_type_pair *type_pair;
|
||||
#endif
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
ddsi_security_info_t security_info;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ddsi_generic_proxy_endpoint {
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_proxy_endpoint_common c;
|
||||
};
|
||||
|
||||
struct ddsi_proxy_writer {
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_proxy_endpoint_common c;
|
||||
ddsrt_avl_tree_t readers; /* matching LOCAL readers, see pwr_rd_match */
|
||||
int32_t n_reliable_readers; /* number of those that are reliable */
|
||||
int32_t n_readers_out_of_sync; /* number of those that require special handling (accepting historical data, waiting for historical data set to become complete) */
|
||||
ddsi_seqno_t last_seq; /* highest known seq published by the writer, not last delivered */
|
||||
uint32_t last_fragnum; /* last known frag for last_seq, or UINT32_MAX if last_seq not partial */
|
||||
ddsi_count_t nackfragcount; /* last nackfrag seq number */
|
||||
ddsrt_atomic_uint32_t next_deliv_seq_lowword; /* lower 32-bits for next sequence number that will be delivered; for generating acks; 32-bit so atomic reads on all supported platforms */
|
||||
unsigned deliver_synchronously: 1; /* iff 1, delivery happens straight from receive thread for non-historical data; else through delivery queue "dqueue" */
|
||||
unsigned have_seen_heartbeat: 1; /* iff 1, we have received at least on heartbeat from this proxy writer */
|
||||
unsigned local_matching_inprogress: 1; /* iff 1, we are still busy matching local readers; this is so we don't deliver incoming data to some but not all readers initially */
|
||||
unsigned alive: 1; /* iff 1, the proxy writer is alive (lease for this proxy writer is not expired); field may be modified only when holding both pwr->e.lock and pwr->c.proxypp->e.lock */
|
||||
unsigned filtered: 1; /* iff 1, builtin proxy writer uses content filter, which affects heartbeats and gaps. */
|
||||
unsigned redundant_networking: 1; /* 1 iff requests receiving data on all advertised interfaces */
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
unsigned supports_ssm: 1; /* iff 1, this proxy writer supports SSM */
|
||||
#endif
|
||||
unsigned local_psmx: 1; /* whether this is a proxy writer for a local PSMX */
|
||||
uint32_t alive_vclock; /* virtual clock counting transitions between alive/not-alive */
|
||||
struct ddsi_defrag *defrag; /* defragmenter for this proxy writer; FIXME: perhaps shouldn't be for historical data */
|
||||
struct ddsi_reorder *reorder; /* message reordering for this proxy writer, out-of-sync readers can have their own, see pwr_rd_match */
|
||||
struct ddsi_dqueue *dqueue; /* delivery queue for asynchronous delivery (historical data is always delivered asynchronously) */
|
||||
struct ddsi_xeventq *evq; /* timed event queue to be used for ACK generation */
|
||||
struct ddsi_local_reader_ary rdary; /* LOCAL readers for fast-pathing; if not fast-pathed, fall back to scanning local_readers */
|
||||
struct ddsi_lease *lease;
|
||||
};
|
||||
|
||||
|
||||
typedef int (*ddsi_filter_fn_t)(struct ddsi_writer *wr, struct ddsi_proxy_reader *prd, struct ddsi_serdata *serdata);
|
||||
|
||||
struct ddsi_proxy_reader {
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_proxy_endpoint_common c;
|
||||
unsigned deleting: 1; /* set when being deleted */
|
||||
unsigned is_fict_trans_reader: 1; /* only true when it is certain that is a fictitious transient data reader (affects built-in topic generation) */
|
||||
unsigned requests_keyhash: 1; /* 1 iff this reader would like to receive keyhashes */
|
||||
unsigned redundant_networking: 1; /* 1 iff requests receiving data on all advertised interfaces */
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
unsigned favours_ssm: 1; /* iff 1, this proxy reader favours SSM when available */
|
||||
#endif
|
||||
unsigned local_psmx: 1; /*whether this is a proxy reader for a local PSMX*/
|
||||
ddsrt_avl_tree_t writers; /* matching LOCAL writers */
|
||||
uint32_t receive_buffer_size; /* assumed receive buffer size inherited from proxypp */
|
||||
ddsi_filter_fn_t filter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief To create a new proxy writer
|
||||
* @component ddsi_proxy_endpoint
|
||||
*
|
||||
* @param proxy_writer out parameter for the created proxy writer
|
||||
* @param gv domain globals
|
||||
* @param ppguid the proxy participant is determined from the GUID and must exist
|
||||
* @param guid guid for the proxy writer
|
||||
* @param as address set
|
||||
* @param plist parameter list
|
||||
* @param dqueue receive queue
|
||||
* @param evq event queue
|
||||
* @param timestamp timestamp to be used as creation time for the proxy writer
|
||||
* @param seq sequence number
|
||||
* @returns 0 on success
|
||||
*/
|
||||
DDS_EXPORT int ddsi_new_proxy_writer (struct ddsi_proxy_writer **proxy_writer, struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct ddsi_addrset *as, const struct ddsi_plist *plist, struct ddsi_dqueue *dqueue, struct ddsi_xeventq *evq, ddsrt_wctime_t timestamp, ddsi_seqno_t seq);
|
||||
|
||||
|
||||
/**
|
||||
* @brief To create a new proxy reader
|
||||
* @component ddsi_proxy_endpoint
|
||||
*
|
||||
* @param proxy_reader out parameter for the created proxy reader
|
||||
* @param gv domain globals
|
||||
* @param ppguid the proxy participant is determined from the GUID and must exist
|
||||
* @param guid guid for the proxy reader
|
||||
* @param as address set
|
||||
* @param plist parameter list
|
||||
* @param timestamp timestamp to be used as creation time for the proxy reader
|
||||
* @param seq sequence number
|
||||
* @param favours_ssm indicates if the proxy reader favors ssm
|
||||
* @return int
|
||||
*/
|
||||
DDS_EXPORT int ddsi_new_proxy_reader (struct ddsi_proxy_reader **proxy_reader, struct ddsi_domaingv *gv, const struct ddsi_guid *ppguid, const struct ddsi_guid *guid, struct ddsi_addrset *as, const struct ddsi_plist *plist, ddsrt_wctime_t timestamp, ddsi_seqno_t seq
|
||||
|
||||
#ifdef DDSRT_HAVE_SSM
|
||||
, int favours_ssm
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PROXY_ENDPOINT_H */
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_PROXY_PARTICIPANT_H
|
||||
#define DDSI_PROXY_PARTICIPANT_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsrt/fibheap.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
#include "dds/ddsi/ddsi_topic.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_lease;
|
||||
struct ddsi_plist;
|
||||
struct ddsi_addrset;
|
||||
struct ddsi_proxy_endpoint_common;
|
||||
|
||||
struct ddsi_proxy_participant
|
||||
{
|
||||
struct ddsi_entity_common e;
|
||||
uint32_t refc; /* number of proxy endpoints (both user & built-in; not groups, they don't have a life of their own) */
|
||||
ddsi_vendorid_t vendor; /* vendor code from discovery */
|
||||
unsigned bes; /* built-in endpoint set */
|
||||
ddsi_guid_t privileged_pp_guid; /* if this PP depends on another PP for its SEDP writing */
|
||||
struct ddsi_plist *plist; /* settings/QoS for this participant */
|
||||
ddsrt_atomic_voidp_t minl_auto; /* clone of min(leaseheap_auto) */
|
||||
ddsrt_fibheap_t leaseheap_auto; /* keeps leases for this proxypp and leases for pwrs (with liveliness automatic) */
|
||||
ddsrt_atomic_voidp_t minl_man; /* clone of min(leaseheap_man) */
|
||||
ddsrt_fibheap_t leaseheap_man; /* keeps leases for this proxypp and leases for pwrs (with liveliness manual-by-participant) */
|
||||
struct ddsi_lease *lease; /* lease for this proxypp */
|
||||
struct ddsi_addrset *as_default; /* default address set to use for user data traffic */
|
||||
struct ddsi_addrset *as_meta; /* default address set to use for discovery traffic */
|
||||
struct ddsi_proxy_endpoint_common *endpoints; /* all proxy endpoints can be reached from here */
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
ddsrt_avl_tree_t topics;
|
||||
#endif
|
||||
ddsi_seqno_t seq; /* sequence number of most recent SPDP message */
|
||||
uint32_t receive_buffer_size; /* assumed size of receive buffer, used to limit bursts involving this proxypp */
|
||||
unsigned implicitly_created : 1; /* participants are implicitly created for Cloud/Fog discovered endpoints */
|
||||
unsigned is_ddsi2_pp: 1; /* if this is the federation-leader on the remote node */
|
||||
unsigned minimal_bes_mode: 1;
|
||||
unsigned lease_expired: 1;
|
||||
unsigned deleting: 1;
|
||||
unsigned proxypp_have_spdp: 1;
|
||||
unsigned owns_lease: 1;
|
||||
unsigned redundant_networking: 1; /* 1 iff requests receiving data on all advertised interfaces */
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
ddsi_security_info_t security_info;
|
||||
struct ddsi_proxy_participant_sec_attributes *sec_attr;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
extern const ddsrt_avl_treedef_t ddsi_proxypp_proxytp_treedef;
|
||||
#endif
|
||||
|
||||
/** @component ddsi_proxy_participant */
|
||||
DDS_EXPORT bool ddsi_new_proxy_participant (struct ddsi_proxy_participant **proxy_participant, struct ddsi_domaingv *gv, const struct ddsi_guid *guid, uint32_t bes, const struct ddsi_guid *privileged_pp_guid, struct ddsi_addrset *as_default, struct ddsi_addrset *as_meta, const struct ddsi_plist *plist, dds_duration_t tlease_dur, ddsi_vendorid_t vendor, unsigned custom_flags, ddsrt_wctime_t timestamp, ddsi_seqno_t seq);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_PROXY_PARTICIPANT_H */
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright(c) 2023 ZettaScale Technology 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 DDSI_PSMX_H
|
||||
#define DDSI_PSMX_H
|
||||
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_psmx_instance_locators {
|
||||
uint32_t length;
|
||||
struct {
|
||||
char *psmx_instance_name;
|
||||
ddsi_locator_t locator;
|
||||
} *instances;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DDSI_PSMX_H
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_QOSMATCH_H
|
||||
#define DDSI_QOSMATCH_H
|
||||
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsi/ddsi_typelib.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_domaingv;
|
||||
|
||||
/**
|
||||
* @brief perform reader/writer QoS (and topic name, type name, partition) matching
|
||||
* @component qos_matching
|
||||
*
|
||||
* @param gv domain globals
|
||||
* @param rd_qos reader qos
|
||||
* @param wr_qos writer qos
|
||||
* @param mask can be used to exclude some of these (including topic name and type name, so be careful!)
|
||||
* @param reason will be set to the policy id of one of the mismatching QoS, or to DDS_INVALID_QOS_POLICY_ID if there is no mismatch or if the mismatch is in topic or type name (those are not really QoS and don't have a policy id)
|
||||
* @param rd_type_pair minimal and complete ddsi type for the reader
|
||||
* @param wr_type_pair minimal and complete ddsi type for the writer
|
||||
* @param rd_typeid_req_lookup is set to true in case the matching cannot be completed because of missing type information. A type-lookup request is required to get the details of the type to do the qos matching (e.g. check assignability)
|
||||
* @param wr_typeid_req_lookup see rd_typeid_req_lookup
|
||||
*
|
||||
* @returns true in case of a match, false otherwise
|
||||
*/
|
||||
bool ddsi_qos_match_mask_p (
|
||||
struct ddsi_domaingv *gv,
|
||||
const dds_qos_t *rd_qos,
|
||||
const dds_qos_t *wr_qos,
|
||||
uint64_t mask,
|
||||
dds_qos_policy_id_t *reason
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
, const struct ddsi_type_pair *rd_type_pair
|
||||
, const struct ddsi_type_pair *wr_type_pair
|
||||
#endif
|
||||
#ifdef DDS_HAS_TYPE_DISCOVERY
|
||||
, bool *rd_typeid_req_lookup
|
||||
, bool *wr_typeid_req_lookup
|
||||
#endif
|
||||
);
|
||||
|
||||
/** @component qos_matching */
|
||||
bool ddsi_qos_match_p (
|
||||
struct ddsi_domaingv *gv,
|
||||
const dds_qos_t *rd_qos,
|
||||
const dds_qos_t *wr_qos,
|
||||
dds_qos_policy_id_t *reason
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
, const struct ddsi_type_pair *rd_type_pair
|
||||
, const struct ddsi_type_pair *wr_type_pair
|
||||
#endif
|
||||
#ifdef DDS_HAS_TYPE_DISCOVERY
|
||||
, bool *rd_typeid_req_lookup
|
||||
, bool *wr_typeid_req_lookup
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_QOSMATCH_H */
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_RADMIN_H
|
||||
#define DDSI_RADMIN_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsrt/align.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
#include "dds/ddsi/ddsi_protocol.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_rbuf;
|
||||
struct ddsi_rmsg;
|
||||
struct ddsi_rdata;
|
||||
struct ddsi_rsample_info;
|
||||
struct ddsi_tran_conn;
|
||||
|
||||
struct ddsi_rmsg_chunk {
|
||||
struct ddsi_rbuf *rbuf;
|
||||
struct ddsi_rmsg_chunk *next;
|
||||
|
||||
/* Size is 0 after initial allocation, must be set with
|
||||
ddsi_rmsg_setsize after receiving a packet from the kernel and
|
||||
before processing it. */
|
||||
union {
|
||||
uint32_t size;
|
||||
|
||||
/* to ensure reasonable alignment of payload */
|
||||
int64_t l;
|
||||
double d;
|
||||
void *p;
|
||||
} u;
|
||||
|
||||
/* unsigned char payload[] -- disallowed by C99 because of nesting */
|
||||
};
|
||||
|
||||
struct ddsi_rmsg {
|
||||
/* Reference count: all references to rdatas of this message are
|
||||
counted. The rdatas themselves do not have a reference count.
|
||||
|
||||
The refcount is biased by RMSG_REFCOUNT_UNCOMMITED_BIAS while
|
||||
still being inserted to allow verifying it is still uncommitted
|
||||
when allocating memory, increasing refcounts, &c.
|
||||
|
||||
Each rdata adds RMS_REFCOUNT_RDATA_BIAS when it leaves
|
||||
defragmentation until it has been rejected by reordering or has
|
||||
been scheduled for delivery. This allows delaying the
|
||||
decrementing of refcounts until after a sample has been added to
|
||||
all radmins even though be delivery of it may take place in
|
||||
concurrently. */
|
||||
ddsrt_atomic_uint32_t refcount;
|
||||
|
||||
/* Worst-case memory requirement is gigantic (64kB UDP packet, only
|
||||
1-byte final fragments, each of one a new interval, or maybe 1
|
||||
byte messages, destined for many readers and in each case
|
||||
introducing a new interval, with receiver state changes in
|
||||
between, &c.), so we can either:
|
||||
|
||||
- allocate a _lot_ and cover the worst case
|
||||
|
||||
- allocate enough for all "reasonable" cases, discarding data when that limit is hit
|
||||
|
||||
- dynamically add chunks of memory, and even entire receive buffers.
|
||||
|
||||
The latter seems the best approach, especially because it also
|
||||
covers the second one. We treat the other chunks specially,
|
||||
which is not strictly required but also not entirely
|
||||
unreasonable, considering that the first chunk has the refcount &
|
||||
the real packet. */
|
||||
struct ddsi_rmsg_chunk *lastchunk;
|
||||
|
||||
/* whether to log */
|
||||
bool trace;
|
||||
|
||||
struct ddsi_rmsg_chunk chunk;
|
||||
};
|
||||
DDSRT_STATIC_ASSERT (sizeof (struct ddsi_rmsg) == offsetof (struct ddsi_rmsg, chunk) + sizeof (struct ddsi_rmsg_chunk));
|
||||
#define DDSI_RMSG_PAYLOAD(m) ((unsigned char *) (m + 1))
|
||||
#define DDSI_RMSG_PAYLOADOFF(m, o) (DDSI_RMSG_PAYLOAD (m) + (o))
|
||||
|
||||
|
||||
struct ddsi_rdata {
|
||||
struct ddsi_rmsg *rmsg; /* received (and refcounted) in rmsg */
|
||||
struct ddsi_rdata *nextfrag; /* fragment chain */
|
||||
uint32_t min, maxp1; /* fragment as byte offsets */
|
||||
uint16_t submsg_zoff; /* offset to submessage from packet start, or 0 */
|
||||
uint16_t payload_zoff; /* offset to payload from packet start */
|
||||
uint16_t keyhash_zoff; /* offset to keyhash from packet start, or 0 */
|
||||
#ifndef NDEBUG
|
||||
ddsrt_atomic_uint32_t refcount_bias_added;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* All relative offsets in packets that we care about (submessage
|
||||
header, payload, writer info) are at multiples of 4 bytes and
|
||||
within 64kB, so technically we can make do with 14 bits instead of
|
||||
16, in case we run out of space.
|
||||
|
||||
If we _really_ need to squeeze out every last bit, only the submsg
|
||||
offset really requires 14 bits, the for the others we could use an
|
||||
offset relative to the submessage header so that it is limited by
|
||||
the maximum size of the inline QoS ... Defining the macros now, so
|
||||
we have the option to do wild things. */
|
||||
#ifndef NDEBUG
|
||||
#define DDSI_ZOFF_TO_OFF(zoff) ((unsigned) (zoff))
|
||||
#define DDSI_OFF_TO_ZOFF(off) (assert ((off) < 65536), ((unsigned short) (off)))
|
||||
#else
|
||||
#define DDSI_ZOFF_TO_OFF(zoff) ((unsigned) (zoff))
|
||||
#define DDSI_OFF_TO_ZOFF(off) ((unsigned short) (off))
|
||||
#endif
|
||||
#define DDSI_RDATA_PAYLOAD_OFF(rdata) DDSI_ZOFF_TO_OFF ((rdata)->payload_zoff)
|
||||
#define DDSI_RDATA_SUBMSG_OFF(rdata) DDSI_ZOFF_TO_OFF ((rdata)->submsg_zoff)
|
||||
#define DDSI_RDATA_KEYHASH_OFF(rdata) DDSI_ZOFF_TO_OFF ((rdata)->keyhash_zoff)
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_RADMIN_H */
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_RHC_H
|
||||
#define DDSI_RHC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_qos;
|
||||
struct ddsi_rhc;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_serdata;
|
||||
|
||||
struct ddsi_writer_info
|
||||
{
|
||||
ddsi_guid_t guid;
|
||||
bool auto_dispose;
|
||||
int32_t ownership_strength;
|
||||
uint64_t iid;
|
||||
#ifdef DDS_HAS_LIFESPAN
|
||||
ddsrt_mtime_t lifespan_exp;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef void (*ddsi_rhc_free_t) (struct ddsi_rhc *rhc);
|
||||
typedef bool (*ddsi_rhc_store_t) (struct ddsi_rhc *rhc, const struct ddsi_writer_info *wrinfo, struct ddsi_serdata *sample, struct ddsi_tkmap_instance *tk);
|
||||
typedef void (*ddsi_rhc_unregister_wr_t) (struct ddsi_rhc *rhc, const struct ddsi_writer_info *wrinfo);
|
||||
typedef void (*ddsi_rhc_relinquish_ownership_t) (struct ddsi_rhc *rhc, const uint64_t wr_iid);
|
||||
typedef void (*ddsi_rhc_set_qos_t) (struct ddsi_rhc *rhc, const struct dds_qos *qos);
|
||||
|
||||
struct ddsi_rhc_ops {
|
||||
ddsi_rhc_store_t store;
|
||||
ddsi_rhc_unregister_wr_t unregister_wr;
|
||||
ddsi_rhc_relinquish_ownership_t relinquish_ownership;
|
||||
ddsi_rhc_set_qos_t set_qos;
|
||||
ddsi_rhc_free_t free;
|
||||
};
|
||||
|
||||
struct ddsi_rhc {
|
||||
const struct ddsi_rhc_ops *ops;
|
||||
};
|
||||
|
||||
/** @component rhc_if */
|
||||
inline bool ddsi_rhc_store (struct ddsi_rhc *rhc, const struct ddsi_writer_info *wrinfo, struct ddsi_serdata *sample, struct ddsi_tkmap_instance *tk) {
|
||||
return rhc->ops->store (rhc, wrinfo, sample, tk);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_RHC_H */
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_SECURITY_MSG_H
|
||||
#define DDSI_SECURITY_MSG_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDS_SECURITY_AUTH_REQUEST "dds.sec.auth_request"
|
||||
#define DDS_SECURITY_AUTH_HANDSHAKE "dds.sec.auth"
|
||||
|
||||
#define DDS_SECURITY_AUTH_VERSION_MAJOR 1
|
||||
#define DDS_SECURITY_AUTH_VERSION_MINOR 0
|
||||
|
||||
#define DDS_SECURITY_AUTH_TOKEN_CLASS_ID_BASE "DDS:Auth:PKI-DH:"
|
||||
#define DDS_SECURITY_AUTH_TOKEN_CLASS_ID DDS_SECURITY_AUTH_TOKEN_CLASS_ID_BASE DDSRT_STRINGIFY(DDS_SECURITY_AUTH_VERSION_MAJOR) "." DDSRT_STRINGIFY(DDS_SECURITY_AUTH_VERSION_MINOR)
|
||||
|
||||
#define DDS_SECURITY_AUTH_REQUEST_TOKEN_CLASS_ID DDS_SECURITY_AUTH_TOKEN_CLASS_ID "+AuthReq"
|
||||
#define DDS_SECURITY_AUTH_HANDSHAKE_REQUEST_TOKEN_ID DDS_SECURITY_AUTH_TOKEN_CLASS_ID "+Req"
|
||||
#define DDS_SECURITY_AUTH_HANDSHAKE_REPLY_TOKEN_ID DDS_SECURITY_AUTH_TOKEN_CLASS_ID "+Reply"
|
||||
#define DDS_SECURITY_AUTH_HANDSHAKE_FINAL_TOKEN_ID DDS_SECURITY_AUTH_TOKEN_CLASS_ID "+Final"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDS_HAS_SECURITY */
|
||||
|
||||
#endif /* DDSI_SECURITY_MSG_H */
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_OMG_SECURITY_H
|
||||
#define DDSI_OMG_SECURITY_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
|
||||
#include "dds/ddsi/ddsi_participant.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_SECURITY
|
||||
|
||||
/**
|
||||
* @brief Check if security is enabled for the participant.
|
||||
* @component security_entity
|
||||
*
|
||||
* @param[in] pp Participant to check if it is secure.
|
||||
*
|
||||
* @returns bool True if participant is secure
|
||||
*/
|
||||
bool ddsi_omg_participant_is_secure(const struct ddsi_participant *pp);
|
||||
|
||||
/**
|
||||
* @brief Check if security allows to create the topic.
|
||||
* @component security_entity
|
||||
*
|
||||
* This function checks with access control if is allowed to create
|
||||
* this topic for the specified domain.
|
||||
*
|
||||
* @param[in] gv The domain global information.
|
||||
* @param[in] pp_guid The participant guid.
|
||||
* @param[in] topic_name The name of the topic.
|
||||
* @param[in] qos The topic QoS used.
|
||||
*
|
||||
* @returns bool
|
||||
* @retval true Creation of the topic is allowed
|
||||
* @retval false Otherwise.
|
||||
*/
|
||||
bool ddsi_omg_security_check_create_topic (const struct ddsi_domaingv *gv, const ddsi_guid_t *pp_guid, const char *topic_name, const struct dds_qos *qos);
|
||||
|
||||
/**
|
||||
* @brief Check if security allows to create the reader.
|
||||
* @component security_entity
|
||||
*
|
||||
* This function checks with access control if is allowed to create
|
||||
* this reader for the specified domain.
|
||||
*
|
||||
* @param[in] pp Participant on which the topic is being created.
|
||||
* @param[in] domain_id The corresponding domain_id.
|
||||
* @param[in] topic_name The name of the topic.
|
||||
* @param[in] reader_qos The reader QoS used.
|
||||
*
|
||||
* @returns bool
|
||||
* @retval true Creation of the writer is allowed
|
||||
* @retval false Otherwise.
|
||||
*/
|
||||
bool ddsi_omg_security_check_create_reader (struct ddsi_participant *pp, uint32_t domain_id, const char *topic_name, const struct dds_qos *reader_qos);
|
||||
|
||||
/**
|
||||
* @brief Check if security allows to create the writer.
|
||||
* @component security_entity
|
||||
*
|
||||
* This function checks with access control if is allowed to create
|
||||
* this writer for the specified domain.
|
||||
*
|
||||
* @param[in] pp Participant on which the topic is being created.
|
||||
* @param[in] domain_id The corresponding domain_id.
|
||||
* @param[in] topic_name The name of the topic.
|
||||
* @param[in] writer_qos The writer QoS used.
|
||||
*
|
||||
* @returns bool
|
||||
* @retval true Creation of the writer is allowed
|
||||
* @retval false Otherwise.
|
||||
*/
|
||||
bool ddsi_omg_security_check_create_writer (struct ddsi_participant *pp, uint32_t domain_id, const char *topic_name, const struct dds_qos *writer_qos);
|
||||
|
||||
#else /* DDS_HAS_SECURITY */
|
||||
|
||||
#include "dds/ddsi/ddsi_unused.h"
|
||||
|
||||
/** @component security_entity */
|
||||
inline bool ddsi_omg_participant_is_secure(UNUSED_ARG(const struct ddsi_participant *pp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @component security_entity */
|
||||
inline bool ddsi_omg_security_check_create_topic (UNUSED_ARG(const struct ddsi_domaingv *gv), UNUSED_ARG(const ddsi_guid_t *pp_guid), UNUSED_ARG(const char *topic_name), UNUSED_ARG(const struct dds_qos *qos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @component security_entity */
|
||||
inline bool ddsi_omg_security_check_create_reader (UNUSED_ARG(struct ddsi_participant *pp), UNUSED_ARG(uint32_t domain_id), UNUSED_ARG(const char *topic_name), UNUSED_ARG(const struct dds_qos *reader_qos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @component security_entity */
|
||||
inline bool ddsi_omg_security_check_create_writer (UNUSED_ARG(struct ddsi_participant *pp), UNUSED_ARG(uint32_t domain_id), UNUSED_ARG(const char *topic_name), UNUSED_ARG(const struct dds_qos *writer_qos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* DDS_HAS_SECURITY */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_OMG_SECURITY_H */
|
||||
+413
@@ -0,0 +1,413 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_SERDATA_H
|
||||
#define DDSI_SERDATA_H
|
||||
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsrt/iovec.h"
|
||||
#include "dds/ddsi/ddsi_sertype.h"
|
||||
#include "dds/ddsi/ddsi_keyhash.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_rdata;
|
||||
struct dds_loaned_sample;
|
||||
|
||||
struct ddsi_serdata {
|
||||
const struct ddsi_serdata_ops *ops; /* cached from type->serdata_ops */
|
||||
uint32_t hash;
|
||||
ddsrt_atomic_uint32_t refc;
|
||||
enum ddsi_serdata_kind kind;
|
||||
const struct ddsi_sertype *type;
|
||||
|
||||
/* these get set by generic code after creating the serdata */
|
||||
ddsrt_wctime_t timestamp;
|
||||
uint32_t statusinfo;
|
||||
|
||||
/* FIXME: can I get rid of this one? */
|
||||
ddsrt_mtime_t twrite; /* write time, not source timestamp, set post-throttling */
|
||||
|
||||
struct dds_loaned_sample *loan;
|
||||
};
|
||||
|
||||
/* Serialised size of sample inclusive of DDSI encoding header
|
||||
- uint32_t because the protocol can't handle samples larger than 4GB anyway
|
||||
- FIXME: get the encoding header out of the serialised data */
|
||||
typedef uint32_t (*ddsi_serdata_size_t) (const struct ddsi_serdata *d)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Free a serdata (called by unref when refcount goes to 0) */
|
||||
typedef void (*ddsi_serdata_free_t) (struct ddsi_serdata *d)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/* Construct a serdata from a fragchain received over the network
|
||||
- "kind" is KEY or DATA depending on the type of payload
|
||||
- "size" is the serialised size of the sample, inclusive of DDSI encoding header
|
||||
- the first fragchain always contains the encoding header in its entirety
|
||||
- fragchains may overlap, though I have never seen any DDS implementation
|
||||
actually send such nasty fragments
|
||||
- FIXME: get the encoding header out of the serialised data */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_from_ser_t) (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Exactly like ddsi_serdata_from_ser_t, but with the data in an iovec and guaranteed absence of overlap */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_from_ser_iov_t) (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, ddsrt_msg_iovlen_t niov, const ddsrt_iovec_t *iov, size_t size)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Construct a serdata from a keyhash (an SDK_KEY by definition) */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_from_keyhash_t) (const struct ddsi_sertype *type, const struct ddsi_keyhash *keyhash)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Construct a serdata from an application sample
|
||||
- "kind" is KEY or DATA depending on the operation invoked by the application;
|
||||
e.g., write results in kind = DATA, dispose in kind = KEY. The important bit
|
||||
is to not assume anything of the contents of non-key fields if kind = KEY
|
||||
unless additional application knowledge is available */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_from_sample_t) (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const void *sample)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Construct a untyped serdata with just a keyvalue given a normal serdata (either key or data)
|
||||
- used for mapping key values to instance ids in tkmap
|
||||
- two reasons: size (keys are typically smaller than samples), and data in tkmap
|
||||
is shared across topics
|
||||
- whether a serdata is untyped or not is known from the context, and the topic
|
||||
field may have any value for a untyped serdata (so in some cases, one can
|
||||
simply do "return ddsi_serdata_ref(d);"
|
||||
*/
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_to_untyped_t) (const struct ddsi_serdata *d)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Fill buffer with 'size' bytes of serialised data, starting from 'off'
|
||||
- 0 <= off < off+sz <= alignup4(size(d))
|
||||
- bytes at offsets 0 .. 3 are DDSI encoding header, size(d) includes that header
|
||||
- what to copy for bytes in [size(d), alignup4(size(d))) depends on the serdata
|
||||
implementation, the protocol treats them as undefined
|
||||
- FIXME: get the encoding header out of the serialised data */
|
||||
typedef void (*ddsi_serdata_to_ser_t) (const struct ddsi_serdata *d, size_t off, size_t sz, void *buf)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/* Provide a pointer to 'size' bytes of serialised data, starting from 'off'
|
||||
- see ddsi_serdata_to_ser_t above
|
||||
- instead of copying, this gives a reference that must remain valid until the
|
||||
corresponding call to to_ser_unref
|
||||
- multiple calls to to_ser_ref() may be issued in parallel
|
||||
- lazily creating the serialised representation is allowed (though I'm not sure
|
||||
how that would work with knowing the serialised size beforehand ...) */
|
||||
typedef struct ddsi_serdata * (*ddsi_serdata_to_ser_ref_t) (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Release a lock on serialised data
|
||||
- ref was previousy filled by ddsi_serdata_to_ser_ref_t */
|
||||
typedef void (*ddsi_serdata_to_ser_unref_t) (struct ddsi_serdata *d, const ddsrt_iovec_t *ref)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/* Turn serdata into an application sample (or just the key values if only key values are
|
||||
available); return false on error (typically out-of-memory, but if from_ser doesn't do any
|
||||
validation it might be a deserialisation error, too).
|
||||
|
||||
If (bufptr != 0), then *bufptr .. buflim is space to be used from *bufptr up (with minimal
|
||||
padding) for any data in the sample that needs to be allocated (e.g., strings, sequences);
|
||||
otherwise malloc() is to be used for those. (This allows read/take to be given a block of memory
|
||||
by the caller.) */
|
||||
typedef bool (*ddsi_serdata_to_sample_t) (const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim)
|
||||
ddsrt_nonnull ((1, 2)) ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Create a sample from a untyped serdata, as returned by serdata_to_untyped. This sample
|
||||
obviously has just the key fields filled in and is used for generating invalid samples. */
|
||||
typedef bool (*ddsi_serdata_untyped_to_sample_t) (const struct ddsi_sertype *type, const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim)
|
||||
ddsrt_nonnull ((1, 2, 3)) ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/* Test key values of two serdatas for equality. The two will have the same ddsi_serdata_ops,
|
||||
but are not necessarily of the same topic (one can decide to never consider them equal if they
|
||||
are of different topics, of course; but the nice thing about _not_ doing that is that all
|
||||
instances with a certain key value with have the same instance id, and that in turn makes
|
||||
computing equijoins across topics much simpler). */
|
||||
typedef bool (*ddsi_serdata_eqkey_t) (const struct ddsi_serdata *a, const struct ddsi_serdata *b)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/* Print a serdata into the provided buffer (truncating as necessary)
|
||||
- topic is present for supporting printing of "untyped" samples
|
||||
- buf != NULL, bufsize > 0 on input
|
||||
- buf must always be terminated with a nul character on return
|
||||
- returns the number of characters (excluding the terminating 0) needed to print it
|
||||
in full (or, as an optimization, it may pretend that it has printed it in full,
|
||||
returning bufsize-1) if it had to truncate) */
|
||||
typedef size_t (*ddsi_serdata_print_t) (const struct ddsi_sertype *type, const struct ddsi_serdata *d, char *buf, size_t size)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/* Add keyhash (from serdata) to buffer (forcing md5 when necessary).
|
||||
- key needs to be set within serdata (can already be md5)
|
||||
- buf needs to be at least 16 bytes large */
|
||||
typedef void (*ddsi_serdata_get_keyhash_t) (const struct ddsi_serdata *d, struct ddsi_keyhash *buf, bool force_md5)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
// Used for taking a loaned sample and constructing a serdata around this
|
||||
// takes over ownership of loan on success (leaves it unchanged on failure)
|
||||
typedef struct ddsi_serdata* (*ddsi_serdata_from_loan_t) (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const char *sample, struct dds_loaned_sample *loaned_sample, bool will_require_cdr)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
// Used for constructing a serdata from data received on a PSMX
|
||||
typedef struct ddsi_serdata* (*ddsi_serdata_from_psmx_t) (const struct ddsi_sertype *type, struct dds_loaned_sample *loaned_sample)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
struct ddsi_serdata_ops {
|
||||
ddsi_serdata_eqkey_t eqkey;
|
||||
ddsi_serdata_size_t get_size;
|
||||
ddsi_serdata_from_ser_t from_ser;
|
||||
ddsi_serdata_from_ser_iov_t from_ser_iov;
|
||||
ddsi_serdata_from_keyhash_t from_keyhash;
|
||||
ddsi_serdata_from_sample_t from_sample;
|
||||
ddsi_serdata_to_ser_t to_ser;
|
||||
ddsi_serdata_to_ser_ref_t to_ser_ref;
|
||||
ddsi_serdata_to_ser_unref_t to_ser_unref;
|
||||
ddsi_serdata_to_sample_t to_sample;
|
||||
ddsi_serdata_to_untyped_t to_untyped;
|
||||
ddsi_serdata_untyped_to_sample_t untyped_to_sample;
|
||||
ddsi_serdata_free_t free;
|
||||
ddsi_serdata_print_t print;
|
||||
ddsi_serdata_get_keyhash_t get_keyhash;
|
||||
ddsi_serdata_from_loan_t from_loaned_sample;
|
||||
ddsi_serdata_from_psmx_t from_psmx;
|
||||
};
|
||||
|
||||
#define DDSI_SERDATA_HAS_PRINT 1
|
||||
#define DDSI_SERDATA_HAS_FROM_SER_IOV 1
|
||||
#define DDSI_SERDATA_HAS_GET_KEYHASH 1
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_serdata_init (struct ddsi_serdata *d, const struct ddsi_sertype *tp, enum ddsi_serdata_kind kind)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Return a pointer to the keyhash in the message fragchain if it was present, or else NULL.
|
||||
* @component typesupport_if
|
||||
*
|
||||
* @param[in] fragchain the fragchain argument passed to @ref ddsi_serdata_from_ser (the first one, not any subsequent ones)
|
||||
* @returns A pointer to the keyhash in the message if it was present, NULL if not. The lifetime is at least that of the fragchain itself.
|
||||
*/
|
||||
const ddsi_keyhash_t *ddsi_serdata_keyhash_from_fragchain (const struct ddsi_rdata *fragchain)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Return a copy of a serdata with possible type conversion
|
||||
* @component typesupport_if
|
||||
*
|
||||
* This constructs a new one from the serialised representation of `serdata`.
|
||||
* This can fail, in which case it returns NULL.
|
||||
*
|
||||
* @param[in] type sertype the returned serdata must have
|
||||
* @param[in] serdata source sample
|
||||
* @returns A reference to a serdata that is equivalent to the input with the correct
|
||||
* type, or a null pointer on failure. The reference must be released with @ref
|
||||
* ddsi_serdata_unref.
|
||||
*/
|
||||
struct ddsi_serdata *ddsi_serdata_copy_as_type (const struct ddsi_sertype *type, const struct ddsi_serdata *serdata)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/**
|
||||
* @brief Return a reference to a serdata with possible type conversion
|
||||
* @component typesupport_if
|
||||
*
|
||||
* If `serdata` is of type `type`, this increments the reference count and returns
|
||||
* `serdata`. Otherwise, it constructs a new one as if by @ref ddsi_serdata_copy_as_type.
|
||||
* This can fail, in which case it returns NULL.
|
||||
*
|
||||
* @param[in] type sertype the returned serdata must have
|
||||
* @param[in] serdata source sample (untouched except for the reference count and/or
|
||||
* extracting the serialised representation)
|
||||
* @returns A reference to a serdata that is equivalent to the input with the correct
|
||||
* topic, or a null pointer on failure. The reference must be released with @ref
|
||||
* ddsi_serdata_unref.
|
||||
*/
|
||||
struct ddsi_serdata *ddsi_serdata_ref_as_type (const struct ddsi_sertype *type, struct ddsi_serdata *serdata)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_ref (const struct ddsi_serdata *serdata_const)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_ref (const struct ddsi_serdata *serdata_const) {
|
||||
#if defined (__cplusplus)
|
||||
DDSRT_WARNING_GNUC_OFF(old-style-cast)
|
||||
DDSRT_WARNING_CLANG_OFF(old-style-cast)
|
||||
#endif
|
||||
struct ddsi_serdata *serdata = (struct ddsi_serdata *)serdata_const;
|
||||
#if defined (__cplusplus)
|
||||
DDSRT_WARNING_CLANG_ON(old-style-cast)
|
||||
DDSRT_WARNING_GNUC_ON(old-style-cast)
|
||||
#endif
|
||||
ddsrt_atomic_inc32 (&serdata->refc);
|
||||
return serdata;
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_serdata_unref (struct ddsi_serdata *serdata)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline void ddsi_serdata_unref (struct ddsi_serdata *serdata) {
|
||||
if (ddsrt_atomic_dec32_ov (&serdata->refc) == 1)
|
||||
serdata->ops->free (serdata);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsi_serdata_size (const struct ddsi_serdata *d)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline uint32_t ddsi_serdata_size (const struct ddsi_serdata *d) {
|
||||
return d->ops->get_size (d);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_ser (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_ser (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size) {
|
||||
return type->serdata_ops->from_ser (type, kind, fragchain, size);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_ser_iov (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, ddsrt_msg_iovlen_t niov, const ddsrt_iovec_t *iov, size_t size)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_ser_iov (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, ddsrt_msg_iovlen_t niov, const ddsrt_iovec_t *iov, size_t size) {
|
||||
return type->serdata_ops->from_ser_iov (type, kind, niov, iov, size);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_keyhash (const struct ddsi_sertype *type, const struct ddsi_keyhash *keyhash)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_keyhash (const struct ddsi_sertype *type, const struct ddsi_keyhash *keyhash) {
|
||||
return type->serdata_ops->from_keyhash (type, keyhash);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_sample (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const void *sample)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_sample (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const void *sample) {
|
||||
return type->serdata_ops->from_sample (type, kind, sample);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_to_untyped (const struct ddsi_serdata *d)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_to_untyped (const struct ddsi_serdata *d) {
|
||||
struct ddsi_serdata * const d1 = d->ops->to_untyped (d);
|
||||
assert (d1->loan == NULL);
|
||||
return d1;
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_serdata_to_ser (const struct ddsi_serdata *d, size_t off, size_t sz, void *buf)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline void ddsi_serdata_to_ser (const struct ddsi_serdata *d, size_t off, size_t sz, void *buf) {
|
||||
d->ops->to_ser (d, off, sz, buf);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref)
|
||||
ddsrt_nonnull_all ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_to_ser_ref (const struct ddsi_serdata *d, size_t off, size_t sz, ddsrt_iovec_t *ref) {
|
||||
return d->ops->to_ser_ref (d, off, sz, ref);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const ddsrt_iovec_t *ref)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline void ddsi_serdata_to_ser_unref (struct ddsi_serdata *d, const ddsrt_iovec_t *ref) {
|
||||
d->ops->to_ser_unref (d, ref);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline bool ddsi_serdata_to_sample (const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim)
|
||||
ddsrt_nonnull ((1, 2)) ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline bool ddsi_serdata_to_sample (const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim) {
|
||||
return d->ops->to_sample (d, sample, bufptr, buflim);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline bool ddsi_serdata_untyped_to_sample (const struct ddsi_sertype *type, const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim)
|
||||
ddsrt_nonnull ((1, 2, 3)) ddsrt_attribute_warn_unused_result;
|
||||
|
||||
inline bool ddsi_serdata_untyped_to_sample (const struct ddsi_sertype *type, const struct ddsi_serdata *d, void *sample, void **bufptr, void *buflim) {
|
||||
return d->ops->untyped_to_sample (type, d, sample, bufptr, buflim);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline bool ddsi_serdata_eqkey (const struct ddsi_serdata *a, const struct ddsi_serdata *b)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline bool ddsi_serdata_eqkey (const struct ddsi_serdata *a, const struct ddsi_serdata *b) {
|
||||
return a->ops->eqkey (a, b);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline size_t ddsi_serdata_print (const struct ddsi_serdata *d, char *buf, size_t size)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline size_t ddsi_serdata_print (const struct ddsi_serdata *d, char *buf, size_t size) {
|
||||
return d->ops->print (d->type, d, buf, size);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline size_t ddsi_serdata_print_untyped (const struct ddsi_sertype *type, const struct ddsi_serdata *d, char *buf, size_t size)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline size_t ddsi_serdata_print_untyped (const struct ddsi_sertype *type, const struct ddsi_serdata *d, char *buf, size_t size) {
|
||||
if (d->ops->print)
|
||||
return d->ops->print (type, d, buf, size);
|
||||
else
|
||||
{
|
||||
buf[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_serdata_get_keyhash (const struct ddsi_serdata *d, struct ddsi_keyhash *buf, bool force_md5)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
inline void ddsi_serdata_get_keyhash (const struct ddsi_serdata *d, struct ddsi_keyhash *buf, bool force_md5) {
|
||||
d->ops->get_keyhash (d, buf, force_md5);
|
||||
}
|
||||
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_loaned_sample(const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const char *sample, struct dds_loaned_sample *loan, bool will_require_cdr) ddsrt_nonnull_all;
|
||||
|
||||
/** @component typesupport_if */
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_loaned_sample(const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const char *sample, struct dds_loaned_sample *loan, bool will_require_cdr)
|
||||
{
|
||||
return type->serdata_ops->from_loaned_sample(type, kind, sample, loan, will_require_cdr);
|
||||
}
|
||||
|
||||
DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_psmx(const struct ddsi_sertype *type, struct dds_loaned_sample *data) ddsrt_nonnull_all;
|
||||
|
||||
inline struct ddsi_serdata *ddsi_serdata_from_psmx(const struct ddsi_sertype *type, struct dds_loaned_sample *data)
|
||||
{
|
||||
return type->serdata_ops->from_psmx(type, data);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //DDSI_SERDATA_H
|
||||
|
||||
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_SERTYPE_H
|
||||
#define DDSI_SERTYPE_H
|
||||
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
#include "dds/ddsi/ddsi_typewrap.h"
|
||||
#include "dds/ddsc/dds_public_alloc.h"
|
||||
#include "dds/ddsc/dds_data_type_properties.h"
|
||||
#include "dds/cdr/dds_cdrstream.h"
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_serdata_ops;
|
||||
struct ddsi_sertype_ops;
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_typeid;
|
||||
struct ddsi_type_pair;
|
||||
|
||||
enum ddsi_serdata_kind {
|
||||
SDK_EMPTY,
|
||||
SDK_KEY,
|
||||
SDK_DATA
|
||||
};
|
||||
|
||||
#define DDSI_SERTYPE_REGISTERING 0x40000000u // set prior to setting gv
|
||||
#define DDSI_SERTYPE_REGISTERED 0x80000000u // set after setting gv
|
||||
#define DDSI_SERTYPE_REFC_MASK 0x0fffffffu
|
||||
|
||||
struct ddsi_sertype {
|
||||
const struct ddsi_sertype_ops *ops;
|
||||
const struct ddsi_serdata_ops *serdata_ops;
|
||||
uint32_t serdata_basehash;
|
||||
uint32_t has_key : 1;
|
||||
uint32_t request_keyhash : 1;
|
||||
uint32_t is_memcpy_safe : 1;
|
||||
uint32_t allowed_data_representation; /* Allowed data representations set in IDL for this type, or DDS_DATA_REPRESENTATION_RESTRICT_DEFAULT in case of
|
||||
no restrictions in the IDL. Unsupported representations for the type are left out when creating the sertype. */
|
||||
char *type_name;
|
||||
ddsrt_atomic_voidp_t gv; /* set during registration */
|
||||
ddsrt_atomic_uint32_t flags_refc; /* counts refs from entities (topic, reader, writer), not from data */
|
||||
const struct ddsi_sertype *base_sertype; /* counted ref to sertype used to derive this sertype, used to overwrite the serdata_ops for a specific data representation */
|
||||
uint32_t sizeof_type;
|
||||
dds_data_type_properties_t data_type_props; /* representation of properties of the data type */
|
||||
};
|
||||
|
||||
/* The old and the new happen to have the same memory layout on a 64-bit machine
|
||||
and so any user that memset's the ddsi_sertype to 0 before filling out the
|
||||
required fields gets unchanged behaviour. 32-bit machines have a different
|
||||
layout and no such luck.
|
||||
|
||||
There are presumably very few users of this type outside Cyclone DDS itself,
|
||||
but the ROS2 RMW implementation does use it -- indeed, it prompted the change.
|
||||
This define makes it possible to have a single version of the source that is
|
||||
compatible with the old and the new definition, even if it is only partially
|
||||
binary compatible. */
|
||||
#define DDSI_SERTOPIC_HAS_TOPICKIND_NO_KEY 1
|
||||
|
||||
/* Type changed: name_type_name and ii removed and gv added; and the set of
|
||||
operations got extended by the a predicate for testing to sertypes (with the
|
||||
same "ops") for equality ("equal") as well as a function for hashing the
|
||||
non-generic part of the sertype definition (via "hash"). These two operations
|
||||
make it possible to intern sertypes without duplicates, which has become
|
||||
relevant now that multiple ddsi_sertypes can be associated with a single topic
|
||||
name.
|
||||
|
||||
Testing for DDSI_SERTOPIC_HAS_EQUAL_AND_HASH allows one to have a single source
|
||||
that can handle both variants, but there's no binary compatbility. */
|
||||
#define DDSI_SERTOPIC_HAS_EQUAL_AND_HASH 1
|
||||
|
||||
/* It was a bad decision to have a boolean argument in "init" specifying whether
|
||||
the entity kind should say "with key" or "without key". A general "flags"
|
||||
argument is much more flexible ... */
|
||||
#define DDSI_SERTYPE_HAS_SERTYPE_INIT_FLAGS 1
|
||||
|
||||
/* Called to compare two sertypes for equality, if it is already known that
|
||||
type name, kind_no_Key, and operations are all the same. (serdata_basehash
|
||||
is computed from the set of operations.) */
|
||||
typedef bool (*ddsi_sertype_equal_t) (const struct ddsi_sertype *a, const struct ddsi_sertype *b);
|
||||
|
||||
/* Hash the custom components of a sertype (this XOR'd with a hash computed from
|
||||
the fields that are defined in struct ddsi_sertype) */
|
||||
typedef uint32_t (*ddsi_sertype_hash_t) (const struct ddsi_sertype *tp);
|
||||
|
||||
/* Called when the refcount dropped to zero */
|
||||
typedef void (*ddsi_sertype_free_t) (struct ddsi_sertype *tp);
|
||||
|
||||
/* Zero out a sample, used for generating samples from just a key value and in cleaning up
|
||||
after dds_return_loan */
|
||||
typedef void (*ddsi_sertype_zero_samples_t) (const struct ddsi_sertype *d, void *samples, size_t count);
|
||||
|
||||
/* (Re)allocate an array of samples, used in growing loaned sample arrays in dds_read */
|
||||
typedef void (*ddsi_sertype_realloc_samples_t) (void **ptrs, const struct ddsi_sertype *d, void *old, size_t oldcount, size_t count);
|
||||
|
||||
/* Release any memory allocated by ddsi_sertype_to_sample (also undo sertype_alloc_sample if "op" so requests) */
|
||||
typedef void (*ddsi_sertype_free_samples_t) (const struct ddsi_sertype *d, void **ptrs, size_t count, dds_free_op_t op);
|
||||
|
||||
/* Gets the type identifier of the requested kind (minimal or complete) for this sertype */
|
||||
typedef ddsi_typeid_t * (*ddsi_sertype_typeid_t) (const struct ddsi_sertype *tp, ddsi_typeid_kind_t kind);
|
||||
|
||||
/* Compute the (unpadded) size of the CDR based on the sertype information and the sample (plus used encoding) */
|
||||
typedef dds_return_t (*ddsi_sertype_get_serialized_size_t) (const struct ddsi_sertype *tp, enum ddsi_serdata_kind sdkind, const void *sample, size_t *size, uint16_t *enc_identifier);
|
||||
|
||||
/* Serialize into a destination buffer */
|
||||
// Note that we assume the destination buffer is large enough (we do not necessarily check)
|
||||
// The required size can be obtained with ddsi_sertype_get_serialized_size_t
|
||||
// Returns true if the serialization succeeds, false otherwise.
|
||||
typedef bool (*ddsi_sertype_serialize_into_t)(const struct ddsi_sertype *d, enum ddsi_serdata_kind sdkind, const void *sample, void *dst_buffer, size_t dst_size);
|
||||
|
||||
/* Gets the type map for this sertype */
|
||||
typedef ddsi_typemap_t * (*ddsi_sertype_typemap_t) (const struct ddsi_sertype *tp);
|
||||
|
||||
/* Gets the CDR blob for the type information of this sertype */
|
||||
typedef ddsi_typeinfo_t * (*ddsi_sertype_typeinfo_t) (const struct ddsi_sertype *tp);
|
||||
|
||||
/* Create a new derived sertype (a shallow copy of the provided sertype) with the
|
||||
serdata_ops for the provided data representation */
|
||||
typedef struct ddsi_sertype * (*ddsi_sertype_derive_t) (const struct ddsi_sertype *sertype, dds_data_representation_id_t data_representation, dds_type_consistency_enforcement_qospolicy_t tce_qos);
|
||||
|
||||
struct ddsi_sertype_v0;
|
||||
typedef void (*ddsi_sertype_v0_t) (struct ddsi_sertype_v0 *dummy);
|
||||
|
||||
// Because Windows ... just can't get its act together ...
|
||||
#ifndef _WIN32
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_v0 (struct ddsi_sertype_v0 *dummy);
|
||||
#else
|
||||
#define ddsi_sertype_v0 ((ddsi_sertype_v0_t) 1)
|
||||
#endif
|
||||
|
||||
struct ddsi_sertype_ops {
|
||||
ddsi_sertype_v0_t version;
|
||||
void *arg;
|
||||
|
||||
ddsi_sertype_free_t free;
|
||||
ddsi_sertype_zero_samples_t zero_samples;
|
||||
ddsi_sertype_realloc_samples_t realloc_samples;
|
||||
ddsi_sertype_free_samples_t free_samples;
|
||||
ddsi_sertype_equal_t equal;
|
||||
ddsi_sertype_hash_t hash;
|
||||
ddsi_sertype_typeid_t type_id;
|
||||
ddsi_sertype_typemap_t type_map;
|
||||
ddsi_sertype_typeinfo_t type_info;
|
||||
ddsi_sertype_derive_t derive_sertype;
|
||||
ddsi_sertype_get_serialized_size_t get_serialized_size;
|
||||
ddsi_sertype_serialize_into_t serialize_into;
|
||||
};
|
||||
|
||||
/** @component typesupport_if */
|
||||
struct ddsi_sertype *ddsi_sertype_lookup_locked (struct ddsi_domaingv *gv, const struct ddsi_sertype *sertype_template);
|
||||
|
||||
/** @component typesupport_if */
|
||||
void ddsi_sertype_register_locked (struct ddsi_domaingv *gv, struct ddsi_sertype *sertype);
|
||||
|
||||
#define DDSI_SERTYPE_FLAG_TOPICKIND_NO_KEY (1u)
|
||||
#define DDSI_SERTYPE_FLAG_REQUEST_KEYHASH (2u)
|
||||
#define DDSI_SERTYPE_FLAG_FIXED_SIZE (4u)
|
||||
|
||||
#define DDSI_SERTYPE_FLAG_MASK (0x7u)
|
||||
#define DDSI_SERTYPE_PROPS_FLAG_MASK (DDSI_SERTYPE_FLAG_REQUEST_KEYHASH)
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_init_props (struct ddsi_sertype *tp, const char *type_name, const struct ddsi_sertype_ops *sertype_ops, const struct ddsi_serdata_ops *serdata_ops, size_t sizeof_type, dds_data_type_properties_t data_type_props, uint32_t allowed_data_representation, uint32_t flags);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_init_flags (struct ddsi_sertype *tp, const char *type_name, const struct ddsi_sertype_ops *sertype_ops, const struct ddsi_serdata_ops *serdata_ops, uint32_t flags);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_init (struct ddsi_sertype *tp, const char *type_name, const struct ddsi_sertype_ops *sertype_ops, const struct ddsi_serdata_ops *serdata_ops, bool topickind_no_key);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_fini (struct ddsi_sertype *tp);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT struct ddsi_sertype *ddsi_sertype_ref (const struct ddsi_sertype *tp);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT void ddsi_sertype_unref (struct ddsi_sertype *tp); /* tp->gv->sertypes_lock may not be held */
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint32_t ddsi_sertype_compute_serdata_basehash (const struct ddsi_serdata_ops *ops);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT bool ddsi_sertype_equal (const struct ddsi_sertype *a, const struct ddsi_sertype *b);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint32_t ddsi_sertype_hash (const struct ddsi_sertype *tp);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint16_t ddsi_sertype_extensibility_enc_format (enum dds_cdr_type_extensibility type_extensibility);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint16_t ddsi_sertype_get_native_enc_identifier (uint32_t enc_version, uint32_t encoding_format);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint32_t ddsi_sertype_enc_id_xcdr_version (uint16_t cdr_identifier);
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_EXPORT uint32_t ddsi_sertype_enc_id_enc_format (uint16_t cdr_identifier);
|
||||
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_free (struct ddsi_sertype *tp) {
|
||||
tp->ops->free (tp);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_zero_samples (const struct ddsi_sertype *tp, void *samples, size_t count) {
|
||||
tp->ops->zero_samples (tp, samples, count);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_realloc_samples (void **ptrs, const struct ddsi_sertype *tp, void *old, size_t oldcount, size_t count)
|
||||
{
|
||||
tp->ops->realloc_samples (ptrs, tp, old, oldcount, count);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_free_samples (const struct ddsi_sertype *tp, void **ptrs, size_t count, dds_free_op_t op) {
|
||||
tp->ops->free_samples (tp, ptrs, count, op);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_zero_sample (const struct ddsi_sertype *tp, void *sample) {
|
||||
ddsi_sertype_zero_samples (tp, sample, 1);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void *ddsi_sertype_alloc_sample (const struct ddsi_sertype *tp) {
|
||||
void *ptr;
|
||||
ddsi_sertype_realloc_samples (&ptr, tp, NULL, 0, 1);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline void ddsi_sertype_free_sample (const struct ddsi_sertype *tp, void *sample, dds_free_op_t op) {
|
||||
ddsi_sertype_free_samples (tp, &sample, 1, op);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline ddsi_typeid_t * ddsi_sertype_typeid (const struct ddsi_sertype *tp, ddsi_typeid_kind_t kind)
|
||||
{
|
||||
if (!tp->ops->type_id)
|
||||
return NULL;
|
||||
return tp->ops->type_id (tp, kind);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline ddsi_typemap_t * ddsi_sertype_typemap (const struct ddsi_sertype *tp)
|
||||
{
|
||||
if (!tp->ops->type_map)
|
||||
return NULL;
|
||||
return tp->ops->type_map (tp);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline ddsi_typeinfo_t *ddsi_sertype_typeinfo (const struct ddsi_sertype *tp)
|
||||
{
|
||||
if (!tp->ops->type_info)
|
||||
return NULL;
|
||||
return tp->ops->type_info (tp);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_sertype * ddsi_sertype_derive_sertype (const struct ddsi_sertype *base_sertype, dds_data_representation_id_t data_representation, dds_type_consistency_enforcement_qospolicy_t tce_qos) {
|
||||
if (!base_sertype->ops->derive_sertype)
|
||||
return NULL;
|
||||
return base_sertype->ops->derive_sertype (base_sertype, data_representation, tce_qos);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline dds_return_t ddsi_sertype_get_serialized_size(const struct ddsi_sertype *tp, enum ddsi_serdata_kind sdkind, const void *sample, size_t *size, uint16_t *enc_identifier) {
|
||||
return tp->ops->get_serialized_size(tp, sdkind, sample, size, enc_identifier);
|
||||
}
|
||||
|
||||
/** @component typesupport_if */
|
||||
DDS_INLINE_EXPORT inline bool ddsi_sertype_serialize_into(const struct ddsi_sertype *tp, enum ddsi_serdata_kind sdkind, const void *sample, void *dst_buffer, size_t dst_size) {
|
||||
return tp->ops->serialize_into(tp, sdkind, sample, dst_buffer, dst_size);
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_SERTYPE_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSI_SOCKWAITSET_H
|
||||
#define DDSI_SOCKWAITSET_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_sock_waitset;
|
||||
struct ddsi_sock_waitset_ctx;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* DDSI_SOCKWAITSET_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright(c) 2020 ZettaScale Technology 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 _DDSI_STATISTICS_H_
|
||||
#define _DDSI_STATISTICS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_reader;
|
||||
struct ddsi_writer;
|
||||
|
||||
/** @component ddsi_statistics */
|
||||
void ddsi_get_writer_stats (struct ddsi_writer *wr, uint64_t *rexmit_bytes, uint32_t *throttle_count, uint64_t *time_throttled, uint64_t *time_retransmit);
|
||||
|
||||
/** @component ddsi_statistics */
|
||||
void ddsi_get_reader_stats (struct ddsi_reader *rd, uint64_t *discarded_bytes);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_THREAD_H
|
||||
#define DDSI_THREAD_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
#include "dds/ddsrt/threads.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_thread_state;
|
||||
|
||||
/* Things don't go wrong if DDSI_CACHE_LINE_SIZE is defined incorrectly,
|
||||
they just run slower because of false cache-line sharing. It can be
|
||||
discovered at run-time, but in practice it's 64 for most CPUs and
|
||||
128 for some. */
|
||||
#define DDSI_CACHE_LINE_SIZE 64
|
||||
|
||||
typedef uint32_t ddsi_vtime_t;
|
||||
#define DDSI_VTIME_NEST_MASK 0xfu
|
||||
#define DDSI_VTIME_TIME_MASK 0xfffffff0u
|
||||
#define DDSI_VTIME_TIME_SHIFT 4
|
||||
|
||||
enum ddsi_thread_state_kind {
|
||||
DDSI_THREAD_STATE_ZERO, /* known to be dead */
|
||||
DDSI_THREAD_STATE_STOPPED, /* internal thread, stopped-but-not-reaped */
|
||||
DDSI_THREAD_STATE_INIT, /* internal thread, initializing */
|
||||
DDSI_THREAD_STATE_LAZILY_CREATED, /* lazily created in response because an application used it. Reclaimed if the thread terminates, but not considered an error if all of Cyclone is shutdown while this thread hasn't terminated yet */
|
||||
DDSI_THREAD_STATE_ALIVE /* known to be alive - for Cyclone internal threads */
|
||||
};
|
||||
|
||||
/*
|
||||
* vtime indicates progress for the garbage collector and the liveliness monitoring.
|
||||
*
|
||||
* vtime is updated without using atomic operations: only the owning thread updates
|
||||
* them, and the garbage collection mechanism and the liveliness monitoring only
|
||||
* observe the value
|
||||
*
|
||||
* gv is constant for internal threads, i.e., for threads with state = ALIVE
|
||||
* gv is non-NULL for internal threads except thread liveliness monitoring
|
||||
*
|
||||
* DDSI_THREAD_DEBUG enables some really costly debugging stuff that may not be fully
|
||||
* portable (I used it once, might as well keep it)
|
||||
*/
|
||||
#define DDSI_THREAD_DEBUG 0
|
||||
#if DDSI_THREAD_DEBUG
|
||||
#define DDSI_THREAD_NSTACKS 20
|
||||
#define DDSI_THREAD_STACKDEPTH 10
|
||||
#define THREAD_BASE_DEBUG \
|
||||
void *stks[DDSI_THREAD_NSTACKS][DDSI_THREAD_STACKDEPTH]; \
|
||||
int stks_depth[DDSI_THREAD_NSTACKS]; \
|
||||
int stks_idx;
|
||||
|
||||
/** @component thread_support */
|
||||
void ddsi_thread_vtime_trace (struct ddsi_thread_state *thrst);
|
||||
#else /* DDSI_THREAD_DEBUG */
|
||||
#define THREAD_BASE_DEBUG
|
||||
#define ddsi_thread_vtime_trace(thrst) do { } while (0)
|
||||
#endif /* DDSI_THREAD_DEBUG */
|
||||
|
||||
/**
|
||||
* When DDS_ALLOW_NESTED_DOMAIN is set, the thread state can store an additional
|
||||
* gv pointer, so that in case of domain nesting in a single thread, the gv
|
||||
* pointer of the nested domain won't overwrite the top-level domain's gv pointer.
|
||||
* Nesting domains has several limitations, and is used for PSMX testing using the
|
||||
* Cyclone DDS PSMX implementation.
|
||||
*/
|
||||
#ifdef DDS_ALLOW_NESTED_DOMAIN
|
||||
#define THREAD_BASE_NESTEDGV ddsrt_atomic_voidp_t nested_gv;
|
||||
#else
|
||||
#define THREAD_BASE_NESTEDGV
|
||||
#endif
|
||||
|
||||
#define THREAD_BASE \
|
||||
ddsrt_atomic_uint32_t vtime; \
|
||||
enum ddsi_thread_state_kind state; \
|
||||
ddsrt_atomic_voidp_t gv; \
|
||||
THREAD_BASE_NESTEDGV \
|
||||
ddsrt_thread_t tid; \
|
||||
uint32_t (*f) (void *arg); \
|
||||
void *f_arg; \
|
||||
THREAD_BASE_DEBUG /* note: no semicolon! */ \
|
||||
char name[24] /* note: no semicolon! */
|
||||
|
||||
struct ddsi_thread_state_base {
|
||||
THREAD_BASE;
|
||||
};
|
||||
|
||||
/* GCC has a nifty feature allowing the specification of the required
|
||||
alignment: __attribute__ ((aligned (DDSI_CACHE_LINE_SIZE))) in this
|
||||
case. Many other compilers implement it as well, but it is by no
|
||||
means a standard feature. So we do it the old-fashioned way. */
|
||||
|
||||
struct ddsi_thread_state {
|
||||
THREAD_BASE;
|
||||
char pad[DDSI_CACHE_LINE_SIZE
|
||||
* ((sizeof (struct ddsi_thread_state_base) + DDSI_CACHE_LINE_SIZE - 1)
|
||||
/ DDSI_CACHE_LINE_SIZE)
|
||||
- sizeof (struct ddsi_thread_state_base)];
|
||||
};
|
||||
#undef THREAD_BASE
|
||||
|
||||
struct ddsi_thread_states {
|
||||
ddsrt_mutex_t lock;
|
||||
ddsrt_atomic_voidp_t thread_states_head;
|
||||
};
|
||||
|
||||
extern struct ddsi_thread_states thread_states;
|
||||
|
||||
// thread_local cannot (and doesn't need to?) be exported on Windows
|
||||
#if defined _WIN32 && !defined __MINGW32__
|
||||
extern ddsrt_thread_local struct ddsi_thread_state *tsd_thread_state;
|
||||
#else
|
||||
DDS_EXPORT extern ddsrt_thread_local struct ddsi_thread_state *tsd_thread_state;
|
||||
#endif
|
||||
|
||||
#ifdef DDS_ALLOW_NESTED_DOMAIN
|
||||
DDS_EXPORT extern ddsrt_atomic_uint32_t ddsi_thread_nested_gv_allowed;
|
||||
#endif
|
||||
|
||||
/** @component thread_support */
|
||||
void ddsi_thread_states_init (void);
|
||||
|
||||
/** @component thread_support */
|
||||
bool ddsi_thread_states_fini (void);
|
||||
|
||||
/** @component thread_support */
|
||||
dds_return_t ddsi_create_thread (struct ddsi_thread_state **thrst, const struct ddsi_domaingv *gv, const char *name, uint32_t (*f) (void *arg), void *arg);
|
||||
|
||||
/** @component thread_support */
|
||||
dds_return_t ddsi_join_thread (struct ddsi_thread_state *thrst);
|
||||
|
||||
/** @component thread_support */
|
||||
DDS_EXPORT struct ddsi_thread_state *ddsi_lookup_thread_state_real (void);
|
||||
|
||||
/** @component thread_support */
|
||||
DDS_INLINE_EXPORT inline struct ddsi_thread_state *ddsi_lookup_thread_state (void) {
|
||||
struct ddsi_thread_state *thrst = tsd_thread_state;
|
||||
if (thrst)
|
||||
return thrst;
|
||||
else
|
||||
return ddsi_lookup_thread_state_real ();
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
inline bool ddsi_vtime_awake_p (ddsi_vtime_t vtime)
|
||||
{
|
||||
return (vtime & DDSI_VTIME_NEST_MASK) != 0;
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
inline bool ddsi_vtime_asleep_p (ddsi_vtime_t vtime)
|
||||
{
|
||||
return (vtime & DDSI_VTIME_NEST_MASK) == 0;
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
inline bool ddsi_thread_is_awake (void)
|
||||
{
|
||||
struct ddsi_thread_state *thrst = ddsi_lookup_thread_state ();
|
||||
ddsi_vtime_t vt = ddsrt_atomic_ld32 (&thrst->vtime);
|
||||
return ddsi_vtime_awake_p (vt);
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
inline bool ddsi_thread_is_asleep (void)
|
||||
{
|
||||
struct ddsi_thread_state *thrst = ddsi_lookup_thread_state ();
|
||||
ddsi_vtime_t vt = ddsrt_atomic_ld32 (&thrst->vtime);
|
||||
return ddsi_vtime_asleep_p (vt);
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
DDS_INLINE_EXPORT inline void ddsi_thread_state_asleep (struct ddsi_thread_state *thrst)
|
||||
{
|
||||
ddsi_vtime_t vt = ddsrt_atomic_ld32 (&thrst->vtime);
|
||||
assert (ddsi_vtime_awake_p (vt));
|
||||
/* nested calls a rare and an extra fence doesn't break things */
|
||||
ddsrt_atomic_fence_rel ();
|
||||
ddsi_thread_vtime_trace (thrst);
|
||||
if ((vt & DDSI_VTIME_NEST_MASK) == 1)
|
||||
vt += (1u << DDSI_VTIME_TIME_SHIFT) - 1u;
|
||||
else
|
||||
vt -= 1u;
|
||||
ddsrt_atomic_st32 (&thrst->vtime, vt);
|
||||
}
|
||||
|
||||
/** @component thread_support */
|
||||
DDS_INLINE_EXPORT inline void ddsi_thread_state_awake (struct ddsi_thread_state *thrst, const struct ddsi_domaingv *gv)
|
||||
{
|
||||
ddsi_vtime_t vt = ddsrt_atomic_ld32 (&thrst->vtime);
|
||||
assert ((vt & DDSI_VTIME_NEST_MASK) < DDSI_VTIME_NEST_MASK);
|
||||
assert (gv != NULL);
|
||||
assert (thrst->state != DDSI_THREAD_STATE_ALIVE || gv == ddsrt_atomic_ldvoidp (&thrst->gv));
|
||||
ddsi_thread_vtime_trace (thrst);
|
||||
#ifdef DDS_ALLOW_NESTED_DOMAIN
|
||||
assert ((vt & DDSI_VTIME_NEST_MASK) == 0 || gv == ddsrt_atomic_ldvoidp (&thrst->gv) || gv == ddsrt_atomic_ldvoidp (&thrst->nested_gv) || 0 == ddsrt_atomic_ldvoidp (&thrst->nested_gv));
|
||||
if ((vt & DDSI_VTIME_NEST_MASK) == 0)
|
||||
ddsrt_atomic_stvoidp (&thrst->gv, (struct ddsi_domaingv *) gv);
|
||||
else if (gv != ddsrt_atomic_ldvoidp (&thrst->gv))
|
||||
{
|
||||
assert (ddsrt_atomic_ld32 (&ddsi_thread_nested_gv_allowed));
|
||||
ddsrt_atomic_stvoidp (&thrst->nested_gv, (struct ddsi_domaingv *) gv);
|
||||
}
|
||||
#else
|
||||
assert ((vt & DDSI_VTIME_NEST_MASK) == 0 || gv == ddsrt_atomic_ldvoidp (&thrst->gv));
|
||||
ddsrt_atomic_stvoidp (&thrst->gv, (struct ddsi_domaingv *) gv);
|
||||
#endif
|
||||
ddsrt_atomic_fence_stst ();
|
||||
ddsrt_atomic_st32 (&thrst->vtime, vt + 1u);
|
||||
/* nested calls a rare and an extra fence doesn't break things */
|
||||
ddsrt_atomic_fence_acq ();
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_THREAD_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_THREADMON_H
|
||||
#define DDSI_THREADMON_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_threadmon;
|
||||
struct ddsi_domaingv;
|
||||
|
||||
/** @component thread_monitor */
|
||||
struct ddsi_threadmon *ddsi_threadmon_new (int64_t liveliness_monitoring_interval, bool noprogress_log_stacktraces);
|
||||
|
||||
/** @component thread_monitor */
|
||||
dds_return_t ddsi_threadmon_start (struct ddsi_threadmon *sl, const char *name);
|
||||
|
||||
/** @component thread_monitor */
|
||||
void ddsi_threadmon_register_domain (struct ddsi_threadmon *sl, const struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component thread_monitor */
|
||||
void ddsi_threadmon_unregister_domain (struct ddsi_threadmon *sl, const struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component thread_monitor */
|
||||
void ddsi_threadmon_stop (struct ddsi_threadmon *sl);
|
||||
|
||||
/** @component thread_monitor */
|
||||
void ddsi_threadmon_free (struct ddsi_threadmon *sl);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_THREADMON_H */
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 _DDS_TKMAP_H_
|
||||
#define _DDS_TKMAP_H_
|
||||
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_tkmap;
|
||||
struct ddsi_serdata;
|
||||
struct dds_topic;
|
||||
struct ddsi_domaingv;
|
||||
|
||||
struct ddsi_tkmap_instance
|
||||
{
|
||||
struct ddsi_serdata *m_sample;
|
||||
uint64_t m_iid;
|
||||
ddsrt_atomic_uint32_t m_refc;
|
||||
};
|
||||
|
||||
/** @component key_instance_map */
|
||||
struct ddsi_tkmap *ddsi_tkmap_new (struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component key_instance_map */
|
||||
void ddsi_tkmap_free (struct ddsi_tkmap *tkmap);
|
||||
|
||||
/** @component key_instance_map */
|
||||
void ddsi_tkmap_instance_ref (struct ddsi_tkmap_instance *tk);
|
||||
|
||||
/** @component key_instance_map */
|
||||
uint64_t ddsi_tkmap_lookup (struct ddsi_tkmap *tkmap, const struct ddsi_serdata *serdata);
|
||||
|
||||
/** @component key_instance_map */
|
||||
struct ddsi_tkmap_instance * ddsi_tkmap_find(struct ddsi_tkmap *map, struct ddsi_serdata *sd, const bool create);
|
||||
|
||||
/** @component key_instance_map */
|
||||
struct ddsi_tkmap_instance * ddsi_tkmap_find_by_id (struct ddsi_tkmap *map, uint64_t iid);
|
||||
|
||||
/** @component key_instance_map */
|
||||
DDS_EXPORT struct ddsi_tkmap_instance * ddsi_tkmap_lookup_instance_ref (struct ddsi_tkmap *map, struct ddsi_serdata * sd);
|
||||
|
||||
/** @component key_instance_map */
|
||||
DDS_EXPORT void ddsi_tkmap_instance_unref (struct ddsi_tkmap *map, struct ddsi_tkmap_instance *tk);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_TOPIC_H
|
||||
#define DDSI_TOPIC_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
#include "dds/ddsi/ddsi_entity.h"
|
||||
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
#include "dds/ddsi/ddsi_typelib.h"
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @component ddsi_topic */
|
||||
int ddsi_is_builtin_topic (ddsi_entityid_t id, ddsi_vendorid_t vendorid);
|
||||
|
||||
#ifdef DDS_HAS_TOPIC_DISCOVERY
|
||||
|
||||
struct ddsi_proxy_participant;
|
||||
struct ddsi_type_pair;
|
||||
struct dds_qos;
|
||||
|
||||
struct ddsi_topic_definition {
|
||||
unsigned char key[16]; /* key for this topic definition (MD5 hash of the type_id and qos) */
|
||||
struct ddsi_type_pair *type_pair; /* has a ddsi_type object for the minimal and complete type, which contains the XTypes type identifiers */
|
||||
struct dds_qos *xqos; /* contains also the topic name and type name */
|
||||
uint32_t refc;
|
||||
struct ddsi_domaingv *gv;
|
||||
};
|
||||
|
||||
struct ddsi_topic {
|
||||
struct ddsi_entity_common e;
|
||||
struct ddsi_topic_definition *definition; /* ref to (shared) topic definition, protected by e.qos_lock */
|
||||
struct ddsi_participant *pp; /* backref to the participant */
|
||||
};
|
||||
|
||||
struct ddsi_proxy_topic
|
||||
{
|
||||
ddsi_entityid_t entityid;
|
||||
struct ddsi_topic_definition *definition; /* ref to (shared) topic definition */
|
||||
ddsrt_wctime_t tupdate; /* timestamp of last update */
|
||||
ddsi_seqno_t seq; /* sequence number of most recent SEDP message */
|
||||
ddsrt_avl_node_t avlnode; /* entry in proxypp->topics */
|
||||
unsigned deleted: 1;
|
||||
};
|
||||
|
||||
/** @component ddsi_topic */
|
||||
dds_return_t ddsi_new_topic (struct ddsi_topic **tp_out, struct ddsi_guid *tpguid, struct ddsi_participant *pp, const char *topic_name, const struct ddsi_sertype *type, const struct dds_qos *xqos, bool is_builtin, bool *new_topic_def);
|
||||
|
||||
/** @component ddsi_topic */
|
||||
void ddsi_update_topic_qos (struct ddsi_topic *tp, const dds_qos_t *xqos);
|
||||
|
||||
/** @component ddsi_topic */
|
||||
dds_return_t ddsi_delete_topic (struct ddsi_domaingv *gv, const struct ddsi_guid *guid);
|
||||
|
||||
/** @component ddsi_topic */
|
||||
dds_return_t ddsi_lookup_topic_definition (struct ddsi_domaingv *gv, const char * topic_name, const ddsi_typeid_t *type_id, struct ddsi_topic_definition **tpd);
|
||||
|
||||
#endif /* DDS_HAS_TOPIC_DISCOVERY */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_TOPIC_H */
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 _DDSI_TRAN_H_
|
||||
#define _DDSI_TRAN_H_
|
||||
|
||||
/* DDSI Transport module */
|
||||
|
||||
#include "dds/ddsrt/ifaddrs.h"
|
||||
#include "dds/ddsrt/atomics.h"
|
||||
#include "dds/ddsi/ddsi_locator.h"
|
||||
#include "dds/ddsi/ddsi_config.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_tran_base;
|
||||
struct ddsi_tran_conn;
|
||||
struct ddsi_tran_listener;
|
||||
struct ddsi_tran_factory;
|
||||
struct ddsi_tran_qos;
|
||||
|
||||
/* 8 for transport/
|
||||
1 for [
|
||||
48 for IPv6 hex digits (3*16) + separators
|
||||
2 for ]:
|
||||
10 for port (DDSI loc has signed 32-bit)
|
||||
11 for @ifindex
|
||||
1 for terminator
|
||||
--
|
||||
81
|
||||
*/
|
||||
#define DDSI_LOCSTRLEN 81
|
||||
|
||||
/** @component locators */
|
||||
char *ddsi_xlocator_to_string (char *dst, size_t sizeof_dst, const ddsi_xlocator_t *loc);
|
||||
|
||||
/** @component locators */
|
||||
DDS_EXPORT char *ddsi_locator_to_string (char *dst, size_t sizeof_dst, const ddsi_locator_t *loc);
|
||||
|
||||
/** @component locators */
|
||||
char *ddsi_xlocator_to_string_no_port (char *dst, size_t sizeof_dst, const ddsi_xlocator_t *loc);
|
||||
|
||||
/** @component locators */
|
||||
char *ddsi_locator_to_string_no_port (char *dst, size_t sizeof_dst, const ddsi_locator_t *loc);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSI_TRANSMIT_H
|
||||
#define DDSI_TRANSMIT_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_xpack;
|
||||
struct ddsi_writer;
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_thread_state;
|
||||
|
||||
/**
|
||||
* @component outgoing_rtps
|
||||
*
|
||||
* Writing new data; serdata_twrite (serdata) is assumed to be really recentish; serdata is unref'd.
|
||||
* If xp == NULL, data is queued, else packed. GC may occur, which means the writer history and watermarks
|
||||
* can be anything. This must be used for all application data.
|
||||
*
|
||||
* @param thrst Thread state
|
||||
* @param xp xpack
|
||||
* @param wr writer
|
||||
* @param serdata serialized sample data
|
||||
* @param tk key-instance map instance
|
||||
* @return int
|
||||
*/
|
||||
DDS_EXPORT int ddsi_write_sample_gc (struct ddsi_thread_state * const thrst, struct ddsi_xpack *xp, struct ddsi_writer *wr, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
|
||||
/**
|
||||
* @component outgoing_rtps
|
||||
*
|
||||
* @remark wr->lock must be held
|
||||
*
|
||||
* @param gv domain globals
|
||||
* @param wr_guid writer guid
|
||||
* @param xp xpack
|
||||
* @return dds_return_t
|
||||
*/
|
||||
dds_return_t ddsi_write_hb_liveliness (struct ddsi_domaingv * const gv, struct ddsi_guid *wr_guid, struct ddsi_xpack *xp);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_TRANSMIT_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright(c) 2022 ZettaScale Technology
|
||||
//
|
||||
// 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 DDSI_TYPEBUILDER_H
|
||||
#define DDSI_TYPEBUILDER_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "dds/dds.h"
|
||||
#include "dds/ddsi/ddsi_typelib.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
/** @component dynamic_types */
|
||||
DDS_EXPORT dds_return_t ddsi_topic_descriptor_from_type (struct ddsi_domaingv *gv, dds_topic_descriptor_t *desc, const struct ddsi_type *type);
|
||||
|
||||
/** @component dynamic_types */
|
||||
DDS_EXPORT void ddsi_topic_descriptor_fini (dds_topic_descriptor_t *desc);
|
||||
|
||||
#endif /* DDS_HAS_TYPELIB */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_TYPEBUILDER_H */
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_TYPELIB_H
|
||||
#define DDSI_TYPELIB_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsrt/avl.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
#include "dds/ddsi/ddsi_typewrap.h"
|
||||
#include "dds/ddsi/ddsi_sertype.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_sertype;
|
||||
struct ddsi_type;
|
||||
enum ddsi_type_include_deps;
|
||||
|
||||
typedef enum ddsi_type_request {
|
||||
DDSI_TYPE_NO_REQUEST,
|
||||
DDSI_TYPE_SEND_REQUEST
|
||||
} ddsi_type_request_t;
|
||||
|
||||
/* Used for converting type-id to strings */
|
||||
struct ddsi_typeid_str {
|
||||
char str[50];
|
||||
};
|
||||
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT bool ddsi_typeinfo_equal (const ddsi_typeinfo_t *a, const ddsi_typeinfo_t *b, enum ddsi_type_include_deps deps);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT ddsi_typeid_t *ddsi_typeinfo_typeid (const ddsi_typeinfo_t *type_info, ddsi_typeid_kind_t kind);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT ddsi_typeinfo_t *ddsi_typeinfo_deser (const unsigned char *data, uint32_t sz);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT void ddsi_typeinfo_fini (ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT void ddsi_typeinfo_free (ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT ddsi_typeinfo_t * ddsi_typeinfo_dup (const ddsi_typeinfo_t *src);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT const ddsi_typeid_t *ddsi_typeinfo_minimal_typeid (const ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT const ddsi_typeid_t *ddsi_typeinfo_complete_typeid (const ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT char *ddsi_make_typeid_str (struct ddsi_typeid_str *buf, const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component type_system */
|
||||
char *ddsi_make_typeid_str_impl (struct ddsi_typeid_str *buf, const DDS_XTypes_TypeIdentifier *type_id);
|
||||
|
||||
/** @component type_system */
|
||||
bool ddsi_typeinfo_present (const ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
bool ddsi_typeinfo_valid (const ddsi_typeinfo_t *typeinfo);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT ddsi_typemap_t *ddsi_typemap_deser (const unsigned char *data, uint32_t sz);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT void ddsi_typemap_fini (ddsi_typemap_t *typemap);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT bool ddsi_typemap_equal (const ddsi_typemap_t *a, const ddsi_typemap_t *b);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT const char * ddsi_typemap_get_type_name (const ddsi_typemap_t *typemap, const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component type_system */
|
||||
dds_return_t ddsi_type_ref_local (struct ddsi_domaingv *gv, struct ddsi_type **type, const struct ddsi_sertype *sertype, ddsi_typeid_kind_t kind);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT dds_return_t ddsi_type_add (struct ddsi_domaingv *gv, struct ddsi_type **type_minimal, struct ddsi_type **type_complete, const ddsi_typeinfo_t *type_info, const ddsi_typemap_t *type_map);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT void ddsi_type_ref (struct ddsi_domaingv *gv, struct ddsi_type **type, const struct ddsi_type *src);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_EXPORT void ddsi_type_unref (struct ddsi_domaingv *gv, struct ddsi_type *type);
|
||||
|
||||
/** @component type_system */
|
||||
void ddsi_type_unref_sertype (struct ddsi_domaingv *gv, const struct ddsi_sertype *sertype);
|
||||
|
||||
/** @component type_system */
|
||||
struct ddsi_typeobj *ddsi_type_get_typeobj (struct ddsi_domaingv *gv, const struct ddsi_type *type);
|
||||
|
||||
/** @component type_system */
|
||||
bool ddsi_type_resolved (struct ddsi_domaingv *gv, const struct ddsi_type *type, enum ddsi_type_include_deps resolved_kind);
|
||||
|
||||
/** @component type_system */
|
||||
struct ddsi_domaingv *ddsi_type_get_gv (const struct ddsi_type *type);
|
||||
|
||||
/** @component type_system */
|
||||
DDS_XTypes_TypeKind ddsi_type_get_kind (const struct ddsi_type *type);
|
||||
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
/**
|
||||
* @brief Waits for the provided type to be resolved
|
||||
* @component type_system
|
||||
*
|
||||
* In case the type is succesfully resolved (or was already resolved), this
|
||||
* function increases the refcount for this type. Caller should do the unref.
|
||||
*/
|
||||
dds_return_t ddsi_wait_for_type_resolved (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id, dds_duration_t timeout, struct ddsi_type **type, enum ddsi_type_include_deps resolved_kind, ddsi_type_request_t request);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Returns the type lookup meta object for the provided type identifier.
|
||||
* @component type_system
|
||||
*
|
||||
* @remark The returned object from this function is not refcounted,
|
||||
* its lifetime is at lease the lifetime of the (proxy) endpoints
|
||||
* that are referring to it.
|
||||
*/
|
||||
DDS_EXPORT struct ddsi_type * ddsi_type_lookup (struct ddsi_domaingv *gv, const ddsi_typeid_t *type_id);
|
||||
|
||||
/**
|
||||
* @brief Compares the provided type lookup meta objects.
|
||||
* @component type_system
|
||||
*
|
||||
*/
|
||||
DDS_EXPORT int ddsi_type_compare (const struct ddsi_type *a, const struct ddsi_type *b);
|
||||
|
||||
#endif /* DDS_HAS_TYPELIB */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_TYPELIB_H */
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_TYPEWRAP_H
|
||||
#define DDSI_TYPEWRAP_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
#include "dds/ddsi/ddsi_xqos.h"
|
||||
#include "dds/ddsi/ddsi_xt_typeinfo.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
|
||||
#define DDS_XTypes_TRY_CONSTRUCT_INVALID 0
|
||||
#define DDS_XTypes_TRY_CONSTRUCT_DISCARD DDS_XTypes_TRY_CONSTRUCT1
|
||||
#define DDS_XTypes_TRY_CONSTRUCT_USE_DEFAULT DDS_XTypes_TRY_CONSTRUCT2
|
||||
#define DDS_XTypes_TRY_CONSTRUCT_TRIM (DDS_XTypes_TRY_CONSTRUCT1 | DDS_XTypes_TRY_CONSTRUCT2)
|
||||
|
||||
typedef struct ddsi_typeid ddsi_typeid_t;
|
||||
typedef struct ddsi_typeinfo ddsi_typeinfo_t;
|
||||
typedef struct ddsi_typeobj ddsi_typeobj_t;
|
||||
typedef struct ddsi_typemap ddsi_typemap_t;
|
||||
|
||||
typedef enum ddsi_typeid_kind {
|
||||
DDSI_TYPEID_KIND_MINIMAL,
|
||||
DDSI_TYPEID_KIND_COMPLETE,
|
||||
DDSI_TYPEID_KIND_PLAIN_COLLECTION_MINIMAL,
|
||||
DDSI_TYPEID_KIND_PLAIN_COLLECTION_COMPLETE,
|
||||
DDSI_TYPEID_KIND_FULLY_DESCRIPTIVE,
|
||||
DDSI_TYPEID_KIND_INVALID
|
||||
} ddsi_typeid_kind_t;
|
||||
|
||||
enum ddsi_type_include_deps {
|
||||
DDSI_TYPE_IGNORE_DEPS,
|
||||
DDSI_TYPE_INCLUDE_DEPS
|
||||
};
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT int ddsi_typeid_compare (const ddsi_typeid_t *a, const ddsi_typeid_t *b);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT void ddsi_typeid_copy (ddsi_typeid_t *dst, const ddsi_typeid_t *src);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT ddsi_typeid_t * ddsi_typeid_dup (const ddsi_typeid_t *src);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT void ddsi_typeid_ser (const ddsi_typeid_t *type_id, unsigned char **buf, uint32_t *sz);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT bool ddsi_typeid_is_none (const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT bool ddsi_typeid_is_hash (const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT bool ddsi_typeid_is_minimal (const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT bool ddsi_typeid_is_complete (const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT bool ddsi_typeid_is_fully_descriptive (const ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT void ddsi_typeid_get_equivalence_hash (const ddsi_typeid_t *type_id, DDS_XTypes_EquivalenceHash *hash);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT ddsi_typeid_kind_t ddsi_typeid_kind (const ddsi_typeid_t *type);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
DDS_EXPORT void ddsi_typeid_fini (ddsi_typeid_t *type_id);
|
||||
|
||||
/** @component xtypes_wrapper */
|
||||
void ddsi_typeobj_fini (ddsi_typeobj_t *typeobj);
|
||||
|
||||
#else /* DDS_HAS_TYPELIB */
|
||||
|
||||
typedef void ddsi_typeid_t;
|
||||
typedef int ddsi_typeid_kind_t;
|
||||
typedef void ddsi_typemap_t;
|
||||
typedef void ddsi_typeinfo_t;
|
||||
|
||||
#endif /* DDS_HAS_TYPELIB */
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_TYPEWRAP_H */
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSI_UNUSED_H
|
||||
#define DDSI_UNUSED_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNUSED_ARG(x) x __attribute__ ((unused))
|
||||
#else
|
||||
#define UNUSED_ARG(x) x
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define UNUSED_ARG_NDEBUG(x) x
|
||||
#else
|
||||
#define UNUSED_ARG_NDEBUG(x) UNUSED_ARG (x)
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_UNUSED_H */
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_WHC_H
|
||||
#define DDSI_WHC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "dds/ddsrt/time.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_serdata;
|
||||
struct ddsi_plist;
|
||||
struct ddsi_tkmap_instance;
|
||||
struct ddsi_whc;
|
||||
|
||||
/**
|
||||
* @brief Base type for whc node
|
||||
*/
|
||||
struct ddsi_whc_node {
|
||||
ddsi_seqno_t seq;
|
||||
};
|
||||
|
||||
struct ddsi_whc_borrowed_sample {
|
||||
ddsi_seqno_t seq;
|
||||
struct ddsi_serdata *serdata;
|
||||
bool unacked;
|
||||
ddsrt_mtime_t last_rexmit_ts;
|
||||
unsigned rexmit_count;
|
||||
};
|
||||
|
||||
struct ddsi_whc_state {
|
||||
ddsi_seqno_t min_seq; /* 0 if WHC empty, else > 0 */
|
||||
ddsi_seqno_t max_seq; /* 0 if WHC empty, else >= min_seq */
|
||||
size_t unacked_bytes;
|
||||
};
|
||||
#define DDSI_WHCST_ISEMPTY(whcst) ((whcst)->max_seq == 0)
|
||||
|
||||
/* Adjust SIZE and alignment stuff as needed: they are here simply so we can allocate
|
||||
an iter on the stack without specifying an implementation. If future changes or
|
||||
implementations require more, these can be adjusted. An implementation should check
|
||||
things fit at compile time. */
|
||||
#define DDSI_WHC_SAMPLE_ITER_SIZE (8 * sizeof(void *))
|
||||
struct ddsi_whc_sample_iter_base {
|
||||
struct ddsi_whc *whc;
|
||||
};
|
||||
struct ddsi_whc_sample_iter {
|
||||
struct ddsi_whc_sample_iter_base c;
|
||||
union {
|
||||
char opaque[DDSI_WHC_SAMPLE_ITER_SIZE];
|
||||
/* cover alignment requirements: */
|
||||
uint64_t x;
|
||||
double y;
|
||||
void *p;
|
||||
} opaque;
|
||||
};
|
||||
|
||||
typedef ddsi_seqno_t (*ddsi_whc_next_seq_t)(const struct ddsi_whc *whc, ddsi_seqno_t seq);
|
||||
typedef void (*ddsi_whc_get_state_t)(const struct ddsi_whc *whc, struct ddsi_whc_state *st);
|
||||
typedef bool (*ddsi_whc_borrow_sample_t)(const struct ddsi_whc *whc, ddsi_seqno_t seq, struct ddsi_whc_borrowed_sample *sample);
|
||||
typedef bool (*ddsi_whc_borrow_sample_key_t)(const struct ddsi_whc *whc, const struct ddsi_serdata *serdata_key, struct ddsi_whc_borrowed_sample *sample);
|
||||
typedef void (*ddsi_whc_return_sample_t)(struct ddsi_whc *whc, struct ddsi_whc_borrowed_sample *sample, bool update_retransmit_info);
|
||||
typedef void (*ddsi_whc_sample_iter_init_t)(const struct ddsi_whc *whc, struct ddsi_whc_sample_iter *it);
|
||||
typedef bool (*ddsi_whc_sample_iter_borrow_next_t)(struct ddsi_whc_sample_iter *it, struct ddsi_whc_borrowed_sample *sample);
|
||||
typedef void (*whc_free_t)(struct ddsi_whc *whc);
|
||||
|
||||
/* min_seq is lowest sequence number that must be retained because of
|
||||
reliable readers that have not acknowledged all data */
|
||||
/* max_drop_seq must go soon, it's way too ugly. */
|
||||
/* plist may be NULL or ddsrt_malloc'd, WHC takes ownership of plist */
|
||||
typedef int (*ddsi_whc_insert_t)(struct ddsi_whc *whc, ddsi_seqno_t max_drop_seq, ddsi_seqno_t seq, ddsrt_mtime_t exp, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
typedef uint32_t (*ddsi_whc_remove_acked_messages_t)(struct ddsi_whc *whc, ddsi_seqno_t max_drop_seq, struct ddsi_whc_state *whcst, struct ddsi_whc_node **deferred_free_list);
|
||||
typedef void (*ddsi_whc_free_deferred_free_list_t)(struct ddsi_whc *whc, struct ddsi_whc_node *deferred_free_list);
|
||||
|
||||
struct ddsi_whc_ops {
|
||||
ddsi_whc_insert_t insert;
|
||||
ddsi_whc_remove_acked_messages_t remove_acked_messages;
|
||||
ddsi_whc_free_deferred_free_list_t free_deferred_free_list;
|
||||
ddsi_whc_get_state_t get_state;
|
||||
ddsi_whc_next_seq_t next_seq;
|
||||
ddsi_whc_borrow_sample_t borrow_sample;
|
||||
ddsi_whc_borrow_sample_key_t borrow_sample_key;
|
||||
ddsi_whc_return_sample_t return_sample;
|
||||
ddsi_whc_sample_iter_init_t sample_iter_init;
|
||||
ddsi_whc_sample_iter_borrow_next_t sample_iter_borrow_next;
|
||||
whc_free_t free;
|
||||
};
|
||||
|
||||
struct ddsi_whc {
|
||||
const struct ddsi_whc_ops *ops;
|
||||
};
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_WHC_H */
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_XEVENT_H
|
||||
#define DDSI_XEVENT_H
|
||||
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsi/ddsi_guid.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_xevent;
|
||||
struct ddsi_xeventq;
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_xpack;
|
||||
|
||||
typedef void (*ddsi_xevent_cb_t) (struct ddsi_domaingv *gv, struct ddsi_xevent *ev, struct ddsi_xpack *xp, void *arg, ddsrt_mtime_t tnow);
|
||||
|
||||
/** @brief removes an event from the event queue and frees it
|
||||
* @component timed_events
|
||||
*
|
||||
* @remark: may be called from inside the event handler
|
||||
* @remark: if the event was created with the `sync_on_delete` flag set, it blocks until
|
||||
* the system guarantees that it is not and will not be executing anymore
|
||||
*
|
||||
* @param[in] ev the event to be deleted
|
||||
*/
|
||||
void ddsi_delete_xevent (struct ddsi_xevent *ev)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @brief reschedules the event iff `tsched` precedes the time for which it is currently scheduled
|
||||
* @component timed_events
|
||||
*
|
||||
* @remark: may be called from inside the event handler
|
||||
*
|
||||
* @param[in] ev the event to be rescheduled
|
||||
* @param[in] tsched new scheduled time
|
||||
*
|
||||
* @return whether the event was actually rescheduled, i.e., whether `tsched` preceded the
|
||||
* time for which it was scheduled before
|
||||
*
|
||||
* @retval 0 not rescheduled
|
||||
* @retval 1 rescheduled
|
||||
*/
|
||||
int ddsi_resched_xevent_if_earlier (struct ddsi_xevent *ev, ddsrt_mtime_t tsched)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @brief returns whether or not the event is scheduled or pending deletion
|
||||
* @component timed_events
|
||||
*
|
||||
* @remark: may be called from inside the event handler
|
||||
*
|
||||
* @param[in] ev the event for which to check whether it is scheduled
|
||||
*
|
||||
* @retval 0 not scheduled
|
||||
* @retval 1 scheduled or pending deletion
|
||||
*/
|
||||
int ddsi_xevent_is_scheduled (struct ddsi_xevent *ev)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/** @brief creates a new event object on the given event queue for invoking `cb` in the
|
||||
* future on the thread handling this queue
|
||||
* @component timed_events
|
||||
*
|
||||
* @remark: delete does not block until an ongoing callback finishes, unless
|
||||
* `sync_on_delete` is set
|
||||
* @remark: just before invoking the callback, the schedule time is set to NEVER
|
||||
* @remark: cb will be called with now = NEVER if the event is still enqueued when
|
||||
* `ddsi_xeventq_free` starts cleaning up (a consequence of the combination of
|
||||
* this and being allowed to delete the event from within the callback is that
|
||||
* one need not always store the returned event pointer)
|
||||
*
|
||||
* @param[in] evq event queue
|
||||
* @param[in] tsched timestamp scheduled, may be NEVER
|
||||
* @param[in] cb callback function pointer
|
||||
* @param[in] arg argument (copied into ddsi_xevent, may be a null pointer
|
||||
* when arg_size = 0)
|
||||
* @param[in] arg_size size of argument in bytes
|
||||
* @param[in] sync_on_delete whether `ddsi_delete_xevent` must block until the
|
||||
* system guarantees that `cb` is not and will not be executing
|
||||
* anymore
|
||||
*
|
||||
* @return the new event object
|
||||
*/
|
||||
struct ddsi_xevent *ddsi_qxev_callback (struct ddsi_xeventq *evq, ddsrt_mtime_t tsched, ddsi_xevent_cb_t cb, const void *arg, size_t arg_size, bool sync_on_delete)
|
||||
ddsrt_nonnull((1,3));
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* DDSI_XEVENT_H */
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSI_XMSG_H
|
||||
#define DDSI_XMSG_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_domaingv;
|
||||
struct ddsi_xpack;
|
||||
|
||||
/** @component rtps_msg */
|
||||
DDS_EXPORT struct ddsi_xpack * ddsi_xpack_new (struct ddsi_domaingv *gv, bool async_mode);
|
||||
|
||||
/** @component rtps_msg */
|
||||
DDS_EXPORT void ddsi_xpack_free (struct ddsi_xpack *xp);
|
||||
|
||||
/** @component rtps_msg */
|
||||
DDS_EXPORT void ddsi_xpack_send (struct ddsi_xpack *xp, bool immediately /* unused */);
|
||||
|
||||
/** @component rtps_msg */
|
||||
void ddsi_xpack_sendq_init (struct ddsi_domaingv *gv);
|
||||
|
||||
/** @component rtps_msg */
|
||||
void ddsi_xpack_sendq_start (struct ddsi_domaingv *gv);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* DDSI_XMSG_H */
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSI_XQOS_H
|
||||
#define DDSI_XQOS_H
|
||||
|
||||
#include "dds/features.h"
|
||||
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/time.h"
|
||||
#include "dds/ddsc/dds_public_qosdefs.h"
|
||||
#include "dds/ddsi/ddsi_protocol.h"
|
||||
#include "dds/ddsi/ddsi_log.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ddsi_typeinfo;
|
||||
|
||||
typedef struct ddsi_octetseq {
|
||||
uint32_t length;
|
||||
unsigned char *value;
|
||||
} ddsi_octetseq_t;
|
||||
|
||||
typedef ddsi_octetseq_t dds_userdata_qospolicy_t;
|
||||
typedef ddsi_octetseq_t dds_topicdata_qospolicy_t;
|
||||
typedef ddsi_octetseq_t dds_groupdata_qospolicy_t;
|
||||
|
||||
typedef struct dds_property {
|
||||
/* The propagate boolean will not be send over the wire.
|
||||
* When the value is 'false', the complete struct shouldn't be send.
|
||||
* It has to be the first variable within the structure because it
|
||||
* is mapped to XbPROP in the serialiser. */
|
||||
unsigned char propagate;
|
||||
char *name;
|
||||
char *value;
|
||||
} dds_property_t;
|
||||
|
||||
typedef struct dds_propertyseq {
|
||||
uint32_t n;
|
||||
dds_property_t *props;
|
||||
} dds_propertyseq_t;
|
||||
|
||||
typedef struct dds_binaryproperty {
|
||||
/* The propagate boolean will not be send over the wire.
|
||||
* When the value is 'false', the complete struct shouldn't be send.
|
||||
* It has to be the first variable within the structure because it
|
||||
* is mapped to XbPROP in the serialiser. */
|
||||
unsigned char propagate;
|
||||
char *name;
|
||||
ddsi_octetseq_t value;
|
||||
} dds_binaryproperty_t;
|
||||
|
||||
typedef struct dds_binarypropertyseq {
|
||||
uint32_t n;
|
||||
dds_binaryproperty_t *props;
|
||||
} dds_binarypropertyseq_t;
|
||||
|
||||
typedef struct dds_property_qospolicy {
|
||||
dds_propertyseq_t value;
|
||||
dds_binarypropertyseq_t binary_value;
|
||||
} dds_property_qospolicy_t;
|
||||
|
||||
typedef struct dds_durability_qospolicy {
|
||||
dds_durability_kind_t kind;
|
||||
} dds_durability_qospolicy_t;
|
||||
|
||||
typedef struct dds_history_qospolicy {
|
||||
dds_history_kind_t kind;
|
||||
int32_t depth;
|
||||
} dds_history_qospolicy_t;
|
||||
|
||||
typedef struct dds_resource_limits_qospolicy {
|
||||
int32_t max_samples;
|
||||
int32_t max_instances;
|
||||
int32_t max_samples_per_instance;
|
||||
} dds_resource_limits_qospolicy_t;
|
||||
|
||||
typedef struct dds_durability_service_qospolicy {
|
||||
dds_duration_t service_cleanup_delay;
|
||||
dds_history_qospolicy_t history;
|
||||
dds_resource_limits_qospolicy_t resource_limits;
|
||||
} dds_durability_service_qospolicy_t;
|
||||
|
||||
typedef struct dds_presentation_qospolicy {
|
||||
dds_presentation_access_scope_kind_t access_scope;
|
||||
unsigned char coherent_access;
|
||||
unsigned char ordered_access;
|
||||
} dds_presentation_qospolicy_t;
|
||||
|
||||
typedef struct dds_deadline_qospolicy {
|
||||
dds_duration_t deadline;
|
||||
} dds_deadline_qospolicy_t;
|
||||
|
||||
typedef struct dds_latency_budget_qospolicy {
|
||||
dds_duration_t duration;
|
||||
} dds_latency_budget_qospolicy_t;
|
||||
|
||||
typedef struct dds_ownership_qospolicy {
|
||||
dds_ownership_kind_t kind;
|
||||
} dds_ownership_qospolicy_t;
|
||||
|
||||
typedef struct dds_ownership_strength_qospolicy {
|
||||
int32_t value;
|
||||
} dds_ownership_strength_qospolicy_t;
|
||||
|
||||
typedef struct dds_liveliness_qospolicy {
|
||||
dds_liveliness_kind_t kind;
|
||||
dds_duration_t lease_duration;
|
||||
} dds_liveliness_qospolicy_t;
|
||||
|
||||
typedef struct dds_time_based_filter_qospolicy {
|
||||
dds_duration_t minimum_separation;
|
||||
} dds_time_based_filter_qospolicy_t;
|
||||
|
||||
typedef struct ddsi_stringseq {
|
||||
uint32_t n;
|
||||
char **strs;
|
||||
} ddsi_stringseq_t;
|
||||
|
||||
typedef ddsi_stringseq_t dds_partition_qospolicy_t;
|
||||
|
||||
typedef struct dds_reliability_qospolicy {
|
||||
dds_reliability_kind_t kind;
|
||||
dds_duration_t max_blocking_time;
|
||||
} dds_reliability_qospolicy_t;
|
||||
|
||||
typedef enum dds_external_reliability_kind {
|
||||
DDS_EXTERNAL_RELIABILITY_BEST_EFFORT = 1,
|
||||
DDS_EXTERNAL_RELIABILITY_RELIABLE = 2
|
||||
} dds_external_reliability_kind_t;
|
||||
|
||||
typedef struct dds_transport_priority_qospolicy {
|
||||
int32_t value;
|
||||
} dds_transport_priority_qospolicy_t;
|
||||
|
||||
typedef struct dds_lifespan_qospolicy {
|
||||
dds_duration_t duration;
|
||||
} dds_lifespan_qospolicy_t;
|
||||
|
||||
typedef struct dds_destination_order_qospolicy {
|
||||
dds_destination_order_kind_t kind;
|
||||
} dds_destination_order_qospolicy_t;
|
||||
|
||||
typedef struct dds_entity_factory_qospolicy {
|
||||
unsigned char autoenable_created_entities;
|
||||
} dds_entity_factory_qospolicy_t;
|
||||
|
||||
typedef struct dds_writer_data_lifecycle_qospolicy {
|
||||
unsigned char autodispose_unregistered_instances;
|
||||
} dds_writer_data_lifecycle_qospolicy_t;
|
||||
|
||||
typedef struct dds_reader_data_lifecycle_qospolicy {
|
||||
dds_duration_t autopurge_nowriter_samples_delay;
|
||||
dds_duration_t autopurge_disposed_samples_delay;
|
||||
} dds_reader_data_lifecycle_qospolicy_t;
|
||||
|
||||
typedef struct dds_reader_lifespan_qospolicy {
|
||||
unsigned char use_lifespan;
|
||||
dds_duration_t duration;
|
||||
} dds_reader_lifespan_qospolicy_t;
|
||||
|
||||
typedef struct dds_writer_batching_qospolicy {
|
||||
unsigned char batch_updates;
|
||||
} dds_writer_batching_qospolicy_t;
|
||||
|
||||
typedef struct dds_ignorelocal_qospolicy {
|
||||
dds_ignorelocal_kind_t value;
|
||||
} dds_ignorelocal_qospolicy_t;
|
||||
|
||||
typedef struct dds_type_consistency_enforcement_qospolicy {
|
||||
dds_type_consistency_kind_t kind;
|
||||
bool ignore_sequence_bounds;
|
||||
bool ignore_string_bounds;
|
||||
bool ignore_member_names;
|
||||
bool prevent_type_widening;
|
||||
bool force_type_validation;
|
||||
} dds_type_consistency_enforcement_qospolicy_t;
|
||||
|
||||
typedef uint32_t dds_locator_mask_t;
|
||||
|
||||
typedef struct dds_data_representation_id_seq {
|
||||
uint32_t n;
|
||||
dds_data_representation_id_t *ids;
|
||||
} dds_data_representation_id_seq_t;
|
||||
|
||||
typedef struct dds_data_representation_qospolicy {
|
||||
dds_data_representation_id_seq_t value;
|
||||
} dds_data_representation_qospolicy_t;
|
||||
|
||||
typedef ddsi_stringseq_t dds_pubsub_message_exchange_qospolicy_t;
|
||||
|
||||
/***/
|
||||
|
||||
/* Qos Present bit indices */
|
||||
#define DDSI_QP_TOPIC_NAME ((uint64_t)1 << 0)
|
||||
#define DDSI_QP_TYPE_NAME ((uint64_t)1 << 1)
|
||||
#define DDSI_QP_PRESENTATION ((uint64_t)1 << 2)
|
||||
#define DDSI_QP_PARTITION ((uint64_t)1 << 3)
|
||||
#define DDSI_QP_GROUP_DATA ((uint64_t)1 << 4)
|
||||
#define DDSI_QP_TOPIC_DATA ((uint64_t)1 << 5)
|
||||
#define DDSI_QP_DURABILITY ((uint64_t)1 << 6)
|
||||
#define DDSI_QP_DURABILITY_SERVICE ((uint64_t)1 << 7)
|
||||
#define DDSI_QP_DEADLINE ((uint64_t)1 << 8)
|
||||
#define DDSI_QP_LATENCY_BUDGET ((uint64_t)1 << 9)
|
||||
#define DDSI_QP_LIVELINESS ((uint64_t)1 << 10)
|
||||
#define DDSI_QP_RELIABILITY ((uint64_t)1 << 11)
|
||||
#define DDSI_QP_DESTINATION_ORDER ((uint64_t)1 << 12)
|
||||
#define DDSI_QP_HISTORY ((uint64_t)1 << 13)
|
||||
#define DDSI_QP_RESOURCE_LIMITS ((uint64_t)1 << 14)
|
||||
#define DDSI_QP_TRANSPORT_PRIORITY ((uint64_t)1 << 15)
|
||||
#define DDSI_QP_LIFESPAN ((uint64_t)1 << 16)
|
||||
#define DDSI_QP_USER_DATA ((uint64_t)1 << 17)
|
||||
#define DDSI_QP_OWNERSHIP ((uint64_t)1 << 18)
|
||||
#define DDSI_QP_OWNERSHIP_STRENGTH ((uint64_t)1 << 19)
|
||||
#define DDSI_QP_TIME_BASED_FILTER ((uint64_t)1 << 20)
|
||||
#define DDSI_QP_ADLINK_WRITER_DATA_LIFECYCLE ((uint64_t)1 << 21)
|
||||
#define DDSI_QP_ADLINK_READER_DATA_LIFECYCLE ((uint64_t)1 << 22)
|
||||
#define DDSI_QP_ADLINK_READER_LIFESPAN ((uint64_t)1 << 24)
|
||||
#define DDSI_QP_CYCLONE_WRITER_BATCHING ((uint64_t)1 << 25)
|
||||
#define DDSI_QP_ADLINK_ENTITY_FACTORY ((uint64_t)1 << 27)
|
||||
#define DDSI_QP_CYCLONE_IGNORELOCAL ((uint64_t)1 << 30)
|
||||
#define DDSI_QP_PROPERTY_LIST ((uint64_t)1 << 31)
|
||||
#define DDSI_QP_TYPE_CONSISTENCY_ENFORCEMENT ((uint64_t)1 << 32)
|
||||
#define DDSI_QP_TYPE_INFORMATION ((uint64_t)1 << 33)
|
||||
#define DDSI_QP_PSMX ((uint64_t)1 << 34)
|
||||
#define DDSI_QP_DATA_REPRESENTATION ((uint64_t)1 << 35)
|
||||
#define DDSI_QP_ENTITY_NAME ((uint64_t)1 << 36)
|
||||
|
||||
|
||||
/* Partition QoS is not RxO according to the specification (DDS 1.2,
|
||||
section 7.1.3), but communication will not take place unless it
|
||||
matches. Same for topic and type. Relaxed qos matching is a bit of
|
||||
a weird one, but it affects matching, so ... */
|
||||
#define DDSI_QP_RXO_MASK (DDSI_QP_DURABILITY | DDSI_QP_PRESENTATION | DDSI_QP_DEADLINE | DDSI_QP_LATENCY_BUDGET | DDSI_QP_OWNERSHIP | DDSI_QP_LIVELINESS | DDSI_QP_RELIABILITY | DDSI_QP_DESTINATION_ORDER | DDSI_QP_DATA_REPRESENTATION)
|
||||
#define DDSI_QP_CHANGEABLE_MASK (DDSI_QP_USER_DATA | DDSI_QP_TOPIC_DATA | DDSI_QP_GROUP_DATA | DDSI_QP_DEADLINE | DDSI_QP_LATENCY_BUDGET | DDSI_QP_OWNERSHIP_STRENGTH | DDSI_QP_TIME_BASED_FILTER | DDSI_QP_PARTITION | DDSI_QP_TRANSPORT_PRIORITY | DDSI_QP_LIFESPAN | DDSI_QP_ADLINK_ENTITY_FACTORY | DDSI_QP_ADLINK_WRITER_DATA_LIFECYCLE | DDSI_QP_ADLINK_READER_DATA_LIFECYCLE)
|
||||
#define DDSI_QP_UNRECOGNIZED_INCOMPATIBLE_MASK ((uint64_t) 0)
|
||||
|
||||
/* readers & writers have an extended qos, hence why it is a separate
|
||||
type */
|
||||
struct dds_qos {
|
||||
/* Entries present, for sparse QoS */
|
||||
uint64_t present;
|
||||
uint64_t aliased;
|
||||
|
||||
/*v---- in ...Qos
|
||||
v--- in ...BuiltinTopicData
|
||||
v-- mapped in DDSI
|
||||
v- reader/writer/publisher/subscriber/participant specific */
|
||||
/* Extras: */
|
||||
/* xx */char *topic_name;
|
||||
/* xx */char *type_name;
|
||||
/* xx */char *entity_name;
|
||||
#ifdef DDS_HAS_TYPELIB
|
||||
/* xx */struct ddsi_typeinfo *type_information;
|
||||
#endif
|
||||
/* PublisherQos, SubscriberQos: */
|
||||
/*xxx */dds_presentation_qospolicy_t presentation;
|
||||
/*xxx */dds_partition_qospolicy_t partition;
|
||||
/*xxx */dds_groupdata_qospolicy_t group_data;
|
||||
/*x xX*/dds_entity_factory_qospolicy_t entity_factory;
|
||||
/* TopicQos: */
|
||||
/*xxx */dds_topicdata_qospolicy_t topic_data;
|
||||
/* DataWriterQos, DataReaderQos: */
|
||||
/*xxx */dds_durability_qospolicy_t durability;
|
||||
/*xxx */dds_durability_service_qospolicy_t durability_service;
|
||||
/*xxx */dds_deadline_qospolicy_t deadline;
|
||||
/*xxx */dds_latency_budget_qospolicy_t latency_budget;
|
||||
/*xxx */dds_liveliness_qospolicy_t liveliness;
|
||||
/*xxx */dds_reliability_qospolicy_t reliability;
|
||||
/*xxx */dds_destination_order_qospolicy_t destination_order;
|
||||
/*x x */dds_history_qospolicy_t history;
|
||||
/*x x */dds_resource_limits_qospolicy_t resource_limits;
|
||||
/*x x */dds_transport_priority_qospolicy_t transport_priority;
|
||||
/*xxx */dds_lifespan_qospolicy_t lifespan;
|
||||
/*xxx */dds_userdata_qospolicy_t user_data;
|
||||
/*xxx */dds_ownership_qospolicy_t ownership;
|
||||
/*xxxW*/dds_ownership_strength_qospolicy_t ownership_strength;
|
||||
/*xxxR*/dds_time_based_filter_qospolicy_t time_based_filter;
|
||||
/*x W*/dds_writer_data_lifecycle_qospolicy_t writer_data_lifecycle;
|
||||
/*x xR*/dds_reader_data_lifecycle_qospolicy_t reader_data_lifecycle;
|
||||
/*x xR*/dds_reader_lifespan_qospolicy_t reader_lifespan;
|
||||
/*x W*/dds_writer_batching_qospolicy_t writer_batching;
|
||||
/* x */dds_ignorelocal_qospolicy_t ignorelocal;
|
||||
/*xxx */dds_property_qospolicy_t property;
|
||||
/*xxxR*/dds_type_consistency_enforcement_qospolicy_t type_consistency;
|
||||
/*xxxX*/dds_pubsub_message_exchange_qospolicy_t psmx;
|
||||
/*xxx */dds_data_representation_qospolicy_t data_representation;
|
||||
};
|
||||
|
||||
DDS_EXPORT extern const dds_qos_t ddsi_default_qos_reader;
|
||||
DDS_EXPORT extern const dds_qos_t ddsi_default_qos_writer;
|
||||
DDS_EXPORT extern const dds_qos_t ddsi_default_qos_topic;
|
||||
DDS_EXPORT extern const dds_qos_t ddsi_default_qos_publisher_subscriber;
|
||||
DDS_EXPORT extern const dds_qos_t ddsi_default_qos_participant;
|
||||
|
||||
/**
|
||||
* @brief Initialize a new empty dds_qos_t as an empty object
|
||||
* @component qos_handling
|
||||
*
|
||||
* In principle, this only clears the "present" and "aliased" bitmasks. A debug build
|
||||
* additionally initializes all other bytes to 0x55.
|
||||
*
|
||||
* @param[out] xqos qos object to be initialized.
|
||||
*/
|
||||
void ddsi_xqos_init_empty (dds_qos_t *xqos);
|
||||
|
||||
/**
|
||||
* @brief Copy "src" to "dst"
|
||||
* @component qos_handling
|
||||
*
|
||||
* @param[out] dst destination, any contents are overwritten
|
||||
* @param[in] src source dds_qos_t
|
||||
*/
|
||||
void ddsi_xqos_copy (dds_qos_t *dst, const dds_qos_t *src);
|
||||
|
||||
/**
|
||||
* @brief Free memory owned by "xqos"
|
||||
* @component qos_handling
|
||||
*
|
||||
* A dds_qos_t may own other allocated blocks of memory, depending on which fields are
|
||||
* set, their types and whether they are marked as "aliased". This function releases any
|
||||
* such memory owned by "xqos", but not "xqos" itself. Afterward, the content of "xqos"
|
||||
* is undefined and must not be used again without initialising it.
|
||||
*
|
||||
* @param[in] xqos dds_qos_t for which to free memory
|
||||
*/
|
||||
void ddsi_xqos_fini (dds_qos_t *xqos);
|
||||
|
||||
/**
|
||||
* @brief Check whether xqos is valid according to the validation rules in the spec
|
||||
* @component qos_handling
|
||||
*
|
||||
* The checks concern the values for the individual fields as well as a few combinations
|
||||
* of fields. Only those that are set are checked (the defaults are all valid anyway),
|
||||
* and where a combination of fields must be checked and some but not all fields are
|
||||
* specified, it uses the defaults for the missing ones.
|
||||
*
|
||||
* Invalid values get logged as category "plist" according to the specified logging
|
||||
* configuration.
|
||||
*
|
||||
* @param[in] logcfg logging configuration
|
||||
* @param[in] xqos qos object to check
|
||||
*
|
||||
* @returns DDS_RETCODE_OK or DDS_RETCODE_BAD_PARAMETER
|
||||
*/
|
||||
dds_return_t ddsi_xqos_valid (const struct ddsrt_log_cfg *logcfg, const dds_qos_t *xqos);
|
||||
|
||||
/**
|
||||
* @brief Extend "a" with selected entries present in "b"
|
||||
* @component qos_handling
|
||||
*
|
||||
* This copies into "a" any entries present in "b" that are included in "mask" and missing
|
||||
* in "a". It doesn't touch any entries already present in "a". Calling this on an empty
|
||||
* "a" with all bits set in "mask" is equivalent to copying "b" into "a"; calling this
|
||||
* with "mask" 0 copies nothing.
|
||||
*
|
||||
* @param[in,out] a dds_qos_t to be extended
|
||||
* @param[in] b dds_qos_t from which to copy entries
|
||||
* @param[in] mask which to include (if DDSI_QP_X is set, include X)
|
||||
*/
|
||||
void ddsi_xqos_mergein_missing (dds_qos_t *a, const dds_qos_t *b, uint64_t mask);
|
||||
|
||||
/**
|
||||
* @brief Determine the set of entries in which "x" differs from "y"
|
||||
* @component qos_handling
|
||||
*
|
||||
* This computes the entries set in "x" but not set in "y", not set in "x" but set in "y",
|
||||
* or set in both "x" and "y" but to a different value. It returns this set reduced to
|
||||
* only those included in "mask", that is, if bit X is clear in "mask", bit X will be
|
||||
* clear in the result.
|
||||
*
|
||||
* @param[in] a one of the two plists to compare
|
||||
* @param[in] b other plist to compare
|
||||
* @param[in] mask subset of entries to be compared
|
||||
*
|
||||
* @returns Bitmask of differences
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsi_xqos_delta (const dds_qos_t *a, const dds_qos_t *b, uint64_t mask);
|
||||
|
||||
/**
|
||||
* @brief Add a property 'name' to the properties of "xqos" if it does not exists
|
||||
* @component qos_handling
|
||||
*
|
||||
* @param[in] xqos qos object to add property to.
|
||||
* @param[in] propagate whether to propagate (emit to wire) the property
|
||||
* @param[in] name property name
|
||||
* @param[in] value property value
|
||||
*
|
||||
* @returns true iff xqos was modified (property did not exist yet)
|
||||
*/
|
||||
bool ddsi_xqos_add_property_if_unset (dds_qos_t *xqos, bool propagate, const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* @brief Duplicate "src"
|
||||
* @component qos_handling
|
||||
*
|
||||
* @param[in] src dds_qos_t to be duplicated
|
||||
*
|
||||
* @returns a new (allocated using ddsrt_malloc) dds_qos_t containing a copy of "src".
|
||||
*/
|
||||
dds_qos_t *ddsi_xqos_dup (const dds_qos_t *src);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_XQOS_H */
|
||||
+1315
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,314 @@
|
||||
/****************************************************************
|
||||
|
||||
Generated by Eclipse Cyclone DDS IDL to C Translator
|
||||
File name: ddsi_xt_typelookup.h
|
||||
Source: ddsi_xt_typelookup.idl
|
||||
Cyclone DDS: V0.11.0
|
||||
|
||||
*****************************************************************/
|
||||
#ifndef DDSI_XT_TYPELOOKUP_H
|
||||
#define DDSI_XT_TYPELOOKUP_H
|
||||
|
||||
#include "dds/ddsi/ddsi_xt_typeinfo.h"
|
||||
|
||||
#include "dds/ddsc/dds_public_impl.h"
|
||||
#include "dds/cdr/dds_cdrstream.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef uint8_t DDS_GuidPrefix_t[12];
|
||||
|
||||
#define DDS_GuidPrefix_t__alloc() \
|
||||
((DDS_GuidPrefix_t*) dds_alloc (sizeof (DDS_GuidPrefix_t)));
|
||||
|
||||
typedef struct DDS_EntityId_t
|
||||
{
|
||||
uint8_t entityKey[3];
|
||||
uint8_t entityKind;
|
||||
} DDS_EntityId_t;
|
||||
|
||||
typedef struct DDS_GUID_t
|
||||
{
|
||||
DDS_GuidPrefix_t guidPrefix;
|
||||
struct DDS_EntityId_t entityId;
|
||||
} DDS_GUID_t;
|
||||
|
||||
typedef struct DDS_SequenceNumber
|
||||
{
|
||||
int32_t high;
|
||||
uint32_t low;
|
||||
} DDS_SequenceNumber;
|
||||
|
||||
typedef struct DDS_SampleIdentity
|
||||
{
|
||||
struct DDS_GUID_t writer_guid;
|
||||
struct DDS_SequenceNumber sequence_number;
|
||||
} DDS_SampleIdentity;
|
||||
|
||||
#define DDS_DDS_RETCODE_OK 0
|
||||
typedef uint8_t DDS_RPC_UnknownOperation;
|
||||
|
||||
#define DDS_RPC_UnknownOperation__alloc() \
|
||||
((DDS_RPC_UnknownOperation*) dds_alloc (sizeof (DDS_RPC_UnknownOperation)));
|
||||
|
||||
typedef uint8_t DDS_RPC_UnknownException;
|
||||
|
||||
#define DDS_RPC_UnknownException__alloc() \
|
||||
((DDS_RPC_UnknownException*) dds_alloc (sizeof (DDS_RPC_UnknownException)));
|
||||
|
||||
typedef uint8_t DDS_RPC_UnusedMember;
|
||||
|
||||
#define DDS_RPC_UnusedMember__alloc() \
|
||||
((DDS_RPC_UnusedMember*) dds_alloc (sizeof (DDS_RPC_UnusedMember)));
|
||||
|
||||
typedef enum DDS_RPC_RemoteExceptionCode
|
||||
{
|
||||
DDS_RPC_REMOTE_EX_OK,
|
||||
DDS_RPC_REMOTE_EX_UNSUPPORTED,
|
||||
DDS_RPC_REMOTE_EX_INVALID_ARGUMENT,
|
||||
DDS_RPC_REMOTE_EX_OUT_OF_RESOURCES,
|
||||
DDS_RPC_REMOTE_EX_UNKNOWN_OPERATION,
|
||||
DDS_RPC_REMOTE_EX_UNKNOWN_EXCEPTION
|
||||
} DDS_RPC_RemoteExceptionCode;
|
||||
|
||||
#define DDS_RPC_RemoteExceptionCode__alloc() \
|
||||
((DDS_RPC_RemoteExceptionCode*) dds_alloc (sizeof (DDS_RPC_RemoteExceptionCode)));
|
||||
|
||||
typedef char DDS_RPC_InstanceName[256];
|
||||
|
||||
#define DDS_RPC_InstanceName__alloc() \
|
||||
((DDS_RPC_InstanceName*) dds_alloc (sizeof (DDS_RPC_InstanceName)));
|
||||
|
||||
typedef struct DDS_RPC_RequestHeader
|
||||
{
|
||||
struct DDS_SampleIdentity requestId;
|
||||
DDS_RPC_InstanceName instanceName;
|
||||
} DDS_RPC_RequestHeader;
|
||||
|
||||
typedef struct DDS_RPC_ReplyHeader
|
||||
{
|
||||
struct DDS_SampleIdentity relatedRequestId;
|
||||
DDS_RPC_RemoteExceptionCode remoteEx;
|
||||
} DDS_RPC_ReplyHeader;
|
||||
|
||||
#define DDS_Builtin_TypeLookup_getTypes_HashId 25318099
|
||||
#define DDS_Builtin_TypeLookup_getDependencies_HashId 95091505
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifier
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifier *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifier;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifier__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifier*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifier)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifier_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifier *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifier)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED */
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypes_In
|
||||
{
|
||||
dds_sequence_DDS_XTypes_TypeIdentifier type_ids;
|
||||
} DDS_Builtin_TypeLookup_getTypes_In;
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierTypeObjectPair *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierTypeObjectPair *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierTypeObjectPair)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED */
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierPair
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierPair *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierPair;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierPair__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierPair*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierPair)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierPair_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierPair *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierPair)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED */
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypes_Out
|
||||
{
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair types;
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierPair complete_to_minimal;
|
||||
} DDS_Builtin_TypeLookup_getTypes_Out;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypes_Result
|
||||
{
|
||||
int32_t _d;
|
||||
union
|
||||
{
|
||||
struct DDS_Builtin_TypeLookup_getTypes_Out result;
|
||||
} _u;
|
||||
} DDS_Builtin_TypeLookup_getTypes_Result;
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifier
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifier *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifier;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifier__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifier*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifier)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifier_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifier *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifier)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIER_DEFINED */
|
||||
|
||||
#ifndef DDS_SEQUENCE_OCTET_DEFINED
|
||||
#define DDS_SEQUENCE_OCTET_DEFINED
|
||||
typedef struct dds_sequence_octet
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
uint8_t *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_octet;
|
||||
|
||||
#define dds_sequence_octet__alloc() \
|
||||
((dds_sequence_octet*) dds_alloc (sizeof (dds_sequence_octet)));
|
||||
|
||||
#define dds_sequence_octet_allocbuf(l) \
|
||||
((uint8_t *) dds_alloc ((l) * sizeof (uint8_t)))
|
||||
#endif /* DDS_SEQUENCE_OCTET_DEFINED */
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypeDependencies_In
|
||||
{
|
||||
dds_sequence_DDS_XTypes_TypeIdentifier type_ids;
|
||||
dds_sequence_octet continuation_point;
|
||||
} DDS_Builtin_TypeLookup_getTypeDependencies_In;
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERWITHSIZE_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERWITHSIZE_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierWithSize
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierWithSize *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierWithSize;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierWithSize__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierWithSize*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierWithSize)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierWithSize_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierWithSize *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierWithSize)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERWITHSIZE_DEFINED */
|
||||
|
||||
#ifndef DDS_SEQUENCE_OCTET_DEFINED
|
||||
#define DDS_SEQUENCE_OCTET_DEFINED
|
||||
typedef struct dds_sequence_octet
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
uint8_t *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_octet;
|
||||
|
||||
#define dds_sequence_octet__alloc() \
|
||||
((dds_sequence_octet*) dds_alloc (sizeof (dds_sequence_octet)));
|
||||
|
||||
#define dds_sequence_octet_allocbuf(l) \
|
||||
((uint8_t *) dds_alloc ((l) * sizeof (uint8_t)))
|
||||
#endif /* DDS_SEQUENCE_OCTET_DEFINED */
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypeDependencies_Out
|
||||
{
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierWithSize dependent_typeids;
|
||||
dds_sequence_octet continuation_point;
|
||||
} DDS_Builtin_TypeLookup_getTypeDependencies_Out;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_getTypeDependencies_Result
|
||||
{
|
||||
int32_t _d;
|
||||
union
|
||||
{
|
||||
struct DDS_Builtin_TypeLookup_getTypeDependencies_Out result;
|
||||
} _u;
|
||||
} DDS_Builtin_TypeLookup_getTypeDependencies_Result;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_Call
|
||||
{
|
||||
int32_t _d;
|
||||
union
|
||||
{
|
||||
struct DDS_Builtin_TypeLookup_getTypes_In getTypes;
|
||||
struct DDS_Builtin_TypeLookup_getTypeDependencies_In getTypeDependencies;
|
||||
} _u;
|
||||
} DDS_Builtin_TypeLookup_Call;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_Request
|
||||
{
|
||||
struct DDS_RPC_RequestHeader header;
|
||||
struct DDS_Builtin_TypeLookup_Call data;
|
||||
} DDS_Builtin_TypeLookup_Request;
|
||||
|
||||
DDS_EXPORT extern const dds_topic_descriptor_t DDS_Builtin_TypeLookup_Request_desc;
|
||||
|
||||
#define DDS_Builtin_TypeLookup_Request__alloc() \
|
||||
((DDS_Builtin_TypeLookup_Request*) dds_alloc (sizeof (DDS_Builtin_TypeLookup_Request)));
|
||||
|
||||
#define DDS_Builtin_TypeLookup_Request_free(d,o) \
|
||||
dds_sample_free ((d), &DDS_Builtin_TypeLookup_Request_desc, (o))
|
||||
|
||||
DDS_EXPORT extern const struct dds_cdrstream_desc DDS_Builtin_TypeLookup_Request_cdrstream_desc;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_Return
|
||||
{
|
||||
int32_t _d;
|
||||
union
|
||||
{
|
||||
struct DDS_Builtin_TypeLookup_getTypes_Result getType;
|
||||
struct DDS_Builtin_TypeLookup_getTypeDependencies_Result getTypeDependencies;
|
||||
} _u;
|
||||
} DDS_Builtin_TypeLookup_Return;
|
||||
|
||||
typedef struct DDS_Builtin_TypeLookup_Reply
|
||||
{
|
||||
struct DDS_RPC_ReplyHeader header;
|
||||
struct DDS_Builtin_TypeLookup_Return return_data;
|
||||
} DDS_Builtin_TypeLookup_Reply;
|
||||
|
||||
DDS_EXPORT extern const dds_topic_descriptor_t DDS_Builtin_TypeLookup_Reply_desc;
|
||||
|
||||
#define DDS_Builtin_TypeLookup_Reply__alloc() \
|
||||
((DDS_Builtin_TypeLookup_Reply*) dds_alloc (sizeof (DDS_Builtin_TypeLookup_Reply)));
|
||||
|
||||
#define DDS_Builtin_TypeLookup_Reply_free(d,o) \
|
||||
dds_sample_free ((d), &DDS_Builtin_TypeLookup_Reply_desc, (o))
|
||||
|
||||
DDS_EXPORT extern const struct dds_cdrstream_desc DDS_Builtin_TypeLookup_Reply_cdrstream_desc;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_XT_TYPELOOKUP_H */
|
||||
@@ -0,0 +1,93 @@
|
||||
/****************************************************************
|
||||
|
||||
Generated by Eclipse Cyclone DDS IDL to C Translator
|
||||
File name: ddsi_xt_typemap.h
|
||||
Source: ddsi_xt_typemap.idl
|
||||
Cyclone DDS: V0.11.0
|
||||
|
||||
*****************************************************************/
|
||||
#ifndef DDSI_XT_TYPEMAP_H
|
||||
#define DDSI_XT_TYPEMAP_H
|
||||
|
||||
#include "dds/ddsi/ddsi_xt_typeinfo.h"
|
||||
|
||||
#include "dds/ddsc/dds_public_impl.h"
|
||||
#include "dds/cdr/dds_cdrstream.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierTypeObjectPair *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierTypeObjectPair *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierTypeObjectPair)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED */
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierTypeObjectPair *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierTypeObjectPair *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierTypeObjectPair)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERTYPEOBJECTPAIR_DEFINED */
|
||||
|
||||
#ifndef DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED
|
||||
#define DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED
|
||||
typedef struct dds_sequence_DDS_XTypes_TypeIdentifierPair
|
||||
{
|
||||
uint32_t _maximum;
|
||||
uint32_t _length;
|
||||
struct DDS_XTypes_TypeIdentifierPair *_buffer;
|
||||
bool _release;
|
||||
} dds_sequence_DDS_XTypes_TypeIdentifierPair;
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierPair__alloc() \
|
||||
((dds_sequence_DDS_XTypes_TypeIdentifierPair*) dds_alloc (sizeof (dds_sequence_DDS_XTypes_TypeIdentifierPair)));
|
||||
|
||||
#define dds_sequence_DDS_XTypes_TypeIdentifierPair_allocbuf(l) \
|
||||
((struct DDS_XTypes_TypeIdentifierPair *) dds_alloc ((l) * sizeof (struct DDS_XTypes_TypeIdentifierPair)))
|
||||
#endif /* DDS_SEQUENCE_DDS_XTYPES_TYPEIDENTIFIERPAIR_DEFINED */
|
||||
|
||||
typedef struct DDS_XTypes_TypeMapping
|
||||
{
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair identifier_object_pair_minimal;
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierTypeObjectPair identifier_object_pair_complete;
|
||||
dds_sequence_DDS_XTypes_TypeIdentifierPair identifier_complete_minimal;
|
||||
} DDS_XTypes_TypeMapping;
|
||||
|
||||
DDS_EXPORT extern const dds_topic_descriptor_t DDS_XTypes_TypeMapping_desc;
|
||||
|
||||
#define DDS_XTypes_TypeMapping__alloc() \
|
||||
((DDS_XTypes_TypeMapping*) dds_alloc (sizeof (DDS_XTypes_TypeMapping)));
|
||||
|
||||
#define DDS_XTypes_TypeMapping_free(d,o) \
|
||||
dds_sample_free ((d), &DDS_XTypes_TypeMapping_desc, (o))
|
||||
|
||||
DDS_EXPORT extern const struct dds_cdrstream_desc DDS_XTypes_TypeMapping_cdrstream_desc;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSI_XT_TYPEMAP_H */
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// Copyright(c) 2022 ZettaScale Technology 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 DDSRT_ALIGN_H
|
||||
#define DDSRT_ALIGN_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define dds_alignof _Alignof
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ALIGN_H */
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSRT_ARCH_H
|
||||
#define DDSRT_ARCH_H
|
||||
|
||||
#if _WIN32
|
||||
# if _WIN64
|
||||
# define DDSRT_64BIT 1
|
||||
# else
|
||||
# define DDSRT_64BIT 0
|
||||
# endif
|
||||
#else
|
||||
# if defined(_LP64)
|
||||
# define DDSRT_64BIT 1
|
||||
# else
|
||||
# define DDSRT_64BIT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ARCH_H */
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSRT_ATOMICS_H
|
||||
#define DDSRT_ATOMICS_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/arch.h"
|
||||
#include "dds/ddsrt/endian.h"
|
||||
#include "dds/ddsrt/types.h"
|
||||
|
||||
/**
|
||||
* @file atomics.h
|
||||
* @brief Contains functions and types for atomic operations on various types
|
||||
*
|
||||
* This header file declares functions and types for atomic operations on uint32_t,
|
||||
* uint64_t, uintptr_t, and void* types.
|
||||
*
|
||||
* 64-bit atomics are not supported by all hardware, but it would be a shame not to use them when
|
||||
* they are available. That necessitates an alternative implementation when they are not, either in
|
||||
* the form of a different implementation where it is used, or as an emulation using a mutex in
|
||||
* ddsrt. It seems that the places where they'd be used end up adding a mutex, so an emulation in
|
||||
* ddsrt while being able to check whether it is supported by hardware is a sensible approach.
|
||||
*/
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Types on which atomic operations are defined.
|
||||
*
|
||||
* @note 64-bit types are defined even if atomic operations on them are not
|
||||
* really supported.
|
||||
*/
|
||||
typedef struct { uint32_t v; } ddsrt_atomic_uint32_t; /**< Type for atomic operations on uint32_t */
|
||||
typedef struct { uint64_t v; } ddsrt_atomic_uint64_t; /**< Type for atomic operations on uint64_t */
|
||||
typedef struct { uintptr_t v; } ddsrt_atomic_uintptr_t; /**< Type for atomic operations on uintptr_t */
|
||||
typedef ddsrt_atomic_uintptr_t ddsrt_atomic_voidp_t; /**< Convenience type for atomic operations on void pointers */
|
||||
|
||||
#if DDSRT_64BIT
|
||||
# define DDSRT_HAVE_ATOMIC64 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initializers for the types on which atomic operations are defined.
|
||||
*/
|
||||
#define DDSRT_ATOMIC_UINT32_INIT(v) { (v) } /**< Initializer for ddsrt_atomic_uint32_t */
|
||||
#define DDSRT_ATOMIC_UINT64_INIT(v) { (v) } /**< Initializer for ddsrt_atomic_uint64_t */
|
||||
#define DDSRT_ATOMIC_UINTPTR_INIT(v) { (v) } /**< Initializer for ddsrt_atomic_uintptr_t */
|
||||
#define DDSRT_ATOMIC_VOIDP_INIT(v) { (uintptr_t) (v) } /**< Initializer for ddsrt_atomic_voidp_t */
|
||||
|
||||
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40100
|
||||
#include "dds/ddsrt/atomics/gcc.h"
|
||||
#elif defined(_WIN32)
|
||||
#include "dds/ddsrt/atomics/msvc.h"
|
||||
#elif defined(__sun)
|
||||
#include "dds/ddsrt/atomics/sun.h"
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
|
||||
#include "dds/ddsrt/atomics/arm.h"
|
||||
#else
|
||||
#error "Atomic operations are not supported"
|
||||
#endif
|
||||
|
||||
#if ! DDSRT_HAVE_ATOMIC64
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_ld64 (const volatile ddsrt_atomic_uint64_t *x);
|
||||
|
||||
/**
|
||||
* @brief Assign a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_st64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_inc64 (volatile ddsrt_atomic_uint64_t *x);
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_inc64_nv (volatile ddsrt_atomic_uint64_t *x);
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_dec64 (volatile ddsrt_atomic_uint64_t *x);
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_dec64_nv (volatile ddsrt_atomic_uint64_t *x);
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_add64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_add64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_sub64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_sub64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_and64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_and64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_and64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_or64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_or64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_EXPORT uint64_t ddsrt_atomic_or64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v);
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 64-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_EXPORT int ddsrt_atomic_cas64 (volatile ddsrt_atomic_uint64_t *x, uint64_t exp, uint64_t des);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize mutexes for atomics
|
||||
*/
|
||||
void ddsrt_atomics_init (void);
|
||||
|
||||
/**
|
||||
* @brief Destroy mutexes for atomics
|
||||
*/
|
||||
void ddsrt_atomics_fini (void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ATOMICS_H */
|
||||
+624
@@ -0,0 +1,624 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSRT_ATOMICS_ARM_H
|
||||
#define DDSRT_ATOMICS_ARM_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(__arm__)
|
||||
#define __arm__
|
||||
#endif
|
||||
|
||||
/* IAR documentation states that __CPU_MODE__ is a predefined preprocessor
|
||||
symbol reflecting the selected CPU mode and is defined to 1 for Thumb and
|
||||
2 for ARM. */
|
||||
#if !defined(__thumb__) && __CPU_MODE__ == 1
|
||||
#define __thumb__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file arm.h
|
||||
* @brief Contains functions and types for atomic operations on various types for arm.
|
||||
*
|
||||
* This header file defines functions for atomic operations on uint32_t,
|
||||
* uint64_t, uintptr_t, and void* types.
|
||||
*/
|
||||
|
||||
/* LD, ST */
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_ld32 (const volatile ddsrt_atomic_uint32_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of an uintptr atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_ldptr (const volatile ddsrt_atomic_uintptr_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a void pointer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline void *ddsrt_atomic_ldvoidp (const volatile ddsrt_atomic_voidp_t *x) { return (void *) ddsrt_atomic_ldptr (x); }
|
||||
|
||||
/**
|
||||
* @brief Assign a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_st32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign an uintptr atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_stptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign a void pointer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_stvoidp (volatile ddsrt_atomic_voidp_t *x, void *v) { ddsrt_atomic_stptr (x, (uintptr_t) v); }
|
||||
|
||||
/* CAS */
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 32-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_cas32 (volatile ddsrt_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
register int result;
|
||||
asm volatile ("ldrex r0, [%1]\n\t" /*exclusive load of ptr */
|
||||
"cmp r0, %2\n\t" /*compare the oldval == *ptr */
|
||||
#if defined(__thumb__)
|
||||
"ite eq\n\t"
|
||||
#endif
|
||||
"strexeq %0, %3, [%1]\n\t" /*store if eq, strex+eq*/
|
||||
#if defined(__thumb__)
|
||||
"clrexne"
|
||||
#endif
|
||||
: "=&r" (result)
|
||||
: "r"(&x->v), "r"(exp),"r"(des)
|
||||
: "r0");
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap an uintptr atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_casptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return ddsrt_atomic_cas32 ((volatile ddsrt_atomic_uint32_t *) x, exp, des);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a void pointer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_casvoidp (volatile ddsrt_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return ddsrt_atomic_casptr ((volatile ddsrt_atomic_uintptr_t *) x, (uintptr_t) exp, (uintptr_t) des);
|
||||
}
|
||||
|
||||
/* ADD */
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_add32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
register unsigned int result;
|
||||
asm volatile ("1: ldrex %0, [%1]\n\t"
|
||||
"add %0, %0, %2\n\t"
|
||||
"strex r1, %0, [%1]\n\t"
|
||||
"cmp r1, #0\n\t"
|
||||
"bne 1b"
|
||||
: "=&r" (result)
|
||||
: "r"(&x->v), "r"(v)
|
||||
: "r1");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_addptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return ddsrt_atomic_add32_nv ((volatile ddsrt_atomic_uint32_t *) x, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
inline void ddsrt_atomic_add32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
(void) ddsrt_atomic_add32_nv (x, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
inline void ddsrt_atomic_addptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
(void) ddsrt_atomic_addptr_nv (x, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_add32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return ddsrt_atomic_add32_nv (x, v) - v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_addptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return ddsrt_atomic_addptr_nv (x, v) - v;
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_sub32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return ddsrt_atomic_add32_nv (x, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_subptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return ddsrt_atomic_addptr_nv (x, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_sub32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return ddsrt_atomic_add32_ov (x, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_subptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return ddsrt_atomic_addptr_ov (x, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
inline void ddsrt_atomic_sub32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
ddsrt_atomic_add32 (x, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
inline void ddsrt_atomic_subptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
ddsrt_atomic_addptr (x, -v);
|
||||
}
|
||||
|
||||
/* INC */
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_inc32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return ddsrt_atomic_add32_ov (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_incptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return ddsrt_atomic_addptr_ov (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_inc32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return ddsrt_atomic_add32_nv (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_incptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return ddsrt_atomic_addptr_nv (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
inline void ddsrt_atomic_inc32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
(void) ddsrt_atomic_inc32_nv (x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
inline void ddsrt_atomic_incptr (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
(void) ddsrt_atomic_incptr_nv (x);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_dec32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return ddsrt_atomic_sub32_ov (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_decptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return ddsrt_atomic_subptr_ov (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_dec32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return ddsrt_atomic_sub32_nv (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_decptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return ddsrt_atomic_subptr_nv (x, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
inline void ddsrt_atomic_dec32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
(void) ddsrt_atomic_dec32_nv (x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
inline void ddsrt_atomic_decptr (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
(void) ddsrt_atomic_decptr_nv (x);
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_and32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (!ddsrt_atomic_cas32 (x, oldval, newval));
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_andptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (!ddsrt_atomic_casptr (x, oldval, newval));
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_and32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (!ddsrt_atomic_cas32 (x, oldval, newval));
|
||||
return newval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_andptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval & v; } while (!ddsrt_atomic_casptr (x, oldval, newval));
|
||||
return newval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_and32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
(void) ddsrt_atomic_and32_nv (x, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_andptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
(void) ddsrt_atomic_andptr_nv (x, v);
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_or32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (!ddsrt_atomic_cas32 (x, oldval, newval));
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_orptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (!ddsrt_atomic_casptr (x, oldval, newval));
|
||||
return oldval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_or32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
uint32_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (!ddsrt_atomic_cas32 (x, oldval, newval));
|
||||
return newval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_orptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
uintptr_t oldval, newval;
|
||||
do { oldval = x->v; newval = oldval | v; } while (!ddsrt_atomic_casptr (x, oldval, newval));
|
||||
return newval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_or32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
(void) ddsrt_atomic_or32_nv (x, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_orptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
(void) ddsrt_atomic_orptr_nv (x, v);
|
||||
}
|
||||
|
||||
/* FENCES */
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence (void) {
|
||||
__asm volatile ("dmb" : : : "memory");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_ldld (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_rel (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ATOMICS_ARM_H */
|
||||
+984
@@ -0,0 +1,984 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSRT_ATOMICS_GCC_H
|
||||
#define DDSRT_ATOMICS_GCC_H
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
DDSRT_WARNING_GNUC_OFF(old-style-cast)
|
||||
DDSRT_WARNING_CLANG_OFF(old-style-cast)
|
||||
#endif
|
||||
|
||||
#if ( DDSRT_HAVE_ATOMIC64 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) || \
|
||||
(!DDSRT_HAVE_ATOMIC64 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
|
||||
# define DDSRT_HAVE_ATOMIC_LIFO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file gcc.h
|
||||
* @brief Contains functions and types for atomic operations on various types for gcc.
|
||||
*
|
||||
* This header file defines functions for atomic operations on uint32_t,
|
||||
* uint64_t, uintptr_t, and void* types.
|
||||
*
|
||||
* It also declares atomic operations for a lifo linked list.
|
||||
*/
|
||||
|
||||
/* LD, ST */
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline uint32_t ddsrt_atomic_ld32(const volatile ddsrt_atomic_uint32_t *x)
|
||||
{
|
||||
return x->v;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Fetch the value of a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline uint64_t ddsrt_atomic_ld64(const volatile ddsrt_atomic_uint64_t *x)
|
||||
{
|
||||
return x->v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of an uintptr atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline uintptr_t ddsrt_atomic_ldptr(const volatile ddsrt_atomic_uintptr_t *x)
|
||||
{
|
||||
return x->v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a void pointer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline void *ddsrt_atomic_ldvoidp(const volatile ddsrt_atomic_voidp_t *x)
|
||||
{
|
||||
return (void *) ddsrt_atomic_ldptr(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assign a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline void ddsrt_atomic_st32(volatile ddsrt_atomic_uint32_t *x, uint32_t v)
|
||||
{
|
||||
x->v = v;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Assign a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline void ddsrt_atomic_st64(volatile ddsrt_atomic_uint64_t *x, uint64_t v)
|
||||
{
|
||||
x->v = v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Assign an uintptr atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline void ddsrt_atomic_stptr(volatile ddsrt_atomic_uintptr_t *x, uintptr_t v)
|
||||
{
|
||||
x->v = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assign a void pointer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT ddsrt_attribute_no_sanitize (("thread"))
|
||||
inline void ddsrt_atomic_stvoidp(volatile ddsrt_atomic_voidp_t *x, void *v)
|
||||
{
|
||||
ddsrt_atomic_stptr(x, (uintptr_t)v);
|
||||
}
|
||||
|
||||
/* INC */
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_inc32(volatile ddsrt_atomic_uint32_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_inc64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_incptr(volatile ddsrt_atomic_uintptr_t *x) {
|
||||
__sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_inc32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return __sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_inc64_ov (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return __sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_incptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return __sync_fetch_and_add (&x->v, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_inc32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_inc64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_incptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return __sync_add_and_fetch (&x->v, 1);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_dec32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_dec64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_decptr (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
__sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_dec32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_dec64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_decptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return __sync_sub_and_fetch (&x->v, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_dec32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_dec64_ov (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_decptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return __sync_fetch_and_sub (&x->v, 1);
|
||||
}
|
||||
|
||||
/* ADD */
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_add32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_add64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_addptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_add32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_add64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_addptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_add (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_add32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_add64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_addptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_add_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_sub32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_sub64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_subptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_sub32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_sub64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_subptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_sub (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_sub32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_sub64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_subptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_sub_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_and32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_and64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_andptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_and32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_and64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_andptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_and (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_and32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_and64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_andptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_and_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_or32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_or64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_orptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
__sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_or32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_or64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_orptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_fetch_and_or (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_or32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_or64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_orptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return __sync_or_and_fetch (&x->v, v);
|
||||
}
|
||||
|
||||
/* CAS */
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 32-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_cas32 (volatile ddsrt_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 64-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_cas64 (volatile ddsrt_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Compare and swap an uintptr atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_casptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return __sync_bool_compare_and_swap (&x->v, exp, des);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a void pointer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_casvoidp (volatile ddsrt_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return ddsrt_atomic_casptr (x, (uintptr_t) exp, (uintptr_t) des);
|
||||
}
|
||||
#if DDSRT_HAVE_ATOMIC_LIFO
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
#if defined(__s390__) || defined(__s390x__) || defined(__zarch__)
|
||||
typedef __int128_t __attribute__((aligned(16))) ddsrt_atomic_int128_t;
|
||||
#else
|
||||
typedef __int128_t ddsrt_atomic_int128_t;
|
||||
#endif
|
||||
typedef union { ddsrt_atomic_int128_t x; struct { uintptr_t a, b; } s; } ddsrt_atomic_uintptr2_t;
|
||||
#else
|
||||
typedef union { uint64_t x; struct { uintptr_t a, b; } s; } ddsrt_atomic_uintptr2_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A lifo linked list supporting atomic operations
|
||||
*/
|
||||
typedef struct {
|
||||
ddsrt_atomic_uintptr2_t aba_head;
|
||||
} ddsrt_atomic_lifo_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the lifo list
|
||||
*
|
||||
* @param[out] head the lifo list
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_lifo_init(ddsrt_atomic_lifo_t *head);
|
||||
|
||||
/**
|
||||
* @brief Push to the lifo list
|
||||
*
|
||||
* @param[in,out] head the lifo list
|
||||
* @param[in] elem the element to push to it
|
||||
* @param[in] linkoff the link offset with respect to elem
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_lifo_push(ddsrt_atomic_lifo_t *head, void *elem, size_t linkoff);
|
||||
|
||||
/**
|
||||
* @brief Pop from the lifo list
|
||||
*
|
||||
* @param[in,out] head the lifo list
|
||||
* @param[in] linkoff the link offset with respect to elem
|
||||
*
|
||||
* @return pointer to the popped elem
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_atomic_lifo_pop(ddsrt_atomic_lifo_t *head, size_t linkoff);
|
||||
|
||||
/**
|
||||
* @brief Push a chain of elements to the lifo list
|
||||
*
|
||||
* @param[in,out] head the lifo list
|
||||
* @param[in] first the element that will be at the top of the stack
|
||||
* @param[in] last the element connected to the existing chain
|
||||
* @param[in] linkoff the link offset with respect to the element
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_atomic_lifo_pushmany(ddsrt_atomic_lifo_t *head, void *first, void *last, size_t linkoff);
|
||||
|
||||
/**
|
||||
* @brief Compare and swap two void pointers atomically
|
||||
*
|
||||
* Assigns a1 to x.a and b1 to x.b iff (x.a == a0 && x.b == b0)
|
||||
*
|
||||
* @param[in,out] x pointer to two variables whose value to swap
|
||||
* @param[in] a0 the value to test x.a for
|
||||
* @param[in] b0 the value to test x.b for
|
||||
* @param[in] a1 the value to assign to x.a
|
||||
* @param[in] b1 the value to assign to x.b
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_casvoidp2 (volatile ddsrt_atomic_uintptr2_t *x, uintptr_t a0, uintptr_t b0, uintptr_t a1, uintptr_t b1) {
|
||||
ddsrt_atomic_uintptr2_t o, n;
|
||||
o.s.a = a0; o.s.b = b0;
|
||||
n.s.a = a1; n.s.b = b1;
|
||||
#if defined(__s390__) || defined(__s390x__) || defined(__zarch__)
|
||||
return __sync_bool_compare_and_swap ((ddsrt_atomic_int128_t*)__builtin_assume_aligned(&x->x, 16), o.x, n.x);
|
||||
#else
|
||||
return __sync_bool_compare_and_swap (&x->x, o.x, n.x);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FENCES */
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence (void) {
|
||||
__sync_synchronize ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_ldld (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for store operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_stst (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and load load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_acq (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
#else
|
||||
__asm__ volatile ("" ::: "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and store store operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_rel (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
#else
|
||||
__asm__ volatile ("" ::: "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
DDSRT_WARNING_CLANG_ON(old-style-cast)
|
||||
DDSRT_WARNING_GNUC_ON(old-style-cast)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ATOMICS_GCC_H */
|
||||
+900
@@ -0,0 +1,900 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSRT_ATOMICS_MSVC_H
|
||||
#define DDSRT_ATOMICS_MSVC_H
|
||||
|
||||
#include "dds/ddsrt/misc.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* x86 has supported 64-bit CAS for a long time, so Windows ought to
|
||||
provide all the interlocked operations for 64-bit operands on x86
|
||||
platforms, but it doesn't. */
|
||||
|
||||
#define DDSRT_ATOMIC_OP32(name, ...) name ((volatile long *) __VA_ARGS__)
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
#define DDSRT_ATOMIC_OP64(name, ...) name##64 ((volatile int64_t *) __VA_ARGS__)
|
||||
#define DDSRT_ATOMIC_PTROP(name, ...) name##64 ((volatile int64_t *) __VA_ARGS__)
|
||||
#else
|
||||
#define DDSRT_ATOMIC_PTROP(name, ...) name ((volatile long *) __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file msvc.h
|
||||
* @brief Contains functions and types for atomic operations on various types for msvc.
|
||||
*
|
||||
* This header file defines functions for atomic operations on uint32_t,
|
||||
* uint64_t, uintptr_t, and void* types.
|
||||
*/
|
||||
|
||||
/* LD, ST */
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_ld32 (const volatile ddsrt_atomic_uint32_t *x) { return x->v; }
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_ld64 (const volatile ddsrt_atomic_uint64_t *x) { return x->v; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of an uintptr atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_ldptr (const volatile ddsrt_atomic_uintptr_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a void pointer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void *ddsrt_atomic_ldvoidp (const volatile ddsrt_atomic_voidp_t *x) { return (void *) ddsrt_atomic_ldptr (x); }
|
||||
|
||||
/**
|
||||
* @brief Assign a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_st32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
|
||||
/**
|
||||
* @brief Assign a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_st64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Assign an uintptr atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_stptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign a void pointer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_stvoidp (volatile ddsrt_atomic_voidp_t *x, void *v) { ddsrt_atomic_stptr (x, (uintptr_t) v); }
|
||||
|
||||
/* CAS */
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 32-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_cas32 (volatile ddsrt_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedCompareExchange, &x->v, des, exp) == exp;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Compare and swap a 64-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_cas64 (volatile ddsrt_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedCompareExchange, &x->v, des, exp) == exp;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Compare and swap an uintptr atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_casptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedCompareExchange, &x->v, des, exp) == exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a void pointer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int ddsrt_atomic_casvoidp (volatile ddsrt_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return ddsrt_atomic_casptr ((volatile ddsrt_atomic_uintptr_t *) x, (uintptr_t) exp, (uintptr_t) des);
|
||||
}
|
||||
|
||||
/* INC */
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_inc32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
DDSRT_ATOMIC_OP32 (InterlockedIncrement, &x->v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_inc64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
DDSRT_ATOMIC_OP64 (InterlockedIncrement, &x->v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_incptr (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
DDSRT_ATOMIC_PTROP (InterlockedIncrement, &x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_inc32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedIncrement, &x->v) - 1;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_inc64_ov (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedIncrement, &x->v) - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_incptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedIncrement, &x->v) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_inc32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedIncrement, &x->v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_inc64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedIncrement, &x->v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_incptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedIncrement, &x->v);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_dec32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
DDSRT_ATOMIC_OP32 (InterlockedDecrement, &x->v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_dec64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
DDSRT_ATOMIC_OP64 (InterlockedDecrement, &x->v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_decptr (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
DDSRT_ATOMIC_PTROP (InterlockedDecrement, &x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_dec32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedDecrement, &x->v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_dec64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedDecrement, &x->v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_decptr_nv (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedDecrement, &x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_dec32_ov (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedDecrement, &x->v) + 1;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_dec64_ov (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedDecrement, &x->v) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_decptr_ov (volatile ddsrt_atomic_uintptr_t *x) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedDecrement, &x->v) + 1;
|
||||
}
|
||||
|
||||
/* ADD */
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_add32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_add64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_addptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_add32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_add64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_addptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_add32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, v) + v;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_add64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, v) + v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_addptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, v) + v;
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_sub32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_sub64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_subptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_sub32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_sub64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_subptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_sub32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedExchangeAdd, &x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_sub64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedExchangeAdd, &x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) an uintptr atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_subptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd, &x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_and32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
DDSRT_ATOMIC_OP32 (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_and64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
DDSRT_ATOMIC_OP64 (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_andptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
DDSRT_ATOMIC_PTROP (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_and32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_and64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_andptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedAnd, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_and32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedAnd, &x->v, v) & v;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_and64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedAnd, &x->v, v) & v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_andptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedAnd, &x->v, v) & v;
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_or32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
DDSRT_ATOMIC_OP32 (InterlockedOr, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_or64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
DDSRT_ATOMIC_OP64 (InterlockedOr, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_orptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
DDSRT_ATOMIC_PTROP (InterlockedOr, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_or32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedOr, &x->v, v);
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_or64_ov (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedOr, &x->v, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_orptr_ov (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedOr, &x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_atomic_or32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return DDSRT_ATOMIC_OP32 (InterlockedOr, &x->v, v) | v;
|
||||
}
|
||||
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_atomic_or64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return DDSRT_ATOMIC_OP64 (InterlockedOr, &x->v, v) | v;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR an uintptr atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uintptr_t ddsrt_atomic_orptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedOr, &x->v, v) | v;
|
||||
}
|
||||
|
||||
/* FENCES */
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence (void) {
|
||||
/* 28113: accessing a local variable tmp via an Interlocked
|
||||
function: This is an unusual usage which could be reconsidered.
|
||||
It is too heavyweight, true, but it does the trick. */
|
||||
DDSRT_WARNING_MSVC_OFF(28113)
|
||||
volatile LONG tmp = 0;
|
||||
InterlockedExchange (&tmp, 0);
|
||||
DDSRT_WARNING_MSVC_ON(28113)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_ldld (void) {
|
||||
#if !(defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for store operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_stst (void) {
|
||||
#if !(defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and load load operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_acq (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and store store operations
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline void ddsrt_atomic_fence_rel (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
||||
#undef DDSRT_ATOMIC_PTROP
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ATOMICS_MSVC_H */
|
||||
+586
@@ -0,0 +1,586 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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
|
||||
|
||||
#include <atomic.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSRT_ATOMIC64_SUPPORT 1
|
||||
|
||||
/**
|
||||
* @file sun.h
|
||||
* @brief Contains functions and types for atomic operations on various types for sun.
|
||||
*
|
||||
* This header file defines functions for atomic operations on uint32_t,
|
||||
* uint64_t, uintptr_t, and void* types.
|
||||
*/
|
||||
|
||||
/* LD, ST */
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_ld32 (const volatile ddsrt_atomic_uint32_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_ld64 (const volatile ddsrt_atomic_uint64_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of an uintptr atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline uintptr_t ddsrt_atomic_ldptr (const volatile ddsrt_atomic_uintptr_t *x) { return x->v; }
|
||||
|
||||
/**
|
||||
* @brief Fetch the value of a void pointer atomically
|
||||
*
|
||||
* @param[in] x Pointer to the variable to fetch the value of
|
||||
*
|
||||
* @return The value of the fetched variable
|
||||
*/
|
||||
inline void *ddsrt_atomic_ldvoidp (const volatile ddsrt_atomic_voidp_t *x) { return (void *) ddsrt_atomic_ldptr (x); }
|
||||
|
||||
/**
|
||||
* @brief Assign a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_st32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_st64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign an uintptr atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_stptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) { x->v = v; }
|
||||
|
||||
/**
|
||||
* @brief Assign a void pointer atomically
|
||||
*
|
||||
* @param[out] x Pointer to the variable to update
|
||||
* @param[in] v The new value to assign to the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_stvoidp (volatile ddsrt_atomic_voidp_t *x, void *v) { ddsrt_atomic_stptr (x, (uintptr_t) v); }
|
||||
|
||||
/* INC */
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
inline void ddsrt_atomic_inc32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
atomic_inc_32 (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*/
|
||||
inline void ddsrt_atomic_inc64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
atomic_inc_64 (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_inc32_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_inc32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return atomic_inc_32_nv (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_inc64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return atomic_inc_64_nv (&x->v);
|
||||
}
|
||||
|
||||
/* DEC */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
inline void ddsrt_atomic_dec32 (volatile ddsrt_atomic_uint32_t *x) {
|
||||
atomic_dec_32 (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
*/
|
||||
inline void ddsrt_atomic_dec64 (volatile ddsrt_atomic_uint64_t *x) {
|
||||
atomic_dec_64 (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_dec32_nv (volatile ddsrt_atomic_uint32_t *x) {
|
||||
return atomic_dec_32_nv (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_dec64_nv (volatile ddsrt_atomic_uint64_t *x) {
|
||||
return atomic_dec_64_nv (&x->v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_dec32_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by one) a 64-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_dec64_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/* ADD */
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
inline void ddsrt_atomic_add32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_add_32 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*/
|
||||
inline void ddsrt_atomic_add64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_add_64 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The old value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_add32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, v) - v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_add32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increment (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to increment
|
||||
* @param[in] v The value to increment by
|
||||
*
|
||||
* @return The new value of the incremented variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_add64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_add_64_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* SUB */
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
inline void ddsrt_atomic_sub32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_add_32 (&x->v, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*/
|
||||
inline void ddsrt_atomic_sub64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_add_64 (&x->v, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The old value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_sub32_ov (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, -v) + v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 32-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_sub32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_add_32_nv (&x->v, -v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decrement (by given amount) a 64-bit unsigned integer atomically and return its new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to decrement
|
||||
* @param[in] v The value to decrement by
|
||||
*
|
||||
* @return The new value of the decremented variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_sub64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_add_64_nv (&x->v, -v);
|
||||
}
|
||||
|
||||
/* AND */
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_and32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_and_32 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_and64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_and_64 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_and32_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The old value of the ANDed variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_and64_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_and32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_and_32_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise AND a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to AND
|
||||
* @param[in] v The value to AND with the variable
|
||||
*
|
||||
* @return The new value of the ANDed variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_and64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_and_64_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* OR */
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_or32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
atomic_or_32 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*/
|
||||
inline void ddsrt_atomic_or64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
atomic_or_64 (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_or32_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the old value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The old value of the ORed variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_or64_ov (volatile ddsrt_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 32-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
inline uint32_t ddsrt_atomic_or32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
return atomic_or_32_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Bitwise OR a 64-bit unsigned integer atomically and return the new value
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable to OR
|
||||
* @param[in] v The value to OR with the variable
|
||||
*
|
||||
* @return The new value of the ORed variable
|
||||
*/
|
||||
inline uint64_t ddsrt_atomic_or64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
return atomic_or_64_nv (&x->v, v);
|
||||
}
|
||||
|
||||
/* CAS */
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 32-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_cas32 (volatile ddsrt_atomic_uint32_t *x, uint32_t exp, uint32_t des) {
|
||||
return atomic_cas_32 (&x->v, exp, des) == exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a 64-bit unsigned integer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_cas64 (volatile ddsrt_atomic_uint64_t *x, uint64_t exp, uint64_t des) {
|
||||
return atomic_cas_64 (&x->v, exp, des) == exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap an uintptr atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_casptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t exp, uintptr_t des) {
|
||||
return atomic_cas_ulong (&x->v, exp, des) == exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare and swap a void pointer atomically
|
||||
*
|
||||
* Assigns des to x iff x == exp
|
||||
*
|
||||
* @param[in,out] x Pointer to the variable whose value to swap
|
||||
* @param[in] exp the value to test x for
|
||||
* @param[in] des the value to assign to the variable
|
||||
*
|
||||
* @return int meant to be interpreted as bool (swapped: 1; not swapped: 0)
|
||||
*/
|
||||
inline int ddsrt_atomic_casvoidp (volatile ddsrt_atomic_voidp_t *x, void *exp, void *des) {
|
||||
return atomic_cas_ptr (&x->v, exp, des) == exp;
|
||||
}
|
||||
|
||||
/* FENCES */
|
||||
|
||||
/**
|
||||
* @brief insert a memory barrier for store and load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence (void) {
|
||||
membar_exit ();
|
||||
membar_enter ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier only for load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_ldld (void) {
|
||||
membar_consumer ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier only for store operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
membar_producer ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and load load operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
membar_enter ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief insert memory barrier for load store and store store operations
|
||||
*/
|
||||
inline void ddsrt_atomic_fence_rel (void) {
|
||||
membar_exit ();
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSRT_ATTRIBUTES_H
|
||||
#define DDSRT_ATTRIBUTES_H
|
||||
|
||||
#if __GNUC__
|
||||
# define ddsrt_gnuc (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
#else
|
||||
# define ddsrt_gnuc (0)
|
||||
#endif
|
||||
|
||||
#if __clang__
|
||||
# define ddsrt_clang (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
||||
#else
|
||||
# define ddsrt_clang (0)
|
||||
#endif
|
||||
|
||||
#ifdef __SUNPRO_C
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute)
|
||||
# define ddsrt_has_attribute(params) __has_attribute(params)
|
||||
#elif ddsrt_gnuc
|
||||
# define ddsrt_has_attribute(params) (1) /* GCC < 5 */
|
||||
#else
|
||||
# define ddsrt_has_attribute(params) (0)
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(malloc)
|
||||
# define ddsrt_attribute_malloc __attribute__ ((__malloc__))
|
||||
#else
|
||||
# define ddsrt_attribute_malloc
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(malloc) && ddsrt_gnuc >= 120000
|
||||
# define ddsrt_attribute_malloc2(params) __attribute__ ((__malloc__ params))
|
||||
#else
|
||||
# define ddsrt_attribute_malloc2(params)
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(unused)
|
||||
# define ddsrt_attribute_unused __attribute__((__unused__))
|
||||
#else
|
||||
# define ddsrt_attribute_unused
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(noreturn)
|
||||
# define ddsrt_attribute_noreturn __attribute__ ((__noreturn__))
|
||||
#else
|
||||
# define ddsrt_attribute_noreturn
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(nonnull)
|
||||
# define ddsrt_nonnull(params) __attribute__ ((__nonnull__ params))
|
||||
# define ddsrt_nonnull_all __attribute__ ((__nonnull__))
|
||||
#else
|
||||
# define ddsrt_nonnull(params)
|
||||
# define ddsrt_nonnull_all
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(returns_nonnull) && (ddsrt_clang || ddsrt_gnuc >= 40900)
|
||||
# define ddsrt_attribute_returns_nonnull __attribute__ ((__returns_nonnull__))
|
||||
#else
|
||||
# define ddsrt_attribute_returns_nonnull
|
||||
#endif
|
||||
|
||||
/* GCC <= 4.2.4 has the attribute, but warns that it ignores it. */
|
||||
#if !ddsrt_has_attribute(alloc_size) || (ddsrt_gnuc <= 40204)
|
||||
# define ddsrt_attribute_alloc_size(params)
|
||||
#else
|
||||
# define ddsrt_attribute_alloc_size(params) __attribute__ ((__alloc_size__ params))
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(const)
|
||||
# define ddsrt_attribute_const __attribute__ ((__const__))
|
||||
#else
|
||||
# define ddsrt_attribute_const
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(pure)
|
||||
# define ddsrt_attribute_pure __attribute__ ((__pure__))
|
||||
#else
|
||||
# define ddsrt_attribute_pure
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(format)
|
||||
# define ddsrt_attribute_format(params) __attribute__ ((__format__ params))
|
||||
# if __MINGW32__
|
||||
# if !defined(__MINGW_PRINTF_FORMAT)
|
||||
# define __MINGW_PRINTF_FORMAT gnu_printf
|
||||
# endif
|
||||
/* GCC assumes printf MS style arguments on Windows */
|
||||
# define ddsrt_attribute_format_printf(string_index, first_to_check) \
|
||||
ddsrt_attribute_format((__MINGW_PRINTF_FORMAT, string_index, first_to_check))
|
||||
# else
|
||||
# define ddsrt_attribute_format_printf(string_index, first_to_check) \
|
||||
ddsrt_attribute_format((printf, string_index, first_to_check))
|
||||
# endif
|
||||
#else
|
||||
# define ddsrt_attribute_format(params)
|
||||
# define ddsrt_attribute_format_printf(string_index, first_to_check)
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(warn_unused_result)
|
||||
# define ddsrt_attribute_warn_unused_result __attribute__ ((__warn_unused_result__))
|
||||
#else
|
||||
# define ddsrt_attribute_warn_unused_result
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(assume_aligned)
|
||||
# define ddsrt_attribute_assume_aligned(params) __attribute__ ((__assume_aligned__ params))
|
||||
#else
|
||||
# define ddsrt_attribute_assume_aligned(params)
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(packed)
|
||||
# define ddsrt_attribute_packed __attribute__ ((__packed__))
|
||||
#else
|
||||
# define ddsrt_attribute_packed
|
||||
#endif
|
||||
|
||||
#if ddsrt_has_attribute(no_sanitize)
|
||||
# define ddsrt_attribute_no_sanitize(params) __attribute__ ((__no_sanitize__ params))
|
||||
#else
|
||||
# define ddsrt_attribute_no_sanitize(params)
|
||||
#endif
|
||||
|
||||
#if defined(__has_feature)
|
||||
# define ddsrt_has_feature_thread_sanitizer __has_feature(thread_sanitizer)
|
||||
#else
|
||||
# define ddsrt_has_feature_thread_sanitizer 0
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ATTRIBUTES_H */
|
||||
+936
@@ -0,0 +1,936 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSRT_AVL_H
|
||||
#define DDSRT_AVL_H
|
||||
|
||||
/** \file avl.h
|
||||
The tree library never performs memory allocations or deallocations internally.
|
||||
|
||||
- Treedef_t: defines the properties of the tree, offsets,
|
||||
comparison functions, augmented structures, flags -- these are
|
||||
related to the code/data structure in which the tree is embedded,
|
||||
and in nearly all cases known at compile time.
|
||||
- avlTree_t: represents the tree, i.e., pointer to the root.
|
||||
- avlNode_t: contains the administrative data for a single node in
|
||||
the tree.
|
||||
|
||||
For a tree node:
|
||||
struct T {
|
||||
avlNode_t avlnode;
|
||||
int key;
|
||||
};
|
||||
by definition, avlnodeoffset == offsetof(struct T, avlnode) and
|
||||
keyoffset = offsetof(struct T, key). The user of the library only
|
||||
ever deals in pointers to (in this case) struct T, never with
|
||||
pointers to the avlNode_t, and the compare function operations on
|
||||
pointers to keys, in this case pointers to "int"s. If you wish, you
|
||||
can also do: keyoffset = 0, in which case the compare function
|
||||
would be operating on struct T's.
|
||||
|
||||
The compare function is assumed to behave just like all compare
|
||||
functions in the C library: < 0, =0, >0 for left argument less
|
||||
than, equal to or greater than the right argument.
|
||||
|
||||
The "augment" function is automatically called whenever some of the
|
||||
children of a node change, as well as when the "augment" function
|
||||
has been called on some of the children. It allows you to maintain
|
||||
a "summary" of the subtree -- currently only used in DDSI, in one
|
||||
spot.
|
||||
|
||||
Trees come in various "variants", configured through "treedef"
|
||||
flags:
|
||||
- direct/indirect key: direct meaning the key value is embedded in
|
||||
the structure containing the avlNode_t, indirect meaning a
|
||||
pointer to the key value is. The compare function doesn't deal
|
||||
with tree nodes, but with key values.
|
||||
- re-entrant: in the style of the C library, meaning, the
|
||||
comparison function gets a user-supplied 3rd argument (in
|
||||
particular used by mmstat).
|
||||
- unique keys/duplicate keys: when keys must be unique, some
|
||||
optimizations apply; it is up to the caller to ensure one doesn't
|
||||
violate the uniqueness of the keys (it'll happily crash in insert
|
||||
if you don't); when duplicate keys are allowed, a forward scan of
|
||||
the tree will visit them in the order of insertion.
|
||||
|
||||
For a tree node:
|
||||
struct T {
|
||||
avlnode_t avlnode;
|
||||
char *key;
|
||||
};
|
||||
you could set the "indirect" flag, and then you simply use
|
||||
strcmp(), avoiding the need for passing templates in looking up key
|
||||
values. Much nicer.
|
||||
|
||||
There is also an orthogonal variant that is enforced through the
|
||||
type system -- note that would be possible for all of the above as
|
||||
well, but the number of cases simply explodes and none of the above
|
||||
flags affects the dynamically changing data structures (just the
|
||||
tree definition), unlike this one.
|
||||
|
||||
- the "C" variant keeps track of the number of nodes in the tree to
|
||||
support a "count" operation in O(1) time, but is otherwise
|
||||
identical.
|
||||
|
||||
The various initializer macros and TreedefInit functions should
|
||||
make sense with this.
|
||||
|
||||
All functions for looking up nodes return NULL if there is no node
|
||||
satisfying the requirements.
|
||||
|
||||
- Init: initializes a tree (really just: root = NULL, perhaps count = 0)
|
||||
- Free: calls "freefun" on each node, which may free the node
|
||||
- FreeArg: as "Free", but with an extra, user-supplied, argument
|
||||
- Root: returns the root node
|
||||
- Lookup: returns a node with key value "key" (ref allowdups flag)
|
||||
- LookupIPath: like Lookup, but also filling an IPath_t structure
|
||||
for efficient insertion in case of a failed lookup (or inserting
|
||||
duplicates)
|
||||
- LookupDPath: like Lookup, but also filling a DPath_t structure
|
||||
that helps with deleting a node
|
||||
- LookupPredEq: locates the node with the greatest key value <= "key"
|
||||
- LookupSuccEq: similar, but smallest key value >= "key"
|
||||
- LookupPred: similar, < "key"
|
||||
- LookupSucc: similar, > "key"
|
||||
- Insert: convenience function: LookupIPath ; InsertIPath
|
||||
- Delete: convenience function: LookupDPath ; DeleteDPath
|
||||
- InsertIPath: insert node based on the "path" obtained from LookupIPath
|
||||
- DeleteDPath: delete node, using information in "path" to do so efficiently
|
||||
- SwapNode: replace "oldn" by "newn" without modifying the tree
|
||||
structure (the key need not be equal, but must be
|
||||
FindPred(oldn).key < newn.key < FindSucc(oldn).key, where a
|
||||
non-existing predecessor has key -inf and a non-existing
|
||||
successor has key +inf, and where it is understood that the <
|
||||
operator becomes <= if allowdups is set
|
||||
- AugmentUpdate: to be called when something in "node" changes that
|
||||
affects the subtree "summary" computed by the configured
|
||||
"augment" function
|
||||
- IsEmpty: returns 1 if tree is empty, 0 if not
|
||||
- IsSingleton: returns 1 if tree contains exactly one node, 0 if not
|
||||
- FindMin: returns the node with the smallest key value in the tree
|
||||
- FindMax: similar, largest key value
|
||||
- FindPred: preceding node in in-order treewalk
|
||||
- FindSucc: similar, following node
|
||||
|
||||
- Walk: calls "f" with user-supplied argument "a" once for each
|
||||
node, starting at FindMin and ending at FindMax
|
||||
- ConstWalk: same, but with a const tree
|
||||
- WalkRange: like Walk, but only visiting nodes with key values in
|
||||
range [min,max] (that's inclusive)
|
||||
- ConstWalkRange: same, but with a const tree
|
||||
- WalkRangeReverse: like WalkRange, but in the reverse direction
|
||||
- ConstWalkRangeReverse: same, but with a const tree
|
||||
- IterFirst: starts forward iteration, starting at (and returning) FindMin
|
||||
- IterSuccEq: similar, starting at LookupSuccEq
|
||||
- IterSucc: similar, starting at LookupSucc
|
||||
- IterNext: returns FindSucc(last returned node); may not be called
|
||||
if preceding IterXXX call on same "iter" returned NULL
|
||||
|
||||
That's all there is to it.
|
||||
|
||||
Note that all calls to Walk(f,a) can be rewritten as:
|
||||
for(n=IterFirst(&it); n; n=IterNext(&it)) { f(n,a) }
|
||||
or as
|
||||
for(n=FindMin(); n; n=FindSucc(n)) { f(n,a) }
|
||||
|
||||
The walk functions and iterators may not alter the tree
|
||||
structure. If that is desired, the latter can easily be rewritten
|
||||
as:
|
||||
n=FindMin() ; while(n) { nn=FindSucc(n); f(n,a); n=nn }
|
||||
because FindMin/FindSucc doesn't store any information to allow
|
||||
fast processing. That'll allow every operation, with the obvious
|
||||
exception of f(n) calling Delete(FindSucc(n)).
|
||||
|
||||
Currently, all trees maintain parent pointers, but it may be worth
|
||||
doing a separate set without it, as it reduces the size of
|
||||
avlNode_t. But in that case, the FindMin/FindSucc option would no
|
||||
longer be a reasonable option because it would be prohibitively
|
||||
expensive, whereas the IterFirst/IterNext option are alway
|
||||
efficiently. If one were to do a threaded tree variant, the
|
||||
implemetantion of IterFirst/IterNext would become absolute trivial
|
||||
and faster still, but at the cost of significantly more overhead in
|
||||
memory and updates.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSRT_AVL_MAX_TREEHEIGHT (12 * sizeof (void *))
|
||||
|
||||
/**
|
||||
* @brief User defined compare function.
|
||||
*
|
||||
* Input arguments are expected to be pointers to the keys.
|
||||
* The expected return values are as follows:
|
||||
* - value < 0 to indicate key a is less than key b
|
||||
* - value > 0 to indicate key a is greater than key b
|
||||
* - value == 0 to indicate key a is equal to key b
|
||||
* @see ddsrt_avl_compare_r_t
|
||||
*/
|
||||
typedef int (*ddsrt_avl_compare_t) (const void *a, const void *b);
|
||||
|
||||
/** @brief Same as @ref ddsrt_avl_compare_t, but with extra argument for state information. */
|
||||
typedef int (*ddsrt_avl_compare_r_t) (const void *a, const void *b, void *arg);
|
||||
|
||||
/**
|
||||
* @brief User defined augment function.
|
||||
*
|
||||
* If provided, it is called whenever the structure of the tree changes,
|
||||
* or when explicitly calling @ref ddsrt_avl_augment_update.
|
||||
* It is called for each node on the path to (and inclusive of) the root.
|
||||
* It is intended to update user data in nodes when a change occurs in one or both child nodes,
|
||||
* or when a the change occurs in the node itself.
|
||||
*/
|
||||
typedef void (*ddsrt_avl_augment_t) (void *vnode, const void *left, const void *right);
|
||||
|
||||
/**
|
||||
* @brief User defined walk function to perform an action on each node in the tree.
|
||||
*/
|
||||
typedef void (*ddsrt_avl_walk_t) (void *vnode, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk_t, but works on const nodes.
|
||||
*/
|
||||
typedef void (*ddsrt_avl_const_walk_t) (const void *vnode, void *arg);
|
||||
|
||||
/// @brief The avl node is the basic element of the avl tree structure.
|
||||
///
|
||||
/// To store user data in the tree, the avl node must be embedded in a user node, which is a struct containing the user data.
|
||||
/// All API calls with a node as input or output, deal with the user node. Example:
|
||||
/// @code{.c}
|
||||
/// typedef struct num_s{ // user node
|
||||
/// ddsrt_avl_node_t node;
|
||||
/// uint64_t val; // user data
|
||||
/// }num_t;
|
||||
/// @endcode
|
||||
typedef struct ddsrt_avl_node {
|
||||
struct ddsrt_avl_node *cs[2]; ///< contains pointers to the left and right child node
|
||||
struct ddsrt_avl_node *parent; ///< points to the parent node
|
||||
int height; ///< is the height of the subtree starting at this node
|
||||
} ddsrt_avl_node_t;
|
||||
|
||||
/**
|
||||
* Save a reference/dereference when using an indirect key. For details, see @ref ddsrt_avl_treedef_init.
|
||||
*/
|
||||
#define DDSRT_AVL_TREEDEF_FLAG_INDKEY 1
|
||||
#define DDSRT_AVL_TREEDEF_FLAG_R 2 /**< Flag used internally by @ref ddsrt_avl_treedef_init_r : compare function has extra argument */
|
||||
#define DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS 4 /**< Flag for @ref ddsrt_avl_treedef_init : multiple nodes with the same key are allowed */
|
||||
|
||||
/**
|
||||
* @brief The tree definition.
|
||||
*
|
||||
* The treedef stores settings for the tree, but does not hold the actual tree itself. This implies that:
|
||||
* - A single treedef can be used for multiple trees of the same type.
|
||||
* - Most tree operations require you to provide both the treedef and the @ref ddsrt_avl_tree.
|
||||
*
|
||||
* To initialize it, use @ref ddsrt_avl_treedef_init, @ref ddsrt_avl_treedef_init_r,
|
||||
* or one of the 'DDSRT_AVL_TREEDEF_INITIALIZER' macros.
|
||||
*/
|
||||
typedef struct ddsrt_avl_treedef {
|
||||
#if defined (__cplusplus)
|
||||
ddsrt_avl_treedef() {}
|
||||
#endif
|
||||
size_t avlnodeoffset;
|
||||
size_t keyoffset;
|
||||
union {
|
||||
ddsrt_avl_compare_t comparekk;
|
||||
ddsrt_avl_compare_r_t comparekk_r;
|
||||
} u;
|
||||
ddsrt_avl_augment_t augment;
|
||||
uint32_t flags;
|
||||
void *cmp_arg; /* for _r variant */
|
||||
} ddsrt_avl_treedef_t;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_treedef */
|
||||
typedef struct ddsrt_avl_ctreedef {
|
||||
ddsrt_avl_treedef_t t;
|
||||
} ddsrt_avl_ctreedef_t;
|
||||
|
||||
/**
|
||||
* @brief The avl tree.
|
||||
*
|
||||
* The tree only knows the root @ref ddsrt_avl_node. The settings for the tree are stored separately in the @ref ddsrt_avl_treedef.
|
||||
* As a result, most tree operations require you to provide both the treedef and the tree.
|
||||
*/
|
||||
typedef struct ddsrt_avl_tree {
|
||||
ddsrt_avl_node_t *root; ///< is the root node of the tree
|
||||
} ddsrt_avl_tree_t;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_tree */
|
||||
typedef struct ddsrt_avl_ctree {
|
||||
ddsrt_avl_tree_t t;
|
||||
size_t count;
|
||||
} ddsrt_avl_ctree_t;
|
||||
|
||||
typedef struct ddsrt_avl_path {
|
||||
int depth; /* total depth of path */
|
||||
int pnodeidx;
|
||||
ddsrt_avl_node_t *parent; /* (nodeidx == 0 ? NULL : *(path[nodeidx-1])) */
|
||||
ddsrt_avl_node_t **pnode[DDSRT_AVL_MAX_TREEHEIGHT];
|
||||
} ddsrt_avl_path_t;
|
||||
|
||||
/**
|
||||
* @brief Path for inserting a node.
|
||||
* @see ddsrt_avl_lookup_ipath
|
||||
* @see ddsrt_avl_insert_ipath
|
||||
*/
|
||||
typedef struct ddsrt_avl_ipath {
|
||||
ddsrt_avl_path_t p;
|
||||
} ddsrt_avl_ipath_t;
|
||||
|
||||
/**
|
||||
* @brief Path for removing a node.
|
||||
* @see ddsrt_avl_lookup_dpath
|
||||
* @see ddsrt_avl_delete_dpath
|
||||
*/
|
||||
typedef struct ddsrt_avl_dpath {
|
||||
ddsrt_avl_path_t p;
|
||||
} ddsrt_avl_dpath_t;
|
||||
|
||||
/**
|
||||
* @brief Iter object for the iterator to store its progress and know where to go next.
|
||||
*/
|
||||
typedef struct ddsrt_avl_iter {
|
||||
const ddsrt_avl_treedef_t *td;
|
||||
ddsrt_avl_node_t *right;
|
||||
ddsrt_avl_node_t **todop;
|
||||
ddsrt_avl_node_t *todo[1+DDSRT_AVL_MAX_TREEHEIGHT];
|
||||
} ddsrt_avl_iter_t;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_iter*/
|
||||
typedef struct ddsrt_avl_citer {
|
||||
ddsrt_avl_iter_t t;
|
||||
} ddsrt_avl_citer_t;
|
||||
|
||||
/* avlnodeoffset and keyoffset must both be in [0,2**31-1] */
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), 0, 0 }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY, 0 }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_R, (cmparg) }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_R, (cmparg) }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_R|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
|
||||
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_R|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
|
||||
|
||||
/* Not maintaining # nodes */
|
||||
|
||||
/// @brief Initialize the @ref ddsrt_avl_treedef
|
||||
///
|
||||
/// Different types of trees are supported. This function defines which type to use.
|
||||
/// Given a node defined as:
|
||||
/// @code{.c}
|
||||
/// typedef struct num_s{ // user node
|
||||
/// ddsrt_avl_node_t node;
|
||||
/// uint64_t val; // user data
|
||||
/// }num_t;
|
||||
/// @endcode
|
||||
///
|
||||
/// For a treedef initialized with default settings:
|
||||
/// @code{.c}
|
||||
/// ddsrt_avl_treedef_t td;
|
||||
/// ddsrt_avl_treedef_init(&td, offsetof(num_t, node), offsetof(num_t, val), num_cmp, 0, 0);
|
||||
/// @endcode
|
||||
///
|
||||
/// A lookup is performed as:
|
||||
/// @code{.c}
|
||||
/// uint64_t key = 7;
|
||||
/// num_t* num_lookup = ddsrt_avl_lookup(&td, &tree, &key);
|
||||
/// @endcode
|
||||
///
|
||||
/// By using keyoffset == 0, you can do the lookup using a dummy node:
|
||||
/// @code{.c}
|
||||
/// num_t dummy;
|
||||
/// dummy.val = 7;
|
||||
/// num_t* num_lookup = ddsrt_avl_lookup(&td, &tree, &dummy);
|
||||
/// @endcode
|
||||
///
|
||||
/// Regarding the flags:
|
||||
/// - The flag @ref DDSRT_AVL_TREEDEF_FLAG_INDKEY affects functions like @ref ddsrt_avl_compare_t and @ref ddsrt_avl_lookup.
|
||||
/// These functions expect their 'key' argument to be a pointer, so by default you need to pass a reference to the key.
|
||||
/// Alternatively, by using @ref DDSRT_AVL_TREEDEF_FLAG_INDKEY you indicate that the key is already a pointer, allowing you to pass the key directly.
|
||||
/// As an example in the case of a C string, using the INDKEY flag means you can provide the key directly (char*), rather than a reference (char**).
|
||||
/// @code{.c}
|
||||
/// typedef struct name_s{ // user node
|
||||
/// ddsrt_avl_node_t node;
|
||||
/// char* val; // user data
|
||||
/// }name_t;
|
||||
/// @endcode
|
||||
///
|
||||
/// If using the default flag:
|
||||
/// @code{.c}
|
||||
/// ddsrt_avl_treedef_t td;
|
||||
/// ddsrt_avl_treedef_init(&td, offsetof(name_t, node), offsetof(name_t, val), name_cmp_default, 0, 0);
|
||||
/// @endcode
|
||||
///
|
||||
/// Then a lookup is done as:
|
||||
/// @code{.c}
|
||||
/// char* key = strdup("John");
|
||||
/// name_t* name_lookup = ddsrt_avl_lookup(&td, &tree, &key); // Using default flag
|
||||
/// @endcode
|
||||
///
|
||||
/// If using the INDKEY flag:
|
||||
/// @code{.c}
|
||||
/// ddsrt_avl_treedef_t td;
|
||||
/// ddsrt_avl_treedef_init(&td, offsetof(name_t, node), offsetof(name_t, val), name_cmp_indkey, 0, DDSRT_AVL_TREEDEF_FLAG_INDKEY);
|
||||
/// @endcode
|
||||
///
|
||||
/// Then a lookup is done as:
|
||||
/// @code{.c}
|
||||
/// char* key = strdup("John");
|
||||
/// name_t* name_lookup = ddsrt_avl_lookup(&td, &tree, key); // Using INDKEY flag
|
||||
/// @endcode
|
||||
///
|
||||
/// - Multiple nodes with the same key are not allowed, unless using @ref DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS.
|
||||
///
|
||||
/// To set multiple flags, use the bitwise or.
|
||||
///
|
||||
/// @param[out] td the treedef to initialize
|
||||
/// @param[in] avlnodeoffset offset of @ref ddsrt_avl_node relative to the user node.
|
||||
/// @param[in] keyoffset offset of the key relative to the user node
|
||||
/// @param[in] comparekk a key compare function, see @ref ddsrt_avl_compare_t
|
||||
/// @param[in] augment optional function @ref ddsrt_avl_augment_t, provide NULL if not used
|
||||
/// @param[in] flags optional flags, use 0 for default
|
||||
/// @see ddsrt_avl_treedef_init_r
|
||||
/// @see ddsrt_avl_init
|
||||
DDS_EXPORT void ddsrt_avl_treedef_init (ddsrt_avl_treedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_t comparekk, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_treedef_init, but there is an extra argument for the compare function.
|
||||
*
|
||||
* @param[out] td the treedef to initialize
|
||||
* @param[in] avlnodeoffset offset of @ref ddsrt_avl_node relative to the user node.
|
||||
* @param[in] keyoffset offset of the key relative to the user node
|
||||
* @param[in] comparekk_r a key compare function, see @ref ddsrt_avl_compare_r_t
|
||||
* @param[in] cmp_arg is fed to the compare function
|
||||
* @param[in] augment optional function @ref ddsrt_avl_augment_t, provide NULL if not used
|
||||
* @param[in] flags optional flags, use 0 for default
|
||||
* @see ddsrt_avl_treedef_init
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_treedef_init_r (ddsrt_avl_treedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_r_t comparekk_r, void *cmp_arg, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
|
||||
|
||||
/**
|
||||
* @brief Initialize the tree.
|
||||
*
|
||||
* The treedef must have been initialized prior to calling this.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[out] tree the avl tree
|
||||
* @see ddsrt_avl_free
|
||||
* @see ddsrt_avl_treedef_init
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_init (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Destroy the tree
|
||||
*
|
||||
* Applies user defined free function to each node, and initializes the tree again.
|
||||
* The free function is optional, but if not provided, the user is responsible for freeing the memory.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] freefun optional user defined free function to use on nodes, NULL if not used
|
||||
* @see ddsrt_avl_init
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_free (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void (*freefun) (void *vnode)) ddsrt_nonnull((1,2));
|
||||
|
||||
/**
|
||||
* @brief Same as @ref ddsrt_avl_free, but with an extra argument for the free function.
|
||||
*
|
||||
* Extra parameter:
|
||||
* @param[in] arg is for the user defined free function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_free_arg (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void (*freefun) (void *vnode, void *arg), void *arg) ddsrt_nonnull((1,2));
|
||||
|
||||
/**
|
||||
* @brief Get the root node
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @returns pointer to root node, NULL if tree is empty
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_root (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** Same as @ref ddsrt_avl_root, but has undefined behavior in case the tree is empty. */
|
||||
DDS_EXPORT void *ddsrt_avl_root_non_empty (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all ddsrt_attribute_returns_nonnull;
|
||||
|
||||
/**
|
||||
* @brief Lookup a node based on the key
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @return pointer to the node satisfying (node.key == key), NULL if failed
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Same as @ref ddsrt_avl_lookup, but also initializes a @ref ddsrt_avl_ipath.
|
||||
*
|
||||
* The path initialized is intended for use with @ref ddsrt_avl_insert_ipath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @param[out] path is the insert path
|
||||
* @return pointer to the node satisfying (node.key == key), NULL if failed
|
||||
* @see ddsrt_avl_lookup_dpath
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_ipath (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Same as @ref ddsrt_avl_lookup, but also initializes a @ref ddsrt_avl_dpath.
|
||||
*
|
||||
* The path initialized is intended for use with @ref ddsrt_avl_delete_dpath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @param[out] path is the delete path
|
||||
* @return pointer to the node satisfying (node.key == key), NULL if failed
|
||||
* @see ddsrt_avl_lookup_ipath
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_dpath (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_lookup, but match greatest node satisfying (node.key <= key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @return pointer to the node satisfying (node.key <= key), NULL if failed
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_pred_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_lookup, but match smallest node satisfying (node.key >= key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @return pointer to the node satisfying (node.key >= key), NULL if failed
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_succ_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_lookup, but match greatest node satisfying (node.key < key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @return pointer to the node satisfying (node.key < key), NULL if failed
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_pred (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_lookup, but match smallest node satisfying (node.key > key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] key key to search for
|
||||
* @return pointer to the node satisfying (node.key > key), NULL if failed
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_lookup_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Insert a node into the tree.
|
||||
*
|
||||
* There is no protection against duplicates (which causes a crash if the treedef says duplicates are not allowed).
|
||||
* If you want a safe insert, you should use @ref ddsrt_avl_lookup_ipath to check for existence, then insert using @ref ddsrt_avl_insert_ipath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] vnode the node to insert
|
||||
* @see ddsrt_avl_delete
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_insert (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Remove a node from the tree.
|
||||
*
|
||||
* Despite the name 'delete', it only removes the node from the tree. To fully delete it, you still need to free the memory associated with the node.
|
||||
* There is no protection against a crash due to trying to remove a nonexisting node.
|
||||
* If you want a safe remove, you should use @ref ddsrt_avl_lookup_dpath to check for existence, then remove using @ref ddsrt_avl_delete_dpath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] vnode the node to remove
|
||||
* @see ddsrt_avl_insert
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_delete (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Same as @ref ddsrt_avl_insert, but also requires a @ref ddsrt_avl_ipath.
|
||||
*
|
||||
* The path required can be initialized by @ref ddsrt_avl_lookup_ipath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] vnode the node to insert
|
||||
* @param[in] path is the insert path
|
||||
* @see ddsrt_avl_delete_dpath
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_insert_ipath (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *vnode, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Same as @ref ddsrt_avl_delete, but also requires a @ref ddsrt_avl_dpath.
|
||||
*
|
||||
* The path required can be initialized by @ref ddsrt_avl_lookup_dpath.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] vnode the node to remove
|
||||
* @param[in] path is the delete path
|
||||
* @see ddsrt_avl_insert_ipath
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_delete_dpath (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *vnode, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Replace a node in the tree.
|
||||
*
|
||||
* Replace a node in the tree without using @ref ddsrt_avl_delete and @ref ddsrt_avl_insert.
|
||||
* This operation can invalidate the tree as it doesn't check whether the key of the new node preserves the ordering of the set.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in,out] tree the avl tree
|
||||
* @param[in] voldn the node to replace
|
||||
* @param[in] vnewn the node to take the old node's place
|
||||
* @see ddsrt_avl_insert
|
||||
* @see ddsrt_avl_delete
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_swap_node (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *voldn, void *vnewn) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Call the user defined augment function @ref ddsrt_avl_augment_t on a node and its parents up to the root.
|
||||
*
|
||||
* It is intended to update user data in nodes when a change occurs in one or both child nodes, or when a the change occurs in the node itself.
|
||||
* Note that @ref ddsrt_avl_augment_t is called automatically whenever the structure of the tree changes, such as in rotations.
|
||||
* It is called for each node on the path to (and inclusive of) the root.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] vnode is the node from which to start the augmentation
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_augment_update (const ddsrt_avl_treedef_t *td, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Check whether the tree is empty or not.
|
||||
*
|
||||
* @param[in] tree the avl tree
|
||||
* @return int meant to be interpreted as bool (1 is true, 0 is false)
|
||||
*/
|
||||
DDS_EXPORT int ddsrt_avl_is_empty (const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Check whether the tree contains exactly one node.
|
||||
*
|
||||
* @param[in] tree the avl tree
|
||||
* @return int meant to be interpreted as bool (1 is true, 0 is false)
|
||||
*/
|
||||
DDS_EXPORT int ddsrt_avl_is_singleton (const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Lookup node with smallest key.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_find_max
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_find_min (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Lookup node with greatest key.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_find_min
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_find_max (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Get the previous node in the ordered set.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] vnode the current node
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_find_succ
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_find_pred (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
|
||||
|
||||
/**
|
||||
* @brief Get the next node in in the ordered set
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] vnode the current node
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_find_pred
|
||||
* @see ddsrt_avl_iter_next
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_find_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
|
||||
|
||||
/**
|
||||
* @brief Walk the tree and apply a user defined function @ref ddsrt_avl_walk_t to each node.
|
||||
*
|
||||
* Functionally the same as doing a loop using @ref ddsrt_avl_find_succ or @ref ddsrt_avl_iter_next, and calling the function on each node.
|
||||
* Modifying the tree structure is not allowed when using the walk function. If that is desired, use @ref ddsrt_avl_find_succ
|
||||
* (or @ref ddsrt_avl_find_pred for the reverse walk).
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
* @see ddsrt_avl_find_succ
|
||||
* @see ddsrt_avl_iter_next
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_walk (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk, but the user defined function @ref ddsrt_avl_const_walk_t works on const nodes.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_const_walk (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk, but walk within a restricted range defined by [min, max].
|
||||
*
|
||||
* - If min is smaller than the smallest value, it starts at the smallest value.
|
||||
* - If max is larger than the largest value, it finishes at the largest value.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] min The smallest value to start at
|
||||
* @param[in] max The largest value to finish at (inclusive)
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_walk_range (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk_range, but the user defined function @ref ddsrt_avl_const_walk_t works on const nodes.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] min The smallest value to start at
|
||||
* @param[in] max The largest value to finish at (inclusive)
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_const_walk_range (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk_range, but walks in the reverse direction.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] min The smallest value to finish at (inclusive)
|
||||
* @param[in] max The largest value to start at
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_walk_range_reverse (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/**
|
||||
* @brief Like @ref ddsrt_avl_walk_range_reverse, but the user defined function @ref ddsrt_avl_const_walk_t works on const nodes.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[in] min The smallest value to finish at (inclusive)
|
||||
* @param[in] max The largest value to start at
|
||||
* @param[in] f is the user defined walk function
|
||||
* @param[in,out] a is an argument for the user defined function
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_avl_const_walk_range_reverse (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/**
|
||||
* @brief Get the first node in in the ordered set, and initialize the iterator @ref ddsrt_avl_iter_t.
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[out] iter the iterator
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_iter_next
|
||||
* @see ddsrt_avl_find_min
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_iter_first (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Similar to @ref ddsrt_avl_iter_first, but start at smallest node satisfying (node.key >= key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[out] iter the iterator
|
||||
* @param[in] key the key with which to do the lookup
|
||||
* @return pointer to the node
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_iter_succ_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Similar to @ref ddsrt_avl_iter_first, but start at smallest node satisfying (node.key > key)
|
||||
*
|
||||
* @param[in] td treedef of the tree
|
||||
* @param[in] tree the avl tree
|
||||
* @param[out] iter the iterator
|
||||
* @param[in] key the key with which to do the lookup
|
||||
* @return pointer to the node
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_iter_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Get the next node in in the ordered set.
|
||||
*
|
||||
* Modifying the tree structure is not allowed when using the iterator. If that is desired, use @ref ddsrt_avl_find_succ.
|
||||
*
|
||||
* @param[in,out] iter the iterator
|
||||
* @return pointer to the node
|
||||
* @see ddsrt_avl_iter_first
|
||||
* @see ddsrt_avl_find_succ
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_avl_iter_next (ddsrt_avl_iter_t *iter) ddsrt_nonnull_all;
|
||||
|
||||
/* Maintaining # nodes */
|
||||
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER (avlnodeoffset, keyoffset, comparekk, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY (avlnodeoffset, keyoffset, comparekk, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
|
||||
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_treedef_init*/
|
||||
DDS_EXPORT void ddsrt_avl_ctreedef_init (ddsrt_avl_ctreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_t comparekk, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_treedef_init_r*/
|
||||
DDS_EXPORT void ddsrt_avl_ctreedef_init_r (ddsrt_avl_ctreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_r_t comparekk_r, void *cmp_arg, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_init*/
|
||||
DDS_EXPORT void ddsrt_avl_cinit (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_free*/
|
||||
DDS_EXPORT void ddsrt_avl_cfree (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void (*freefun) (void *vnode)) ddsrt_nonnull((1,2));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_free_arg*/
|
||||
DDS_EXPORT void ddsrt_avl_cfree_arg (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void (*freefun) (void *vnode, void *arg), void *arg) ddsrt_nonnull((1,2));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_root*/
|
||||
DDS_EXPORT void *ddsrt_avl_croot (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_root_non_empty*/
|
||||
DDS_EXPORT void *ddsrt_avl_croot_non_empty (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_ipath*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_ipath (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_dpath*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_dpath (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_pred_eq*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_pred_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_succ_eq*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_succ_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_pred*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_pred (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_lookup_succ*/
|
||||
DDS_EXPORT void *ddsrt_avl_clookup_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_insert*/
|
||||
DDS_EXPORT void ddsrt_avl_cinsert (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_delete*/
|
||||
DDS_EXPORT void ddsrt_avl_cdelete (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_insert_ipath*/
|
||||
DDS_EXPORT void ddsrt_avl_cinsert_ipath (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *vnode, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_delete_dpath*/
|
||||
DDS_EXPORT void ddsrt_avl_cdelete_dpath (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *vnode, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_swap_node*/
|
||||
DDS_EXPORT void ddsrt_avl_cswap_node (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *voldn, void *vnewn) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_augment_update*/
|
||||
DDS_EXPORT void ddsrt_avl_caugment_update (const ddsrt_avl_ctreedef_t *td, void *vnode) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_is_empty*/
|
||||
DDS_EXPORT int ddsrt_avl_cis_empty (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_is_singleton*/
|
||||
DDS_EXPORT int ddsrt_avl_cis_singleton (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_count*/
|
||||
DDS_EXPORT size_t ddsrt_avl_ccount (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_find_min*/
|
||||
DDS_EXPORT void *ddsrt_avl_cfind_min (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_find_max*/
|
||||
DDS_EXPORT void *ddsrt_avl_cfind_max (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_find_pred*/
|
||||
DDS_EXPORT void *ddsrt_avl_cfind_pred (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_find_succ*/
|
||||
DDS_EXPORT void *ddsrt_avl_cfind_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_walk*/
|
||||
DDS_EXPORT void ddsrt_avl_cwalk (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_const_walk*/
|
||||
DDS_EXPORT void ddsrt_avl_cconst_walk (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_walk_range*/
|
||||
DDS_EXPORT void ddsrt_avl_cwalk_range (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_const_walk_range*/
|
||||
DDS_EXPORT void ddsrt_avl_cconst_walk_range (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_walk_range_reverse*/
|
||||
DDS_EXPORT void ddsrt_avl_cwalk_range_reverse (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_const_walk_range_reverse*/
|
||||
DDS_EXPORT void ddsrt_avl_cconst_walk_range_reverse (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_iter_first*/
|
||||
DDS_EXPORT void *ddsrt_avl_citer_first (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_iter_succ_eq*/
|
||||
DDS_EXPORT void *ddsrt_avl_citer_succ_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_iter_succ*/
|
||||
DDS_EXPORT void *ddsrt_avl_citer_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter, const void *key) ddsrt_nonnull_all;
|
||||
|
||||
/** @brief Counted version of @ref ddsrt_avl_iter_next*/
|
||||
DDS_EXPORT void *ddsrt_avl_citer_next (ddsrt_avl_citer_t *iter) ddsrt_nonnull_all;
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_AVL_H */
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// Copyright(c) 2022 ZettaScale Technology 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 DDSRT_BITS_H
|
||||
#define DDSRT_BITS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/static_assert.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Find first set (POSIX style): returns index of least significant bit set in input
|
||||
|
||||
@param[in] x input, may be 0
|
||||
@return position of least significant bit set in x (LSB is 1, MSB is 32), returns 0 if x == 0
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_ffs32u (uint32_t x)
|
||||
{
|
||||
// Compiler support checks based on https://en.wikipedia.org/wiki/Find_first_set
|
||||
#if defined __clang__ && __clang_major__ >= 5
|
||||
DDSRT_STATIC_ASSERT (sizeof (int) == sizeof (uint32_t));
|
||||
return (uint32_t) __builtin_ffs ((int) x);
|
||||
#elif defined __GNUC__ && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
DDSRT_STATIC_ASSERT (sizeof (int) == sizeof (uint32_t));
|
||||
return (uint32_t) __builtin_ffs ((int) x);
|
||||
#elif defined _MSC_VER && _MSC_VER >= 1400 // Visual Studio 2005
|
||||
DDSRT_STATIC_ASSERT (sizeof (unsigned long) == sizeof (uint32_t));
|
||||
unsigned long index;
|
||||
return _BitScanForward (&index, x) ? (index + 1) : 0;
|
||||
#else
|
||||
if (x == 0)
|
||||
return 0;
|
||||
uint32_t n = 1;
|
||||
if ((x & 0x0000FFFF) == 0) { n += 16; x >>= 16; };
|
||||
if ((x & 0x000000FF) == 0) { n += 8; x >>= 8; };
|
||||
if ((x & 0x0000000F) == 0) { n += 4; x >>= 4; };
|
||||
if ((x & 0x00000003) == 0) { n += 2; x >>= 2; };
|
||||
if ((x & 0x00000001) == 0) { n += 1; };
|
||||
return n;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_BITS_H */
|
||||
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
// Copyright(c) 2006 to 2021 ZettaScale Technology 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 DDSRT_BSWAP_H
|
||||
#define DDSRT_BSWAP_H
|
||||
|
||||
/** @file bswap.h
|
||||
This header implements byteswapping (between big endian and little endian) for different integer types.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/endian.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Defines the byte order options: native, big endian, and little endian
|
||||
*/
|
||||
enum ddsrt_byte_order_selector {
|
||||
DDSRT_BOSEL_NATIVE,
|
||||
DDSRT_BOSEL_BE,
|
||||
DDSRT_BOSEL_LE,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Byteswap uint16_t
|
||||
*
|
||||
* @param[in] x the uint16_t to byteswap
|
||||
* @return the byteswapped uint16_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint16_t ddsrt_bswap2u (uint16_t x)
|
||||
{
|
||||
return (uint16_t) ((x >> 8) | (x << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Byteswap int16_t
|
||||
*
|
||||
* @param[in] x the int16_t to byteswap
|
||||
* @return the byteswapped int16_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int16_t ddsrt_bswap2 (int16_t x)
|
||||
{
|
||||
return (int16_t) ddsrt_bswap2u ((uint16_t) x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Byteswap uint32_t
|
||||
*
|
||||
* @param[in] x the uint32_t to byteswap
|
||||
* @return the byteswapped uint32_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint32_t ddsrt_bswap4u (uint32_t x)
|
||||
{
|
||||
return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Byteswap int32_t
|
||||
*
|
||||
* @param[in] x the int32_t to byteswap
|
||||
* @return the byteswapped int32_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int32_t ddsrt_bswap4 (int32_t x)
|
||||
{
|
||||
return (int32_t) ddsrt_bswap4u ((uint32_t) x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Byteswap uint64_t
|
||||
*
|
||||
* @param[in] x the uint64_t to byteswap
|
||||
* @return the byteswapped uint64_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline uint64_t ddsrt_bswap8u (uint64_t x)
|
||||
{
|
||||
const uint32_t newhi = ddsrt_bswap4u ((uint32_t) x);
|
||||
const uint32_t newlo = ddsrt_bswap4u ((uint32_t) (x >> 32));
|
||||
return ((uint64_t) newhi << 32) | (uint64_t) newlo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Byteswap int64_t
|
||||
*
|
||||
* @param[in] x the int64_t to byteswap
|
||||
* @return the byteswapped int64_t
|
||||
*/
|
||||
DDS_INLINE_EXPORT inline int64_t ddsrt_bswap8 (int64_t x)
|
||||
{
|
||||
return (int64_t) ddsrt_bswap8u ((uint64_t) x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macros for byteswapping
|
||||
*
|
||||
* These macros are for converting integer types from and to big endian or little endian.
|
||||
* They abstract from the endianness of your system by providing a different implementation based on the value of DDSRT_ENDIAN
|
||||
* (for example if you want to convert to big endian, it converts if your system is little endian,
|
||||
* but if your system is already big endian, the conversion is skipped).
|
||||
* Postfix numbers indicate the number of bytes of the integer (2,4,8 for 16-bit, 32-bit, 64-bit respectively),
|
||||
* whilst an 'u' postfix indicates an unsigned integer type.
|
||||
*
|
||||
* - ddsrt_toBE: convert from native to big endian
|
||||
* - ddsrt_toLE: convert from native to little endian
|
||||
* - ddsrt_toBO: convert from native to byte order 'bo', @see ddsrt_byte_order_selector
|
||||
* - ddsrt_fromBE: convert from big endian to native endianness (DDSRT_ENDIAN)
|
||||
*/
|
||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
|
||||
#define ddsrt_toBE2(x) ddsrt_bswap2 (x)
|
||||
#define ddsrt_toBE2u(x) ddsrt_bswap2u (x)
|
||||
#define ddsrt_toBE4(x) ddsrt_bswap4 (x)
|
||||
#define ddsrt_toBE4u(x) ddsrt_bswap4u (x)
|
||||
#define ddsrt_toBE8(x) ddsrt_bswap8 (x)
|
||||
#define ddsrt_toBE8u(x) ddsrt_bswap8u (x)
|
||||
#define ddsrt_toLE2(x) (x)
|
||||
#define ddsrt_toLE2u(x) (x)
|
||||
#define ddsrt_toLE4(x) (x)
|
||||
#define ddsrt_toLE4u(x) (x)
|
||||
#define ddsrt_toLE8(x) (x)
|
||||
#define ddsrt_toLE8u(x) (x)
|
||||
#define ddsrt_toBO2(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap2 (x) : (x))
|
||||
#define ddsrt_toBO2u(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap2u (x) : (x))
|
||||
#define ddsrt_toBO4(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap4 (x) : (x))
|
||||
#define ddsrt_toBO4u(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap4u (x) : (x))
|
||||
#define ddsrt_toBO8(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap8 (x) : (x))
|
||||
#define ddsrt_toBO8u(bo, x) ((bo) == DDSRT_BOSEL_BE ? ddsrt_bswap8u (x) : (x))
|
||||
#define ddsrt_fromBE2(x) ddsrt_bswap2 (x)
|
||||
#define ddsrt_fromBE2u(x) ddsrt_bswap2u (x)
|
||||
#define ddsrt_fromBE4(x) ddsrt_bswap4 (x)
|
||||
#define ddsrt_fromBE4u(x) ddsrt_bswap4u (x)
|
||||
#define ddsrt_fromBE8(x) ddsrt_bswap8 (x)
|
||||
#define ddsrt_fromBE8u(x) ddsrt_bswap8u (x)
|
||||
#else
|
||||
#define ddsrt_toBE2u(x) (x)
|
||||
#define ddsrt_toBE4(x) (x)
|
||||
#define ddsrt_toBE4u(x) (x)
|
||||
#define ddsrt_toBE8(x) (x)
|
||||
#define ddsrt_toBE8u(x) (x)
|
||||
#define ddsrt_toLE2(x) ddsrt_bswap2 (x)
|
||||
#define ddsrt_toLE2u(x) ddsrt_bswap2u (x)
|
||||
#define ddsrt_toLE4(x) ddsrt_bswap4 (x)
|
||||
#define ddsrt_toLE4u(x) ddsrt_bswap4u (x)
|
||||
#define ddsrt_toLE8(x) ddsrt_bswap8 (x)
|
||||
#define ddsrt_toLE8u(x) ddsrt_bswap8u (x)
|
||||
#define ddsrt_toBO2(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap2 (x) : (x))
|
||||
#define ddsrt_toBO2u(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap2u (x) : (x))
|
||||
#define ddsrt_toBO4(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap4 (x) : (x))
|
||||
#define ddsrt_toBO4u(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap4u (x) : (x))
|
||||
#define ddsrt_toBO8(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap8 (x) : (x))
|
||||
#define ddsrt_toBO8u(bo, x) ((bo) == DDSRT_BOSEL_LE ? ddsrt_bswap8u (x) : (x))
|
||||
#define ddsrt_fromBE2(x) (x)
|
||||
#define ddsrt_fromBE2u(x) (x)
|
||||
#define ddsrt_fromBE4(x) (x)
|
||||
#define ddsrt_fromBE4u(x) (x)
|
||||
#define ddsrt_fromBE8(x) (x)
|
||||
#define ddsrt_fromBE8u(x) (x)
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_BSWAP_H */
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSRT_CDTORS_H
|
||||
#define DDSRT_CDTORS_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/sync.h"
|
||||
|
||||
/**
|
||||
* @file cdtors.h
|
||||
* @brief Contains initializing and finalizing functions for some ddsrt units, and provides a singleton mutex and cond.
|
||||
*
|
||||
* Initializes and finalizes mutexes of ddsrt/random and ddsrt/atomics, and for Windows also the ddsrt/socket
|
||||
* (not necessary for other platforms).
|
||||
*/
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize ddsrt units
|
||||
*
|
||||
* This doesn't need to be done more than once per process. It keeps track of the number of invocations,
|
||||
* and if the current call isn't the first one, it just waits for initializing (by the first one) to finish.
|
||||
* Note calling @ref ddsrt_init in parallel to the last invocation of @ref ddsrt_fini results in undefined behavior.
|
||||
*/
|
||||
void ddsrt_init(void);
|
||||
|
||||
/**
|
||||
* @brief Finalize ddsrt units
|
||||
*
|
||||
* Since @ref ddsrt_init increments the reference count, it is decremented here. Only the last invocation
|
||||
* (when the reference count is 1) actually finalizes it.
|
||||
*/
|
||||
void ddsrt_fini(void);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the global 'init_mutex'
|
||||
*
|
||||
* @return ddsrt_mutex_t* pointer to the mutex
|
||||
*/
|
||||
ddsrt_mutex_t *ddsrt_get_singleton_mutex(void);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the global 'init_cond'
|
||||
*
|
||||
* @return ddsrt_cond_t* pointer to the condition
|
||||
*/
|
||||
ddsrt_cond_t *ddsrt_get_singleton_cond(void);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_CDTORS_H */
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSRT_CIRCLIST_H
|
||||
#define DDSRT_CIRCLIST_H
|
||||
|
||||
/**
|
||||
* @file circlist.h
|
||||
*
|
||||
* Circular doubly linked list implementation.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro to get the pointer to the user node, see @ref ddsrt_circlist_elem for an example.
|
||||
*/
|
||||
#define DDSRT_FROM_CIRCLIST(typ_, member_, cle_) ((typ_ *) ((char *) (cle_) - offsetof (typ_, member_)))
|
||||
|
||||
/** @brief the circular doubly linked list */
|
||||
struct ddsrt_circlist {
|
||||
struct ddsrt_circlist_elem *latest; /**< pointer to latest inserted element */
|
||||
};
|
||||
|
||||
/// @brief The circlist element is the basic element of circular doubly linked list structure.
|
||||
///
|
||||
/// To store user data in the list, the element must be embedded in a user element, which is a struct containing the user data.
|
||||
/// All API calls with an element as input or output, deal with the circlist element. Example:
|
||||
/// @code{.c}
|
||||
/// typedef struct num_s{ // user element
|
||||
/// uint64_t val; // user data
|
||||
/// ddsrt_circlist_elem elem;
|
||||
/// }num_t;
|
||||
/// @endcode
|
||||
///
|
||||
/// For functions like @ref ddsrt_circlist_latest, this means that to get a pointer to the user element, you can use the macro @ref DDSRT_FROM_CIRCLIST :
|
||||
/// @code{.c}
|
||||
/// num_t* num = DDSRT_FROM_CIRCLIST(num_t, elem, ddsrt_circlist_latest(listptr));
|
||||
/// @endcode
|
||||
struct ddsrt_circlist_elem {
|
||||
struct ddsrt_circlist_elem *next;
|
||||
struct ddsrt_circlist_elem *prev;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief initialize the list
|
||||
*
|
||||
* @param[out] list the circular list
|
||||
*/
|
||||
void ddsrt_circlist_init (struct ddsrt_circlist *list);
|
||||
|
||||
/**
|
||||
* @brief check whether the list is empty
|
||||
*
|
||||
* @param[in] list the circular list
|
||||
* @return true if empty, false if not empty
|
||||
*/
|
||||
bool ddsrt_circlist_isempty (const struct ddsrt_circlist *list);
|
||||
|
||||
/**
|
||||
* @brief append an element to the list
|
||||
*
|
||||
* @param[in,out] list the circular list
|
||||
* @param[in] elem the element to append
|
||||
*
|
||||
* See @ref ddsrt_circlist_remove
|
||||
*/
|
||||
void ddsrt_circlist_append (struct ddsrt_circlist *list, struct ddsrt_circlist_elem *elem);
|
||||
|
||||
/**
|
||||
* @brief remove an element from the list
|
||||
*
|
||||
* The user is still responsible for freeing the memory associated with the element.
|
||||
*
|
||||
* @param[in,out] list the circular list
|
||||
* @param[in] elem the element to append
|
||||
*
|
||||
* See @ref ddsrt_circlist_append
|
||||
*/
|
||||
void ddsrt_circlist_remove (struct ddsrt_circlist *list, struct ddsrt_circlist_elem *elem);
|
||||
|
||||
/**
|
||||
* @brief get the oldest (earliest appended) element
|
||||
*
|
||||
* @param[in] list the circular list
|
||||
* @return pointer to the oldest element
|
||||
*
|
||||
* See @ref ddsrt_circlist_latest, @ref ddsrt_circlist_elem
|
||||
*/
|
||||
struct ddsrt_circlist_elem *ddsrt_circlist_oldest (const struct ddsrt_circlist *list);
|
||||
|
||||
/**
|
||||
* @brief get the latest (most recently appended) element
|
||||
*
|
||||
* @param[in] list the circular list
|
||||
* @return pointer to the latest element
|
||||
*
|
||||
* See @ref ddsrt_circlist_oldest, @ref ddsrt_circlist_elem
|
||||
*/
|
||||
struct ddsrt_circlist_elem *ddsrt_circlist_latest (const struct ddsrt_circlist *list);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_CIRCLIST_H */
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Copyright(c) 2019 ZettaScale Technology 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 DDSRT_COUNTARGS_H
|
||||
#define DDSRT_COUNTARGS_H
|
||||
|
||||
/** @file countargs.h
|
||||
@brief This header provides a macro @ref DDSRT_COUNT_ARGS that returns the number of arguments provided
|
||||
(the other macros are just helper macros for @ref DDSRT_COUNT_ARGS)
|
||||
*/
|
||||
|
||||
#define DDSRT_COUNT_ARGS_MSVC_WORKAROUND(x) x
|
||||
|
||||
/** @brief Returns the number of arguments provided (at most 20) */
|
||||
#define DDSRT_COUNT_ARGS(...) DDSRT_COUNT_ARGS1 (__VA_ARGS__, 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
#define DDSRT_COUNT_ARGS1(...) DDSRT_COUNT_ARGS_MSVC_WORKAROUND (DDSRT_COUNT_ARGS_ARGN (__VA_ARGS__))
|
||||
#define DDSRT_COUNT_ARGS_ARGN(a,b,c,d,e,f,g,h,i,j, k,l,m,n,o,p,q,r,s,t, N,...) N
|
||||
|
||||
#endif
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
// Copyright(c) 2006 to 2022 ZettaScale Technology 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 DDSRT_DYNLIB_H
|
||||
#define DDSRT_DYNLIB_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/config.h"
|
||||
#include "dds/ddsrt/types.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//typedef void *ddsrt_dynlib_t;
|
||||
typedef struct ddsrt_dynlib *ddsrt_dynlib_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Load a dynamic shared library.
|
||||
*
|
||||
* The function ddsrt_dlopen() loads the dynamic shared object (shared library)
|
||||
* file, identified by 'name', sets the handle parameter for the loaded library and
|
||||
* returns the result with dds return code.
|
||||
*
|
||||
* If the 'translate' boolean is true, this function will first try to open the
|
||||
* library with a translated 'name'. Translated in this context means that if
|
||||
* "mylibrary" is provided, it will be translated into libmylibrary.so,
|
||||
* libmylibrary.dylib or mylibrary.dll depending on the platform.
|
||||
* This translation only happens when the given name does not contain
|
||||
* a directory.
|
||||
* If the function isn't able to load the library with the translated name, it
|
||||
* will still try the given name.
|
||||
*
|
||||
* @param[in] name Library file name.
|
||||
* @param[in] translate Automatic name translation on/off.
|
||||
* @param[out] handle Library handle that will be assigned after successfull operation. It is assigned to NULL if loading fails.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Library handle was successfully loaded.
|
||||
* @retval DDS_RETCODE_BAD_PARAM
|
||||
* There is an invalid input in the parameter list
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Loading failed.
|
||||
* Use ddsrt_dlerror() to diagnose the failure.
|
||||
*/
|
||||
dds_return_t
|
||||
ddsrt_dlopen(
|
||||
const char *name,
|
||||
bool translate,
|
||||
ddsrt_dynlib_t *handle) ddsrt_nonnull_all;
|
||||
|
||||
#if DDSRT_HAVE_DYNLIB
|
||||
dds_return_t
|
||||
ddsrt_platform_dlopen(
|
||||
const char *name,
|
||||
bool translate,
|
||||
ddsrt_dynlib_t *handle) ddsrt_nonnull_all;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Close the library.
|
||||
*
|
||||
* The function ddsrt_dlclose() informs the system that the
|
||||
* library, identified by 'handle', is no longer needed.
|
||||
* will get the memory address of a symbol,
|
||||
* identified by 'symbol', from a loaded library 'handle'.
|
||||
*
|
||||
* @param[in] handle Library handle.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Library handle was successfully closed.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Library closing failed.
|
||||
* Use ddsrt_dlerror() to diagnose the failure.
|
||||
*/
|
||||
dds_return_t
|
||||
ddsrt_dlclose(
|
||||
ddsrt_dynlib_t handle);
|
||||
|
||||
#if DDSRT_HAVE_DYNLIB
|
||||
dds_return_t
|
||||
ddsrt_platform_dlclose(
|
||||
ddsrt_dynlib_t handle);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the memory address of a symbol.
|
||||
*
|
||||
* The function ddsrt_dlsym() will get the memory address of a symbol,
|
||||
* identified by 'symbol', from a loaded library 'handle'.
|
||||
*
|
||||
* @param[in] handle Library handle.
|
||||
* @param[in] symbol Symbol name.
|
||||
* @param[out] address The memory address of the loaded symbol (void*).
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Symbol was found in the loaded library.
|
||||
* Address parameter is ready to use.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Symbol was not found.
|
||||
* Use ddsrt_dlerror() to diagnose the failure.
|
||||
*/
|
||||
dds_return_t
|
||||
ddsrt_dlsym(
|
||||
ddsrt_dynlib_t handle,
|
||||
const char *symbol,
|
||||
void **address);
|
||||
|
||||
#if DDSRT_HAVE_DYNLIB
|
||||
dds_return_t
|
||||
ddsrt_platform_dlsym(
|
||||
ddsrt_dynlib_t handle,
|
||||
const char *symbol,
|
||||
void **address);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the most recent library related error.
|
||||
*
|
||||
* The function ddsrt_dlerror() will return the most recent error of a
|
||||
* call to ddsrt_dlopen, ddsrt_dlclose, ddsrt_dlsym in human readable form.
|
||||
*
|
||||
* If no error was found, it's either due to the fact that there
|
||||
* actually was no error since init or last ddsrt_dlerror() call,
|
||||
* or due to an unknown unrelated error.
|
||||
*
|
||||
* @param[out] buf Buffer to store the error message
|
||||
* @param[in] buflen The length of the provided buffer (must be > 0).
|
||||
*
|
||||
* @returns A dds_return_t indicating success (>0) or failure.
|
||||
*
|
||||
* @retval >0
|
||||
* The length of the returned error message
|
||||
* @retval 0
|
||||
* No dynamic library loading related error present
|
||||
* @retval DDS_RETCODE_NOT_ENOUGH_SPACE
|
||||
* Buffer is not large enough to hold the error message
|
||||
*/
|
||||
dds_return_t
|
||||
ddsrt_dlerror(
|
||||
char *buf,
|
||||
size_t buflen);
|
||||
|
||||
#if DDSRT_HAVE_DYNLIB
|
||||
dds_return_t
|
||||
ddsrt_platform_dlerror(
|
||||
char *buf,
|
||||
size_t buflen);
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_DYNLIB_H */
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSRT_ENDIAN_H
|
||||
#define DDSRT_ENDIAN_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DDSRT_LITTLE_ENDIAN 1
|
||||
#define DDSRT_BIG_ENDIAN 2
|
||||
|
||||
#if _WIN32
|
||||
# if defined(__BIG_ENDIAN)
|
||||
# define DDSRT_ENDIAN DDSRT_BIG_ENDIAN
|
||||
# else
|
||||
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
|
||||
# endif
|
||||
/* _WIN32 */
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
# if __LITTLE_ENDIAN__ == 1
|
||||
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
|
||||
# else
|
||||
# define DDSRT_ENDIAN DDSRT_BIG_ENDIAN
|
||||
# endif
|
||||
/* __IAR_SYSTEMS_ICC__ */
|
||||
#else
|
||||
# if defined(__BYTE_ORDER__)
|
||||
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# define DDSRT_ENDIAN DDSRT_BIG_ENDIAN
|
||||
# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
|
||||
# endif
|
||||
# elif defined(__sun)
|
||||
# include <sys/isa_defs.h>
|
||||
# if defined(_BIG_ENDIAN)
|
||||
# define DDSRT_ENDIAN DDSRT_BIG_ENDIAN
|
||||
# elif defined(_LITTLE_ENDIAN)
|
||||
# define DDSRT_ENDIAN DDSRT_LITTLE_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#if (DDSRT_ENDIAN != DDSRT_LITTLE_ENDIAN) && \
|
||||
(DDSRT_ENDIAN != DDSRT_BIG_ENDIAN)
|
||||
# error "Endianness cannot be determined"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ENDIAN_H */
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSRT_ENVIRON_H
|
||||
#define DDSRT_ENVIRON_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
#include "dds/ddsrt/expand_vars.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get value for environment variable.
|
||||
*
|
||||
* @param[in] name Environment variable name.
|
||||
* @param[out] value Alias to value of environment variable - must not be modified
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Environment variable written to @buf.
|
||||
* @retval DDS_RETCODE_NOT_FOUND
|
||||
* Environment variable not found.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* FIXME: document
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* FIXME: document
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Unspecified error.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_getenv(
|
||||
const char *name,
|
||||
const char **value)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Set environment variable value.
|
||||
*
|
||||
* Sets the environment variable to the value specified in value, or
|
||||
* alternatively, unsets the environment variable if value is an empty string.
|
||||
*
|
||||
* @param[in] name Environment variable name.
|
||||
* @param[in] value Value to set environment variable to.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Environment variable successfully set to @value.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* Invalid environment variable name.
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* Not enough system resources to set environment variable.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Unspecified system error.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_setenv(
|
||||
const char *name,
|
||||
const char *value)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Unset environment variable value.
|
||||
*
|
||||
* @param[in] name Environment variable name.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
* @retval DDS_RETCODE_OK
|
||||
* Environment variable successfully unset.
|
||||
* @retval DDS_RETCODE_BAD_PARAMETER
|
||||
* Invalid environment variable name.
|
||||
* @retval DDS_RETCODE_OUT_OF_RESOURCES
|
||||
* Not enough system resources to unset environment variable.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* Unspecified system error.
|
||||
*/
|
||||
DDS_EXPORT dds_return_t
|
||||
ddsrt_unsetenv(
|
||||
const char *name)
|
||||
ddsrt_nonnull_all;
|
||||
|
||||
/**
|
||||
* @brief Expand environment variables within string.
|
||||
*
|
||||
* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X.
|
||||
*
|
||||
* The result string should be freed with ddsrt_free().
|
||||
*
|
||||
* @param[in] string String to expand.
|
||||
* @param[in] domid Domain id that this is relevant to
|
||||
* UINT32_MAX means none (see logging)
|
||||
* also made available as
|
||||
* ${CYCLONEDDS_DOMAIN_ID}
|
||||
*
|
||||
* @returns Allocated char*.
|
||||
*
|
||||
* @retval NULL
|
||||
* Expansion failed.
|
||||
* @retval Pointer
|
||||
* Copy of the string argument with the environment
|
||||
* variables expanded.
|
||||
*/
|
||||
DDS_EXPORT char*
|
||||
ddsrt_expand_envvars(
|
||||
const char *string,
|
||||
uint32_t domid);
|
||||
|
||||
/**
|
||||
* @brief Expand environment variables within string.
|
||||
*
|
||||
* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, $ and \
|
||||
* can be escaped with \.
|
||||
*
|
||||
* The result string should be freed with ddsrt_free().
|
||||
*
|
||||
* @param[in] string String to expand.
|
||||
*
|
||||
* @returns Allocated char*.
|
||||
*
|
||||
* @retval NULL
|
||||
* Expansion failed.
|
||||
* @retval Pointer
|
||||
* Copy of the string argument with the environment
|
||||
* variables expanded.
|
||||
*/
|
||||
DDS_EXPORT char*
|
||||
ddsrt_expand_envvars_sh(
|
||||
const char *string,
|
||||
uint32_t domid);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_ENVIRON_H */
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
// Copyright(c) 2006 to 2020 ZettaScale Technology 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 DDSRT_EXPAND_VARS_H
|
||||
#define DDSRT_EXPAND_VARS_H
|
||||
|
||||
#include "dds/export.h"
|
||||
#include "dds/ddsrt/attributes.h"
|
||||
#include "dds/ddsrt/retcode.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef const char * (*expand_lookup_fn)(const char *name, void *data);
|
||||
|
||||
/**
|
||||
* @brief Expand variables within string.
|
||||
*
|
||||
* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X.
|
||||
*
|
||||
* The result string should be freed with ddsrt_free().
|
||||
*
|
||||
* @param[in] string String to expand.
|
||||
* @param[in] lookup Lookup function to retrieve replacement value
|
||||
* @param[in] data Data passed to lookup function
|
||||
*
|
||||
* @returns Allocated char*.
|
||||
*
|
||||
* @retval NULL
|
||||
* Expansion failed.
|
||||
* @retval Pointer
|
||||
* Copy of the string argument with the variables expanded.
|
||||
*/
|
||||
char*
|
||||
ddsrt_expand_vars(
|
||||
const char *string,
|
||||
expand_lookup_fn lookup,
|
||||
void * data);
|
||||
|
||||
/**
|
||||
* @brief Expand variables within string.
|
||||
*
|
||||
* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, $ and \
|
||||
* can be escaped with \.
|
||||
*
|
||||
* The result string should be freed with ddsrt_free().
|
||||
*
|
||||
* @param[in] string String to expand.
|
||||
* @param[in] lookup Lookup function to retrieve replacement value
|
||||
* @param[in] data Data passed to lookup function
|
||||
*
|
||||
* @returns Allocated char*.
|
||||
*
|
||||
* @retval NULL
|
||||
* Expansion failed.
|
||||
* @retval Pointer
|
||||
* Copy of the string argument with the variables expanded.
|
||||
*/
|
||||
char*
|
||||
ddsrt_expand_vars_sh(
|
||||
const char *string,
|
||||
expand_lookup_fn lookup,
|
||||
void * data);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_EXPAND_VARS_H */
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
// Copyright(c) 2006 to 2019 ZettaScale Technology 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 DDSRT_FIBHEAP_H
|
||||
#define DDSRT_FIBHEAP_H
|
||||
|
||||
/** @file fibheap.h
|
||||
The main purpose of a fibonacci heap is for use as a priority queue i.e. repeatedly extracting the minimum of the set.
|
||||
Certain operations i.e. insert, merge, decrease_key are very efficient in that they have O(1) time complexity,
|
||||
but they they degrade the shape of the heap, which requires rebalancing to fix.
|
||||
The necessary rebalancing is delayed until the next call to extract_min.
|
||||
|
||||
For example, after lots of calls to insert and/or decrease_key, the next call to extract_min is very expensive
|
||||
since it has to rebalance, and this could take as much as O(N) in the worst case. This is where you pay off the debt
|
||||
for procrastinating on rebalancing. Once balanced, following calls to extract_min will be O(log(N)).
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dds/export.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// @brief The fibheap node is the basic element of the fibonacci heap.
|
||||
///
|
||||
/// - children: Rather than have a pointer to each child, it has one pointer to a representative child.
|
||||
/// The other children can then be reached through the child's prev/next.
|
||||
/// - prev/next: Siblings form a circular doubly linked list, so all can be reached going either direction.
|
||||
/// A node without siblings will point prev/next to itself.
|
||||
/// - mark: Is either 0 (unmarked) or 1 (marked). It is marked to indicate the node has lost a child since the last time
|
||||
/// it was made the child of another node. Newly created nodes are unmarked.
|
||||
/// A node becomes unmarked whenever it is made the child of another node.
|
||||
/// The mark flag is of importance for @ref ddsrt_fibheap_decrease_key and @ref ddsrt_fibheap_delete.
|
||||
///
|
||||
/// To store user data in the heap, the node must be embedded in a user node, which is a struct containing the user data e.g.:
|
||||
/// @code{.c}
|
||||
/// typedef struct num_s{ // user node
|
||||
/// uint64_t val; // user data
|
||||
/// ddsrt_fibheap_node node;
|
||||
/// }num_t;
|
||||
/// @endcode
|
||||
///
|
||||
/// The offset obtained as 'offsetof(num_t, node)' is needed for @ref ddsrt_fibheap_def_init
|
||||
typedef struct ddsrt_fibheap_node {
|
||||
struct ddsrt_fibheap_node *parent; ///< The node's parent
|
||||
struct ddsrt_fibheap_node *children; ///< The node's representative child.
|
||||
struct ddsrt_fibheap_node *prev; ///< The node's left sibling.
|
||||
struct ddsrt_fibheap_node *next; ///< The node’s right sibling.
|
||||
unsigned mark: 1; ///< Indicates whether the node has lost a child since the last time it was made the child of another node.
|
||||
unsigned degree: 31; ///< The number of children the node has
|
||||
} ddsrt_fibheap_node_t;
|
||||
|
||||
/**
|
||||
* @brief The fibonacci heap definition for the @ref ddsrt_fibheap
|
||||
*
|
||||
* Regarding the compare function, input arguments are pointers to the user nodes.
|
||||
* The expected return values are as follows:
|
||||
* - value < 0 to indicate va is less than vb
|
||||
* - value > 0 to indicate va is greater than vb
|
||||
* - value == 0 to indicate va is equal to vb
|
||||
*
|
||||
* See @ref ddsrt_fibheap_def_init, @ref DDSRT_FIBHEAPDEF_INITIALIZER
|
||||
*/
|
||||
typedef struct ddsrt_fibheap_def {
|
||||
uintptr_t offset; ///< The offset of the @ref ddsrt_fibheap_node with respect to the user node
|
||||
int (*cmp) (const void *va, const void *vb); ///< compare function for user nodes
|
||||
} ddsrt_fibheap_def_t;
|
||||
|
||||
/** @brief The fibonacci heap */
|
||||
typedef struct ddsrt_fibheap {
|
||||
ddsrt_fibheap_node_t *roots; ///< points to root node with minimum key value
|
||||
} ddsrt_fibheap_t;
|
||||
|
||||
/**
|
||||
* @brief Macro to initialize @ref ddsrt_fibheap_def
|
||||
*
|
||||
* See @ref ddsrt_fibheap_def_init
|
||||
*/
|
||||
#define DDSRT_FIBHEAPDEF_INITIALIZER(offset, cmp) { (offset), (cmp) }
|
||||
|
||||
/**
|
||||
* @brief Initialize the @ref ddsrt_fibheap_def
|
||||
*
|
||||
* @param[out] fhdef the fibonacci heap definition to initialize
|
||||
* @param[in] offset the offset
|
||||
* @param[in] cmp the compare function
|
||||
*
|
||||
* See @ref ddsrt_fibheap_init, @ref DDSRT_FIBHEAPDEF_INITIALIZER
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_def_init (ddsrt_fibheap_def_t *fhdef, uintptr_t offset, int (*cmp) (const void *va, const void *vb));
|
||||
|
||||
/**
|
||||
* @brief Initialize the @ref ddsrt_fibheap
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[out] fh the fibonacci heap
|
||||
*
|
||||
* See @ref ddsrt_fibheap_def_init
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_init (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh);
|
||||
|
||||
/**
|
||||
* @brief Access the minimum node
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in] fh the fibonacci heap
|
||||
* @return pointer to the minimum user node, NULL if empty
|
||||
*
|
||||
* See @ref ddsrt_fibheap_extract_min
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_fibheap_min (const ddsrt_fibheap_def_t *fhdef, const ddsrt_fibheap_t *fh);
|
||||
|
||||
/**
|
||||
* @brief Merge two fibonacci heaps
|
||||
*
|
||||
* Contents of heap b are merged into heap a, emptying heap b.
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in,out] a target fibonacci heap
|
||||
* @param[in,out] b source fibonacci heap
|
||||
*
|
||||
* See @ref ddsrt_fibheap_insert
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_merge (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *a, ddsrt_fibheap_t *b);
|
||||
|
||||
/**
|
||||
* @brief Insert a node into a fibonacci heap
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in,out] fh the fibonacci heap
|
||||
* @param[in] vnode user node to insert
|
||||
*
|
||||
* See @ref ddsrt_fibheap_extract_min, @ref ddsrt_fibheap_delete, @ref ddsrt_fibheap_merge
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_insert (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode);
|
||||
|
||||
/**
|
||||
* @brief Remove a node from a fibonacci heap
|
||||
*
|
||||
* Despite the name 'delete', it only removes the node from the heap.
|
||||
* To fully delete it, you still need to free the memory associated with the node.
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in,out] fh the fibonacci heap
|
||||
* @param[in] vnode user node to delete
|
||||
*
|
||||
* See @ref ddsrt_fibheap_extract_min, @ref ddsrt_fibheap_insert
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_delete (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode);
|
||||
|
||||
/**
|
||||
* @brief Take the minimum node from a fibonacci heap
|
||||
*
|
||||
* The user is responsible for freeing the memory associated with the node.
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in,out] fh the fibonacci heap
|
||||
* @return pointer to the minimum user node, NULL if empty
|
||||
*
|
||||
* See @ref ddsrt_fibheap_min, @ref ddsrt_fibheap_delete, @ref ddsrt_fibheap_insert
|
||||
*/
|
||||
DDS_EXPORT void *ddsrt_fibheap_extract_min (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh);
|
||||
|
||||
/**
|
||||
* @brief Reposition a node in the fibonacci heap to account for a decrease of its key
|
||||
*
|
||||
* Despite the name 'decrease_key', the function doesn't decrease the key.
|
||||
* It assumes the key has already been decreased, and repositions the node such as to maintain a valid heap structure.
|
||||
*
|
||||
* @param[in] fhdef the fibonacci heap definition
|
||||
* @param[in,out] fh the fibonacci heap
|
||||
* @param[in] vnode user node to reposition
|
||||
*/
|
||||
DDS_EXPORT void ddsrt_fibheap_decrease_key (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DDSRT_FIBHEAP_H */
|
||||
Loaded 100 of 3700 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user