stricter warning checks and the corresponding fixes
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									87e4780446
								
							
						
					
					
						commit
						b7487b18a6
					
				
					 101 changed files with 1756 additions and 1615 deletions
				
			
		| 
						 | 
				
			
			@ -77,6 +77,28 @@ if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
 | 
			
		|||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# Set reasonably strict warning options for clang, gcc, msvc
 | 
			
		||||
# Enable coloured ouput if Ninja is used for building
 | 
			
		||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
 | 
			
		||||
  add_definitions(-Wall -Wextra -Wconversion -Wunused)
 | 
			
		||||
  message("${CMAKE_GENERATOR}")
 | 
			
		||||
  #if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT(${CMAKE_GENERATOR} STREQUAL "Xcode"))
 | 
			
		||||
  #  set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
 | 
			
		||||
  #  set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
 | 
			
		||||
  #  set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
 | 
			
		||||
  #endif()
 | 
			
		||||
  if(${CMAKE_GENERATOR} STREQUAL "Ninja")
 | 
			
		||||
    add_definitions(-Xclang -fcolor-diagnostics)
 | 
			
		||||
  endif()
 | 
			
		||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
 | 
			
		||||
  add_definitions(-Wall -Wextra -Wconversion)
 | 
			
		||||
  if(${CMAKE_GENERATOR} STREQUAL "Ninja")
 | 
			
		||||
    add_definitions(-fdiagnostics-color=always)
 | 
			
		||||
  endif()
 | 
			
		||||
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "MSVC")
 | 
			
		||||
  add_definitions(/W3)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
include(FileIDs)
 | 
			
		||||
include(GNUInstallDirs)
 | 
			
		||||
include(AnalyzeBuild)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,6 @@ int main (int argc, char *argv[])
 | 
			
		|||
    err = cu_runner_run();
 | 
			
		||||
    cu_runner_fini();
 | 
			
		||||
err_init:
 | 
			
		||||
    return err;
 | 
			
		||||
    return (int)err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ cu_runner_init(
 | 
			
		|||
 | 
			
		||||
    for (i = 1; e == CUE_SUCCESS && i < argc; i++) {
 | 
			
		||||
        c = (argv[i][0] == '-') ? argv[i][1] : -1;
 | 
			
		||||
        switch (argv[i][1]) {
 | 
			
		||||
        switch (c) {
 | 
			
		||||
            case 'a':
 | 
			
		||||
                runner.automated = true;
 | 
			
		||||
                break;
 | 
			
		||||
| 
						 | 
				
			
			@ -111,19 +111,19 @@ cu_runner_init(
 | 
			
		|||
                    runner.results = argv[++i];
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                /* no break */
 | 
			
		||||
                /* FALLS THROUGH */
 | 
			
		||||
            case 's':
 | 
			
		||||
                if ((i+1) < argc) {
 | 
			
		||||
                    runner.suite = argv[++i];
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                /* no break */
 | 
			
		||||
                /* FALLS THROUGH */
 | 
			
		||||
            case 't':
 | 
			
		||||
                if ((i+1) < argc) {
 | 
			
		||||
                    runner.test = argv[++i];
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                /* no break */
 | 
			
		||||
                /* FALLS THROUGH */
 | 
			
		||||
            default:
 | 
			
		||||
                e = (CU_ErrorCode)256;
 | 
			
		||||
                CU_set_error(e); /* Will print as "Undefined Errpr" */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -392,7 +392,7 @@ main(int argc, char *argv[])
 | 
			
		|||
    /* Before handing over argc and argv over to criterion, go over the list to
 | 
			
		||||
       extract the custom options. Note that these are meant to be "hidden" */
 | 
			
		||||
    cr_argc = 0;
 | 
			
		||||
    if ((cr_argv = calloc(argc, sizeof(*cr_argv))) == NULL) {
 | 
			
		||||
    if ((cr_argv = calloc((unsigned)argc, sizeof(*cr_argv))) == NULL) {
 | 
			
		||||
        result = 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        for (argno = 0; argno < argc; argno++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -408,13 +408,14 @@ main(int argc, char *argv[])
 | 
			
		|||
                }
 | 
			
		||||
 | 
			
		||||
                sz = snprintf(runfn, sizeof(runfn), runfmt, pfx);
 | 
			
		||||
                assert(sz > 0 && sz < sizeof(runfn));
 | 
			
		||||
                assert(sz > 0 && sz < (int)sizeof(runfn));
 | 
			
		||||
                sz = snprintf(listfn, sizeof(listfn), listfmt, pfx);
 | 
			
		||||
                assert(sz > 0 && sz < sizeof(listfn));
 | 
			
		||||
                assert(sz > 0 && sz < (int)sizeof(listfn));
 | 
			
		||||
                now = time(NULL);
 | 
			
		||||
                sz = (int)strftime(
 | 
			
		||||
                    stamp, sizeof(stamp), stampfmt, localtime(&now));
 | 
			
		||||
                assert(sz != 0);
 | 
			
		||||
                (void)sz;
 | 
			
		||||
            } else if (strncmp(argv[argno], "--suite", 7) == 0) {
 | 
			
		||||
                if ((argno + 1) == argc) {
 | 
			
		||||
                    fprintf(stderr, "--suite requires an argument\n");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3043,7 +3043,7 @@ DDS_EXPORT _Must_inspect_result_ dds_return_t
 | 
			
		|||
dds_return_loan(
 | 
			
		||||
        _In_ dds_entity_t reader_or_condition,
 | 
			
		||||
        _Inout_updates_(bufsz) void **buf,
 | 
			
		||||
        _In_ size_t bufsz);
 | 
			
		||||
        _In_ int32_t bufsz);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
  Instance handle <=> key value mapping.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,10 +43,10 @@ struct rhc;
 | 
			
		|||
 | 
			
		||||
/* Internal entity status flags */
 | 
			
		||||
 | 
			
		||||
#define DDS_INTERNAL_STATUS_MASK     (0xFF000000)
 | 
			
		||||
#define DDS_INTERNAL_STATUS_MASK     (0xFF000000u)
 | 
			
		||||
 | 
			
		||||
#define DDS_WAITSET_TRIGGER_STATUS   (0x01000000)
 | 
			
		||||
#define DDS_DELETING_STATUS          (0x02000000)
 | 
			
		||||
#define DDS_WAITSET_TRIGGER_STATUS   (0x01000000u)
 | 
			
		||||
#define DDS_DELETING_STATUS          (0x02000000u)
 | 
			
		||||
 | 
			
		||||
/* This can be used when polling for various states.
 | 
			
		||||
 * Obviously, it is encouraged to use condition variables and such. But
 | 
			
		||||
| 
						 | 
				
			
			@ -78,8 +78,8 @@ typedef struct c_listener {
 | 
			
		|||
 | 
			
		||||
/* Entity flag values */
 | 
			
		||||
 | 
			
		||||
#define DDS_ENTITY_ENABLED      0x0001
 | 
			
		||||
#define DDS_ENTITY_IMPLICIT     0x0002
 | 
			
		||||
#define DDS_ENTITY_ENABLED      0x0001u
 | 
			
		||||
#define DDS_ENTITY_IMPLICIT     0x0002u
 | 
			
		||||
 | 
			
		||||
typedef struct dds_domain
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ This file was the one orginally in ./src/api/dcps/saj/code/.
 | 
			
		|||
(and therefore by implication ./src/api/dcps/cj/java/code).
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#define BUILTIN_TOPIC_KEY_TYPE_NATIVE   long
 | 
			
		||||
#define BUILTIN_TOPIC_KEY_TYPE_NATIVE   unsigned long
 | 
			
		||||
 | 
			
		||||
module DDS {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -990,7 +990,7 @@ dds_valid_hdl(
 | 
			
		|||
    /* When the given handle already contains an error, then return that
 | 
			
		||||
     * same error to retain the original information. */
 | 
			
		||||
    if (hdl >= 0) {
 | 
			
		||||
        utr = ut_handle_status(hdl, NULL, kind);
 | 
			
		||||
        utr = ut_handle_status(hdl, NULL, (int32_t)kind);
 | 
			
		||||
        if(utr == UT_HANDLE_OK){
 | 
			
		||||
            rc = DDS_RETCODE_OK;
 | 
			
		||||
        } else if(utr == UT_HANDLE_UNEQUAL_KIND){
 | 
			
		||||
| 
						 | 
				
			
			@ -1029,7 +1029,7 @@ dds_entity_lock(
 | 
			
		|||
    /* When the given handle already contains an error, then return that
 | 
			
		||||
     * same error to retain the original information. */
 | 
			
		||||
    if (hdl >= 0) {
 | 
			
		||||
        utr = ut_handle_claim(hdl, NULL, kind, (void**)e);
 | 
			
		||||
        utr = ut_handle_claim(hdl, NULL, (int32_t)kind, (void**)e);
 | 
			
		||||
        if (utr == UT_HANDLE_OK) {
 | 
			
		||||
            os_mutexLock(&((*e)->m_mutex));
 | 
			
		||||
            /* The handle could have been closed while we were waiting for the mutex. */
 | 
			
		||||
| 
						 | 
				
			
			@ -1195,14 +1195,13 @@ dds_entity_observer_unregister(
 | 
			
		|||
        _In_ dds_entity_t observer)
 | 
			
		||||
{
 | 
			
		||||
    dds__retcode_t rc;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    dds_entity *e;
 | 
			
		||||
    rc = dds_entity_lock(observed, DDS_KIND_DONTCARE, &e);
 | 
			
		||||
    if (rc == DDS_RETCODE_OK) {
 | 
			
		||||
        rc = dds_entity_observer_unregister_nl(e, observer);
 | 
			
		||||
        dds_entity_unlock(e);
 | 
			
		||||
    } else{
 | 
			
		||||
        ret = DDS_ERRNO(rc, "Error occurred on locking entity");
 | 
			
		||||
        rc = DDS_ERRNO(rc, "Error occurred on locking entity");
 | 
			
		||||
    }
 | 
			
		||||
    return rc;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ static const char * dds_err_code_array[DDS_ERR_CODE_NUM] =
 | 
			
		|||
 | 
			
		||||
const char * dds_err_str (dds_return_t err)
 | 
			
		||||
{
 | 
			
		||||
  unsigned index = DDS_ERR_NR_INDEX (err);
 | 
			
		||||
  unsigned index = (unsigned)DDS_ERR_NR_INDEX (err);
 | 
			
		||||
  if (err >= 0)
 | 
			
		||||
  {
 | 
			
		||||
    return "Success";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,12 +37,7 @@ char *os_environ[] = { NULL };
 | 
			
		|||
 | 
			
		||||
struct q_globals gv;
 | 
			
		||||
 | 
			
		||||
dds_globals dds_global =
 | 
			
		||||
{
 | 
			
		||||
  DDS_DOMAIN_DEFAULT, 0,
 | 
			
		||||
  NULL, NULL, NULL, NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
dds_globals dds_global = { .m_default_domain = DDS_DOMAIN_DEFAULT };
 | 
			
		||||
static struct cfgst * dds_cfgst = NULL;
 | 
			
		||||
 | 
			
		||||
dds_return_t
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
#ifndef NDEBUG
 | 
			
		||||
static bool keyhash_is_reset(const dds_key_hash_t *kh)
 | 
			
		||||
{
 | 
			
		||||
  static const char nullhash[sizeof(kh->m_hash)];
 | 
			
		||||
  static const char nullhash[sizeof(kh->m_hash)] = { 0 };
 | 
			
		||||
  return kh->m_flags == 0 && memcmp(kh->m_hash, nullhash, sizeof(nullhash)) == 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ void dds_key_md5 (dds_key_hash_t * kh)
 | 
			
		|||
  md5_finish (&md5st, (unsigned char *) kh->m_hash);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
/*
 | 
			
		||||
  dds_key_gen: Generates key and keyhash for a sample.
 | 
			
		||||
  See section 9.6.3.3 of DDSI spec.
 | 
			
		||||
*/
 | 
			
		||||
| 
						 | 
				
			
			@ -85,9 +85,13 @@ void dds_key_gen
 | 
			
		|||
        case DDS_OP_VAL_2BY: len += 2; break;
 | 
			
		||||
        case DDS_OP_VAL_4BY: len += 4; break;
 | 
			
		||||
        case DDS_OP_VAL_8BY: len += 8; break;
 | 
			
		||||
        case DDS_OP_VAL_STR: src = *((char**) src); /* Fall-through intentional */
 | 
			
		||||
        case DDS_OP_VAL_BST: len += (uint32_t) (5 + strlen (src)); break;
 | 
			
		||||
        case DDS_OP_VAL_ARR: 
 | 
			
		||||
        case DDS_OP_VAL_STR:
 | 
			
		||||
          src = *((char**) src);
 | 
			
		||||
          /* FALLS THROUGH */
 | 
			
		||||
        case DDS_OP_VAL_BST:
 | 
			
		||||
          len += (uint32_t) (5 + strlen (src));
 | 
			
		||||
          break;
 | 
			
		||||
        case DDS_OP_VAL_ARR:
 | 
			
		||||
          len += op[2] * dds_op_size[DDS_OP_SUBTYPE (*op)];
 | 
			
		||||
          break;
 | 
			
		||||
        default: assert (0);
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +147,8 @@ void dds_key_gen
 | 
			
		|||
      case DDS_OP_VAL_STR:
 | 
			
		||||
      {
 | 
			
		||||
        src = *((char**) src);
 | 
			
		||||
      } /* Fall-through intentional */
 | 
			
		||||
      }
 | 
			
		||||
        /* FALLS THROUGH */
 | 
			
		||||
      case DDS_OP_VAL_BST:
 | 
			
		||||
      {
 | 
			
		||||
        uint32_t u32;
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +178,7 @@ void dds_key_gen
 | 
			
		|||
 | 
			
		||||
  /* Hash is md5 of key */
 | 
			
		||||
 | 
			
		||||
  if ((kh->m_flags & DDS_KEY_IS_HASH) == 0) 
 | 
			
		||||
  if ((kh->m_flags & DDS_KEY_IS_HASH) == 0)
 | 
			
		||||
  {
 | 
			
		||||
    dds_key_md5 (kh);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@
 | 
			
		|||
#include "dds__err.h"
 | 
			
		||||
#include "dds__report.h"
 | 
			
		||||
 | 
			
		||||
#define DDS_PARTICIPANT_STATUS_MASK    0
 | 
			
		||||
#define DDS_PARTICIPANT_STATUS_MASK    0u
 | 
			
		||||
 | 
			
		||||
/* List of created participants */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +101,7 @@ dds_participant_qos_validate(
 | 
			
		|||
{
 | 
			
		||||
    dds_return_t ret = DDS_RETCODE_OK;
 | 
			
		||||
    assert(qos);
 | 
			
		||||
    (void)enabled;
 | 
			
		||||
 | 
			
		||||
    /* Check consistency. */
 | 
			
		||||
    if ((qos->present & QP_USER_DATA) && !validate_octetseq(&qos->user_data)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -120,6 +121,7 @@ dds_participant_qos_set(
 | 
			
		|||
        bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = dds_participant_qos_validate(qos, enabled);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
        if (enabled) {
 | 
			
		||||
            /* TODO: CHAM-95: DDSI does not support changing QoS policies. */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,15 +18,15 @@
 | 
			
		|||
#include "dds__report.h"
 | 
			
		||||
#include "ddsc/ddsc_project.h"
 | 
			
		||||
 | 
			
		||||
#define DDS_PUBLISHER_STATUS_MASK   0
 | 
			
		||||
#define DDS_PUBLISHER_STATUS_MASK   0u
 | 
			
		||||
 | 
			
		||||
static dds_return_t
 | 
			
		||||
dds_publisher_instance_hdl(
 | 
			
		||||
        dds_entity *e,
 | 
			
		||||
        dds_instance_handle_t *i)
 | 
			
		||||
{
 | 
			
		||||
    assert(e);
 | 
			
		||||
    assert(i);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    (void)i;
 | 
			
		||||
    /* TODO: Get/generate proper handle. */
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Getting publisher instance handle is not supported");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +66,7 @@ dds_publisher_qos_set(
 | 
			
		|||
        bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = dds_publisher_qos_validate(qos, enabled);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
        if (enabled) {
 | 
			
		||||
            /* TODO: CHAM-95: DDSI does not support changing QoS policies. */
 | 
			
		||||
| 
						 | 
				
			
			@ -207,6 +208,7 @@ dds_publisher_begin_coherent(
 | 
			
		|||
        _In_ dds_entity_t e)
 | 
			
		||||
{
 | 
			
		||||
    /* TODO: CHAM-124 Currently unsupported. */
 | 
			
		||||
    (void)e;
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -215,6 +217,7 @@ dds_publisher_end_coherent(
 | 
			
		|||
        _In_ dds_entity_t e)
 | 
			
		||||
{
 | 
			
		||||
    /* TODO: CHAM-124 Currently unsupported. */
 | 
			
		||||
    (void)e;
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not being supported yet");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -207,6 +207,7 @@ dds_readcdr_impl(
 | 
			
		|||
  assert (si);
 | 
			
		||||
  assert (hand == DDS_HANDLE_NIL);
 | 
			
		||||
  assert (maxs > 0);
 | 
			
		||||
  (void)take;
 | 
			
		||||
 | 
			
		||||
  if (asleep)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -817,7 +818,7 @@ _Must_inspect_result_ dds_return_t
 | 
			
		|||
dds_return_loan(
 | 
			
		||||
        _In_ dds_entity_t reader_or_condition,
 | 
			
		||||
        _Inout_updates_(bufsz) void **buf,
 | 
			
		||||
        _In_ size_t bufsz)
 | 
			
		||||
        _In_ int32_t bufsz)
 | 
			
		||||
{
 | 
			
		||||
    dds__retcode_t rc;
 | 
			
		||||
    const dds_topic_descriptor_t * desc;
 | 
			
		||||
| 
						 | 
				
			
			@ -845,7 +846,7 @@ dds_return_loan(
 | 
			
		|||
 | 
			
		||||
    /* Only free sample contents if they have been allocated */
 | 
			
		||||
    if (desc->m_flagset & DDS_TOPIC_NO_OPTIMIZE) {
 | 
			
		||||
        size_t i = 0;
 | 
			
		||||
        int32_t i = 0;
 | 
			
		||||
        for (i = 0; i < bufsz; i++) {
 | 
			
		||||
            dds_sample_free(buf[i], desc, DDS_FREE_CONTENTS);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -134,6 +134,7 @@ dds_reader_qos_set(
 | 
			
		|||
        bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = dds_reader_qos_validate(qos, enabled);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
        if (enabled) {
 | 
			
		||||
            /* TODO: CHAM-95: DDSI does not support changing QoS policies. */
 | 
			
		||||
| 
						 | 
				
			
			@ -517,7 +518,7 @@ dds_reader_ddsi2direct(
 | 
			
		|||
      else
 | 
			
		||||
      {
 | 
			
		||||
        memset (&pwrguid_next, 0xff, sizeof (pwrguid_next));
 | 
			
		||||
        pwrguid_next.entityid.u = (pwrguid_next.entityid.u & ~0xff) | NN_ENTITYID_KIND_WRITER_NO_KEY;
 | 
			
		||||
        pwrguid_next.entityid.u = (pwrguid_next.entityid.u & ~(uint32_t)0xff) | NN_ENTITYID_KIND_WRITER_NO_KEY;
 | 
			
		||||
      }
 | 
			
		||||
      os_mutexUnlock (&rd->e.lock);
 | 
			
		||||
      if ((pwr = ephash_lookup_proxy_writer_guid (&pwrguid)) != NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -541,9 +542,7 @@ dds_reader_lock_samples(
 | 
			
		|||
{
 | 
			
		||||
    uint32_t ret = 0;
 | 
			
		||||
    dds_reader *rd;
 | 
			
		||||
 | 
			
		||||
    ret = dds_reader_lock(reader, &rd);
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
    if (dds_reader_lock(reader, &rd) == DDS_RETCODE_OK) {
 | 
			
		||||
        ret = dds_rhc_lock_samples(rd->m_rd->rhc);
 | 
			
		||||
        dds_reader_unlock(rd);
 | 
			
		||||
    } else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -248,7 +248,7 @@ struct rhc_instance
 | 
			
		|||
  unsigned inv_isread : 1;     /* whether or not that state change has been read before */
 | 
			
		||||
  unsigned disposed_gen;       /* bloody generation counters - worst invention of mankind */
 | 
			
		||||
  unsigned no_writers_gen;     /* __/ */
 | 
			
		||||
  uint32_t strength;           /* "current" ownership strength */
 | 
			
		||||
  int32_t strength;            /* "current" ownership strength */
 | 
			
		||||
  nn_guid_t wr_guid;           /* guid of last writer (if wr_iid != 0 then wr_guid is the corresponding guid, else undef) */
 | 
			
		||||
  nn_wctime_t tstamp;          /* source time stamp of last update */
 | 
			
		||||
  struct rhc_instance *next;   /* next non-empty instance in arbitrary ordering */
 | 
			
		||||
| 
						 | 
				
			
			@ -313,7 +313,7 @@ struct trigger_info
 | 
			
		|||
#define QMASK_OF_SAMPLE(s) ((s)->isread ? DDS_READ_SAMPLE_STATE : DDS_NOT_READ_SAMPLE_STATE)
 | 
			
		||||
#define QMASK_OF_INVSAMPLE(i) ((i)->inv_isread ? DDS_READ_SAMPLE_STATE : DDS_NOT_READ_SAMPLE_STATE)
 | 
			
		||||
#define INST_NSAMPLES(i) ((i)->nvsamples + (i)->inv_exists)
 | 
			
		||||
#define INST_NREAD(i) ((i)->nvread + ((i)->inv_exists & (i)->inv_isread))
 | 
			
		||||
#define INST_NREAD(i) ((i)->nvread + (unsigned)((i)->inv_exists & (i)->inv_isread))
 | 
			
		||||
#define INST_IS_EMPTY(i) (INST_NSAMPLES (i) == 0)
 | 
			
		||||
#define INST_HAS_READ(i) (INST_NREAD (i) > 0)
 | 
			
		||||
#define INST_HAS_UNREAD(i) (INST_NREAD (i) < INST_NSAMPLES (i))
 | 
			
		||||
| 
						 | 
				
			
			@ -413,7 +413,8 @@ void dds_rhc_set_qos (struct rhc * rhc, const nn_xqos_t * qos)
 | 
			
		|||
  rhc->by_source_ordering = (qos->destination_order.kind == NN_BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS);
 | 
			
		||||
  rhc->exclusive_ownership = (qos->ownership.kind == NN_EXCLUSIVE_OWNERSHIP_QOS);
 | 
			
		||||
  rhc->reliable = (qos->reliability.kind == NN_RELIABLE_RELIABILITY_QOS);
 | 
			
		||||
  rhc->history_depth = (qos->history.kind == NN_KEEP_LAST_HISTORY_QOS) ? qos->history.depth : ~0u;
 | 
			
		||||
  assert(qos->history.kind != NN_KEEP_LAST_HISTORY_QOS || qos->history.depth > 0);
 | 
			
		||||
  rhc->history_depth = (qos->history.kind == NN_KEEP_LAST_HISTORY_QOS) ? (uint32_t)qos->history.depth : ~0u;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct rhc_sample * alloc_sample (struct rhc_instance *inst)
 | 
			
		||||
| 
						 | 
				
			
			@ -706,7 +707,7 @@ static int inst_accepts_sample
 | 
			
		|||
  }
 | 
			
		||||
  if (rhc->exclusive_ownership && inst->wr_iid_islive && inst->wr_iid != pwr_info->iid)
 | 
			
		||||
  {
 | 
			
		||||
    uint32_t strength = pwr_info->ownership_strength;
 | 
			
		||||
    int32_t strength = pwr_info->ownership_strength;
 | 
			
		||||
    if (strength > inst->strength) {
 | 
			
		||||
      /* ok */
 | 
			
		||||
    } else if (strength < inst->strength) {
 | 
			
		||||
| 
						 | 
				
			
			@ -729,6 +730,7 @@ static void update_inst
 | 
			
		|||
  const struct rhc *rhc, struct rhc_instance *inst,
 | 
			
		||||
  const struct proxy_writer_info * __restrict pwr_info, bool wr_iid_valid, nn_wctime_t tstamp)
 | 
			
		||||
{
 | 
			
		||||
  (void)rhc;
 | 
			
		||||
  inst->tstamp = tstamp;
 | 
			
		||||
  inst->wr_iid_islive = wr_iid_valid;
 | 
			
		||||
  if (wr_iid_valid)
 | 
			
		||||
| 
						 | 
				
			
			@ -1016,7 +1018,6 @@ static void dds_rhc_unregister
 | 
			
		|||
 | 
			
		||||
static struct rhc_instance * alloc_new_instance
 | 
			
		||||
(
 | 
			
		||||
  const struct rhc *rhc,
 | 
			
		||||
  const struct proxy_writer_info *pwr_info,
 | 
			
		||||
  struct serdata *serdata,
 | 
			
		||||
  struct tkmap_instance *tk
 | 
			
		||||
| 
						 | 
				
			
			@ -1086,7 +1087,7 @@ static rhc_store_result_t rhc_store_new_instance
 | 
			
		|||
    return RHC_REJECTED;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  inst = alloc_new_instance (rhc, pwr_info, sample, tk);
 | 
			
		||||
  inst = alloc_new_instance (pwr_info, sample, tk);
 | 
			
		||||
  if (has_data)
 | 
			
		||||
  {
 | 
			
		||||
    if (!add_sample (rhc, inst, pwr_info, sample, cb_data))
 | 
			
		||||
| 
						 | 
				
			
			@ -1298,8 +1299,8 @@ bool dds_rhc_store
 | 
			
		|||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          rhc->n_not_alive_disposed += inst->isdisposed - old_isdisposed;
 | 
			
		||||
          rhc->n_new += inst->isnew - old_isnew;
 | 
			
		||||
          rhc->n_not_alive_disposed += (uint32_t)(inst->isdisposed - old_isdisposed);
 | 
			
		||||
          rhc->n_new += (uint32_t)(inst->isnew - old_isnew);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
| 
						 | 
				
			
			@ -1740,7 +1741,8 @@ static int dds_rhc_read_w_qminv
 | 
			
		|||
      dds_entity_status_signal((dds_entity*)(rhc->reader));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return n;
 | 
			
		||||
  assert (n <= INT_MAX);
 | 
			
		||||
  return (int)n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dds_rhc_take_w_qminv
 | 
			
		||||
| 
						 | 
				
			
			@ -1904,7 +1906,8 @@ static int dds_rhc_take_w_qminv
 | 
			
		|||
      dds_entity_status_signal((dds_entity*)(rhc->reader));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return n;
 | 
			
		||||
  assert (n <= INT_MAX);
 | 
			
		||||
  return (int)n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dds_rhc_takecdr_w_qminv
 | 
			
		||||
| 
						 | 
				
			
			@ -1916,6 +1919,7 @@ static int dds_rhc_takecdr_w_qminv
 | 
			
		|||
  bool trigger_waitsets = false;
 | 
			
		||||
  uint64_t iid;
 | 
			
		||||
  uint32_t n = 0;
 | 
			
		||||
  (void)cond;
 | 
			
		||||
 | 
			
		||||
  if (lock)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -2053,7 +2057,8 @@ static int dds_rhc_takecdr_w_qminv
 | 
			
		|||
      dds_entity_status_signal((dds_entity*)(rhc->reader));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return n;
 | 
			
		||||
  assert (n <= INT_MAX);
 | 
			
		||||
  return (int)n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ static void dds_stream_read
 | 
			
		|||
  (dds_stream_t * is, char * data, const uint32_t * ops);
 | 
			
		||||
 | 
			
		||||
#define DDS_SWAP16(v) \
 | 
			
		||||
  (((v) >> 8) | ((v) << 8))
 | 
			
		||||
  ((uint16_t)(((v) >> 8) | ((v) << 8)))
 | 
			
		||||
#define DDS_SWAP32(v) \
 | 
			
		||||
  (((v) >> 24) | \
 | 
			
		||||
  (((v) & 0x00ff0000) >> 8) | \
 | 
			
		||||
| 
						 | 
				
			
			@ -207,12 +207,12 @@ void dds_stream_grow (dds_stream_t * st, size_t size)
 | 
			
		|||
 | 
			
		||||
  /* Reallocate on 4k boundry */
 | 
			
		||||
 | 
			
		||||
  size_t newSize = (needed & ~0xfff) + 0x1000;
 | 
			
		||||
  size_t newSize = (needed & ~(size_t)0xfff) + 0x1000;
 | 
			
		||||
  uint8_t * old = st->m_buffer.p8;
 | 
			
		||||
 | 
			
		||||
  st->m_buffer.p8 = dds_realloc (old, newSize);
 | 
			
		||||
  memset (st->m_buffer.p8 + st->m_size, 0, newSize - st->m_size);
 | 
			
		||||
  st->m_size = (int32_t) newSize;
 | 
			
		||||
  st->m_size = newSize;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool dds_stream_read_bool (dds_stream_t * is)
 | 
			
		||||
| 
						 | 
				
			
			@ -280,12 +280,12 @@ double dds_stream_read_double (dds_stream_t * is)
 | 
			
		|||
  return val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char * dds_stream_reuse_string 
 | 
			
		||||
char * dds_stream_reuse_string
 | 
			
		||||
  (dds_stream_t * is, char * str, const uint32_t bound)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t length;
 | 
			
		||||
  void * src;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  DDS_CDR_ALIGN4 (is);
 | 
			
		||||
  if (DDS_IS_OK (is, 4))
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -356,7 +356,7 @@ void dds_stream_swap (void * buff, uint32_t size, uint32_t num)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void dds_stream_read_fixed_buffer 
 | 
			
		||||
static void dds_stream_read_fixed_buffer
 | 
			
		||||
  (dds_stream_t * is, void * buff, uint32_t len, const uint32_t size, const bool swap)
 | 
			
		||||
{
 | 
			
		||||
  if (size && len)
 | 
			
		||||
| 
						 | 
				
			
			@ -423,12 +423,16 @@ void dds_stream_write_uint64 (dds_stream_t * os, uint64_t val)
 | 
			
		|||
 | 
			
		||||
void dds_stream_write_float (dds_stream_t * os, float val)
 | 
			
		||||
{
 | 
			
		||||
  DDS_OS_PUT4 (os, val, float);
 | 
			
		||||
  union { float f; uint32_t u; } u;
 | 
			
		||||
  u.f = val;
 | 
			
		||||
  dds_stream_write_uint32 (os, u.u);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_write_double (dds_stream_t * os, double val)
 | 
			
		||||
{
 | 
			
		||||
  DDS_OS_PUT8 (os, val, double);
 | 
			
		||||
  union { double f; uint64_t u; } u;
 | 
			
		||||
  u.f = val;
 | 
			
		||||
  dds_stream_write_uint64 (os, u.u);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dds_stream_write_string (dds_stream_t * os, const char * val)
 | 
			
		||||
| 
						 | 
				
			
			@ -457,7 +461,7 @@ void dds_stream_write_buffer (dds_stream_t * os, uint32_t len, uint8_t * buffer)
 | 
			
		|||
  DDS_OS_PUT_BYTES (os, buffer, len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void dds_stream_write 
 | 
			
		||||
static void dds_stream_write
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * os,
 | 
			
		||||
  const char * data,
 | 
			
		||||
| 
						 | 
				
			
			@ -633,7 +637,7 @@ static void dds_stream_write
 | 
			
		|||
                const uint32_t * jsr_ops = ops + DDS_OP_ADR_JSR (*ops) - 3;
 | 
			
		||||
                const uint32_t jmp = DDS_OP_ADR_JMP (*ops);
 | 
			
		||||
                const uint32_t elem_size = ops[1];
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                while (num--)
 | 
			
		||||
                {
 | 
			
		||||
                  dds_stream_write (os, addr, jsr_ops);
 | 
			
		||||
| 
						 | 
				
			
			@ -1225,7 +1229,8 @@ void dds_stream_write_key
 | 
			
		|||
        DDS_OS_PUT8 (os, *((uint64_t*) src), uint64_t);
 | 
			
		||||
        break;
 | 
			
		||||
      case DDS_OP_VAL_STR:
 | 
			
		||||
        src = *(char**) src; /* drop through */
 | 
			
		||||
        src = *(char**) src;
 | 
			
		||||
        /* FALLS THROUGH */
 | 
			
		||||
      case DDS_OP_VAL_BST:
 | 
			
		||||
        dds_stream_write_string (os, src);
 | 
			
		||||
        break;
 | 
			
		||||
| 
						 | 
				
			
			@ -1243,14 +1248,14 @@ void dds_stream_write_key
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* 
 | 
			
		||||
/*
 | 
			
		||||
  dds_stream_get_keyhash: Extract key values from a stream and generate
 | 
			
		||||
  keyhash used for instance identification. Non key fields are skipped.
 | 
			
		||||
  Key hash data is big endian CDR encoded with no padding. Returns length
 | 
			
		||||
  of key hash. Input stream may contain full sample of just key data.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
static uint32_t dds_stream_get_keyhash 
 | 
			
		||||
static uint32_t dds_stream_get_keyhash
 | 
			
		||||
(
 | 
			
		||||
  dds_stream_t * is,
 | 
			
		||||
  char * dst,
 | 
			
		||||
| 
						 | 
				
			
			@ -1308,7 +1313,7 @@ static uint32_t dds_stream_get_keyhash
 | 
			
		|||
        {
 | 
			
		||||
          case DDS_OP_VAL_1BY:
 | 
			
		||||
          {
 | 
			
		||||
            *dst++ = DDS_IS_GET1 (is);
 | 
			
		||||
            *dst++ = (char) DDS_IS_GET1 (is);
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
          case DDS_OP_VAL_2BY:
 | 
			
		||||
| 
						 | 
				
			
			@ -1523,7 +1528,7 @@ static uint32_t dds_stream_get_keyhash
 | 
			
		|||
                if ((jeq_op[1] == disc) || (has_default && (num == 0)))
 | 
			
		||||
                {
 | 
			
		||||
                  subtype = DDS_JEQ_TYPE (jeq_op[0]);
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
                  switch (subtype)
 | 
			
		||||
                  {
 | 
			
		||||
                    case DDS_OP_VAL_1BY:
 | 
			
		||||
| 
						 | 
				
			
			@ -1579,7 +1584,7 @@ static uint32_t dds_stream_get_keyhash
 | 
			
		|||
#ifndef NDEBUG
 | 
			
		||||
static bool keyhash_is_reset(const dds_key_hash_t *kh)
 | 
			
		||||
{
 | 
			
		||||
  static const char nullhash[sizeof(kh->m_hash)];
 | 
			
		||||
  static const char nullhash[sizeof(kh->m_hash)] = { 0 };
 | 
			
		||||
  return kh->m_flags == 0 && memcmp(kh->m_hash, nullhash, sizeof(nullhash)) == 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,8 +25,8 @@ dds_subscriber_instance_hdl(
 | 
			
		|||
        dds_entity *e,
 | 
			
		||||
        dds_instance_handle_t *i)
 | 
			
		||||
{
 | 
			
		||||
    assert(e);
 | 
			
		||||
    assert(i);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    (void)i;
 | 
			
		||||
    /* TODO: Get/generate proper handle. */
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Generating subscriber instance handle is not supported");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -67,6 +67,7 @@ dds_subscriber_qos_set(
 | 
			
		|||
        bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = dds__subscriber_qos_validate(qos, enabled);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
        if (enabled) {
 | 
			
		||||
            /* TODO: CHAM-95: DDSI does not support changing QoS policies. */
 | 
			
		||||
| 
						 | 
				
			
			@ -210,6 +211,7 @@ dds_subscriber_begin_coherent(
 | 
			
		|||
        _In_ dds_entity_t e)
 | 
			
		||||
{
 | 
			
		||||
    /* TODO: CHAM-124 Currently unsupported. */
 | 
			
		||||
    (void)e;
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not currently being supported");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -218,6 +220,7 @@ dds_subscriber_end_coherent(
 | 
			
		|||
        _In_ dds_entity_t e)
 | 
			
		||||
{
 | 
			
		||||
    /* TODO: CHAM-124 Currently unsupported. */
 | 
			
		||||
    (void)e;
 | 
			
		||||
    return DDS_ERRNO(DDS_RETCODE_UNSUPPORTED, "Using coherency to get a coherent data set is not currently being supported");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ dds_time_t dds_time (void)
 | 
			
		|||
 
 | 
			
		||||
void dds_sleepfor (dds_duration_t n)
 | 
			
		||||
{
 | 
			
		||||
  os_time interval = { (os_timeSec) (n / DDS_NSECS_IN_SEC), (uint32_t) (n % DDS_NSECS_IN_SEC) };
 | 
			
		||||
  os_time interval = { (os_timeSec) (n / DDS_NSECS_IN_SEC), (int32_t) (n % DDS_NSECS_IN_SEC) };
 | 
			
		||||
  os_nanoSleep (interval);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -297,6 +297,7 @@ dds_topic_qos_set(
 | 
			
		|||
        bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t ret = dds_topic_qos_validate(qos, enabled);
 | 
			
		||||
    (void)e;
 | 
			
		||||
    if (ret == DDS_RETCODE_OK) {
 | 
			
		||||
        if (enabled) {
 | 
			
		||||
            /* TODO: CHAM-95: DDSI does not support changing QoS policies. */
 | 
			
		||||
| 
						 | 
				
			
			@ -426,9 +427,9 @@ dds_create_topic(
 | 
			
		|||
        st->id = next_topicid++;
 | 
			
		||||
 | 
			
		||||
#ifdef VXWORKS_RTP
 | 
			
		||||
        st->hash = (st->id * UINT64_C (12844332200329132887UL)) >> 32;
 | 
			
		||||
        st->hash = (uint32_t)((st->id * UINT64_C (12844332200329132887UL)) >> 32);
 | 
			
		||||
#else
 | 
			
		||||
        st->hash = (st->id * UINT64_C (12844332200329132887)) >> 32;
 | 
			
		||||
        st->hash = (uint32_t)((st->id * UINT64_C (12844332200329132887)) >> 32);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        /* Check if topic cannot be optimised (memcpy marshal) */
 | 
			
		||||
| 
						 | 
				
			
			@ -518,6 +519,9 @@ dds_topic_mod_filter(
 | 
			
		|||
            *ctx = t->m_stopic->filter_ctx;
 | 
			
		||||
        }
 | 
			
		||||
        dds_topic_unlock(t);
 | 
			
		||||
    } else {
 | 
			
		||||
        *filter = 0;
 | 
			
		||||
        *ctx = NULL;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -541,7 +545,7 @@ dds_topic_get_filter(
 | 
			
		|||
    void *ctx;
 | 
			
		||||
    dds_topic_mod_filter (topic, &filter, &ctx, false);
 | 
			
		||||
    return
 | 
			
		||||
      (filter == dds_topic_chaining_filter) ? (dds_topic_filter_fn)ctx : NULL;
 | 
			
		||||
      (filter == dds_topic_chaining_filter) ? (dds_topic_filter_fn)ctx : 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			@ -560,7 +564,7 @@ dds_topic_get_filter_with_ctx(
 | 
			
		|||
  dds_topic_intern_filter_fn filter;
 | 
			
		||||
  void *ctx;
 | 
			
		||||
  dds_topic_mod_filter (topic, &filter, &ctx, false);
 | 
			
		||||
  return (filter == dds_topic_chaining_filter) ? NULL : filter;
 | 
			
		||||
  return (filter == dds_topic_chaining_filter) ? 0 : filter;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_Pre_satisfies_((topic & DDS_ENTITY_KIND_MASK) == DDS_KIND_TOPIC)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -125,7 +125,7 @@ dds_waitset_wait_impl(
 | 
			
		|||
                    to.tv_nsec = DDS_NSECS_IN_SEC - 1;
 | 
			
		||||
                } else {
 | 
			
		||||
                    to.tv_sec = (os_timeSec) (dt / DDS_NSECS_IN_SEC);
 | 
			
		||||
                    to.tv_nsec = (uint32_t) (dt % DDS_NSECS_IN_SEC);
 | 
			
		||||
                    to.tv_nsec = (int32_t) (dt % DDS_NSECS_IN_SEC);
 | 
			
		||||
                }
 | 
			
		||||
                (void)os_condTimedWait(&ws->m_entity.m_cond, &ws->m_entity.m_mutex, &to);
 | 
			
		||||
                tnow = dds_time();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ struct whc_intvnode {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
struct whc_idxnode {
 | 
			
		||||
  int64_t iid;
 | 
			
		||||
  uint64_t iid;
 | 
			
		||||
  seqno_t prune_seq;
 | 
			
		||||
  struct tkmap_instance *tk;
 | 
			
		||||
  unsigned headidx;
 | 
			
		||||
| 
						 | 
				
			
			@ -1017,11 +1017,11 @@ static unsigned whc_remove_acked_messages (struct whc *whc_generic, seqno_t max_
 | 
			
		|||
 | 
			
		||||
  if (config.enabled_logcats & LC_WHC)
 | 
			
		||||
  {
 | 
			
		||||
    struct whc_state whcst;
 | 
			
		||||
    get_state_locked(whc, &whcst);
 | 
			
		||||
    struct whc_state tmp;
 | 
			
		||||
    get_state_locked(whc, &tmp);
 | 
			
		||||
    TRACE_WHC(("whc_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq));
 | 
			
		||||
    TRACE_WHC(("  whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n",
 | 
			
		||||
               whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth));
 | 
			
		||||
               tmp.min_seq, tmp.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  check_whc (whc);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -192,6 +192,7 @@ get_bandwidth_limit(
 | 
			
		|||
  struct config_channel_listelem *channel = find_channel (transport_priority);
 | 
			
		||||
  return channel->data_bandwidth_limit;
 | 
			
		||||
#else
 | 
			
		||||
  (void)transport_priority;
 | 
			
		||||
  return 0;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -360,25 +361,25 @@ static struct whc *make_whc(const dds_qos_t *qos)
 | 
			
		|||
   an index at all (e.g., volatile KEEP_ALL) */
 | 
			
		||||
  if (config.startup_mode_full) {
 | 
			
		||||
    startup_mode = gv.startup_mode &&
 | 
			
		||||
      (qos->durability.kind >= DDS_DURABILITY_TRANSIENT ||
 | 
			
		||||
       (qos->durability.kind == DDS_DURABILITY_VOLATILE &&
 | 
			
		||||
        qos->reliability.kind != DDS_RELIABILITY_BEST_EFFORT));
 | 
			
		||||
      (qos->durability.kind >= NN_TRANSIENT_DURABILITY_QOS ||
 | 
			
		||||
       (qos->durability.kind == NN_VOLATILE_DURABILITY_QOS &&
 | 
			
		||||
        qos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS));
 | 
			
		||||
  } else {
 | 
			
		||||
    startup_mode = gv.startup_mode &&
 | 
			
		||||
      (qos->durability.kind == DDS_DURABILITY_VOLATILE &&
 | 
			
		||||
       qos->reliability.kind != DDS_RELIABILITY_BEST_EFFORT);
 | 
			
		||||
      (qos->durability.kind == NN_VOLATILE_DURABILITY_QOS &&
 | 
			
		||||
       qos->reliability.kind != NN_BEST_EFFORT_RELIABILITY_QOS);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Construct WHC -- if aggressive_keep_last1 is set, the WHC will
 | 
			
		||||
    drop all samples for which a later update is available.  This
 | 
			
		||||
    forces it to maintain a tlidx.  */
 | 
			
		||||
  handle_as_transient_local = (qos->durability.kind == DDS_DURABILITY_TRANSIENT_LOCAL);
 | 
			
		||||
  if (!config.aggressive_keep_last_whc || qos->history.kind == DDS_HISTORY_KEEP_ALL)
 | 
			
		||||
  handle_as_transient_local = (qos->durability.kind == NN_TRANSIENT_LOCAL_DURABILITY_QOS);
 | 
			
		||||
  if (!config.aggressive_keep_last_whc || qos->history.kind == NN_KEEP_ALL_HISTORY_QOS)
 | 
			
		||||
    hdepth = 0;
 | 
			
		||||
  else
 | 
			
		||||
    hdepth = (unsigned)qos->history.depth;
 | 
			
		||||
  if (handle_as_transient_local) {
 | 
			
		||||
    if (qos->durability_service.history.kind == DDS_HISTORY_KEEP_ALL)
 | 
			
		||||
    if (qos->durability_service.history.kind == NN_KEEP_ALL_HISTORY_QOS)
 | 
			
		||||
      tldepth = 0;
 | 
			
		||||
    else
 | 
			
		||||
      tldepth = (unsigned)qos->durability_service.history.depth;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,7 +104,7 @@ qos_init(void)
 | 
			
		|||
    g_pol_liveliness.lease_duration.sec = 40000;
 | 
			
		||||
    g_pol_liveliness.lease_duration.nanosec = 44000;
 | 
			
		||||
 | 
			
		||||
    g_pol_time_based_filter.minimum_separation.sec = 50000;
 | 
			
		||||
    g_pol_time_based_filter.minimum_separation.sec = 12000;
 | 
			
		||||
    g_pol_time_based_filter.minimum_separation.nanosec = 55000;
 | 
			
		||||
 | 
			
		||||
    g_pol_partition.name._buffer = (char**)c_partitions;
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +127,7 @@ qos_init(void)
 | 
			
		|||
 | 
			
		||||
    g_pol_durability_service.history_depth = 1;
 | 
			
		||||
    g_pol_durability_service.history_kind = DDS_KEEP_LAST_HISTORY_QOS;
 | 
			
		||||
    g_pol_durability_service.max_samples = 2;
 | 
			
		||||
    g_pol_durability_service.max_samples = 12;
 | 
			
		||||
    g_pol_durability_service.max_instances = 3;
 | 
			
		||||
    g_pol_durability_service.max_samples_per_instance = 4;
 | 
			
		||||
    g_pol_durability_service.service_cleanup_delay.sec = 90000;
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +170,7 @@ teardown(void)
 | 
			
		|||
int64_t from_ddsi_duration (DDS_Duration_t x)
 | 
			
		||||
{
 | 
			
		||||
  int64_t t;
 | 
			
		||||
  t = x.sec * 10^9 + x.nanosec;
 | 
			
		||||
  t = (int64_t)x.sec * T_SECOND + x.nanosec;
 | 
			
		||||
  return t;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -627,12 +627,13 @@ Test(ddsc_builtin_topics, datareader_qos, .init = setup, .fini = teardown)
 | 
			
		|||
  dds_qset_destination_order(g_qos, (dds_destination_order_kind_t)g_pol_destination_order.kind);
 | 
			
		||||
  dds_qset_userdata(g_qos, g_pol_userdata.value._buffer, g_pol_userdata.value._length);
 | 
			
		||||
  dds_qset_time_based_filter(g_qos, from_ddsi_duration(g_pol_time_based_filter.minimum_separation));
 | 
			
		||||
  dds_qset_presentation(g_qos, g_pol_presentation.access_scope, g_pol_presentation.coherent_access, g_pol_presentation.ordered_access);
 | 
			
		||||
  dds_qset_presentation(g_qos, (dds_presentation_access_scope_kind_t)g_pol_presentation.access_scope, g_pol_presentation.coherent_access, g_pol_presentation.ordered_access);
 | 
			
		||||
  dds_qset_partition(g_qos, g_pol_partition.name._length, c_partitions);
 | 
			
		||||
  dds_qset_topicdata(g_qos, g_pol_topicdata.value._buffer, g_pol_topicdata.value._length);
 | 
			
		||||
  dds_qset_groupdata(g_qos, g_pol_groupdata.value._buffer, g_pol_groupdata.value._length);
 | 
			
		||||
 | 
			
		||||
  rdr = dds_create_reader(g_subscriber, g_topic, g_qos, NULL);
 | 
			
		||||
  cr_assert_gt(rdr, 0, "Failed to create a data reader.");
 | 
			
		||||
 | 
			
		||||
  subscription_samples[0] = DDS_SubscriptionBuiltinTopicData__alloc();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -693,7 +694,7 @@ Test(ddsc_builtin_topics, datawriter_qos, .init = setup, .fini = teardown)
 | 
			
		|||
  void * publication_samples[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  dds_qset_durability(g_qos, g_pol_durability.kind);
 | 
			
		||||
  dds_qset_durability(g_qos, (dds_durability_kind_t)g_pol_durability.kind);
 | 
			
		||||
  dds_qset_deadline(g_qos, from_ddsi_duration(g_pol_deadline.period));
 | 
			
		||||
  dds_qset_latency_budget(g_qos, from_ddsi_duration(g_pol_latency_budget.duration));
 | 
			
		||||
  dds_qset_liveliness(g_qos, (dds_liveliness_kind_t)g_pol_liveliness.kind, from_ddsi_duration(g_pol_liveliness.lease_duration));
 | 
			
		||||
| 
						 | 
				
			
			@ -703,11 +704,12 @@ Test(ddsc_builtin_topics, datawriter_qos, .init = setup, .fini = teardown)
 | 
			
		|||
  dds_qset_userdata(g_qos, g_pol_userdata.value._buffer, g_pol_userdata.value._length);
 | 
			
		||||
  dds_qset_ownership(g_qos, (dds_ownership_kind_t)g_pol_ownership.kind);
 | 
			
		||||
  dds_qset_ownership_strength(g_qos, g_pol_ownership_strength.value);
 | 
			
		||||
  dds_qset_presentation(g_qos, g_pol_presentation.access_scope, g_pol_presentation.coherent_access, g_pol_presentation.ordered_access);
 | 
			
		||||
  dds_qset_presentation(g_qos, (dds_presentation_access_scope_kind_t)g_pol_presentation.access_scope, g_pol_presentation.coherent_access, g_pol_presentation.ordered_access);
 | 
			
		||||
  dds_qset_partition(g_qos, g_pol_partition.name._length, c_partitions);
 | 
			
		||||
  dds_qset_topicdata(g_qos, g_pol_topicdata.value._buffer, g_pol_topicdata.value._length);
 | 
			
		||||
 | 
			
		||||
  wrtr = dds_create_writer(g_publisher, g_topic, g_qos, NULL);
 | 
			
		||||
  cr_assert_gt(wrtr, 0, "Failed to create a data writer.");
 | 
			
		||||
 | 
			
		||||
  publication_samples[0] = DDS_PublicationBuiltinTopicData__alloc();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -771,7 +773,7 @@ Test(ddsc_builtin_topics, topic_qos, .init = setup, .fini = teardown)
 | 
			
		|||
 | 
			
		||||
  void * topic_samples[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
  dds_qset_durability(g_qos, g_pol_durability.kind);
 | 
			
		||||
  dds_qset_durability(g_qos, (dds_durability_kind_t)g_pol_durability.kind);
 | 
			
		||||
  dds_qset_durability_service(g_qos,
 | 
			
		||||
                              from_ddsi_duration(g_pol_durability_service.service_cleanup_delay),
 | 
			
		||||
                              (dds_history_kind_t)g_pol_durability_service.history_kind,
 | 
			
		||||
| 
						 | 
				
			
			@ -794,6 +796,7 @@ Test(ddsc_builtin_topics, topic_qos, .init = setup, .fini = teardown)
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
  tpc = dds_create_topic(g_participant, &Space_Type1_desc, "SpaceType1", g_qos, NULL);
 | 
			
		||||
  cr_assert_gt(tpc, 0, "Failed to create a topic.");
 | 
			
		||||
 | 
			
		||||
  topic_samples[0] = DDS_PublicationBuiltinTopicData__alloc();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
disposing_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_qos_t *qos = dds_qos_create ();
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,8 +15,10 @@
 | 
			
		|||
 | 
			
		||||
/* We are deliberately testing some bad arguments that SAL will complain about.
 | 
			
		||||
 * So, silence SAL regarding these issues. */
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 6387 28020)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Add --verbose command line argument to get the cr_log_info traces (if there are any). */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -320,13 +322,13 @@ Test(ddsc_entity, get_entities, .init = create_entity, .fini = delete_entity)
 | 
			
		|||
    /* Get Children, of which there are currently none. */
 | 
			
		||||
    status = dds_get_children (entity, NULL, 0);
 | 
			
		||||
    if (status > 0) {
 | 
			
		||||
        cr_assert("dds_get_children(entity, NULL, 0) un-expectantly found children");
 | 
			
		||||
        cr_assert(false, "dds_get_children(entity, NULL, 0) un-expectantly found children");
 | 
			
		||||
    } else {
 | 
			
		||||
        cr_assert_eq(status, 0, "dds_get_children(entity, NULL, 0) failed");
 | 
			
		||||
    }
 | 
			
		||||
    status = dds_get_children (entity, &child, 1);
 | 
			
		||||
    if (status > 0) {
 | 
			
		||||
        cr_assert("dds_get_children(entity, child, 1) un-expectantly returned children");
 | 
			
		||||
        cr_assert(false, "dds_get_children(entity, child, 1) un-expectantly returned children");
 | 
			
		||||
    } else {
 | 
			
		||||
        cr_assert_eq(status, 0, "dds_get_children(entity, child, 1) failed");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -362,4 +364,6 @@ Test(ddsc_entity, delete, .init = create_entity)
 | 
			
		|||
    entity = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,6 +40,7 @@ static dds_entity_t g_querycond   = 0;
 | 
			
		|||
static bool
 | 
			
		||||
accept_all(const void * sample)
 | 
			
		||||
{
 | 
			
		||||
    (void)sample;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -840,7 +841,7 @@ Test(ddsc_entity_explicit_subscriber, invalid_topic)
 | 
			
		|||
Test(ddsc_entity_get_children, implicit_publisher)
 | 
			
		||||
{
 | 
			
		||||
    dds_entity_t participant;
 | 
			
		||||
    dds_entity_t publisher;
 | 
			
		||||
    dds_entity_t publisher = 0;
 | 
			
		||||
    dds_entity_t writer;
 | 
			
		||||
    dds_entity_t topic;
 | 
			
		||||
    dds_entity_t child[2], child2[2];
 | 
			
		||||
| 
						 | 
				
			
			@ -885,7 +886,7 @@ Test(ddsc_entity_get_children, implicit_publisher)
 | 
			
		|||
Test(ddsc_entity_get_children, implicit_subscriber)
 | 
			
		||||
{
 | 
			
		||||
    dds_entity_t participant;
 | 
			
		||||
    dds_entity_t subscriber;
 | 
			
		||||
    dds_entity_t subscriber = 0;
 | 
			
		||||
    dds_entity_t reader;
 | 
			
		||||
    dds_entity_t topic;
 | 
			
		||||
    dds_entity_t child[2], child2[2];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,7 +130,7 @@ Test(ddsc_entity_status, publication_matched, .init=init_entity_status, .fini=fi
 | 
			
		|||
 | 
			
		||||
    /* Wait for publication matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_publication_matched_status(wri, &publication_matched);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(publication_matched.current_count,        1);
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +149,7 @@ Test(ddsc_entity_status, publication_matched, .init=init_entity_status, .fini=fi
 | 
			
		|||
 | 
			
		||||
    /* Wait for publication matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_publication_matched_status(wri, &publication_matched);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(publication_matched.current_count,         0);
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fini=f
 | 
			
		|||
 | 
			
		||||
    /* Wait for subscription  matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_subscription_matched_status(rea, &subscription_matched);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(subscription_matched.current_count,        1);
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +186,7 @@ Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fini=f
 | 
			
		|||
 | 
			
		||||
    /* Wait for subscription  matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_subscription_matched_status(rea, &subscription_matched);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(subscription_matched.current_count,         0);
 | 
			
		||||
| 
						 | 
				
			
			@ -199,8 +199,10 @@ Test(ddsc_entity_status, subscription_matched, .init=init_entity_status, .fini=f
 | 
			
		|||
Test(ddsc_entity, incompatible_qos, .init=init_entity_status, .fini=fini_entity_status)
 | 
			
		||||
{
 | 
			
		||||
    dds_entity_t reader2;
 | 
			
		||||
    dds_requested_incompatible_qos_status_t req_incompatible_qos = {0};
 | 
			
		||||
    dds_offered_incompatible_qos_status_t off_incompatible_qos = {0};
 | 
			
		||||
    dds_requested_incompatible_qos_status_t req_incompatible_qos;
 | 
			
		||||
    dds_offered_incompatible_qos_status_t off_incompatible_qos;
 | 
			
		||||
    memset (&req_incompatible_qos, 0, sizeof (req_incompatible_qos));
 | 
			
		||||
    memset (&off_incompatible_qos, 0, sizeof (off_incompatible_qos));
 | 
			
		||||
    dds_qset_durability (qos, DDS_DURABILITY_PERSISTENT);
 | 
			
		||||
 | 
			
		||||
    /* Create a reader with persistent durability */
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +238,7 @@ Test(ddsc_entity, incompatible_qos, .init=init_entity_status, .fini=fini_entity_
 | 
			
		|||
 | 
			
		||||
    /* Wait for offered incompatible QoS status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_offered_incompatible_qos_status (wri, &off_incompatible_qos);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(off_incompatible_qos.total_count,           1);
 | 
			
		||||
| 
						 | 
				
			
			@ -267,7 +269,7 @@ Test(ddsc_entity, liveliness_changed, .init=init_entity_status, .fini=fini_entit
 | 
			
		|||
 | 
			
		||||
    /* wait for LIVELINESS_CHANGED status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_get_liveliness_changed_status (rea, &liveliness_changed);
 | 
			
		||||
    cr_assert_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -288,7 +290,7 @@ Test(ddsc_entity, liveliness_changed, .init=init_entity_status, .fini=fini_entit
 | 
			
		|||
 | 
			
		||||
    /* wait for LIVELINESS_CHANGED when a writer is deleted */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_get_liveliness_changed_status (rea, &liveliness_changed);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -301,10 +303,12 @@ Test(ddsc_entity, liveliness_changed, .init=init_entity_status, .fini=fini_entit
 | 
			
		|||
 | 
			
		||||
Test(ddsc_entity, sample_rejected, .init=init_entity_status, .fini=fini_entity_status)
 | 
			
		||||
{
 | 
			
		||||
    dds_sample_rejected_status_t sample_rejected = {0};
 | 
			
		||||
    dds_sample_rejected_status_t sample_rejected;
 | 
			
		||||
 | 
			
		||||
    /* Topic instance */
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample_rejected, 0, sizeof (sample_rejected));
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    ret = dds_set_enabled_status(wri, DDS_PUBLICATION_MATCHED_STATUS);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -313,9 +317,9 @@ Test(ddsc_entity, sample_rejected, .init=init_entity_status, .fini=fini_entity_s
 | 
			
		|||
 | 
			
		||||
    /* Wait for subscription matched and publication matched */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_set_enabled_status(rea, DDS_SAMPLE_REJECTED_STATUS);
 | 
			
		||||
    cr_assert_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -329,7 +333,7 @@ Test(ddsc_entity, sample_rejected, .init=init_entity_status, .fini=fini_entity_s
 | 
			
		|||
 | 
			
		||||
    /* wait for sample rejected status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_sample_rejected_status (rea, &sample_rejected);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(sample_rejected.total_count,        4);
 | 
			
		||||
| 
						 | 
				
			
			@ -360,7 +364,7 @@ Test(ddsc_entity, inconsistent_topic)
 | 
			
		|||
 | 
			
		||||
    /* Wait for pub inconsistent topic status callback */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_inconsistent_topic_status (top, &topic_status);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_gt(topic_status.total_count, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -387,10 +391,12 @@ Test(ddsc_entity, inconsistent_topic)
 | 
			
		|||
Test(ddsc_entity, sample_lost, .init=init_entity_status, .fini=fini_entity_status)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    dds_sample_lost_status_t sample_lost = {0};
 | 
			
		||||
    dds_sample_lost_status_t sample_lost;
 | 
			
		||||
    dds_time_t time1;
 | 
			
		||||
    /* Topic instance */
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample_lost, 0, sizeof (sample_lost));
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    ret = dds_set_enabled_status(wri, DDS_PUBLICATION_MATCHED_STATUS);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -399,9 +405,9 @@ Test(ddsc_entity, sample_lost, .init=init_entity_status, .fini=fini_entity_statu
 | 
			
		|||
 | 
			
		||||
    /* Wait for subscription matched and publication matched */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_set_enabled_status(rea, DDS_SAMPLE_LOST_STATUS);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -418,7 +424,7 @@ Test(ddsc_entity, sample_lost, .init=init_entity_status, .fini=fini_entity_statu
 | 
			
		|||
 | 
			
		||||
    /* wait for sample lost status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_get_sample_lost_status (rea, &sample_lost);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
    cr_assert_eq(sample_lost.total_count,          1);
 | 
			
		||||
| 
						 | 
				
			
			@ -432,7 +438,8 @@ Test(ddsc_entity, sample_lost, .init=init_entity_status, .fini=fini_entity_statu
 | 
			
		|||
 | 
			
		||||
Test(ddsc_entity, data_available, .init=init_entity_status, .fini=fini_entity_status)
 | 
			
		||||
{
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    ret = dds_set_enabled_status(wri, DDS_PUBLICATION_MATCHED_STATUS);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -441,9 +448,9 @@ Test(ddsc_entity, data_available, .init=init_entity_status, .fini=fini_entity_st
 | 
			
		|||
 | 
			
		||||
    /* Wait for subscription and publication matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults2, wsresultsize2, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    /* Write the sample */
 | 
			
		||||
    ret = dds_write (wri, &sample);
 | 
			
		||||
| 
						 | 
				
			
			@ -455,7 +462,7 @@ Test(ddsc_entity, data_available, .init=init_entity_status, .fini=fini_entity_st
 | 
			
		|||
    cr_assert_eq(sta, DDS_SUBSCRIPTION_MATCHED_STATUS);
 | 
			
		||||
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults2, wsresultsize2, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_get_status_changes (rea, &sta);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			@ -477,10 +484,11 @@ Test(ddsc_entity, all_data_available, .init=init_entity_status, .fini=fini_entit
 | 
			
		|||
    dds_sample_info_t info;
 | 
			
		||||
 | 
			
		||||
    /* Topic instance */
 | 
			
		||||
    RoundTripModule_DataType p_sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType p_sample;
 | 
			
		||||
    void * s_samples[1];
 | 
			
		||||
    RoundTripModule_DataType s_sample;
 | 
			
		||||
 | 
			
		||||
    memset (&p_sample, 0, sizeof (p_sample));
 | 
			
		||||
    memset (&s_sample, 0, sizeof (s_sample));
 | 
			
		||||
    s_samples[0] = &s_sample;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -500,13 +508,13 @@ Test(ddsc_entity, all_data_available, .init=init_entity_status, .fini=fini_entit
 | 
			
		|||
 | 
			
		||||
    /* Wait for publication matched status */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetwr, wsresults, wsresultsize, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    /* Wait for subscription matched status on both readers */
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd, wsresults2, wsresultsize2, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
    ret = dds_waitset_wait(waitSetrd2, wsresults2, wsresultsize2, waitTimeout);
 | 
			
		||||
    cr_assert_eq(ret, wsresultsize);
 | 
			
		||||
    cr_assert_eq(ret, (dds_return_t)wsresultsize);
 | 
			
		||||
 | 
			
		||||
    ret = dds_write (wri, &p_sample);
 | 
			
		||||
    cr_assert_dds_return_t_eq(ret, DDS_RETCODE_OK);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,17 +83,17 @@ static dds_entity_t    cb_writer     = 0;
 | 
			
		|||
static dds_entity_t    cb_reader     = 0;
 | 
			
		||||
static dds_entity_t    cb_subscriber = 0;
 | 
			
		||||
 | 
			
		||||
static dds_inconsistent_topic_status_t          cb_inconsistent_topic_status        = { 0 };
 | 
			
		||||
static dds_liveliness_lost_status_t             cb_liveliness_lost_status           = { 0 };
 | 
			
		||||
static dds_offered_deadline_missed_status_t     cb_offered_deadline_missed_status   = { 0 };
 | 
			
		||||
static dds_offered_incompatible_qos_status_t    cb_offered_incompatible_qos_status  = { 0 };
 | 
			
		||||
static dds_sample_lost_status_t                 cb_sample_lost_status               = { 0 };
 | 
			
		||||
static dds_sample_rejected_status_t             cb_sample_rejected_status           = { 0 };
 | 
			
		||||
static dds_liveliness_changed_status_t          cb_liveliness_changed_status        = { 0 };
 | 
			
		||||
static dds_requested_deadline_missed_status_t   cb_requested_deadline_missed_status = { 0 };
 | 
			
		||||
static dds_requested_incompatible_qos_status_t  cb_requested_incompatible_qos_status= { 0 };
 | 
			
		||||
static dds_publication_matched_status_t         cb_publication_matched_status       = { 0 };
 | 
			
		||||
static dds_subscription_matched_status_t        cb_subscription_matched_status      = { 0 };
 | 
			
		||||
static dds_inconsistent_topic_status_t          cb_inconsistent_topic_status;
 | 
			
		||||
static dds_liveliness_lost_status_t             cb_liveliness_lost_status;
 | 
			
		||||
static dds_offered_deadline_missed_status_t     cb_offered_deadline_missed_status;
 | 
			
		||||
static dds_offered_incompatible_qos_status_t    cb_offered_incompatible_qos_status;
 | 
			
		||||
static dds_sample_lost_status_t                 cb_sample_lost_status;
 | 
			
		||||
static dds_sample_rejected_status_t             cb_sample_rejected_status;
 | 
			
		||||
static dds_liveliness_changed_status_t          cb_liveliness_changed_status;
 | 
			
		||||
static dds_requested_deadline_missed_status_t   cb_requested_deadline_missed_status;
 | 
			
		||||
static dds_requested_incompatible_qos_status_t  cb_requested_incompatible_qos_status;
 | 
			
		||||
static dds_publication_matched_status_t         cb_publication_matched_status;
 | 
			
		||||
static dds_subscription_matched_status_t        cb_subscription_matched_status;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
| 
						 | 
				
			
			@ -101,6 +101,7 @@ inconsistent_topic_cb(
 | 
			
		|||
        dds_entity_t topic,
 | 
			
		||||
        const dds_inconsistent_topic_status_t status, void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_topic = topic;
 | 
			
		||||
    cb_inconsistent_topic_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -115,6 +116,7 @@ liveliness_lost_cb(
 | 
			
		|||
        const dds_liveliness_lost_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_writer = writer;
 | 
			
		||||
    cb_liveliness_lost_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -129,6 +131,7 @@ offered_deadline_missed_cb(
 | 
			
		|||
        const dds_offered_deadline_missed_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_writer = writer;
 | 
			
		||||
    cb_offered_deadline_missed_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -143,6 +146,7 @@ offered_incompatible_qos_cb(
 | 
			
		|||
        const dds_offered_incompatible_qos_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_writer = writer;
 | 
			
		||||
    cb_offered_incompatible_qos_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -156,6 +160,7 @@ data_on_readers_cb(
 | 
			
		|||
        dds_entity_t subscriber,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_subscriber = subscriber;
 | 
			
		||||
    cb_called |= DDS_DATA_ON_READERS_STATUS;
 | 
			
		||||
| 
						 | 
				
			
			@ -169,6 +174,7 @@ sample_lost_cb(
 | 
			
		|||
        const dds_sample_lost_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_sample_lost_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -182,6 +188,7 @@ data_available_cb(
 | 
			
		|||
        dds_entity_t reader,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_called |= DDS_DATA_AVAILABLE_STATUS;
 | 
			
		||||
| 
						 | 
				
			
			@ -195,6 +202,7 @@ sample_rejected_cb(
 | 
			
		|||
        const dds_sample_rejected_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_sample_rejected_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -209,6 +217,7 @@ liveliness_changed_cb(
 | 
			
		|||
        const dds_liveliness_changed_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_liveliness_changed_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -223,6 +232,7 @@ requested_deadline_missed_cb(
 | 
			
		|||
        const dds_requested_deadline_missed_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_requested_deadline_missed_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -237,6 +247,7 @@ requested_incompatible_qos_cb(
 | 
			
		|||
        const dds_requested_incompatible_qos_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_requested_incompatible_qos_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -251,6 +262,7 @@ publication_matched_cb(
 | 
			
		|||
        const dds_publication_matched_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_writer = writer;
 | 
			
		||||
    cb_publication_matched_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -265,6 +277,7 @@ subscription_matched_cb(
 | 
			
		|||
        const dds_subscription_matched_status_t status,
 | 
			
		||||
        void* arg)
 | 
			
		||||
{
 | 
			
		||||
    (void)arg;
 | 
			
		||||
    os_mutexLock(&g_mutex);
 | 
			
		||||
    cb_reader = reader;
 | 
			
		||||
    cb_subscription_matched_status = status;
 | 
			
		||||
| 
						 | 
				
			
			@ -584,12 +597,13 @@ Test(ddsc_listener, getters_setters)
 | 
			
		|||
 ****************************************************************************/
 | 
			
		||||
Test(ddsc_listener, propagation, .init=init_triggering_base, .fini=fini_triggering_base)
 | 
			
		||||
{
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    dds_listener_t *listener_par = NULL;
 | 
			
		||||
    dds_listener_t *listener_pub = NULL;
 | 
			
		||||
    dds_listener_t *listener_sub = NULL;
 | 
			
		||||
    uint32_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    /* Let participant be interested in data. */
 | 
			
		||||
    listener_par = dds_listener_create(NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -807,7 +821,8 @@ Test(ddsc_listener, data_available, .init=init_triggering_test, .fini=fini_trigg
 | 
			
		|||
    dds_return_t ret;
 | 
			
		||||
    uint32_t triggered;
 | 
			
		||||
    uint32_t status;
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    /* We are interested in data available notifications. */
 | 
			
		||||
    dds_lset_data_available(g_listener, data_available_cb);
 | 
			
		||||
| 
						 | 
				
			
			@ -837,7 +852,8 @@ Test(ddsc_listener, data_on_readers, .init=init_triggering_test, .fini=fini_trig
 | 
			
		|||
    dds_return_t ret;
 | 
			
		||||
    uint32_t triggered;
 | 
			
		||||
    uint32_t status;
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    /* We are interested in data available notifications. */
 | 
			
		||||
    dds_lset_data_on_readers(g_listener, data_on_readers_cb);
 | 
			
		||||
| 
						 | 
				
			
			@ -875,7 +891,8 @@ Test(ddsc_listener, sample_lost, .init=init_triggering_test, .fini=fini_triggeri
 | 
			
		|||
    uint32_t triggered;
 | 
			
		||||
    dds_time_t the_past;
 | 
			
		||||
    uint32_t status;
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    /* Get a time that should be historic on all platforms.*/
 | 
			
		||||
    the_past = dds_time() - 1000000;
 | 
			
		||||
| 
						 | 
				
			
			@ -911,7 +928,8 @@ Test(ddsc_listener, sample_rejected, .init=init_triggering_test, .fini=fini_trig
 | 
			
		|||
    dds_return_t ret;
 | 
			
		||||
    uint32_t triggered;
 | 
			
		||||
    uint32_t status;
 | 
			
		||||
    RoundTripModule_DataType sample = { 0 };
 | 
			
		||||
    RoundTripModule_DataType sample;
 | 
			
		||||
    memset (&sample, 0, sizeof (sample));
 | 
			
		||||
 | 
			
		||||
    /* We are interested in sample rejected notifications. */
 | 
			
		||||
    dds_lset_sample_rejected(g_listener, sample_rejected_cb);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,14 +15,19 @@
 | 
			
		|||
 | 
			
		||||
/* We are deliberately testing some bad arguments that SAL will complain about.
 | 
			
		||||
 * So, silence SAL regarding these issues. */
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 28020)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define cr_assert_status_eq(s1, s2, ...) cr_assert_eq(dds_err_nr(s1), s2, __VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
/* Dummy callback */
 | 
			
		||||
static void data_available_cb(dds_entity_t reader, void* arg) {}
 | 
			
		||||
static void data_available_cb(dds_entity_t reader, void* arg)
 | 
			
		||||
{
 | 
			
		||||
  (void)reader;
 | 
			
		||||
  (void)arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Test(ddsc_publisher, create)
 | 
			
		||||
| 
						 | 
				
			
			@ -62,8 +67,10 @@ Test(ddsc_publisher, create)
 | 
			
		|||
  dds_delete(publisher);
 | 
			
		||||
 | 
			
		||||
/* Somehow, the compiler thinks the char arrays might not be zero-terminated... */
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 6054)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Use qos with single partition */
 | 
			
		||||
  dds_qset_partition (qos, 1, singlePartitions);
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +90,9 @@ Test(ddsc_publisher, create)
 | 
			
		|||
  cr_assert_gt(publisher, 0, "dds_create_publisher(participant,qos,NULL) where qos with duplicate partitions");
 | 
			
		||||
  dds_delete(publisher);
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Use listener(NULL) */
 | 
			
		||||
  listener = dds_listener_create(NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -265,4 +274,6 @@ Test(ddsc_publisher, coherency)
 | 
			
		|||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,13 +15,12 @@
 | 
			
		|||
#include <criterion/logging.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
#else
 | 
			
		||||
/* We are deliberately testing some bad arguments that SAL will complain about.
 | 
			
		||||
 * So, silence SAL regarding these issues. */
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 6387 28020)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
| 
						 | 
				
			
			@ -243,7 +242,7 @@ qos_fini(void)
 | 
			
		|||
 ****************************************************************************/
 | 
			
		||||
Test(ddsc_qos, userdata, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_userdata p = { 0 };
 | 
			
		||||
    struct pol_userdata p = { NULL, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_userdata(NULL, g_pol_userdata.value, g_pol_userdata.sz);
 | 
			
		||||
| 
						 | 
				
			
			@ -261,7 +260,7 @@ Test(ddsc_qos, userdata, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, topicdata, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_topicdata p = { 0 };
 | 
			
		||||
    struct pol_topicdata p = { NULL, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_topicdata(NULL, g_pol_topicdata.value, g_pol_topicdata.sz);
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +278,7 @@ Test(ddsc_qos, topicdata, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, groupdata, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_groupdata p = { 0 };
 | 
			
		||||
    struct pol_groupdata p = { NULL, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_groupdata(NULL, g_pol_groupdata.value, g_pol_groupdata.sz);
 | 
			
		||||
| 
						 | 
				
			
			@ -297,7 +296,7 @@ Test(ddsc_qos, groupdata, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, durability, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_durability p = { 0 };
 | 
			
		||||
    struct pol_durability p = { DDS_DURABILITY_VOLATILE };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_durability(NULL, g_pol_durability.kind);
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +311,7 @@ Test(ddsc_qos, durability, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, history, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_history p = { 0 };
 | 
			
		||||
    struct pol_history p = { DDS_HISTORY_KEEP_ALL, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_history(NULL, g_pol_history.kind, g_pol_history.depth);
 | 
			
		||||
| 
						 | 
				
			
			@ -328,7 +327,7 @@ Test(ddsc_qos, history, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, resource_limits, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_resource_limits p = { 0 };
 | 
			
		||||
    struct pol_resource_limits p = { 0, 0, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_resource_limits(NULL, g_pol_resource_limits.max_samples, g_pol_resource_limits.max_instances, g_pol_resource_limits.max_samples_per_instance);
 | 
			
		||||
| 
						 | 
				
			
			@ -345,7 +344,7 @@ Test(ddsc_qos, resource_limits, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, presentation, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_presentation p = { 0 };
 | 
			
		||||
    struct pol_presentation p = { DDS_PRESENTATION_INSTANCE, false, false };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_presentation(NULL, g_pol_presentation.access_scope, g_pol_presentation.coherent_access, g_pol_presentation.ordered_access);
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +406,7 @@ Test(ddsc_qos, latency_budget, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, ownership, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_ownership p = { 0 };
 | 
			
		||||
    struct pol_ownership p = { DDS_OWNERSHIP_SHARED };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_ownership(NULL, g_pol_ownership.kind);
 | 
			
		||||
| 
						 | 
				
			
			@ -437,7 +436,7 @@ Test(ddsc_qos, ownership_strength, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, liveliness, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_liveliness p = { 0 };
 | 
			
		||||
    struct pol_liveliness p = { DDS_LIVELINESS_AUTOMATIC, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_liveliness(NULL, g_pol_liveliness.kind, g_pol_liveliness.lease_duration);
 | 
			
		||||
| 
						 | 
				
			
			@ -468,7 +467,7 @@ Test(ddsc_qos, time_base_filter, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, partition, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_partition p = { 0 };
 | 
			
		||||
    struct pol_partition p = { 0, NULL };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_partition(NULL, g_pol_partition.n, c_partitions);
 | 
			
		||||
| 
						 | 
				
			
			@ -490,7 +489,7 @@ Test(ddsc_qos, partition, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, reliability, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_reliability p = { 0 };
 | 
			
		||||
    struct pol_reliability p = { DDS_RELIABILITY_BEST_EFFORT, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_reliability(NULL, g_pol_reliability.kind, g_pol_reliability.max_blocking_time);
 | 
			
		||||
| 
						 | 
				
			
			@ -521,7 +520,7 @@ Test(ddsc_qos, transport_priority, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, destination_order, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_destination_order p = { 0 };
 | 
			
		||||
    struct pol_destination_order p = { DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_destination_order(NULL, g_pol_destination_order.kind);
 | 
			
		||||
| 
						 | 
				
			
			@ -536,7 +535,7 @@ Test(ddsc_qos, destination_order, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, writer_data_lifecycle, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_writer_data_lifecycle p = { 0 };
 | 
			
		||||
    struct pol_writer_data_lifecycle p = { false };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_writer_data_lifecycle(NULL, g_pol_writer_data_lifecycle.autodispose);
 | 
			
		||||
| 
						 | 
				
			
			@ -551,7 +550,7 @@ Test(ddsc_qos, writer_data_lifecycle, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, reader_data_lifecycle, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_reader_data_lifecycle p = { 0 };
 | 
			
		||||
    struct pol_reader_data_lifecycle p = { 0, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_reader_data_lifecycle(NULL, g_pol_reader_data_lifecycle.autopurge_nowriter_samples_delay, g_pol_reader_data_lifecycle.autopurge_disposed_samples_delay);
 | 
			
		||||
| 
						 | 
				
			
			@ -567,7 +566,7 @@ Test(ddsc_qos, reader_data_lifecycle, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
 | 
			
		||||
Test(ddsc_qos, durability_service, .init=qos_init, .fini=qos_fini)
 | 
			
		||||
{
 | 
			
		||||
    struct pol_durability_service p = { 0 };
 | 
			
		||||
    struct pol_durability_service p = { 0, DDS_HISTORY_KEEP_LAST, 0, 0, 0, 0 };
 | 
			
		||||
 | 
			
		||||
    /* NULLs shouldn't crash and be a noops. */
 | 
			
		||||
    dds_qset_durability_service(NULL,
 | 
			
		||||
| 
						 | 
				
			
			@ -615,7 +614,6 @@ Test(ddsc_qos, durability_service, .init=qos_init, .fini=qos_fini)
 | 
			
		|||
    cr_assert_eq(p.max_samples_per_instance, g_pol_durability_service.max_samples_per_instance);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
querycondition_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_qos_t *qos = dds_qos_create ();
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,7 +67,6 @@ static Space_Type1        g_data[MAX_SAMPLES];
 | 
			
		|||
static dds_sample_info_t  g_info[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static dds_instance_handle_t   g_hdl_valid;
 | 
			
		||||
static dds_instance_handle_t   g_hdl_nil = DDS_HANDLE_NIL;
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
filter_mod2(const void * sample)
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +88,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
read_instance_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    char name[100];
 | 
			
		||||
| 
						 | 
				
			
			@ -180,6 +179,7 @@ read_instance_init(void)
 | 
			
		|||
    for(int i = 0; i < ret; i++) {
 | 
			
		||||
        Space_Type1 *s = (Space_Type1*)g_samples[i];
 | 
			
		||||
        PRINT_SAMPLE("INIT: Read      ", (*s));
 | 
			
		||||
        (void)s;
 | 
			
		||||
    }
 | 
			
		||||
    /*  | long_1 | long_2 | long_3 |    sst   | vst |    ist     |
 | 
			
		||||
     *  ----------------------------------------------------------
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
readcondition_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_qos_t *qos = dds_qos_create ();
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
reader_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    char name[100];
 | 
			
		||||
| 
						 | 
				
			
			@ -174,6 +174,7 @@ reader_init(void)
 | 
			
		|||
    for(int i = 0; i < ret; i++) {
 | 
			
		||||
        Space_Type1 *s = (Space_Type1*)g_samples[i];
 | 
			
		||||
        PRINT_SAMPLE("INIT: Read      ", (*s));
 | 
			
		||||
        (void)s;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Re-write the samples that should be not_read&old_view. */
 | 
			
		||||
| 
						 | 
				
			
			@ -2499,7 +2500,7 @@ Test(ddsc_take_mask, take_instance_last_sample)
 | 
			
		|||
    int expected_long_3 = 2;
 | 
			
		||||
#endif
 | 
			
		||||
    dds_return_t expected_cnt = 1;
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    char name[100];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,9 +89,6 @@ static void*              g_samples[MAX_SAMPLES];
 | 
			
		|||
static Space_Type1        g_data[MAX_SAMPLES];
 | 
			
		||||
static dds_sample_info_t  g_info[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static dds_instance_handle_t   g_hdl_valid;
 | 
			
		||||
static dds_instance_handle_t   g_hdl_nil = DDS_HANDLE_NIL;
 | 
			
		||||
 | 
			
		||||
static char*
 | 
			
		||||
create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +125,7 @@ filter_mod2(const void * sample)
 | 
			
		|||
static void
 | 
			
		||||
reader_iterator_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    char name[100];
 | 
			
		||||
| 
						 | 
				
			
			@ -364,9 +361,9 @@ Test(ddsc_read_next, reader, .init=reader_iterator_init, .fini=reader_iterator_f
 | 
			
		|||
        dds_instance_state_t expected_ist    = SAMPLE_IST(expected_long_1);
 | 
			
		||||
 | 
			
		||||
        /* Check data. */
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1 );
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2   );
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_2 *2);
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1);
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2);
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_3);
 | 
			
		||||
 | 
			
		||||
        /* Check states. */
 | 
			
		||||
        cr_assert_eq(g_info[0].valid_data,     true);
 | 
			
		||||
| 
						 | 
				
			
			@ -399,7 +396,7 @@ Theory((dds_entity_t rdr), ddsc_read_next, invalid_readers, .init=reader_iterato
 | 
			
		|||
    dds_return_t ret;
 | 
			
		||||
 | 
			
		||||
    ret = dds_read_next(rdr, g_samples, g_info);
 | 
			
		||||
    cr_assert_eq(dds_err_nr(ret), dds_err_nr(exp), "returned %d != expected %d", dds_err_str(ret), dds_err_nr(exp));
 | 
			
		||||
    cr_assert_eq(dds_err_nr(ret), dds_err_nr(exp), "returned %d != expected %d", dds_err_nr(ret), dds_err_nr(exp));
 | 
			
		||||
}
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -476,9 +473,9 @@ Test(ddsc_read_next_wl, reader, .init=reader_iterator_init, .fini=reader_iterato
 | 
			
		|||
        dds_instance_state_t expected_ist    = SAMPLE_IST(expected_long_1);
 | 
			
		||||
 | 
			
		||||
        /* Check data. */
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_2/3 );
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2   );
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_2 *2);
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1);
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2);
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_3);
 | 
			
		||||
 | 
			
		||||
        /* Check states. */
 | 
			
		||||
        cr_assert_eq(g_info[0].valid_data,     true);
 | 
			
		||||
| 
						 | 
				
			
			@ -590,9 +587,9 @@ Test(ddsc_take_next, reader, .init=reader_iterator_init, .fini=reader_iterator_f
 | 
			
		|||
        dds_instance_state_t expected_ist    = SAMPLE_IST(expected_long_1);
 | 
			
		||||
 | 
			
		||||
        /* Check data. */
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1 );
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2   );
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_2 *2);
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1);
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2);
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_3);
 | 
			
		||||
 | 
			
		||||
        /* Check states. */
 | 
			
		||||
        cr_assert_eq(g_info[0].valid_data,     true);
 | 
			
		||||
| 
						 | 
				
			
			@ -700,9 +697,9 @@ Test(ddsc_take_next_wl, reader, .init=reader_iterator_init, .fini=reader_iterato
 | 
			
		|||
        dds_instance_state_t expected_ist    = SAMPLE_IST(expected_long_1);
 | 
			
		||||
 | 
			
		||||
        /* Check data. */
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_2/3 );
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2   );
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_2 *2);
 | 
			
		||||
        cr_assert_eq(sample->long_1, expected_long_1);
 | 
			
		||||
        cr_assert_eq(sample->long_2, expected_long_2);
 | 
			
		||||
        cr_assert_eq(sample->long_3, expected_long_3);
 | 
			
		||||
 | 
			
		||||
        /* Check states. */
 | 
			
		||||
        cr_assert_eq(g_info[0].valid_data,     true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,6 @@ static dds_time_t   g_present     = 0;
 | 
			
		|||
 | 
			
		||||
static void*             g_samples[MAX_SAMPLES];
 | 
			
		||||
static Space_Type1       g_data[MAX_SAMPLES];
 | 
			
		||||
static dds_sample_info_t g_info[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static char*
 | 
			
		||||
create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +53,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
registering_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_qos_t *qos = dds_qos_create ();
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +162,6 @@ TheoryDataPoints(ddsc_register_instance, invalid_params) = {
 | 
			
		|||
};
 | 
			
		||||
Theory((dds_instance_handle_t *hndl2, void *datap), ddsc_register_instance, invalid_params/*, .init=registering_init, .fini=registering_fini*/)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
 | 
			
		||||
    /* Only test when the combination of parameters is actually invalid.*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,19 +92,27 @@ Test(ddsc_reader, return_loan_bad_params, .init = create_entities, .fini = delet
 | 
			
		|||
        DDS_TO_STRING(DDS_RETCODE_BAD_PARAMETER),
 | 
			
		||||
        dds_err_str(result));
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 6387)
 | 
			
		||||
#endif
 | 
			
		||||
    result = dds_return_loan(reader, buf, 10);
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
    cr_expect_eq(dds_err_nr(result), DDS_RETCODE_BAD_PARAMETER, "Invalid buffer size, Expected(%s) Returned(%s)",
 | 
			
		||||
        DDS_TO_STRING(DDS_RETCODE_BAD_PARAMETER),
 | 
			
		||||
        dds_err_str(result));
 | 
			
		||||
 | 
			
		||||
    buf = create_loan_buf(10, false);
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 28020)
 | 
			
		||||
#endif
 | 
			
		||||
    result = dds_return_loan(0, buf, 10);
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
    cr_expect_eq(dds_err_nr(result), DDS_RETCODE_BAD_PARAMETER, "Invalid entity, Expected(%s) Returned(%s)",
 | 
			
		||||
        DDS_TO_STRING(DDS_RETCODE_BAD_PARAMETER),
 | 
			
		||||
        dds_err_str(result));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,11 +17,23 @@
 | 
			
		|||
 | 
			
		||||
/* We are deliberately testing some bad arguments that SAL will complain about.
 | 
			
		||||
 * So, silence SAL regarding these issues. */
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(push)
 | 
			
		||||
#pragma warning(disable: 6387 28020)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void on_data_available(dds_entity_t reader, void* arg) {}
 | 
			
		||||
static void on_publication_matched(dds_entity_t writer, const dds_publication_matched_status_t status, void* arg) {}
 | 
			
		||||
static void on_data_available(dds_entity_t reader, void* arg)
 | 
			
		||||
{
 | 
			
		||||
  (void)reader;
 | 
			
		||||
  (void)arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void on_publication_matched(dds_entity_t writer, const dds_publication_matched_status_t status, void* arg)
 | 
			
		||||
{
 | 
			
		||||
  (void)writer;
 | 
			
		||||
  (void)status;
 | 
			
		||||
  (void)arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Test(ddsc_subscriber, notify_readers) {
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
| 
						 | 
				
			
			@ -108,4 +120,6 @@ Test(ddsc_subscriber, create) {
 | 
			
		|||
  dds_delete(participant);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
#pragma warning(pop)
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,7 +67,6 @@ static Space_Type1        g_data[MAX_SAMPLES];
 | 
			
		|||
static dds_sample_info_t  g_info[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static dds_instance_handle_t   g_hdl_valid;
 | 
			
		||||
static dds_instance_handle_t   g_hdl_nil = DDS_HANDLE_NIL;
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
filter_mod2(const void * sample)
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +88,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
take_instance_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    char name[100];
 | 
			
		||||
| 
						 | 
				
			
			@ -180,6 +179,7 @@ take_instance_init(void)
 | 
			
		|||
    for(int i = 0; i < ret; i++) {
 | 
			
		||||
        Space_Type1 *s = (Space_Type1*)g_samples[i];
 | 
			
		||||
        PRINT_SAMPLE("INIT: Read      ", (*s));
 | 
			
		||||
        (void)s;
 | 
			
		||||
    }
 | 
			
		||||
    /*  | long_1 | long_2 | long_3 |    sst   | vst |    ist     |
 | 
			
		||||
     *  ----------------------------------------------------------
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
#define MAX_SAMPLES  (7)
 | 
			
		||||
Test(ddsc_transient_local, late_joiner)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    dds_entity_t par;
 | 
			
		||||
    dds_entity_t pub;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ create_topic_name(const char *prefix, char *name, size_t size)
 | 
			
		|||
static void
 | 
			
		||||
unregistering_init(void)
 | 
			
		||||
{
 | 
			
		||||
    Space_Type1 sample = { 0 };
 | 
			
		||||
    Space_Type1 sample = { 0, 0, 0 };
 | 
			
		||||
    dds_qos_t *qos = dds_qos_create ();
 | 
			
		||||
    dds_attach_t triggered;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -664,11 +664,10 @@ TheoryDataPoints(ddsc_waitset_wait, invalid_params) = {
 | 
			
		|||
};
 | 
			
		||||
Theory((dds_attach_t *a, size_t size, int msec), ddsc_waitset_wait, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
 | 
			
		||||
    /* Only test when the combination of parameters is actually invalid. */
 | 
			
		||||
    cr_assume(((a == NULL) && (size != 0)) || ((a != NULL) && (size == 0)) || (size < 0) || (msec < 0));
 | 
			
		||||
    cr_assume(((a == NULL) && (size != 0)) || ((a != NULL) && (size == 0)) || (msec < 0));
 | 
			
		||||
 | 
			
		||||
    ret = dds_waitset_wait(waitset, a, size, DDS_MSECS(msec));
 | 
			
		||||
    cr_assert_eq(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER, "returned %d != expected %d", dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
 | 
			
		||||
| 
						 | 
				
			
			@ -722,11 +721,10 @@ TheoryDataPoints(ddsc_waitset_wait_until, invalid_params) = {
 | 
			
		|||
};
 | 
			
		||||
Theory((dds_attach_t *a, size_t size), ddsc_waitset_wait_until, invalid_params, .init=ddsc_waitset_basic_init, .fini=ddsc_waitset_basic_fini)
 | 
			
		||||
{
 | 
			
		||||
    dds_return_t exp = DDS_RETCODE_BAD_PARAMETER * -1;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
 | 
			
		||||
    /* Only test when the combination of parameters is actually invalid. */
 | 
			
		||||
    cr_assume(((a == NULL) && (size != 0)) || ((a != NULL) && (size == 0)) || (size < 0));
 | 
			
		||||
    cr_assume(((a == NULL) && (size != 0)) || ((a != NULL) && (size == 0)));
 | 
			
		||||
 | 
			
		||||
    ret = dds_waitset_wait_until(waitset, a, size, dds_time());
 | 
			
		||||
    cr_assert_eq(dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER, "returned %d != expected %d", dds_err_nr(ret), DDS_RETCODE_BAD_PARAMETER);
 | 
			
		||||
| 
						 | 
				
			
			@ -820,7 +818,7 @@ Theory((size_t size), ddsc_waitset_get_entities, array_sizes, .init=ddsc_waitset
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /* Every found entity should be a known one. */
 | 
			
		||||
    cr_assert_eq(NumberOfSetBits(found), ret, "Not all found entities are known");
 | 
			
		||||
    cr_assert_eq((dds_return_t)NumberOfSetBits(found), ret, "Not all found entities are known");
 | 
			
		||||
}
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -839,7 +837,6 @@ Test(ddsc_waitset_get_entities, no_array, .init=ddsc_waitset_attached_init, .fin
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
Test(ddsc_waitset_get_entities, deleted_waitset, .init=ddsc_waitset_attached_init, .fini=ddsc_waitset_attached_fini)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t found = 0;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    dds_entity_t entities[MAX_ENTITIES_CNT];
 | 
			
		||||
    dds_delete(waitset);
 | 
			
		||||
| 
						 | 
				
			
			@ -1078,7 +1075,6 @@ static os_result
 | 
			
		|||
thread_reached_state(thread_state_t *actual, thread_state_t expected, int32_t msec)
 | 
			
		||||
{
 | 
			
		||||
    /* Convenience function. */
 | 
			
		||||
    bool stopped = false;
 | 
			
		||||
    os_time msec10 = { 0, 10000000 };
 | 
			
		||||
    while ((msec > 0) && (*actual != expected)) {
 | 
			
		||||
        os_nanoSleep(msec10);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,8 @@
 | 
			
		|||
/* Tests in this file only concern themselves with very basic api tests of
 | 
			
		||||
   dds_write and dds_write_ts */
 | 
			
		||||
 | 
			
		||||
static const int payloadSize = 32;
 | 
			
		||||
static RoundTripModule_DataType data = { 0 };
 | 
			
		||||
static const uint32_t payloadSize = 32;
 | 
			
		||||
static RoundTripModule_DataType data;
 | 
			
		||||
 | 
			
		||||
static dds_entity_t participant = 0;
 | 
			
		||||
static dds_entity_t topic = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -175,11 +175,7 @@ int ddsi_serdata_is_key (const struct serdata * serdata);
 | 
			
		|||
int ddsi_serdata_is_empty (const struct serdata * serdata);
 | 
			
		||||
 | 
			
		||||
OSAPI_EXPORT void ddsi_serstate_append_blob (serstate_t st, size_t align, size_t sz, const void *data);
 | 
			
		||||
OSAPI_EXPORT void ddsi_serstate_set_msginfo
 | 
			
		||||
(
 | 
			
		||||
  serstate_t st, unsigned statusinfo, nn_wctime_t timestamp,
 | 
			
		||||
  void * dummy
 | 
			
		||||
);
 | 
			
		||||
OSAPI_EXPORT void ddsi_serstate_set_msginfo (serstate_t st, unsigned statusinfo, nn_wctime_t timestamp);
 | 
			
		||||
OSAPI_EXPORT serstate_t ddsi_serstate_new (const struct sertopic * topic);
 | 
			
		||||
OSAPI_EXPORT serdata_t ddsi_serstate_fix (serstate_t st);
 | 
			
		||||
nn_mtime_t ddsi_serstate_twrite (const struct serstate *serstate);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,9 +18,9 @@
 | 
			
		|||
#include "ddsi/q_rtps.h" /* for nn_guid_t, nn_guid_prefix_t */
 | 
			
		||||
#include "ddsi/q_protocol.h" /* for nn_sequence_number_t */
 | 
			
		||||
 | 
			
		||||
#define bswap2(x) ((short) bswap2u ((unsigned short) (x)))
 | 
			
		||||
#define bswap4(x) ((int) bswap4u ((unsigned) (x)))
 | 
			
		||||
#define bswap8(x) ((long long) bswap8u ((unsigned long long) (x)))
 | 
			
		||||
#define bswap2(x) ((int16_t) bswap2u ((uint16_t) (x)))
 | 
			
		||||
#define bswap4(x) ((int32_t) bswap4u ((uint32_t) (x)))
 | 
			
		||||
#define bswap8(x) ((int64_t) bswap8u ((uint64_t) (x)))
 | 
			
		||||
 | 
			
		||||
#if NN_HAVE_C99_INLINE && !defined SUPPRESS_BSWAP_INLINES
 | 
			
		||||
#include "q_bswap_template.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -28,9 +28,9 @@
 | 
			
		|||
#if defined (__cplusplus)
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
unsigned short bswap2u (unsigned short x);
 | 
			
		||||
unsigned bswap4u (unsigned x);
 | 
			
		||||
unsigned long long bswap8u (unsigned long long x);
 | 
			
		||||
uint16_t bswap2u (uint16_t x);
 | 
			
		||||
uint32_t bswap4u (uint32_t x);
 | 
			
		||||
uint64_t bswap8u (uint64_t x);
 | 
			
		||||
void bswapSN (nn_sequence_number_t *sn);
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,21 +16,21 @@
 | 
			
		|||
#define VDDS_INLINE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
VDDS_INLINE unsigned short bswap2u (unsigned short x)
 | 
			
		||||
VDDS_INLINE uint16_t bswap2u (uint16_t x)
 | 
			
		||||
{
 | 
			
		||||
  return (unsigned short) ((x >> 8) | (x << 8));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VDDS_INLINE unsigned bswap4u (unsigned x)
 | 
			
		||||
VDDS_INLINE uint32_t bswap4u (uint32_t x)
 | 
			
		||||
{
 | 
			
		||||
  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VDDS_INLINE unsigned long long bswap8u (unsigned long long x)
 | 
			
		||||
VDDS_INLINE uint64_t bswap8u (uint64_t x)
 | 
			
		||||
{
 | 
			
		||||
  const unsigned newhi = bswap4u ((unsigned) x);
 | 
			
		||||
  const unsigned newlo = bswap4u ((unsigned) (x >> 32));
 | 
			
		||||
  return ((unsigned long long) newhi << 32) | (unsigned long long) newlo;
 | 
			
		||||
  const uint32_t newhi = bswap4u ((uint32_t) x);
 | 
			
		||||
  const uint32_t newlo = bswap4u ((uint32_t) (x >> 32));
 | 
			
		||||
  return ((uint64_t) newhi << 32) | (uint64_t) newlo;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VDDS_INLINE void bswapSN (nn_sequence_number_t *sn)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,6 @@ struct sertopic;
 | 
			
		|||
struct whc;
 | 
			
		||||
struct nn_xqos;
 | 
			
		||||
struct nn_plist;
 | 
			
		||||
struct v_gid_s;
 | 
			
		||||
 | 
			
		||||
struct proxy_group;
 | 
			
		||||
struct proxy_endpoint_common;
 | 
			
		||||
| 
						 | 
				
			
			@ -142,7 +141,7 @@ struct local_reader_ary {
 | 
			
		|||
  os_mutex rdary_lock;
 | 
			
		||||
  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") */
 | 
			
		||||
  int n_readers;
 | 
			
		||||
  unsigned n_readers;
 | 
			
		||||
  struct reader **rdary; /* for efficient delivery, null-pointer terminated */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -552,7 +551,7 @@ int delete_proxy_reader (const struct nn_guid *guid, nn_wctime_t timestamp, int
 | 
			
		|||
void update_proxy_reader (struct proxy_reader * prd, struct addrset *as);
 | 
			
		||||
void update_proxy_writer (struct proxy_writer * pwr, struct addrset *as);
 | 
			
		||||
 | 
			
		||||
int new_proxy_group (const struct nn_guid *guid, const struct v_gid_s *gid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp);
 | 
			
		||||
int new_proxy_group (const struct nn_guid *guid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp);
 | 
			
		||||
void delete_proxy_group (const struct nn_guid *guid, nn_wctime_t timestamp, int isimplicit);
 | 
			
		||||
 | 
			
		||||
void writer_exit_startup_mode (struct writer *wr);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ struct hbcontrol {
 | 
			
		|||
 | 
			
		||||
void writer_hbcontrol_init (struct hbcontrol *hbc);
 | 
			
		||||
int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
 | 
			
		||||
void writer_hbcontrol_note_asyncwrite (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
 | 
			
		||||
void writer_hbcontrol_note_asyncwrite (struct writer *wr, nn_mtime_t tnow);
 | 
			
		||||
int writer_hbcontrol_ack_required (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
 | 
			
		||||
struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow, unsigned packetid, int *hbansreq);
 | 
			
		||||
int writer_hbcontrol_must_send (const struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,6 @@
 | 
			
		|||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct v_gid_s;
 | 
			
		||||
struct nn_guid;
 | 
			
		||||
 | 
			
		||||
int vendor_is_lite (nn_vendorid_t vendor);
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +39,7 @@ int WildcardOverlap(char * p1, char * p2);
 | 
			
		|||
int ddsi2_patmatch (const char *pat, const char *str);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint32_t crc32_calc (const void *buf, uint32_t length);
 | 
			
		||||
uint32_t crc32_calc (const void *buf, size_t length);
 | 
			
		||||
 | 
			
		||||
#if defined (__cplusplus)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ typedef struct nn_udpv4mcgen_address {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
struct cdrstring {
 | 
			
		||||
  unsigned length;
 | 
			
		||||
  uint32_t length;
 | 
			
		||||
  unsigned char contents[1]; /* C90 does not support flex. array members */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,10 +26,10 @@ typedef struct {
 | 
			
		|||
} nn_protocol_version_t;
 | 
			
		||||
typedef union nn_guid_prefix {
 | 
			
		||||
  unsigned char s[12];
 | 
			
		||||
  unsigned u[3];
 | 
			
		||||
  uint32_t u[3];
 | 
			
		||||
} nn_guid_prefix_t;
 | 
			
		||||
typedef union nn_entityid {
 | 
			
		||||
  unsigned u;
 | 
			
		||||
  uint32_t u;
 | 
			
		||||
} nn_entityid_t;
 | 
			
		||||
typedef struct nn_guid {
 | 
			
		||||
  nn_guid_prefix_t prefix;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ void nn_xmsg_guid_seq_fragid (const struct nn_xmsg *m, nn_guid_t *wrguid, seqno_
 | 
			
		|||
void *nn_xmsg_submsg_from_marker (struct nn_xmsg *msg, struct nn_xmsg_marker marker);
 | 
			
		||||
void *nn_xmsg_append (struct nn_xmsg *m, struct nn_xmsg_marker *marker, size_t sz);
 | 
			
		||||
void nn_xmsg_shrink (struct nn_xmsg *m, struct nn_xmsg_marker marker, size_t sz);
 | 
			
		||||
void nn_xmsg_serdata (struct nn_xmsg *m, struct serdata *serdata, unsigned off, unsigned len);
 | 
			
		||||
void nn_xmsg_serdata (struct nn_xmsg *m, struct serdata *serdata, size_t off, size_t len);
 | 
			
		||||
void nn_xmsg_submsg_setnext (struct nn_xmsg *msg, struct nn_xmsg_marker marker);
 | 
			
		||||
void nn_xmsg_submsg_init (struct nn_xmsg *msg, struct nn_xmsg_marker marker, SubmessageKind_t smkind);
 | 
			
		||||
void nn_xmsg_add_timestamp (struct nn_xmsg *m, nn_wctime_t t);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ extern "C" {
 | 
			
		|||
#define NN_DDS_LENGTH_UNLIMITED -1
 | 
			
		||||
 | 
			
		||||
typedef struct nn_octetseq {
 | 
			
		||||
  unsigned length;
 | 
			
		||||
  uint32_t length;
 | 
			
		||||
  unsigned char *value;
 | 
			
		||||
} nn_octetseq_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ typedef struct nn_property {
 | 
			
		|||
} nn_property_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_propertyseq {
 | 
			
		||||
  unsigned n;
 | 
			
		||||
  uint32_t n;
 | 
			
		||||
  nn_property_t *props;
 | 
			
		||||
} nn_propertyseq_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ typedef struct nn_binaryproperty {
 | 
			
		|||
} nn_binaryproperty_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_binarypropertyseq {
 | 
			
		||||
  unsigned n;
 | 
			
		||||
  uint32_t n;
 | 
			
		||||
  nn_binaryproperty_t *props;
 | 
			
		||||
} nn_binarypropertyseq_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,13 +78,13 @@ typedef enum nn_history_kind {
 | 
			
		|||
 | 
			
		||||
typedef struct nn_history_qospolicy {
 | 
			
		||||
  nn_history_kind_t kind;
 | 
			
		||||
  int depth;
 | 
			
		||||
  int32_t depth;
 | 
			
		||||
} nn_history_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_resource_limits_qospolicy {
 | 
			
		||||
  int max_samples;
 | 
			
		||||
  int max_instances;
 | 
			
		||||
  int max_samples_per_instance;
 | 
			
		||||
  int32_t max_samples;
 | 
			
		||||
  int32_t max_instances;
 | 
			
		||||
  int32_t max_samples_per_instance;
 | 
			
		||||
} nn_resource_limits_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_durability_service_qospolicy {
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ typedef struct nn_ownership_qospolicy {
 | 
			
		|||
} nn_ownership_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_ownership_strength_qospolicy {
 | 
			
		||||
  int value;
 | 
			
		||||
  int32_t value;
 | 
			
		||||
} nn_ownership_strength_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef enum nn_liveliness_kind {
 | 
			
		||||
| 
						 | 
				
			
			@ -142,7 +142,7 @@ typedef struct nn_time_based_filter_qospolicy {
 | 
			
		|||
} nn_time_based_filter_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_stringseq {
 | 
			
		||||
  unsigned n;
 | 
			
		||||
  uint32_t n;
 | 
			
		||||
  char **strs;
 | 
			
		||||
} nn_stringseq_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ typedef struct nn_reliability_qospolicy {
 | 
			
		|||
} nn_reliability_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_external_reliability_qospolicy {
 | 
			
		||||
  int kind;
 | 
			
		||||
  uint32_t kind;
 | 
			
		||||
  nn_duration_t max_blocking_time;
 | 
			
		||||
} nn_external_reliability_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ typedef struct nn_external_reliability_qospolicy {
 | 
			
		|||
#define NN_INTEROP_RELIABLE_RELIABILITY_QOS     2
 | 
			
		||||
 | 
			
		||||
typedef struct nn_transport_priority_qospolicy {
 | 
			
		||||
  int value;
 | 
			
		||||
  int32_t value;
 | 
			
		||||
} nn_transport_priority_qospolicy_t;
 | 
			
		||||
 | 
			
		||||
typedef struct nn_lifespan_qospolicy {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -158,16 +158,25 @@ typedef struct ddsi_iovec {
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#if ! SYSDEPS_HAVE_MSGHDR
 | 
			
		||||
#if defined _WIN32
 | 
			
		||||
typedef DWORD ddsi_msg_iovlen_t;
 | 
			
		||||
#else
 | 
			
		||||
typedef int ddsi_msg_iovlen_t;
 | 
			
		||||
#endif
 | 
			
		||||
struct msghdr
 | 
			
		||||
{
 | 
			
		||||
  void *msg_name;
 | 
			
		||||
  socklen_t msg_namelen;
 | 
			
		||||
  ddsi_iovec_t *msg_iov;
 | 
			
		||||
  size_t msg_iovlen;
 | 
			
		||||
  ddsi_msg_iovlen_t msg_iovlen;
 | 
			
		||||
  void *msg_control;
 | 
			
		||||
  size_t msg_controllen;
 | 
			
		||||
  int msg_flags;
 | 
			
		||||
};
 | 
			
		||||
#elif defined __linux
 | 
			
		||||
typedef size_t ddsi_msg_iovlen_t;
 | 
			
		||||
#else /* POSIX says int (which macOS, FreeBSD, Solaris do) */
 | 
			
		||||
typedef int ddsi_msg_iovlen_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef MSG_TRUNC
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -120,11 +120,7 @@ void ddsi_serstate_append_blob (serstate_t st, size_t align, size_t sz, const vo
 | 
			
		|||
  memcpy (p, data, sz);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ddsi_serstate_set_msginfo
 | 
			
		||||
(
 | 
			
		||||
  serstate_t st, unsigned statusinfo, nn_wctime_t timestamp,
 | 
			
		||||
  void * dummy
 | 
			
		||||
)
 | 
			
		||||
void ddsi_serstate_set_msginfo (serstate_t st, unsigned statusinfo, nn_wctime_t timestamp)
 | 
			
		||||
{
 | 
			
		||||
  serdata_t d = st->data;
 | 
			
		||||
  d->v.msginfo.statusinfo = statusinfo;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -132,7 +132,7 @@ static const ut_avlTreedef_t ddsi_tcp_treedef = UT_AVL_TREEDEF_INITIALIZER_INDKE
 | 
			
		|||
(
 | 
			
		||||
  offsetof (struct ddsi_tcp_node, m_avlnode),
 | 
			
		||||
  offsetof (struct ddsi_tcp_node, m_conn),
 | 
			
		||||
  (ut_avlCompare_t) ddsi_tcp_cmp_conn,
 | 
			
		||||
  ddsi_tcp_cmp_conn,
 | 
			
		||||
  0
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -559,15 +559,11 @@ static size_t iovlen_sum (size_t niov, const ddsi_iovec_t *iov)
 | 
			
		|||
  return tot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Turns out Darwin uses "int" for msg_iovlen, but glibc uses "size_t". The simplest
 | 
			
		||||
 way out is to do the assignment with the conversion warnings disabled */
 | 
			
		||||
//OSPL_DIAG_OFF(conversion)
 | 
			
		||||
static void set_msghdr_iov (struct msghdr *mhdr, ddsi_iovec_t *iov, size_t iovlen)
 | 
			
		||||
{
 | 
			
		||||
  mhdr->msg_iov = iov;
 | 
			
		||||
  mhdr->msg_iovlen = iovlen;
 | 
			
		||||
  mhdr->msg_iovlen = (ddsi_msg_iovlen_t)iovlen;
 | 
			
		||||
}
 | 
			
		||||
//OSPL_DIAG_ON(conversion)
 | 
			
		||||
 | 
			
		||||
static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *dst, size_t niov, const ddsi_iovec_t *iov, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,15 +97,11 @@ static ssize_t ddsi_udp_conn_read (ddsi_tran_conn_t conn, unsigned char * buf, s
 | 
			
		|||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Turns out Darwin uses "int" for msg_iovlen, but glibc uses "size_t". The simplest
 | 
			
		||||
 way out is to do the assignment with the conversion warnings disabled */
 | 
			
		||||
//OSPL_DIAG_OFF(conversion)
 | 
			
		||||
static void set_msghdr_iov (struct msghdr *mhdr, ddsi_iovec_t *iov, size_t iovlen)
 | 
			
		||||
{
 | 
			
		||||
  mhdr->msg_iov = iov;
 | 
			
		||||
  mhdr->msg_iovlen = iovlen;
 | 
			
		||||
  mhdr->msg_iovlen = (ddsi_msg_iovlen_t)iovlen;
 | 
			
		||||
}
 | 
			
		||||
//OSPL_DIAG_ON(conversion)
 | 
			
		||||
 | 
			
		||||
static ssize_t ddsi_udp_conn_write (ddsi_tran_conn_t conn, const nn_locator_t *dst, size_t niov, const ddsi_iovec_t *iov, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -296,7 +292,7 @@ static ddsi_tran_conn_t ddsi_udp_create_conn
 | 
			
		|||
 | 
			
		||||
static int joinleave_asm_mcgroup (os_socket socket, int join, const nn_locator_t *mcloc, const struct nn_interface *interf)
 | 
			
		||||
{
 | 
			
		||||
  int rc;
 | 
			
		||||
  os_result rc;
 | 
			
		||||
  os_sockaddr_storage mcip;
 | 
			
		||||
  ddsi_ipaddr_from_loc(&mcip, mcloc);
 | 
			
		||||
#if OS_SOCKET_HAS_IPV6
 | 
			
		||||
| 
						 | 
				
			
			@ -319,13 +315,13 @@ static int joinleave_asm_mcgroup (os_socket socket, int join, const nn_locator_t
 | 
			
		|||
      mreq.imr_interface.s_addr = htonl (INADDR_ANY);
 | 
			
		||||
    rc = os_sockSetsockopt (socket, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, (char *) &mreq, sizeof (mreq));
 | 
			
		||||
  }
 | 
			
		||||
  return (rc == -1) ? os_getErrno() : 0;
 | 
			
		||||
  return (rc != os_resultSuccess) ? os_getErrno() : 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DDSI_INCLUDE_SSM
 | 
			
		||||
static int joinleave_ssm_mcgroup (os_socket socket, int join, const nn_locator_t *srcloc, const nn_locator_t *mcloc, const struct nn_interface *interf)
 | 
			
		||||
{
 | 
			
		||||
  int rc;
 | 
			
		||||
  os_result rc;
 | 
			
		||||
  os_sockaddr_storage mcip, srcip;
 | 
			
		||||
  ddsi_ipaddr_from_loc(&mcip, mcloc);
 | 
			
		||||
  ddsi_ipaddr_from_loc(&srcip, srcloc);
 | 
			
		||||
| 
						 | 
				
			
			@ -352,7 +348,7 @@ static int joinleave_ssm_mcgroup (os_socket socket, int join, const nn_locator_t
 | 
			
		|||
      mreq.imr_interface.s_addr = INADDR_ANY;
 | 
			
		||||
    rc = os_sockSetsockopt (socket, IPPROTO_IP, join ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP, &mreq, sizeof (mreq));
 | 
			
		||||
  }
 | 
			
		||||
  return (rc == -1) ? os_getErrno() : 0;
 | 
			
		||||
  return (rc != os_resultSuccess) ? os_getErrno() : 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,7 +233,7 @@ void set_unspec_locator (nn_locator_t *loc)
 | 
			
		|||
 | 
			
		||||
int is_unspec_locator (const nn_locator_t *loc)
 | 
			
		||||
{
 | 
			
		||||
  static const nn_locator_t zloc;
 | 
			
		||||
  static const nn_locator_t zloc = { .kind = 0 };
 | 
			
		||||
  return (loc->kind == NN_LOCATOR_KIND_INVALID &&
 | 
			
		||||
          loc->port == NN_LOCATOR_PORT_INVALID &&
 | 
			
		||||
          memcmp (&zloc.address, loc->address, sizeof (zloc.address)) == 0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -204,6 +204,7 @@ DI(if_thread_properties);
 | 
			
		|||
#define GROUP_W_ATTRS(name, children, attrs) name, children, attrs, 1, NULL, 0, 0, 0, 0, 0, 0
 | 
			
		||||
#define MGROUP(name, children, attrs) name, children, attrs
 | 
			
		||||
#define ATTR(name) name, NULL, NULL
 | 
			
		||||
#define DEPRECATED_ATTR(name) "|" name, NULL, NULL
 | 
			
		||||
/* MOVED: whereto must be a path relative to DDSI2Service, may not be used in/for lists and only for elements, may not be chained */
 | 
			
		||||
#define MOVED(name, whereto) ">" name, NULL, NULL, 0, whereto, 0, 0, 0, 0, 0, 0, NULL
 | 
			
		||||
static const struct cfgelem timestamp_cfgattrs[] = {
 | 
			
		||||
| 
						 | 
				
			
			@ -465,15 +466,19 @@ static const struct cfgelem unsupp_watermarks_cfgelems[] = {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct cfgelem control_topic_cfgattrs[] = {
 | 
			
		||||
    { ATTR("Enable"), 1, "false", ABSOFF(enable_control_topic), 0, uf_boolean, 0, pf_boolean },
 | 
			
		||||
    { ATTR("InitialReset"), 1, "inf", ABSOFF(initial_deaf_mute_reset), 0, uf_duration_inf, 0, pf_duration },
 | 
			
		||||
    { DEPRECATED_ATTR("Enable"), 1, "false", ABSOFF(enable_control_topic), 0, uf_boolean, 0, pf_boolean,
 | 
			
		||||
      "<p>This element controls whether DDSI2E should create a topic to control DDSI2E's behaviour dynamically.<p>"
 | 
			
		||||
    },
 | 
			
		||||
    { DEPRECATED_ATTR("InitialReset"), 1, "inf", ABSOFF(initial_deaf_mute_reset), 0, uf_duration_inf, 0, pf_duration,
 | 
			
		||||
      "<p>This element controls after how much time an initial deaf/mute state will automatically reset.<p>"
 | 
			
		||||
    },
 | 
			
		||||
    END_MARKER
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct cfgelem control_topic_cfgelems[] = {
 | 
			
		||||
    { LEAF ("Deaf"), 1, "false", ABSOFF (initial_deaf), 0, uf_deaf_mute, 0, pf_boolean,
 | 
			
		||||
    { DEPRECATED_LEAF ("Deaf"), 1, "false", ABSOFF (initial_deaf), 0, uf_deaf_mute, 0, pf_boolean,
 | 
			
		||||
    "<p>This element controls whether DDSI2E defaults to deaf mode or to normal mode. This controls both the initial behaviour and what behaviour it auto-reverts to.</p>" },
 | 
			
		||||
    { LEAF ("Mute"), 1, "false", ABSOFF (initial_mute), 0, uf_deaf_mute, 0, pf_boolean,
 | 
			
		||||
    { DEPRECATED_LEAF ("Mute"), 1, "false", ABSOFF (initial_mute), 0, uf_deaf_mute, 0, pf_boolean,
 | 
			
		||||
    "<p>This element controls whether DDSI2E defaults to mute mode or to normal mode. This controls both the initial behaviour and what behaviour it auto-reverts to.</p>" },
 | 
			
		||||
    END_MARKER
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -548,7 +553,8 @@ static const struct cfgelem unsupp_cfgelems[] = {
 | 
			
		|||
{ LEAF("RetransmitMergingPeriod"), 1, "5 ms", ABSOFF(retransmit_merging_period), 0, uf_duration_us_1s, 0, pf_duration,
 | 
			
		||||
"<p>This setting determines the size of the time window in which a NACK of some sample is ignored because a retransmit of that sample has been multicasted too recently. This setting has no effect on unicasted retransmits.</p>\n\
 | 
			
		||||
<p>See also Internal/RetransmitMerging.</p>" },
 | 
			
		||||
{ LEAF_W_ATTRS("HeartbeatInterval", heartbeat_interval_attrs), 1, "100 ms", ABSOFF(const_hb_intv_sched), 0, uf_duration_inf, 0, pf_duration },
 | 
			
		||||
{ LEAF_W_ATTRS("HeartbeatInterval", heartbeat_interval_attrs), 1, "100 ms", ABSOFF(const_hb_intv_sched), 0, uf_duration_inf, 0, pf_duration,
 | 
			
		||||
  "<p>This elemnents allows configuring the base interval for sending writer heartbeats and the bounds within it can vary.</p>" },
 | 
			
		||||
{ LEAF("MaxQueuedRexmitBytes"), 1, "50 kB", ABSOFF(max_queued_rexmit_bytes), 0, uf_memsize, 0, pf_memsize,
 | 
			
		||||
"<p>This setting limits the maximum number of bytes queued for retransmission. The default value of 0 is unlimited unless an AuxiliaryBandwidthLimit has been set, in which case it becomes NackDelay * AuxiliaryBandwidthLimit. It must be large enough to contain the largest sample that may need to be retransmitted.</p>" },
 | 
			
		||||
{ LEAF("MaxQueuedRexmitMessages"), 1, "200", ABSOFF(max_queued_rexmit_msgs), 0, uf_uint, 0, pf_uint,
 | 
			
		||||
| 
						 | 
				
			
			@ -1306,7 +1312,7 @@ static int uf_boolean_default (struct cfgst *cfgst, void *parent, struct cfgelem
 | 
			
		|||
  static const enum boolean_default ms[] = {
 | 
			
		||||
    BOOLDEF_DEFAULT, BOOLDEF_FALSE, BOOLDEF_TRUE, 0,
 | 
			
		||||
  };
 | 
			
		||||
  int *elem = cfg_address (cfgst, parent, cfgelem);
 | 
			
		||||
  enum boolean_default *elem = cfg_address (cfgst, parent, cfgelem);
 | 
			
		||||
  int idx = list_index (vs, value);
 | 
			
		||||
  assert (sizeof (vs) / sizeof (*vs) == sizeof (ms) / sizeof (*ms));
 | 
			
		||||
  if (idx < 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -2857,7 +2863,7 @@ struct cfgst * config_init
 | 
			
		|||
            forces us to include a crc32 routine when we have md5
 | 
			
		||||
            available anyway */
 | 
			
		||||
            p->partitionId = config.nof_networkPartitions; /* starting at 1 */
 | 
			
		||||
            p->partitionHash = crc32_calc(p->name, (int) strlen(p->name));
 | 
			
		||||
            p->partitionHash = crc32_calc(p->name, strlen(p->name));
 | 
			
		||||
            p = p->next;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ int spdp_write (struct participant *pp)
 | 
			
		|||
  ddsi_serstate_append_blob (serstate, 4, payload_sz, payload_blob);
 | 
			
		||||
  kh = nn_hton_guid (pp->e.guid);
 | 
			
		||||
  serstate_set_key (serstate, 0, &kh);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_plist_fini(&ps);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
| 
						 | 
				
			
			@ -362,7 +362,7 @@ int spdp_dispose_unregister (struct participant *pp)
 | 
			
		|||
  ddsi_serstate_append_blob (serstate, 4, payload_sz, payload_blob);
 | 
			
		||||
  kh = nn_hton_guid (pp->e.guid);
 | 
			
		||||
  serstate_set_key (serstate, 1, &kh);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -977,7 +977,7 @@ static int sedp_write_endpoint
 | 
			
		|||
    statusinfo = NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER;
 | 
			
		||||
  else
 | 
			
		||||
    statusinfo = 0;
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1443,7 +1443,7 @@ int sedp_write_topic (struct participant *pp, const struct nn_plist *datap)
 | 
			
		|||
  md5_finish (&md5st, digest);
 | 
			
		||||
 | 
			
		||||
  serstate_set_key (serstate, 0, digest);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1509,7 +1509,7 @@ int sedp_write_cm_participant (struct participant *pp, int alive)
 | 
			
		|||
    statusinfo = NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER;
 | 
			
		||||
  else
 | 
			
		||||
    statusinfo = 0;
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1619,7 +1619,7 @@ int sedp_write_cm_publisher (const struct nn_plist *datap, int alive)
 | 
			
		|||
    statusinfo = NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER;
 | 
			
		||||
  else
 | 
			
		||||
    statusinfo = 0;
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1674,7 +1674,7 @@ int sedp_write_cm_subscriber (const struct nn_plist *datap, int alive)
 | 
			
		|||
    statusinfo = NN_STATUSINFO_DISPOSE | NN_STATUSINFO_UNREGISTER;
 | 
			
		||||
  else
 | 
			
		||||
    statusinfo = 0;
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, statusinfo, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
  nn_xmsg_free (mpayload);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1698,10 +1698,8 @@ static void handle_SEDP_GROUP_alive (nn_plist_t *datap /* note: potentially modi
 | 
			
		|||
  nn_log (LC_DISCOVERY, " alive\n");
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    struct v_gid_s *gid = NULL;
 | 
			
		||||
    char *name;
 | 
			
		||||
    name = (datap->present & PP_ENTITY_NAME) ? datap->entity_name : "";
 | 
			
		||||
    new_proxy_group (&datap->group_guid, gid, name, &datap->qos, timestamp);
 | 
			
		||||
    char *name = (datap->present & PP_ENTITY_NAME) ? datap->entity_name : "";
 | 
			
		||||
    new_proxy_group (&datap->group_guid, name, &datap->qos, timestamp);
 | 
			
		||||
  }
 | 
			
		||||
err:
 | 
			
		||||
  return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -197,7 +197,7 @@ void local_reader_ary_insert (struct local_reader_ary *x, struct reader *rd)
 | 
			
		|||
 | 
			
		||||
void local_reader_ary_remove (struct local_reader_ary *x, struct reader *rd)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
  unsigned i;
 | 
			
		||||
  os_mutexLock (&x->rdary_lock);
 | 
			
		||||
  for (i = 0; i < x->n_readers; i++)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -1943,7 +1943,7 @@ static nn_entityid_t builtin_entityid_match (nn_entityid_t x)
 | 
			
		|||
  return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void writer_qos_mismatch (struct writer * wr, int32_t reason)
 | 
			
		||||
static void writer_qos_mismatch (struct writer * wr, uint32_t reason)
 | 
			
		||||
{
 | 
			
		||||
  /* When the reason is DDS_INVALID_QOS_POLICY_ID, it means that we compared
 | 
			
		||||
   * readers/writers from different topics: ignore that. */
 | 
			
		||||
| 
						 | 
				
			
			@ -1963,7 +1963,7 @@ static void writer_qos_mismatch (struct writer * wr, int32_t reason)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void reader_qos_mismatch (struct reader * rd, int32_t reason)
 | 
			
		||||
static void reader_qos_mismatch (struct reader * rd, uint32_t reason)
 | 
			
		||||
{
 | 
			
		||||
  /* When the reason is DDS_INVALID_QOS_POLICY_ID, it means that we compared
 | 
			
		||||
   * readers/writers from different topics: ignore that. */
 | 
			
		||||
| 
						 | 
				
			
			@ -1996,7 +1996,7 @@ static void connect_writer_with_proxy_reader (struct writer *wr, struct proxy_re
 | 
			
		|||
    return;
 | 
			
		||||
  if (!isb0 && (reason = qos_match_p (prd->c.xqos, wr->xqos)) >= 0)
 | 
			
		||||
  {
 | 
			
		||||
    writer_qos_mismatch (wr, reason);
 | 
			
		||||
    writer_qos_mismatch (wr, (uint32_t)reason);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  proxy_reader_add_connection (prd, wr);
 | 
			
		||||
| 
						 | 
				
			
			@ -2015,7 +2015,7 @@ static void connect_proxy_writer_with_reader (struct proxy_writer *pwr, struct r
 | 
			
		|||
    return;
 | 
			
		||||
  if (!isb0 && (reason = qos_match_p (rd->xqos, pwr->c.xqos)) >= 0)
 | 
			
		||||
  {
 | 
			
		||||
    reader_qos_mismatch (rd, reason);
 | 
			
		||||
    reader_qos_mismatch (rd, (uint32_t)reason);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  reader_add_connection (rd, pwr, &init_count);
 | 
			
		||||
| 
						 | 
				
			
			@ -2025,12 +2025,13 @@ static void connect_proxy_writer_with_reader (struct proxy_writer *pwr, struct r
 | 
			
		|||
static void connect_writer_with_reader (struct writer *wr, struct reader *rd, nn_mtime_t tnow)
 | 
			
		||||
{
 | 
			
		||||
  int32_t reason;
 | 
			
		||||
  (void)tnow;
 | 
			
		||||
  if (is_builtin_entityid (wr->e.guid.entityid, ownvendorid) || is_builtin_entityid (rd->e.guid.entityid, ownvendorid))
 | 
			
		||||
    return;
 | 
			
		||||
  if ((reason = qos_match_p (rd->xqos, wr->xqos)) >= 0)
 | 
			
		||||
  {
 | 
			
		||||
    writer_qos_mismatch (wr, reason);
 | 
			
		||||
    reader_qos_mismatch (rd, reason);
 | 
			
		||||
    writer_qos_mismatch (wr, (uint32_t)reason);
 | 
			
		||||
    reader_qos_mismatch (rd, (uint32_t)reason);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  reader_add_local_connection (rd, wr);
 | 
			
		||||
| 
						 | 
				
			
			@ -3882,10 +3883,11 @@ uint64_t participant_instance_id (const struct nn_guid *guid)
 | 
			
		|||
 | 
			
		||||
/* PROXY-GROUP --------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
int new_proxy_group (const struct nn_guid *guid, const struct v_gid_s *gid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp)
 | 
			
		||||
int new_proxy_group (const struct nn_guid *guid, const char *name, const struct nn_xqos *xqos, nn_wctime_t timestamp)
 | 
			
		||||
{
 | 
			
		||||
  struct proxy_participant *proxypp;
 | 
			
		||||
  nn_guid_t ppguid;
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
  ppguid.prefix = guid->prefix;
 | 
			
		||||
  ppguid.entityid.u = NN_ENTITYID_PARTICIPANT;
 | 
			
		||||
  if ((proxypp = ephash_lookup_proxy_participant_guid (&ppguid)) == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -3948,6 +3950,8 @@ int new_proxy_group (const struct nn_guid *guid, const struct v_gid_s *gid, cons
 | 
			
		|||
static void delete_proxy_group_locked (struct proxy_group *pgroup, nn_wctime_t timestamp, int isimplicit)
 | 
			
		||||
{
 | 
			
		||||
  struct proxy_participant *proxypp = pgroup->proxypp;
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
  (void)isimplicit;
 | 
			
		||||
  assert ((pgroup->xqos != NULL) == (pgroup->name != NULL));
 | 
			
		||||
  nn_log (LC_DISCOVERY, "delete_proxy_group_locked %x:%x:%x:%x\n", PGUID (pgroup->guid));
 | 
			
		||||
  ut_avlDelete (&proxypp_groups_treedef, &proxypp->groups, pgroup);
 | 
			
		||||
| 
						 | 
				
			
			@ -4032,7 +4036,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid,
 | 
			
		|||
  struct proxy_writer *pwr;
 | 
			
		||||
  int isreliable;
 | 
			
		||||
  nn_mtime_t tnow = now_mt ();
 | 
			
		||||
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
  assert (is_writer_entityid (guid->entityid));
 | 
			
		||||
  assert (ephash_lookup_proxy_writer_guid (guid) == NULL);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4224,6 +4228,8 @@ static void gc_delete_proxy_writer (struct gcreq *gcreq)
 | 
			
		|||
int delete_proxy_writer (const struct nn_guid *guid, nn_wctime_t timestamp, int isimplicit)
 | 
			
		||||
{
 | 
			
		||||
  struct proxy_writer *pwr;
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
  (void)isimplicit;
 | 
			
		||||
  nn_log (LC_DISCOVERY, "delete_proxy_writer (%x:%x:%x:%x) ", PGUID (*guid));
 | 
			
		||||
  os_mutexLock (&gv.lock);
 | 
			
		||||
  if ((pwr = ephash_lookup_proxy_writer_guid (guid)) == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -4255,6 +4261,7 @@ int new_proxy_reader (const struct nn_guid *ppguid, const struct nn_guid *guid,
 | 
			
		|||
  struct proxy_participant *proxypp;
 | 
			
		||||
  struct proxy_reader *prd;
 | 
			
		||||
  nn_mtime_t tnow = now_mt ();
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
 | 
			
		||||
  assert (!is_writer_entityid (guid->entityid));
 | 
			
		||||
  assert (ephash_lookup_proxy_reader_guid (guid) == NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -4352,6 +4359,8 @@ static void gc_delete_proxy_reader (struct gcreq *gcreq)
 | 
			
		|||
int delete_proxy_reader (const struct nn_guid *guid, nn_wctime_t timestamp, int isimplicit)
 | 
			
		||||
{
 | 
			
		||||
  struct proxy_reader *prd;
 | 
			
		||||
  (void)timestamp;
 | 
			
		||||
  (void)isimplicit;
 | 
			
		||||
  nn_log (LC_DISCOVERY, "delete_proxy_reader (%x:%x:%x:%x) ", PGUID (*guid));
 | 
			
		||||
  os_mutexLock (&gv.lock);
 | 
			
		||||
  if ((prd = ephash_lookup_proxy_reader_guid (guid)) == NULL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,11 +38,11 @@ static const uint64_t unihashconsts[] = {
 | 
			
		|||
static uint32_t hash_entity_guid (const struct entity_common *c)
 | 
			
		||||
{
 | 
			
		||||
  return
 | 
			
		||||
    (int) (((((uint32_t) c->guid.prefix.u[0] + unihashconsts[0]) *
 | 
			
		||||
             ((uint32_t) c->guid.prefix.u[1] + unihashconsts[1])) +
 | 
			
		||||
            (((uint32_t) c->guid.prefix.u[2] + unihashconsts[2]) *
 | 
			
		||||
             ((uint32_t) c->guid.entityid.u  + unihashconsts[3])))
 | 
			
		||||
           >> 32);
 | 
			
		||||
    (uint32_t) (((((uint32_t) c->guid.prefix.u[0] + unihashconsts[0]) *
 | 
			
		||||
                  ((uint32_t) c->guid.prefix.u[1] + unihashconsts[1])) +
 | 
			
		||||
                 (((uint32_t) c->guid.prefix.u[2] + unihashconsts[2]) *
 | 
			
		||||
                  ((uint32_t) c->guid.entityid.u  + unihashconsts[3])))
 | 
			
		||||
                >> 32);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t hash_entity_guid_wrapper (const void *c)
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +121,7 @@ static void *ephash_lookup_guid_int (const struct ephash *ephash, const struct n
 | 
			
		|||
  /* FIXME: could (now) require guid to be first in entity_common; entity_common already is first in entity */
 | 
			
		||||
  struct entity_common e;
 | 
			
		||||
  struct entity_common *res;
 | 
			
		||||
  (void)ephash;
 | 
			
		||||
  e.guid = *guid;
 | 
			
		||||
  res = ut_chhLookup (gv.guid_hash->hash, &e);
 | 
			
		||||
  if (res && res->kind == kind)
 | 
			
		||||
| 
						 | 
				
			
			@ -287,7 +288,7 @@ void *ephash_enum_next (struct ephash_enum *st)
 | 
			
		|||
  if (st->cur)
 | 
			
		||||
  {
 | 
			
		||||
    st->cur = ut_chhIterNext (&st->it);
 | 
			
		||||
    while (st->cur && (int)st->cur->kind != st->kind)
 | 
			
		||||
    while (st->cur && st->cur->kind != st->kind)
 | 
			
		||||
      st->cur = ut_chhIterNext (&st->it);
 | 
			
		||||
  }
 | 
			
		||||
  return res;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -199,6 +199,8 @@ _Check_return_ bool nn_freelist_push (_Inout_ struct nn_freelist *fl, _Inout_ _W
 | 
			
		|||
_Check_return_ _Ret_maybenull_ void *nn_freelist_pushmany (_Inout_ struct nn_freelist *fl, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *first, _Inout_opt_ _When_ (return != 0, _Post_invalid_) void *last, uint32_t n)
 | 
			
		||||
{
 | 
			
		||||
  void *m = first;
 | 
			
		||||
  (void)last;
 | 
			
		||||
  (void)n;
 | 
			
		||||
  while (m)
 | 
			
		||||
  {
 | 
			
		||||
    void *mnext = get_next (fl, m);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,8 @@ static void check(const struct inverse_uint32_set *set)
 | 
			
		|||
    assert(n->max <= set->max);
 | 
			
		||||
    assert(pn == NULL || n->min > pn->max+1);
 | 
			
		||||
  }
 | 
			
		||||
#else
 | 
			
		||||
  (void)set;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -199,11 +199,12 @@ static const uint32_t crc32_table[] = {
 | 
			
		|||
  0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
uint32_t crc32_calc (const void *buf, uint32_t length)
 | 
			
		||||
uint32_t crc32_calc (const void *buf, size_t length)
 | 
			
		||||
{
 | 
			
		||||
  const uint8_t *vptr = buf;
 | 
			
		||||
  uint32_t i, reg = 0;
 | 
			
		||||
  uint32_t reg = 0;
 | 
			
		||||
  uint8_t top;
 | 
			
		||||
  size_t i;
 | 
			
		||||
  for (i = 0; i < length; i++)
 | 
			
		||||
  {
 | 
			
		||||
    top = (uint8_t) (reg >> 24);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -222,7 +222,7 @@ static int set_reuse_options (os_socket socket)
 | 
			
		|||
 | 
			
		||||
static int bind_socket (os_socket socket, unsigned short port)
 | 
			
		||||
{
 | 
			
		||||
  int rc;
 | 
			
		||||
  os_result rc;
 | 
			
		||||
 | 
			
		||||
#if OS_SOCKET_HAS_IPV6
 | 
			
		||||
  if (config.transport_selector == TRANS_TCP6 || config.transport_selector == TRANS_UDP6)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ typedef struct nn_ipaddress_params_tmp {
 | 
			
		|||
 | 
			
		||||
struct dd {
 | 
			
		||||
  const unsigned char *buf;
 | 
			
		||||
  unsigned bufsz;
 | 
			
		||||
  size_t bufsz;
 | 
			
		||||
  unsigned bswap: 1;
 | 
			
		||||
  nn_protocol_version_t protocol_version;
 | 
			
		||||
  nn_vendorid_t vendorid;
 | 
			
		||||
| 
						 | 
				
			
			@ -90,9 +90,9 @@ static int trace_plist (const char *fmt, ...)
 | 
			
		|||
 | 
			
		||||
static void log_octetseq (logcat_t cat, unsigned n, const unsigned char *xs);
 | 
			
		||||
 | 
			
		||||
static unsigned align4u (unsigned x)
 | 
			
		||||
static size_t align4u (size_t x)
 | 
			
		||||
{
 | 
			
		||||
  return (x + 3u) & (unsigned)-4;
 | 
			
		||||
  return (x + 3u) & ~(size_t)3;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int protocol_version_is_newer (nn_protocol_version_t pv)
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ static int protocol_version_is_newer (nn_protocol_version_t pv)
 | 
			
		|||
  return (pv.major < mv.major) ? 0 : (pv.major > mv.major) ? 1 : (pv.minor > mv.minor);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int validate_string (const struct dd *dd, unsigned *len)
 | 
			
		||||
static int validate_string (const struct dd *dd, size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  const struct cdrstring *x = (const struct cdrstring *) dd->buf;
 | 
			
		||||
  if (dd->bufsz < sizeof (struct cdrstring))
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ static int validate_string (const struct dd *dd, unsigned *len)
 | 
			
		|||
  *len = dd->bswap ? bswap4u (x->length) : x->length;
 | 
			
		||||
  if (*len < 1 || *len > dd->bufsz - offsetof (struct cdrstring, contents))
 | 
			
		||||
  {
 | 
			
		||||
    TRACE (("plist/validate_string: length %u out of range\n", *len));
 | 
			
		||||
    TRACE (("plist/validate_string: length %" PRIuSIZE " out of range\n", *len));
 | 
			
		||||
    return ERR_INVALID;
 | 
			
		||||
  }
 | 
			
		||||
  if (x->contents[*len-1] != 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ static int validate_string (const struct dd *dd, unsigned *len)
 | 
			
		|||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int alias_string (const unsigned char **ptr, const struct dd *dd, unsigned *len)
 | 
			
		||||
static int alias_string (const unsigned char **ptr, const struct dd *dd, size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  int rc;
 | 
			
		||||
  if ((rc = validate_string (dd, len)) < 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -153,7 +153,7 @@ static void unalias_string (char **str, int bswap)
 | 
			
		|||
  memcpy (*str, alias, len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int validate_octetseq (const struct dd *dd, unsigned *len)
 | 
			
		||||
static int validate_octetseq (const struct dd *dd, size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  const struct cdroctetseq *x = (const struct cdroctetseq *) dd->buf;
 | 
			
		||||
  if (dd->bufsz < offsetof (struct cdroctetseq, value))
 | 
			
		||||
| 
						 | 
				
			
			@ -166,14 +166,15 @@ static int validate_octetseq (const struct dd *dd, unsigned *len)
 | 
			
		|||
 | 
			
		||||
static int alias_octetseq (nn_octetseq_t *oseq, const struct dd *dd)
 | 
			
		||||
{
 | 
			
		||||
  unsigned len;
 | 
			
		||||
  size_t len;
 | 
			
		||||
  int rc;
 | 
			
		||||
  if ((rc = validate_octetseq (dd, &len)) < 0)
 | 
			
		||||
    return rc;
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    const struct cdroctetseq *x = (const struct cdroctetseq *) dd->buf;
 | 
			
		||||
    oseq->length = len;
 | 
			
		||||
    assert(len <= UINT32_MAX); /* it really is an uint32_t on the wire */
 | 
			
		||||
    oseq->length = (uint32_t)len;
 | 
			
		||||
    oseq->value = (len == 0) ? NULL : (unsigned char *) x->value;
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +182,8 @@ static int alias_octetseq (nn_octetseq_t *oseq, const struct dd *dd)
 | 
			
		|||
 | 
			
		||||
static int alias_blob (nn_octetseq_t *oseq, const struct dd *dd)
 | 
			
		||||
{
 | 
			
		||||
  oseq->length = dd->bufsz;
 | 
			
		||||
  assert (dd->bufsz <= UINT32_MAX);
 | 
			
		||||
  oseq->length = (uint32_t)dd->bufsz;
 | 
			
		||||
  oseq->value = (oseq->length == 0) ? NULL : (unsigned char *) dd->buf;
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -225,16 +227,16 @@ static int validate_stringseq (const struct dd *dd)
 | 
			
		|||
  {
 | 
			
		||||
    for (i = 0; i < n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      int rc;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t) (seqend - seq);
 | 
			
		||||
      if ((rc = validate_string (&dd1, &len1)) < 0)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("plist/validate_stringseq: invalid string\n"));
 | 
			
		||||
        return rc;
 | 
			
		||||
      }
 | 
			
		||||
      seq += sizeof (unsigned) + align4u (len1);
 | 
			
		||||
      seq += sizeof (uint32_t) + align4u (len1);
 | 
			
		||||
    }
 | 
			
		||||
    if (i < n)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -266,7 +268,7 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd)
 | 
			
		|||
  memcpy (&strseq->n, seq, sizeof (strseq->n));
 | 
			
		||||
  if (dd->bswap)
 | 
			
		||||
    strseq->n = bswap4u (strseq->n);
 | 
			
		||||
  seq += sizeof (unsigned);
 | 
			
		||||
  seq += sizeof (uint32_t);
 | 
			
		||||
  if (strseq->n >= UINT_MAX / sizeof(*strs))
 | 
			
		||||
  {
 | 
			
		||||
    TRACE (("plist/alias_stringseq: length %u out of range\n", strseq->n));
 | 
			
		||||
| 
						 | 
				
			
			@ -281,9 +283,9 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd)
 | 
			
		|||
    strs = os_malloc (strseq->n * sizeof (*strs));
 | 
			
		||||
    for (i = 0; i < strseq->n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t)(seqend - seq);
 | 
			
		||||
      /* (const char **) to silence the compiler, unfortunately strseq
 | 
			
		||||
         can't have a const char **strs, that would require a const
 | 
			
		||||
         and a non-const version of it. */
 | 
			
		||||
| 
						 | 
				
			
			@ -292,7 +294,7 @@ static int alias_stringseq (nn_stringseq_t *strseq, const struct dd *dd)
 | 
			
		|||
        TRACE (("plist/alias_stringseq: invalid string\n"));
 | 
			
		||||
        goto fail;
 | 
			
		||||
      }
 | 
			
		||||
      seq += sizeof (unsigned) + align4u (len1);
 | 
			
		||||
      seq += sizeof (uint32_t) + align4u (len1);
 | 
			
		||||
    }
 | 
			
		||||
    if (i != strseq->n)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -358,11 +360,11 @@ assert (dest->strs == NULL);
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int validate_property (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int validate_property (_In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  struct dd ddV = *dd;
 | 
			
		||||
  unsigned lenN;
 | 
			
		||||
  unsigned lenV;
 | 
			
		||||
  size_t lenN;
 | 
			
		||||
  size_t lenV;
 | 
			
		||||
  int rc;
 | 
			
		||||
 | 
			
		||||
  /* Check name. */
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +374,7 @@ static int validate_property (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		|||
    TRACE (("plist/validate_property: name validation failed\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenN = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenN = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u(lenN);     /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -385,7 +387,7 @@ static int validate_property (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		|||
    TRACE (("plist/validate_property: value validation failed\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenV = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenV = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u(lenV);     /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  *len = lenN + lenV;
 | 
			
		||||
| 
						 | 
				
			
			@ -394,11 +396,11 @@ static int validate_property (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  struct dd ddV = *dd;
 | 
			
		||||
  unsigned lenN;
 | 
			
		||||
  unsigned lenV;
 | 
			
		||||
  size_t lenN;
 | 
			
		||||
  size_t lenV;
 | 
			
		||||
  int rc;
 | 
			
		||||
 | 
			
		||||
  /* Get name */
 | 
			
		||||
| 
						 | 
				
			
			@ -408,7 +410,7 @@ static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd,
 | 
			
		|||
    TRACE (("plist/alias_property: invalid name buffer\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenN = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenN = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u(lenN);     /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* Get value */
 | 
			
		||||
| 
						 | 
				
			
			@ -420,7 +422,7 @@ static int alias_property (_Out_ nn_property_t *prop, _In_ const struct dd *dd,
 | 
			
		|||
    TRACE (("plist/validate_property: invalid value buffer\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenV = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenV = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u (lenV);    /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* We got this from the wire; so it has been propagated. */
 | 
			
		||||
| 
						 | 
				
			
			@ -453,7 +455,7 @@ static void duplicate_property (_Out_ nn_property_t *dest, _In_ const nn_propert
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int validate_propertyseq (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int validate_propertyseq (_In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  const unsigned char *seq = dd->buf;
 | 
			
		||||
  const unsigned char *seqend = seq + dd->bufsz;
 | 
			
		||||
| 
						 | 
				
			
			@ -481,10 +483,10 @@ static int validate_propertyseq (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		|||
  {
 | 
			
		||||
    for (i = 0; i < n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      int rc;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t) (seqend - seq);
 | 
			
		||||
      if ((rc = validate_property (&dd1, &len1)) != 0)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("plist/validate_propertyseq: invalid property\n"));
 | 
			
		||||
| 
						 | 
				
			
			@ -498,12 +500,12 @@ static int validate_propertyseq (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		|||
      return ERR_INVALID;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  *len = align4u((unsigned)(seq - dd->buf));
 | 
			
		||||
  *len = align4u((size_t)(seq - dd->buf));
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  /* Not truly an alias: it allocates an array of pointers that alias
 | 
			
		||||
     the individual components. Also: see validate_propertyseq */
 | 
			
		||||
| 
						 | 
				
			
			@ -522,7 +524,7 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd
 | 
			
		|||
  memcpy (&pseq->n, seq, sizeof (pseq->n));
 | 
			
		||||
  if (dd->bswap)
 | 
			
		||||
      pseq->n = bswap4u (pseq->n);
 | 
			
		||||
  seq += sizeof (unsigned);
 | 
			
		||||
  seq += sizeof (uint32_t);
 | 
			
		||||
  if (pseq->n >= UINT_MAX / sizeof(*props))
 | 
			
		||||
  {
 | 
			
		||||
    TRACE (("plist/alias_propertyseq: length %u out of range\n", pseq->n));
 | 
			
		||||
| 
						 | 
				
			
			@ -537,9 +539,9 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd
 | 
			
		|||
    props = os_malloc (pseq->n * sizeof (*props));
 | 
			
		||||
    for (i = 0; i < pseq->n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t) (seqend - seq);
 | 
			
		||||
      if ((result = alias_property (&props[i], &dd1, &len1)) != 0)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("plist/alias_propertyseq: invalid property\n"));
 | 
			
		||||
| 
						 | 
				
			
			@ -555,7 +557,7 @@ static int alias_propertyseq (_Out_ nn_propertyseq_t *pseq, _In_ const struct dd
 | 
			
		|||
    }
 | 
			
		||||
    pseq->props = props;
 | 
			
		||||
  }
 | 
			
		||||
  *len = align4u((unsigned)(seq - dd->buf));
 | 
			
		||||
  *len = align4u((size_t)(seq - dd->buf));
 | 
			
		||||
  return 0;
 | 
			
		||||
 fail:
 | 
			
		||||
  os_free (props);
 | 
			
		||||
| 
						 | 
				
			
			@ -608,11 +610,11 @@ static void duplicate_propertyseq (_Out_ nn_propertyseq_t *dest, _In_ const nn_p
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  struct dd ddV = *dd;
 | 
			
		||||
  unsigned lenN;
 | 
			
		||||
  unsigned lenV;
 | 
			
		||||
  size_t lenN;
 | 
			
		||||
  size_t lenV;
 | 
			
		||||
  int rc;
 | 
			
		||||
 | 
			
		||||
  /* Check name. */
 | 
			
		||||
| 
						 | 
				
			
			@ -622,7 +624,7 @@ static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ unsigned *le
 | 
			
		|||
    TRACE (("plist/validate_property: name validation failed\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenN = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenN = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u(lenN);     /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* Check value. */
 | 
			
		||||
| 
						 | 
				
			
			@ -634,7 +636,7 @@ static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ unsigned *le
 | 
			
		|||
    TRACE (("plist/validate_property: value validation failed\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenV = sizeof(unsigned) + /* cdr sequence len arg + */
 | 
			
		||||
  lenV = sizeof(uint32_t) + /* cdr sequence len arg + */
 | 
			
		||||
         align4u(lenV);     /* seqlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  *len = lenN + lenV;
 | 
			
		||||
| 
						 | 
				
			
			@ -643,11 +645,11 @@ static int validate_binaryproperty (_In_ const struct dd *dd, _Out_ unsigned *le
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  struct dd ddV = *dd;
 | 
			
		||||
  unsigned lenN;
 | 
			
		||||
  unsigned lenV;
 | 
			
		||||
  size_t lenN;
 | 
			
		||||
  size_t lenV;
 | 
			
		||||
  int rc;
 | 
			
		||||
 | 
			
		||||
  /* Get name */
 | 
			
		||||
| 
						 | 
				
			
			@ -657,7 +659,7 @@ static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const str
 | 
			
		|||
    TRACE (("plist/alias_property: invalid name buffer\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenN = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  lenN = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
         align4u(lenN);     /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* Get value */
 | 
			
		||||
| 
						 | 
				
			
			@ -669,7 +671,7 @@ static int alias_binaryproperty (_Out_ nn_binaryproperty_t *prop, _In_ const str
 | 
			
		|||
    TRACE (("plist/validate_property: invalid value buffer\n"));
 | 
			
		||||
    return rc;
 | 
			
		||||
  }
 | 
			
		||||
  lenV = sizeof(unsigned) +           /* cdr sequence len arg + */
 | 
			
		||||
  lenV = sizeof(uint32_t) +           /* cdr sequence len arg + */
 | 
			
		||||
         align4u(prop->value.length); /* seqlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* We got this from the wire; so it has been propagated. */
 | 
			
		||||
| 
						 | 
				
			
			@ -703,7 +705,7 @@ static void duplicate_binaryproperty (_Out_ nn_binaryproperty_t *dest, _In_ cons
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  const unsigned char *seq = dd->buf;
 | 
			
		||||
  const unsigned char *seqend = seq + dd->bufsz;
 | 
			
		||||
| 
						 | 
				
			
			@ -731,10 +733,10 @@ static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ unsigned
 | 
			
		|||
  {
 | 
			
		||||
    for (i = 0; i < n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      int rc;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t) (seqend - seq);
 | 
			
		||||
      if ((rc = validate_binaryproperty (&dd1, &len1)) != 0)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("plist/validate_binarypropertyseq: invalid property\n"));
 | 
			
		||||
| 
						 | 
				
			
			@ -748,12 +750,12 @@ static int validate_binarypropertyseq (_In_ const struct dd *dd, _Out_ unsigned
 | 
			
		|||
      return ERR_INVALID;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  *len = align4u((unsigned)(seq - dd->buf));
 | 
			
		||||
  *len = align4u((size_t)(seq - dd->buf));
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
_Success_(return == 0)
 | 
			
		||||
static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ const struct dd *dd, _Out_ unsigned *len)
 | 
			
		||||
static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ const struct dd *dd, _Out_ size_t *len)
 | 
			
		||||
{
 | 
			
		||||
  /* Not truly an alias: it allocates an array of pointers that alias
 | 
			
		||||
     the individual components. Also: see validate_binarypropertyseq */
 | 
			
		||||
| 
						 | 
				
			
			@ -772,7 +774,7 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con
 | 
			
		|||
  memcpy (&pseq->n, seq, sizeof (pseq->n));
 | 
			
		||||
  if (dd->bswap)
 | 
			
		||||
      pseq->n = bswap4u (pseq->n);
 | 
			
		||||
  seq += sizeof (unsigned);
 | 
			
		||||
  seq += sizeof (uint32_t);
 | 
			
		||||
  if (pseq->n >= UINT_MAX / sizeof(*props))
 | 
			
		||||
  {
 | 
			
		||||
    TRACE (("plist/alias_binarypropertyseq: length %u out of range\n", pseq->n));
 | 
			
		||||
| 
						 | 
				
			
			@ -787,9 +789,9 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con
 | 
			
		|||
    props = os_malloc (pseq->n * sizeof (*props));
 | 
			
		||||
    for (i = 0; i < pseq->n && seq <= seqend; i++)
 | 
			
		||||
    {
 | 
			
		||||
      unsigned len1;
 | 
			
		||||
      size_t len1;
 | 
			
		||||
      dd1.buf = seq;
 | 
			
		||||
      dd1.bufsz = (unsigned) (seqend - seq);
 | 
			
		||||
      dd1.bufsz = (size_t) (seqend - seq);
 | 
			
		||||
      if ((result = alias_binaryproperty (&props[i], &dd1, &len1)) != 0)
 | 
			
		||||
      {
 | 
			
		||||
        TRACE (("plist/alias_binarypropertyseq: invalid property\n"));
 | 
			
		||||
| 
						 | 
				
			
			@ -805,7 +807,7 @@ static int alias_binarypropertyseq (_Out_ nn_binarypropertyseq_t *pseq, _In_ con
 | 
			
		|||
    }
 | 
			
		||||
    pseq->props = props;
 | 
			
		||||
  }
 | 
			
		||||
  *len = align4u((unsigned)(seq - dd->buf));
 | 
			
		||||
  *len = align4u((size_t)(seq - dd->buf));
 | 
			
		||||
  return 0;
 | 
			
		||||
 fail:
 | 
			
		||||
  os_free (props);
 | 
			
		||||
| 
						 | 
				
			
			@ -1012,7 +1014,7 @@ void nn_plist_unalias (nn_plist_t *ps)
 | 
			
		|||
static int do_octetseq (nn_octetseq_t *dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd)
 | 
			
		||||
{
 | 
			
		||||
  int res;
 | 
			
		||||
  unsigned len;
 | 
			
		||||
  size_t len;
 | 
			
		||||
  if (!(wanted & fl))
 | 
			
		||||
    return NN_STRICT_P ? validate_octetseq (dd, &len) : 0;
 | 
			
		||||
  if ((res = alias_octetseq (dst, dd)) >= 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -1039,7 +1041,7 @@ static int do_blob (nn_octetseq_t *dst, uint64_t *present, uint64_t *aliased, ui
 | 
			
		|||
static int do_string (char **dst, uint64_t *present, uint64_t *aliased, uint64_t wanted, uint64_t fl, const struct dd *dd)
 | 
			
		||||
{
 | 
			
		||||
  int res;
 | 
			
		||||
  unsigned len;
 | 
			
		||||
  size_t len;
 | 
			
		||||
  if (!(wanted & fl))
 | 
			
		||||
    return NN_STRICT_P ? validate_string (dd, &len) : 0;
 | 
			
		||||
  if ((res = alias_string ((const unsigned char **) dst, dd, &len)) >= 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -1321,7 +1323,7 @@ int validate_liveliness_qospolicy (const nn_liveliness_qospolicy_t *q)
 | 
			
		|||
 | 
			
		||||
static void bswap_external_reliability_qospolicy (nn_external_reliability_qospolicy_t *qext)
 | 
			
		||||
{
 | 
			
		||||
  qext->kind = bswap4 (qext->kind);
 | 
			
		||||
  qext->kind = bswap4u (qext->kind);
 | 
			
		||||
  bswap_duration (&qext->max_blocking_time);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1915,9 +1917,9 @@ static int do_prismtech_participant_version_info (nn_prismtech_participant_versi
 | 
			
		|||
  else
 | 
			
		||||
  {
 | 
			
		||||
    int res;
 | 
			
		||||
    unsigned sz = NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE - sizeof(unsigned);
 | 
			
		||||
    unsigned *pu = (unsigned *)dd->buf;
 | 
			
		||||
    unsigned len;
 | 
			
		||||
    unsigned sz = NN_PRISMTECH_PARTICIPANT_VERSION_INFO_FIXED_CDRSIZE - sizeof(uint32_t);
 | 
			
		||||
    uint32_t *pu = (uint32_t *)dd->buf;
 | 
			
		||||
    size_t len;
 | 
			
		||||
    struct dd dd1 = *dd;
 | 
			
		||||
 | 
			
		||||
    memcpy (pvi, dd->buf, sz);
 | 
			
		||||
| 
						 | 
				
			
			@ -2069,7 +2071,7 @@ _Success_(return == 0)
 | 
			
		|||
static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present, _Inout_ uint64_t *aliased, _In_ uint64_t wanted, _In_ uint64_t fl, _In_ const struct dd *dd)
 | 
			
		||||
{
 | 
			
		||||
  struct dd ddtmp = *dd;
 | 
			
		||||
  unsigned len;
 | 
			
		||||
  size_t len;
 | 
			
		||||
  int res;
 | 
			
		||||
 | 
			
		||||
  memset(dh, 0, sizeof(nn_dataholder_t));
 | 
			
		||||
| 
						 | 
				
			
			@ -2082,7 +2084,7 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present,
 | 
			
		|||
      /* check class_id */
 | 
			
		||||
      if ((res = validate_string (&ddtmp, &len)) == 0)
 | 
			
		||||
      {
 | 
			
		||||
        len = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
        len = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
              align4u(len);      /* strlen + possible padding */
 | 
			
		||||
        /* check properties */
 | 
			
		||||
        ddtmp.buf = &(dd->buf[len]);
 | 
			
		||||
| 
						 | 
				
			
			@ -2117,7 +2119,7 @@ static int do_dataholder (_Out_ nn_dataholder_t *dh, _Inout_ uint64_t *present,
 | 
			
		|||
    TRACE (("plist/do_dataholder: invalid class_id\n"));
 | 
			
		||||
    return res;
 | 
			
		||||
  }
 | 
			
		||||
  len = sizeof(unsigned) + /* cdr string len arg + */
 | 
			
		||||
  len = sizeof(uint32_t) + /* cdr string len arg + */
 | 
			
		||||
        align4u(len);      /* strlen + possible padding */
 | 
			
		||||
 | 
			
		||||
  /* get properties */
 | 
			
		||||
| 
						 | 
				
			
			@ -3046,7 +3048,7 @@ int nn_plist_init_frommsg
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    dd.buf = (const unsigned char *) (par + 1);
 | 
			
		||||
    dd.bufsz = (unsigned) length;
 | 
			
		||||
    dd.bufsz = length;
 | 
			
		||||
    if ((res = init_one_parameter (dest, &dest_tmp, pwanted, qwanted, pid, &dd)) < 0)
 | 
			
		||||
    {
 | 
			
		||||
      /* make sure we print a trace message on error */
 | 
			
		||||
| 
						 | 
				
			
			@ -3070,7 +3072,7 @@ unsigned char *nn_plist_quickscan (struct nn_rsample_info *dest, const struct nn
 | 
			
		|||
     following parameter list, or NULL on error.  Most errors will go
 | 
			
		||||
     undetected, unlike nn_plist_init_frommsg(). */
 | 
			
		||||
  const unsigned char *pl;
 | 
			
		||||
 | 
			
		||||
  (void)rmsg;
 | 
			
		||||
  dest->statusinfo = 0;
 | 
			
		||||
  dest->pt_wr_info_zoff = NN_OFF_TO_ZOFF (0);
 | 
			
		||||
  dest->complex_qos = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1067,7 +1067,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
 | 
			
		|||
       gradually lowering rate.  If we just got a request for a
 | 
			
		||||
       retransmit, and there is more to be retransmitted, surely the
 | 
			
		||||
       rate should be kept up for now */
 | 
			
		||||
    writer_hbcontrol_note_asyncwrite (wr, &whcst, now_mt ());
 | 
			
		||||
    writer_hbcontrol_note_asyncwrite (wr, now_mt ());
 | 
			
		||||
  }
 | 
			
		||||
  /* If "final" flag not set, we must respond with a heartbeat. Do it
 | 
			
		||||
     now if we haven't done so already */
 | 
			
		||||
| 
						 | 
				
			
			@ -1543,7 +1543,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
 | 
			
		|||
    struct whc_state whcst;
 | 
			
		||||
    wr->whc->ops->get_state(wr->whc, &whcst);
 | 
			
		||||
    force_heartbeat_to_peer (wr, &whcst, prd, 1);
 | 
			
		||||
    writer_hbcontrol_note_asyncwrite (wr, &whcst, now_mt ());
 | 
			
		||||
    writer_hbcontrol_note_asyncwrite (wr, now_mt ());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 out:
 | 
			
		||||
| 
						 | 
				
			
			@ -1792,11 +1792,12 @@ static serstate_t make_raw_serstate
 | 
			
		|||
)
 | 
			
		||||
{
 | 
			
		||||
  serstate_t st = ddsi_serstate_new (topic);
 | 
			
		||||
  ddsi_serstate_set_msginfo (st, statusinfo, tstamp, NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (st, statusinfo, tstamp);
 | 
			
		||||
  st->kind = justkey ? STK_KEY : STK_DATA;
 | 
			
		||||
  /* the CDR header is always fully contained in the first fragment
 | 
			
		||||
     (see valid_DataFrag), so extracting it is easy */
 | 
			
		||||
  assert (fragchain->min == 0);
 | 
			
		||||
  (void)sz;
 | 
			
		||||
 | 
			
		||||
  /* alignment at head-of-stream is guaranteed, requesting 1 byte
 | 
			
		||||
     alignment is therefore fine for pasting together fragments of
 | 
			
		||||
| 
						 | 
				
			
			@ -1891,7 +1892,7 @@ static serdata_t extract_sample_from_data
 | 
			
		|||
    {
 | 
			
		||||
      serstate_t st;
 | 
			
		||||
      st = ddsi_serstate_new (topic);
 | 
			
		||||
      ddsi_serstate_set_msginfo (st, statusinfo, tstamp, NULL);
 | 
			
		||||
      ddsi_serstate_set_msginfo (st, statusinfo, tstamp);
 | 
			
		||||
      st->kind = STK_KEY;
 | 
			
		||||
      ddsi_serstate_append_blob (st, 1, sizeof (qos->keyhash), qos->keyhash.value);
 | 
			
		||||
      sample = ddsi_serstate_fix_with_key (st, topic, sampleinfo->bswap);
 | 
			
		||||
| 
						 | 
				
			
			@ -3285,8 +3286,8 @@ static int check_and_handle_deafness_recover(struct local_deaf_state *st)
 | 
			
		|||
      ddsi_conn_free(data);
 | 
			
		||||
      rebuildws = 1;
 | 
			
		||||
      st->state = LDSR_REJOIN;
 | 
			
		||||
      /* FALLS THROUGH */
 | 
			
		||||
    }
 | 
			
		||||
      /* FALLS THROUGH */
 | 
			
		||||
    case LDSR_REJOIN:
 | 
			
		||||
      TRACE(("check_and_handle_deafness_recover: state %d rejoin on disc socket\n", (int)st->state));
 | 
			
		||||
      if (ddsi_rejoin_transferred_mcgroups(gv.disc_conn_mc) < 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "os/os.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ cleanup_thread_state(
 | 
			
		|||
    _In_opt_ void *data)
 | 
			
		||||
{
 | 
			
		||||
    struct thread_state1 *ts = get_thread_state(os_threadIdSelf());
 | 
			
		||||
 | 
			
		||||
    (void)data;
 | 
			
		||||
    assert(ts->state == THREAD_STATE_ALIVE);
 | 
			
		||||
    assert(vtime_asleep_p(ts->vtime));
 | 
			
		||||
    reset_thread_state(ts);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ int64_t writer_hbcontrol_intv (const struct writer *wr, const struct whc_state *
 | 
			
		|||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void writer_hbcontrol_note_asyncwrite (struct writer *wr, const struct whc_state *whcst, nn_mtime_t tnow)
 | 
			
		||||
void writer_hbcontrol_note_asyncwrite (struct writer *wr, nn_mtime_t tnow)
 | 
			
		||||
{
 | 
			
		||||
  struct hbcontrol * const hbc = &wr->hbcontrol;
 | 
			
		||||
  nn_mtime_t tnext;
 | 
			
		||||
| 
						 | 
				
			
			@ -284,7 +284,7 @@ struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_
 | 
			
		|||
  /* Update statistics, intervals, scheduling of heartbeat event,
 | 
			
		||||
     &c. -- there's no real difference between async and sync so we
 | 
			
		||||
     reuse the async version. */
 | 
			
		||||
  writer_hbcontrol_note_asyncwrite (wr, whcst, tnow);
 | 
			
		||||
  writer_hbcontrol_note_asyncwrite (wr, tnow);
 | 
			
		||||
 | 
			
		||||
  *hbansreq = writer_hbcontrol_ack_required_generic (wr, whcst, tlast, tnow, 1);
 | 
			
		||||
  if (*hbansreq >= 2) {
 | 
			
		||||
| 
						 | 
				
			
			@ -467,6 +467,7 @@ int create_fragment_message (struct writer *wr, seqno_t seq, const struct nn_pli
 | 
			
		|||
  unsigned fragstart, fraglen;
 | 
			
		||||
  enum nn_xmsg_kind xmsg_kind = isnew ? NN_XMSG_KIND_DATA : NN_XMSG_KIND_DATA_REXMIT;
 | 
			
		||||
  int ret = 0;
 | 
			
		||||
  (void)plist;
 | 
			
		||||
 | 
			
		||||
  ASSERT_MUTEX_HELD (&wr->e.lock);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -920,7 +921,9 @@ static os_result throttle_writer (struct nn_xpack *xp, struct writer *wr)
 | 
			
		|||
  wr->whc->ops->get_state(wr->whc, &whcst);
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
#ifndef NDEBUG
 | 
			
		||||
    nn_vendorid_t ownvendorid = MY_VENDOR_ID;
 | 
			
		||||
#endif
 | 
			
		||||
    ASSERT_MUTEX_HELD (&wr->e.lock);
 | 
			
		||||
    assert (wr->throttling == 0);
 | 
			
		||||
    assert (vtime_awake_p (lookup_thread_state ()->vtime));
 | 
			
		||||
| 
						 | 
				
			
			@ -1004,6 +1007,7 @@ static int write_sample_eot (struct nn_xpack *xp, struct writer *wr, struct nn_p
 | 
			
		|||
 | 
			
		||||
  /* If GC not allowed, we must be sure to never block when writing.  That is only the case for (true, aggressive) KEEP_LAST writers, and also only if there is no limit to how much unacknowledged data the WHC may contain. */
 | 
			
		||||
  assert(gc_allowed || (wr->xqos->history.kind == NN_KEEP_LAST_HISTORY_QOS && wr->aggressive_keep_last && wr->whc_low == INT32_MAX));
 | 
			
		||||
  (void)gc_allowed;
 | 
			
		||||
 | 
			
		||||
  if (ddsi_serdata_size (serdata) > config.max_sample_size)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -1112,7 +1116,7 @@ static int write_sample_eot (struct nn_xpack *xp, struct writer *wr, struct nn_p
 | 
			
		|||
    else
 | 
			
		||||
    {
 | 
			
		||||
      if (wr->heartbeat_xevent)
 | 
			
		||||
        writer_hbcontrol_note_asyncwrite (wr, &whcst, tnow);
 | 
			
		||||
        writer_hbcontrol_note_asyncwrite (wr, tnow);
 | 
			
		||||
      enqueue_sample_wrlock_held (wr, seq, plist, serdata, NULL, 1);
 | 
			
		||||
      os_mutexUnlock (&wr->e.lock);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1138,7 +1138,7 @@ static void write_pmd_message (struct nn_xpack *xp, struct participant *pp, unsi
 | 
			
		|||
  serstate = ddsi_serstate_new (NULL);
 | 
			
		||||
  ddsi_serstate_append_blob (serstate, 4, sizeof (u.pad), &u.pmd);
 | 
			
		||||
  serstate_set_key (serstate, 0, &u.pmd);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now (), NULL);
 | 
			
		||||
  ddsi_serstate_set_msginfo (serstate, 0, now ());
 | 
			
		||||
  serdata = ddsi_serstate_fix (serstate);
 | 
			
		||||
 | 
			
		||||
  /* HORRIBLE HACK ALERT -- serstate/serdata looks at whether topic is
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -230,9 +230,9 @@ struct nn_xpack
 | 
			
		|||
#endif /* DDSI_INCLUDE_ENCRYPTION */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static unsigned align4u (unsigned x)
 | 
			
		||||
static size_t align4u (size_t x)
 | 
			
		||||
{
 | 
			
		||||
  return (x + 3u) & (unsigned)-4;
 | 
			
		||||
  return (x + 3) & ~(size_t)3;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* XMSGPOOL ------------------------------------------------------------
 | 
			
		||||
| 
						 | 
				
			
			@ -472,7 +472,7 @@ void nn_xmsg_submsg_init (struct nn_xmsg *msg, struct nn_xmsg_marker marker, Sub
 | 
			
		|||
{
 | 
			
		||||
  SubmessageHeader_t *hdr = (SubmessageHeader_t *) (msg->data->payload + marker.offset);
 | 
			
		||||
  assert (submsg_is_compatible (msg, smkind));
 | 
			
		||||
  hdr->submessageId = smkind;
 | 
			
		||||
  hdr->submessageId = (unsigned char)smkind;
 | 
			
		||||
  hdr->flags = PLATFORM_IS_LITTLE_ENDIAN ? SMFLAG_ENDIANNESS : 0;
 | 
			
		||||
  hdr->octetsToNextHeader = 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -554,15 +554,15 @@ void nn_xmsg_add_entityid (struct nn_xmsg * m)
 | 
			
		|||
  nn_xmsg_submsg_setnext (m, sm);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void nn_xmsg_serdata (struct nn_xmsg *m, serdata_t serdata, unsigned off, unsigned len)
 | 
			
		||||
void nn_xmsg_serdata (struct nn_xmsg *m, serdata_t serdata, size_t off, size_t len)
 | 
			
		||||
{
 | 
			
		||||
  if (!ddsi_serdata_is_empty (serdata))
 | 
			
		||||
  {
 | 
			
		||||
    unsigned len4 = align4u (len);
 | 
			
		||||
    size_t len4 = align4u (len);
 | 
			
		||||
    assert (m->refd_payload == NULL);
 | 
			
		||||
    m->refd_payload = ddsi_serdata_ref (serdata);
 | 
			
		||||
    m->refd_payload_iov.iov_base = (char *) &m->refd_payload->hdr + off;
 | 
			
		||||
    m->refd_payload_iov.iov_len = len4;
 | 
			
		||||
    m->refd_payload_iov.iov_len = (ddsi_iov_len_t) len4;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -752,13 +752,14 @@ void nn_xmsg_setwriterseq_fragid (struct nn_xmsg *msg, const nn_guid_t *wrguid,
 | 
			
		|||
  msg->kindspecific.data.wrfragid = wrfragid;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned nn_xmsg_add_string_padded(_Inout_opt_ unsigned char *buf, _In_ char *str)
 | 
			
		||||
size_t nn_xmsg_add_string_padded(_Inout_opt_ unsigned char *buf, _In_ char *str)
 | 
			
		||||
{
 | 
			
		||||
  unsigned len = (unsigned) strlen (str) + 1;
 | 
			
		||||
  size_t len = strlen (str) + 1;
 | 
			
		||||
  assert (len <= UINT32_MAX);
 | 
			
		||||
  if (buf) {
 | 
			
		||||
    /* Add cdr string */
 | 
			
		||||
    struct cdrstring *p = (struct cdrstring *) buf;
 | 
			
		||||
    p->length = len;
 | 
			
		||||
    p->length = (uint32_t)len;
 | 
			
		||||
    memcpy (p->contents, str, len);
 | 
			
		||||
    /* clear padding */
 | 
			
		||||
    if (len < align4u (len)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -770,7 +771,7 @@ unsigned nn_xmsg_add_string_padded(_Inout_opt_ unsigned char *buf, _In_ char *st
 | 
			
		|||
  return len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned nn_xmsg_add_octseq_padded(_Inout_opt_ unsigned char *buf, _In_ nn_octetseq_t *seq)
 | 
			
		||||
size_t nn_xmsg_add_octseq_padded(_Inout_opt_ unsigned char *buf, _In_ nn_octetseq_t *seq)
 | 
			
		||||
{
 | 
			
		||||
  unsigned len = seq->length;
 | 
			
		||||
  if (buf) {
 | 
			
		||||
| 
						 | 
				
			
			@ -783,15 +784,15 @@ unsigned nn_xmsg_add_octseq_padded(_Inout_opt_ unsigned char *buf, _In_ nn_octet
 | 
			
		|||
      memset (buf + len, 0, align4u (len) - len);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  len = 4 +           /* cdr sequence len arg + */
 | 
			
		||||
        align4u(len); /* seqlen + possible padding */
 | 
			
		||||
  return len;
 | 
			
		||||
  return 4 +           /* cdr sequence len arg + */
 | 
			
		||||
         align4u(len); /* seqlen + possible padding */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
unsigned nn_xmsg_add_dataholder_padded (_Inout_opt_ unsigned char *buf, const struct nn_dataholder *dh)
 | 
			
		||||
size_t nn_xmsg_add_dataholder_padded (_Inout_opt_ unsigned char *buf, const struct nn_dataholder *dh)
 | 
			
		||||
{
 | 
			
		||||
  unsigned i, len;
 | 
			
		||||
  unsigned i;
 | 
			
		||||
  size_t len;
 | 
			
		||||
  unsigned dummy = 0;
 | 
			
		||||
  unsigned *cnt = &dummy;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -870,7 +871,8 @@ void nn_xmsg_addpar_octetseq (struct nn_xmsg *m, unsigned pid, const nn_octetseq
 | 
			
		|||
void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, unsigned pid, const nn_stringseq_t *sseq)
 | 
			
		||||
{
 | 
			
		||||
  unsigned char *tmp;
 | 
			
		||||
  unsigned i, len = 0;
 | 
			
		||||
  uint32_t i;
 | 
			
		||||
  size_t len = 0;
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < sseq->n; i++)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -879,8 +881,8 @@ void nn_xmsg_addpar_stringseq (struct nn_xmsg *m, unsigned pid, const nn_strings
 | 
			
		|||
 | 
			
		||||
  tmp = nn_xmsg_addpar (m, pid, 4 + len);
 | 
			
		||||
 | 
			
		||||
  *((unsigned *) tmp) = sseq->n;
 | 
			
		||||
  tmp += sizeof (int);
 | 
			
		||||
  *((uint32_t *) tmp) = sseq->n;
 | 
			
		||||
  tmp += sizeof (uint32_t);
 | 
			
		||||
  for (i = 0; i < sseq->n; i++)
 | 
			
		||||
  {
 | 
			
		||||
    tmp += nn_xmsg_add_string_padded(tmp, sseq->strs[i]);
 | 
			
		||||
| 
						 | 
				
			
			@ -995,11 +997,12 @@ void nn_xmsg_addpar_share (struct nn_xmsg *m, unsigned pid, const struct nn_shar
 | 
			
		|||
void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, unsigned pid, const struct nn_subscription_keys_qospolicy *q)
 | 
			
		||||
{
 | 
			
		||||
  unsigned char *tmp;
 | 
			
		||||
  unsigned i, len = 8; /* use_key_list, length of key_list */
 | 
			
		||||
  size_t len = 8; /* use_key_list, length of key_list */
 | 
			
		||||
  unsigned i;
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < q->key_list.n; i++)
 | 
			
		||||
  {
 | 
			
		||||
    unsigned len1 = (unsigned) strlen (q->key_list.strs[i]) + 1;
 | 
			
		||||
    size_t len1 = strlen (q->key_list.strs[i]) + 1;
 | 
			
		||||
    len += 4 + align4u (len1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1011,13 +1014,14 @@ void nn_xmsg_addpar_subscription_keys (struct nn_xmsg *m, unsigned pid, const st
 | 
			
		|||
      tmp[i] = 0;
 | 
			
		||||
  }
 | 
			
		||||
  tmp += sizeof (int);
 | 
			
		||||
  *((unsigned *) tmp) = q->key_list.n;
 | 
			
		||||
  tmp += sizeof (unsigned);
 | 
			
		||||
  *((uint32_t *) tmp) = q->key_list.n;
 | 
			
		||||
  tmp += sizeof (uint32_t);
 | 
			
		||||
  for (i = 0; i < q->key_list.n; i++)
 | 
			
		||||
  {
 | 
			
		||||
    struct cdrstring *p = (struct cdrstring *) tmp;
 | 
			
		||||
    unsigned len1 = (unsigned) strlen (q->key_list.strs[i]) + 1;
 | 
			
		||||
    p->length = len1;
 | 
			
		||||
    size_t len1 = strlen (q->key_list.strs[i]) + 1;
 | 
			
		||||
    assert (len1 <= UINT32_MAX);
 | 
			
		||||
    p->length = (uint32_t)len1;
 | 
			
		||||
    memcpy (p->contents, q->key_list.strs[i], len1);
 | 
			
		||||
    if (len1 < align4u (len1))
 | 
			
		||||
      memset (p->contents + len1, 0, align4u (len1) - len1);
 | 
			
		||||
| 
						 | 
				
			
			@ -1077,7 +1081,7 @@ void nn_xmsg_addpar_eotinfo (struct nn_xmsg *m, unsigned pid, const struct nn_pr
 | 
			
		|||
void nn_xmsg_addpar_dataholder (_In_ struct nn_xmsg *m, _In_ unsigned pid, _In_ const struct nn_dataholder *dh)
 | 
			
		||||
{
 | 
			
		||||
    unsigned char *tmp;
 | 
			
		||||
    unsigned len;
 | 
			
		||||
    size_t len;
 | 
			
		||||
 | 
			
		||||
    /* Get total payload length. */
 | 
			
		||||
    len = nn_xmsg_add_dataholder_padded(NULL, dh);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,8 @@ int main (int argc, char ** argv)
 | 
			
		|||
    dds_entity_t writer;
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    HelloWorldData_Msg msg;
 | 
			
		||||
    (void)argc;
 | 
			
		||||
    (void)argv;
 | 
			
		||||
 | 
			
		||||
    /* Create a Participant. */
 | 
			
		||||
    participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,8 @@ int main (int argc, char ** argv)
 | 
			
		|||
    dds_sample_info_t infos[MAX_SAMPLES];
 | 
			
		||||
    dds_return_t ret;
 | 
			
		||||
    dds_qos_t *qos;
 | 
			
		||||
    (void)argc;
 | 
			
		||||
    (void)argv;
 | 
			
		||||
 | 
			
		||||
    /* Create a Participant. */
 | 
			
		||||
    participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,7 +65,7 @@ static ExampleTimeStats *exampleAddTimingToTimeStats
 | 
			
		|||
  {
 | 
			
		||||
    stats->values[stats->valuesSize++] = timing;
 | 
			
		||||
  }
 | 
			
		||||
  stats->average = (stats->count * stats->average + timing) / (stats->count + 1);
 | 
			
		||||
  stats->average = ((double)stats->count * stats->average + (double)timing) / (double)(stats->count + 1);
 | 
			
		||||
  stats->min = (stats->count == 0 || timing < stats->min) ? timing : stats->min;
 | 
			
		||||
  stats->max = (stats->count == 0 || timing > stats->max) ? timing : stats->max;
 | 
			
		||||
  stats->count++;
 | 
			
		||||
| 
						 | 
				
			
			@ -117,8 +117,9 @@ static bool CtrlHandler (DWORD fdwCtrlType)
 | 
			
		|||
  return true; //Don't let other handlers handle this key
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
static void CtrlHandler (int fdwCtrlType)
 | 
			
		||||
static void CtrlHandler (int sig)
 | 
			
		||||
{
 | 
			
		||||
  (void)sig;
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -149,14 +150,14 @@ static dds_time_t elapsed = 0;
 | 
			
		|||
 | 
			
		||||
static bool warmUp = true;
 | 
			
		||||
 | 
			
		||||
static void data_available(dds_entity_t reader, void *arg)
 | 
			
		||||
static void data_available(dds_entity_t rd, void *arg)
 | 
			
		||||
{
 | 
			
		||||
  dds_time_t difference = 0;
 | 
			
		||||
  int status;
 | 
			
		||||
  (void)arg;
 | 
			
		||||
  /* Take sample and check that it is valid */
 | 
			
		||||
  preTakeTime = dds_time ();
 | 
			
		||||
  status = dds_take (reader, samples, info, MAX_SAMPLES, MAX_SAMPLES);
 | 
			
		||||
  status = dds_take (rd, samples, info, MAX_SAMPLES, MAX_SAMPLES);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  postTakeTime = dds_time ();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -218,8 +219,8 @@ static void usage(void)
 | 
			
		|||
 | 
			
		||||
int main (int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
  unsigned long payloadSize = 0;
 | 
			
		||||
  unsigned long long numSamples = 0;
 | 
			
		||||
  uint32_t payloadSize = 0;
 | 
			
		||||
  uint64_t numSamples = 0;
 | 
			
		||||
  bool invalidargs = false;
 | 
			
		||||
  dds_time_t timeOut = 0;
 | 
			
		||||
  dds_time_t time;
 | 
			
		||||
| 
						 | 
				
			
			@ -271,9 +272,11 @@ int main (int argc, char *argv[])
 | 
			
		|||
  participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  listener = dds_listener_create(NULL);
 | 
			
		||||
  dds_lset_data_available(listener, data_available);
 | 
			
		||||
 | 
			
		||||
  if (use_listener)
 | 
			
		||||
  {
 | 
			
		||||
    listener = dds_listener_create(NULL);
 | 
			
		||||
    dds_lset_data_available(listener, data_available);
 | 
			
		||||
  }
 | 
			
		||||
  prepare_dds(&writer, &reader, &readCond, listener);
 | 
			
		||||
 | 
			
		||||
  setvbuf(stdout, NULL, _IONBF, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +303,7 @@ int main (int argc, char *argv[])
 | 
			
		|||
  }
 | 
			
		||||
  if (argc - argidx >= 1)
 | 
			
		||||
  {
 | 
			
		||||
    payloadSize = atol (argv[argidx]);
 | 
			
		||||
    payloadSize = (uint32_t) atol (argv[argidx]);
 | 
			
		||||
 | 
			
		||||
    if (payloadSize > 100 * 1048576)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +312,7 @@ int main (int argc, char *argv[])
 | 
			
		|||
  }
 | 
			
		||||
  if (argc - argidx >= 2)
 | 
			
		||||
  {
 | 
			
		||||
    numSamples = atol (argv[argidx+1]);
 | 
			
		||||
    numSamples = (uint64_t) atol (argv[argidx+1]);
 | 
			
		||||
  }
 | 
			
		||||
  if (argc - argidx >= 3)
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -317,7 +320,7 @@ int main (int argc, char *argv[])
 | 
			
		|||
  }
 | 
			
		||||
  if (invalidargs || (argc - argidx == 1 && (strcmp (argv[argidx], "-h") == 0 || strcmp (argv[argidx], "--help") == 0)))
 | 
			
		||||
    usage();
 | 
			
		||||
  printf ("# payloadSize: %lu | numSamples: %llu | timeOut: %" PRIi64 "\n\n", payloadSize, numSamples, timeOut);
 | 
			
		||||
  printf ("# payloadSize: %" PRIu32 " | numSamples: %" PRIu64 " | timeOut: %" PRIi64 "\n\n", payloadSize, numSamples, timeOut);
 | 
			
		||||
 | 
			
		||||
  pub_data.payload._length = payloadSize;
 | 
			
		||||
  pub_data.payload._buffer = payloadSize ? dds_alloc (payloadSize) : NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -418,7 +421,7 @@ done:
 | 
			
		|||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *writer, dds_entity_t *reader, dds_entity_t *readCond, dds_listener_t *listener)
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t *rdcond, dds_listener_t *listener)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
  dds_entity_t topic;
 | 
			
		||||
| 
						 | 
				
			
			@ -448,8 +451,8 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, dds_entity_t *reader, dds_
 | 
			
		|||
  dwQos = dds_qos_create ();
 | 
			
		||||
  dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
 | 
			
		||||
  dds_qset_writer_data_lifecycle (dwQos, false);
 | 
			
		||||
  *writer = dds_create_writer (publisher, topic, dwQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (*writer, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  *wr = dds_create_writer (publisher, topic, dwQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (*wr, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (dwQos);
 | 
			
		||||
 | 
			
		||||
  /* A DDS_Subscriber is created on the domain participant. */
 | 
			
		||||
| 
						 | 
				
			
			@ -463,17 +466,17 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, dds_entity_t *reader, dds_
 | 
			
		|||
  /* A DDS_DataReader is created on the Subscriber & Topic with a modified QoS. */
 | 
			
		||||
  drQos = dds_qos_create ();
 | 
			
		||||
  dds_qset_reliability (drQos, DDS_RELIABILITY_RELIABLE, DDS_SECS(10));
 | 
			
		||||
  *reader = dds_create_reader (subscriber, topic, drQos, listener);
 | 
			
		||||
  DDS_ERR_CHECK (*reader, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  *rd = dds_create_reader (subscriber, topic, drQos, listener);
 | 
			
		||||
  DDS_ERR_CHECK (*rd, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (drQos);
 | 
			
		||||
 | 
			
		||||
  waitSet = dds_create_waitset (participant);
 | 
			
		||||
  if (listener == NULL) {
 | 
			
		||||
    *readCond = dds_create_readcondition (*reader, DDS_ANY_STATE);
 | 
			
		||||
    status = dds_waitset_attach (waitSet, *readCond, *reader);
 | 
			
		||||
    *rdcond = dds_create_readcondition (*rd, DDS_ANY_STATE);
 | 
			
		||||
    status = dds_waitset_attach (waitSet, *rdcond, *rd);
 | 
			
		||||
    DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  } else {
 | 
			
		||||
    *readCond = 0;
 | 
			
		||||
    *rdcond = 0;
 | 
			
		||||
  }
 | 
			
		||||
  status = dds_waitset_attach (waitSet, waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
| 
						 | 
				
			
			@ -481,19 +484,19 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, dds_entity_t *reader, dds_
 | 
			
		|||
  return participant;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void finalize_dds(dds_entity_t participant, dds_entity_t reader, dds_entity_t readCond)
 | 
			
		||||
static void finalize_dds(dds_entity_t ppant, dds_entity_t rd, dds_entity_t rdcond)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
 | 
			
		||||
  /* Disable callbacks */
 | 
			
		||||
  dds_set_enabled_status (reader, 0);
 | 
			
		||||
  dds_set_enabled_status (rd, 0);
 | 
			
		||||
 | 
			
		||||
  (void) dds_waitset_detach (waitSet, readCond);
 | 
			
		||||
  (void) dds_waitset_detach (waitSet, rdcond);
 | 
			
		||||
  status = dds_waitset_detach (waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  (void) dds_delete (readCond);
 | 
			
		||||
  (void) dds_delete (rdcond);
 | 
			
		||||
  status = dds_delete (waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (participant);
 | 
			
		||||
  status = dds_delete (ppant);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,9 @@ static bool CtrlHandler (DWORD fdwCtrlType)
 | 
			
		|||
  return true; //Don't let other handlers handle this key
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
static void CtrlHandler (int fdwCtrlType)
 | 
			
		||||
static void CtrlHandler (int sig)
 | 
			
		||||
{
 | 
			
		||||
  (void)sig;
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,308 +1,309 @@
 | 
			
		|||
#include "ddsc/dds.h"
 | 
			
		||||
#include "Throughput.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The Throughput example measures data throughput in bytes per second. The publisher
 | 
			
		||||
 * allows you to specify a payload size in bytes as well as allowing you to specify
 | 
			
		||||
 * whether to send data in bursts. The publisher will continue to send data forever
 | 
			
		||||
 * unless a time out is specified. The subscriber will receive data and output the
 | 
			
		||||
 * total amount received and the data rate in bytes per second. It will also indicate
 | 
			
		||||
 * if any samples were received out of order. A maximum number of cycles can be
 | 
			
		||||
 * specified and once this has been reached the subscriber will terminate and output
 | 
			
		||||
 * totals and averages.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define MAX_SAMPLES 100
 | 
			
		||||
 | 
			
		||||
static bool done = false;
 | 
			
		||||
 | 
			
		||||
/* Forward declarations */
 | 
			
		||||
static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant);
 | 
			
		||||
static void start_writing(dds_entity_t writer, ThroughputModule_DataType *sample,
 | 
			
		||||
    unsigned int burstInterval, unsigned int burstSize, unsigned int timeOut);
 | 
			
		||||
static int parse_args(int argc, char **argv, uint32_t *payloadSize, unsigned int *burstInterval,
 | 
			
		||||
    unsigned int *burstSize, unsigned int *timeOut, char **partitionName);
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName);
 | 
			
		||||
static void finalize_dds(dds_entity_t participant, dds_entity_t writer, ThroughputModule_DataType sample);
 | 
			
		||||
 | 
			
		||||
/* Functions to handle Ctrl-C presses. */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
static int CtrlHandler (DWORD fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  done = true;
 | 
			
		||||
  return true; /* Don't let other handlers handle this key */
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
struct sigaction oldAction;
 | 
			
		||||
static void CtrlHandler (int fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  done = true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main (int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t payloadSize = 8192;
 | 
			
		||||
  unsigned int burstInterval = 0;
 | 
			
		||||
  unsigned int burstSize = 1;
 | 
			
		||||
  unsigned int timeOut = 0;
 | 
			
		||||
  char * partitionName = "Throughput example";
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t writer;
 | 
			
		||||
  ThroughputModule_DataType sample;
 | 
			
		||||
 | 
			
		||||
  /* Register handler for Ctrl-C */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) CtrlHandler, true);
 | 
			
		||||
#else
 | 
			
		||||
  struct sigaction sat;
 | 
			
		||||
  sat.sa_handler = CtrlHandler;
 | 
			
		||||
  sigemptyset (&sat.sa_mask);
 | 
			
		||||
  sat.sa_flags = 0;
 | 
			
		||||
  sigaction (SIGINT, &sat, &oldAction);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (parse_args(argc, argv, &payloadSize, &burstInterval, &burstSize, &timeOut, &partitionName) == EXIT_FAILURE) {
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  participant = prepare_dds(&writer, partitionName);
 | 
			
		||||
 | 
			
		||||
  /* Wait until have a reader */
 | 
			
		||||
  if (wait_for_reader(writer, participant) == 0) {
 | 
			
		||||
    printf ("=== [Publisher]  Did not discover a reader.\n");
 | 
			
		||||
    DDS_ERR_CHECK (dds_delete (participant), DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Fill the sample payload with data */
 | 
			
		||||
  sample.count = 0;
 | 
			
		||||
  sample.payload._buffer = dds_alloc (payloadSize);
 | 
			
		||||
  sample.payload._length = payloadSize;
 | 
			
		||||
  sample.payload._release = true;
 | 
			
		||||
  for (uint32_t i = 0; i < payloadSize; i++) {
 | 
			
		||||
    sample.payload._buffer[i] = 'a';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Register the sample instance and write samples repeatedly or until time out */
 | 
			
		||||
  start_writing(writer, &sample, burstInterval, burstSize, timeOut);
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler (0, false);
 | 
			
		||||
#else
 | 
			
		||||
  sigaction (SIGINT, &oldAction, 0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Cleanup */
 | 
			
		||||
  finalize_dds(participant, writer, sample);
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int parse_args(
 | 
			
		||||
    int argc,
 | 
			
		||||
    char **argv,
 | 
			
		||||
    uint32_t *payloadSize,
 | 
			
		||||
    unsigned int *burstInterval,
 | 
			
		||||
    unsigned int *burstSize,
 | 
			
		||||
    unsigned int *timeOut,
 | 
			
		||||
    char **partitionName)
 | 
			
		||||
{
 | 
			
		||||
  int result = EXIT_SUCCESS;
 | 
			
		||||
  /*
 | 
			
		||||
   * Get the program parameters
 | 
			
		||||
   * Parameters: publisher [payloadSize] [burstInterval] [burstSize] [timeOut] [partitionName]
 | 
			
		||||
   */
 | 
			
		||||
  if (argc == 2 && (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0))
 | 
			
		||||
  {
 | 
			
		||||
    printf ("Usage (parameters must be supplied in order):\n");
 | 
			
		||||
    printf ("./publisher [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]\n");
 | 
			
		||||
    printf ("Defaults:\n");
 | 
			
		||||
    printf ("./publisher 8192 0 1 0 \"Throughput example\"\n");
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 1)
 | 
			
		||||
  {
 | 
			
		||||
    *payloadSize = atoi (argv[1]); /* The size of the payload in bytes */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 2)
 | 
			
		||||
  {
 | 
			
		||||
    *burstInterval = atoi (argv[2]); /* The time interval between each burst in ms */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 3)
 | 
			
		||||
  {
 | 
			
		||||
    *burstSize = atoi (argv[3]); /* The number of samples to send each burst */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 4)
 | 
			
		||||
  {
 | 
			
		||||
    *timeOut = atoi (argv[4]); /* The number of seconds the publisher should run for (0 = infinite) */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 5)
 | 
			
		||||
  {
 | 
			
		||||
    *partitionName = argv[5]; /* The name of the partition */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  printf ("payloadSize: %u bytes burstInterval: %u ms burstSize: %u timeOut: %u seconds partitionName: %s\n",
 | 
			
		||||
    *payloadSize, *burstInterval, *burstSize, *timeOut, *partitionName);
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
 | 
			
		||||
{
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t topic;
 | 
			
		||||
  dds_entity_t publisher;
 | 
			
		||||
  const char *pubParts[1];
 | 
			
		||||
  dds_qos_t *pubQos;
 | 
			
		||||
  dds_qos_t *dwQos;
 | 
			
		||||
 | 
			
		||||
  /* A domain participant is created for the default domain. */
 | 
			
		||||
  participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A topic is created for our sample type on the domain participant. */
 | 
			
		||||
  topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (topic, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A publisher is created on the domain participant. */
 | 
			
		||||
  pubQos = dds_qos_create ();
 | 
			
		||||
  pubParts[0] = partitionName;
 | 
			
		||||
  dds_qset_partition (pubQos, 1, pubParts);
 | 
			
		||||
  publisher = dds_create_publisher (participant, pubQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (publisher, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (pubQos);
 | 
			
		||||
 | 
			
		||||
  /* A DataWriter is created on the publisher. */
 | 
			
		||||
  dwQos = dds_qos_create ();
 | 
			
		||||
  dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
 | 
			
		||||
  dds_qset_history (dwQos, DDS_HISTORY_KEEP_ALL, 0);
 | 
			
		||||
  dds_qset_resource_limits (dwQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
 | 
			
		||||
  *writer = dds_create_writer (publisher, topic, dwQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (*writer, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (dwQos);
 | 
			
		||||
 | 
			
		||||
  /* Enable write batching */
 | 
			
		||||
  dds_write_set_batch (true);
 | 
			
		||||
 | 
			
		||||
  return participant;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant)
 | 
			
		||||
{
 | 
			
		||||
  printf ("\n=== [Publisher]  Waiting for a reader ...\n");
 | 
			
		||||
 | 
			
		||||
  dds_return_t ret;
 | 
			
		||||
  dds_entity_t waitset;
 | 
			
		||||
 | 
			
		||||
  ret = dds_set_enabled_status(writer, DDS_PUBLICATION_MATCHED_STATUS);
 | 
			
		||||
  DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  waitset = dds_create_waitset(participant);
 | 
			
		||||
  DDS_ERR_CHECK (waitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  ret = dds_waitset_attach(waitset, writer, (dds_attach_t)NULL);
 | 
			
		||||
  DDS_ERR_CHECK (waitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  ret = dds_waitset_wait(waitset, NULL, 0, DDS_SECS(30));
 | 
			
		||||
  DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void start_writing(
 | 
			
		||||
    dds_entity_t writer,
 | 
			
		||||
    ThroughputModule_DataType *sample,
 | 
			
		||||
    unsigned int burstInterval,
 | 
			
		||||
    unsigned int burstSize,
 | 
			
		||||
    unsigned int timeOut)
 | 
			
		||||
{
 | 
			
		||||
  bool timedOut = false;
 | 
			
		||||
  dds_time_t pubStart = dds_time ();
 | 
			
		||||
  dds_time_t now;
 | 
			
		||||
  dds_time_t deltaTv;
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
 | 
			
		||||
  if (!done)
 | 
			
		||||
  {
 | 
			
		||||
    dds_time_t burstStart = pubStart;
 | 
			
		||||
    unsigned int burstCount = 0;
 | 
			
		||||
 | 
			
		||||
    printf ("=== [Publisher]  Writing samples...\n");
 | 
			
		||||
 | 
			
		||||
    while (!done && !timedOut)
 | 
			
		||||
    {
 | 
			
		||||
      /* Write data until burst size has been reached */
 | 
			
		||||
 | 
			
		||||
      if (burstCount < burstSize)
 | 
			
		||||
      {
 | 
			
		||||
        status = dds_write (writer, sample);
 | 
			
		||||
        if (dds_err_nr(status) == DDS_RETCODE_TIMEOUT)
 | 
			
		||||
        {
 | 
			
		||||
          timedOut = true;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
          sample->count++;
 | 
			
		||||
          burstCount++;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      else if (burstInterval)
 | 
			
		||||
      {
 | 
			
		||||
        /* Sleep until burst interval has passed */
 | 
			
		||||
 | 
			
		||||
        dds_time_t time = dds_time ();
 | 
			
		||||
        deltaTv = time - burstStart;
 | 
			
		||||
        if (deltaTv < DDS_MSECS (burstInterval))
 | 
			
		||||
        {
 | 
			
		||||
          dds_write_flush (writer);
 | 
			
		||||
          dds_sleepfor (DDS_MSECS (burstInterval) - deltaTv);
 | 
			
		||||
        }
 | 
			
		||||
        burstStart = dds_time ();
 | 
			
		||||
        burstCount = 0;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        burstCount = 0;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (timeOut)
 | 
			
		||||
      {
 | 
			
		||||
        now = dds_time ();
 | 
			
		||||
        deltaTv = now - pubStart;
 | 
			
		||||
        if ((deltaTv) > DDS_SECS (timeOut))
 | 
			
		||||
        {
 | 
			
		||||
          timedOut = true;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    dds_write_flush (writer);
 | 
			
		||||
 | 
			
		||||
    if (done)
 | 
			
		||||
    {
 | 
			
		||||
      printf ("=== [Publisher]  Terminated, %llu samples written.\n", (unsigned long long) sample->count);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      printf ("=== [Publisher]  Timed out, %llu samples written.\n", (unsigned long long) sample->count);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void finalize_dds(dds_entity_t participant, dds_entity_t writer, ThroughputModule_DataType sample)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status = dds_dispose (writer, &sample);
 | 
			
		||||
  if (dds_err_nr (status) != DDS_RETCODE_TIMEOUT)
 | 
			
		||||
  {
 | 
			
		||||
    DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  dds_free (sample.payload._buffer);
 | 
			
		||||
  status = dds_delete (participant);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
}
 | 
			
		||||
#include "ddsc/dds.h"
 | 
			
		||||
#include "Throughput.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The Throughput example measures data throughput in bytes per second. The publisher
 | 
			
		||||
 * allows you to specify a payload size in bytes as well as allowing you to specify
 | 
			
		||||
 * whether to send data in bursts. The publisher will continue to send data forever
 | 
			
		||||
 * unless a time out is specified. The subscriber will receive data and output the
 | 
			
		||||
 * total amount received and the data rate in bytes per second. It will also indicate
 | 
			
		||||
 * if any samples were received out of order. A maximum number of cycles can be
 | 
			
		||||
 * specified and once this has been reached the subscriber will terminate and output
 | 
			
		||||
 * totals and averages.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define MAX_SAMPLES 100
 | 
			
		||||
 | 
			
		||||
static bool done = false;
 | 
			
		||||
 | 
			
		||||
/* Forward declarations */
 | 
			
		||||
static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant);
 | 
			
		||||
static void start_writing(dds_entity_t writer, ThroughputModule_DataType *sample,
 | 
			
		||||
    int burstInterval, uint32_t burstSize, int timeOut);
 | 
			
		||||
static int parse_args(int argc, char **argv, uint32_t *payloadSize, int *burstInterval,
 | 
			
		||||
    uint32_t *burstSize, int *timeOut, char **partitionName);
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName);
 | 
			
		||||
static void finalize_dds(dds_entity_t participant, dds_entity_t writer, ThroughputModule_DataType sample);
 | 
			
		||||
 | 
			
		||||
/* Functions to handle Ctrl-C presses. */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
static int CtrlHandler (DWORD fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  done = true;
 | 
			
		||||
  return true; /* Don't let other handlers handle this key */
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
struct sigaction oldAction;
 | 
			
		||||
static void CtrlHandler (int sig)
 | 
			
		||||
{
 | 
			
		||||
  (void)sig;
 | 
			
		||||
  done = true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main (int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t payloadSize = 8192;
 | 
			
		||||
  int burstInterval = 0;
 | 
			
		||||
  uint32_t burstSize = 1;
 | 
			
		||||
  int timeOut = 0;
 | 
			
		||||
  char * partitionName = "Throughput example";
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t writer;
 | 
			
		||||
  ThroughputModule_DataType sample;
 | 
			
		||||
 | 
			
		||||
  /* Register handler for Ctrl-C */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) CtrlHandler, true);
 | 
			
		||||
#else
 | 
			
		||||
  struct sigaction sat;
 | 
			
		||||
  sat.sa_handler = CtrlHandler;
 | 
			
		||||
  sigemptyset (&sat.sa_mask);
 | 
			
		||||
  sat.sa_flags = 0;
 | 
			
		||||
  sigaction (SIGINT, &sat, &oldAction);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (parse_args(argc, argv, &payloadSize, &burstInterval, &burstSize, &timeOut, &partitionName) == EXIT_FAILURE) {
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  participant = prepare_dds(&writer, partitionName);
 | 
			
		||||
 | 
			
		||||
  /* Wait until have a reader */
 | 
			
		||||
  if (wait_for_reader(writer, participant) == 0) {
 | 
			
		||||
    printf ("=== [Publisher]  Did not discover a reader.\n");
 | 
			
		||||
    DDS_ERR_CHECK (dds_delete (participant), DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Fill the sample payload with data */
 | 
			
		||||
  sample.count = 0;
 | 
			
		||||
  sample.payload._buffer = dds_alloc (payloadSize);
 | 
			
		||||
  sample.payload._length = payloadSize;
 | 
			
		||||
  sample.payload._release = true;
 | 
			
		||||
  for (uint32_t i = 0; i < payloadSize; i++) {
 | 
			
		||||
    sample.payload._buffer[i] = 'a';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Register the sample instance and write samples repeatedly or until time out */
 | 
			
		||||
  start_writing(writer, &sample, burstInterval, burstSize, timeOut);
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler (0, false);
 | 
			
		||||
#else
 | 
			
		||||
  sigaction (SIGINT, &oldAction, 0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Cleanup */
 | 
			
		||||
  finalize_dds(participant, writer, sample);
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int parse_args(
 | 
			
		||||
    int argc,
 | 
			
		||||
    char **argv,
 | 
			
		||||
    uint32_t *payloadSize,
 | 
			
		||||
    int *burstInterval,
 | 
			
		||||
    uint32_t *burstSize,
 | 
			
		||||
    int *timeOut,
 | 
			
		||||
    char **partitionName)
 | 
			
		||||
{
 | 
			
		||||
  int result = EXIT_SUCCESS;
 | 
			
		||||
  /*
 | 
			
		||||
   * Get the program parameters
 | 
			
		||||
   * Parameters: publisher [payloadSize] [burstInterval] [burstSize] [timeOut] [partitionName]
 | 
			
		||||
   */
 | 
			
		||||
  if (argc == 2 && (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0))
 | 
			
		||||
  {
 | 
			
		||||
    printf ("Usage (parameters must be supplied in order):\n");
 | 
			
		||||
    printf ("./publisher [payloadSize (bytes)] [burstInterval (ms)] [burstSize (samples)] [timeOut (seconds)] [partitionName]\n");
 | 
			
		||||
    printf ("Defaults:\n");
 | 
			
		||||
    printf ("./publisher 8192 0 1 0 \"Throughput example\"\n");
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 1)
 | 
			
		||||
  {
 | 
			
		||||
    *payloadSize = (uint32_t) atoi (argv[1]); /* The size of the payload in bytes */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 2)
 | 
			
		||||
  {
 | 
			
		||||
    *burstInterval = atoi (argv[2]); /* The time interval between each burst in ms */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 3)
 | 
			
		||||
  {
 | 
			
		||||
    *burstSize = (uint32_t) atoi (argv[3]); /* The number of samples to send each burst */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 4)
 | 
			
		||||
  {
 | 
			
		||||
    *timeOut = atoi (argv[4]); /* The number of seconds the publisher should run for (0 = infinite) */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 5)
 | 
			
		||||
  {
 | 
			
		||||
    *partitionName = argv[5]; /* The name of the partition */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  printf ("payloadSize: %u bytes burstInterval: %u ms burstSize: %u timeOut: %u seconds partitionName: %s\n",
 | 
			
		||||
    *payloadSize, *burstInterval, *burstSize, *timeOut, *partitionName);
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
 | 
			
		||||
{
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t topic;
 | 
			
		||||
  dds_entity_t publisher;
 | 
			
		||||
  const char *pubParts[1];
 | 
			
		||||
  dds_qos_t *pubQos;
 | 
			
		||||
  dds_qos_t *dwQos;
 | 
			
		||||
 | 
			
		||||
  /* A domain participant is created for the default domain. */
 | 
			
		||||
  participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A topic is created for our sample type on the domain participant. */
 | 
			
		||||
  topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (topic, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A publisher is created on the domain participant. */
 | 
			
		||||
  pubQos = dds_qos_create ();
 | 
			
		||||
  pubParts[0] = partitionName;
 | 
			
		||||
  dds_qset_partition (pubQos, 1, pubParts);
 | 
			
		||||
  publisher = dds_create_publisher (participant, pubQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (publisher, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (pubQos);
 | 
			
		||||
 | 
			
		||||
  /* A DataWriter is created on the publisher. */
 | 
			
		||||
  dwQos = dds_qos_create ();
 | 
			
		||||
  dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
 | 
			
		||||
  dds_qset_history (dwQos, DDS_HISTORY_KEEP_ALL, 0);
 | 
			
		||||
  dds_qset_resource_limits (dwQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
 | 
			
		||||
  *writer = dds_create_writer (publisher, topic, dwQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (*writer, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (dwQos);
 | 
			
		||||
 | 
			
		||||
  /* Enable write batching */
 | 
			
		||||
  dds_write_set_batch (true);
 | 
			
		||||
 | 
			
		||||
  return participant;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_return_t wait_for_reader(dds_entity_t writer, dds_entity_t participant)
 | 
			
		||||
{
 | 
			
		||||
  printf ("\n=== [Publisher]  Waiting for a reader ...\n");
 | 
			
		||||
 | 
			
		||||
  dds_return_t ret;
 | 
			
		||||
  dds_entity_t waitset;
 | 
			
		||||
 | 
			
		||||
  ret = dds_set_enabled_status(writer, DDS_PUBLICATION_MATCHED_STATUS);
 | 
			
		||||
  DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  waitset = dds_create_waitset(participant);
 | 
			
		||||
  DDS_ERR_CHECK (waitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  ret = dds_waitset_attach(waitset, writer, (dds_attach_t)NULL);
 | 
			
		||||
  DDS_ERR_CHECK (waitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  ret = dds_waitset_wait(waitset, NULL, 0, DDS_SECS(30));
 | 
			
		||||
  DDS_ERR_CHECK (ret, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void start_writing(
 | 
			
		||||
    dds_entity_t writer,
 | 
			
		||||
    ThroughputModule_DataType *sample,
 | 
			
		||||
    int burstInterval,
 | 
			
		||||
    uint32_t burstSize,
 | 
			
		||||
    int timeOut)
 | 
			
		||||
{
 | 
			
		||||
  bool timedOut = false;
 | 
			
		||||
  dds_time_t pubStart = dds_time ();
 | 
			
		||||
  dds_time_t now;
 | 
			
		||||
  dds_time_t deltaTv;
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
 | 
			
		||||
  if (!done)
 | 
			
		||||
  {
 | 
			
		||||
    dds_time_t burstStart = pubStart;
 | 
			
		||||
    unsigned int burstCount = 0;
 | 
			
		||||
 | 
			
		||||
    printf ("=== [Publisher]  Writing samples...\n");
 | 
			
		||||
 | 
			
		||||
    while (!done && !timedOut)
 | 
			
		||||
    {
 | 
			
		||||
      /* Write data until burst size has been reached */
 | 
			
		||||
 | 
			
		||||
      if (burstCount < burstSize)
 | 
			
		||||
      {
 | 
			
		||||
        status = dds_write (writer, sample);
 | 
			
		||||
        if (dds_err_nr(status) == DDS_RETCODE_TIMEOUT)
 | 
			
		||||
        {
 | 
			
		||||
          timedOut = true;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
          sample->count++;
 | 
			
		||||
          burstCount++;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      else if (burstInterval)
 | 
			
		||||
      {
 | 
			
		||||
        /* Sleep until burst interval has passed */
 | 
			
		||||
 | 
			
		||||
        dds_time_t time = dds_time ();
 | 
			
		||||
        deltaTv = time - burstStart;
 | 
			
		||||
        if (deltaTv < DDS_MSECS (burstInterval))
 | 
			
		||||
        {
 | 
			
		||||
          dds_write_flush (writer);
 | 
			
		||||
          dds_sleepfor (DDS_MSECS (burstInterval) - deltaTv);
 | 
			
		||||
        }
 | 
			
		||||
        burstStart = dds_time ();
 | 
			
		||||
        burstCount = 0;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        burstCount = 0;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (timeOut)
 | 
			
		||||
      {
 | 
			
		||||
        now = dds_time ();
 | 
			
		||||
        deltaTv = now - pubStart;
 | 
			
		||||
        if ((deltaTv) > DDS_SECS (timeOut))
 | 
			
		||||
        {
 | 
			
		||||
          timedOut = true;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    dds_write_flush (writer);
 | 
			
		||||
 | 
			
		||||
    if (done)
 | 
			
		||||
    {
 | 
			
		||||
      printf ("=== [Publisher]  Terminated, %llu samples written.\n", (unsigned long long) sample->count);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      printf ("=== [Publisher]  Timed out, %llu samples written.\n", (unsigned long long) sample->count);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void finalize_dds(dds_entity_t participant, dds_entity_t writer, ThroughputModule_DataType sample)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status = dds_dispose (writer, &sample);
 | 
			
		||||
  if (dds_err_nr (status) != DDS_RETCODE_TIMEOUT)
 | 
			
		||||
  {
 | 
			
		||||
    DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  dds_free (sample.payload._buffer);
 | 
			
		||||
  status = dds_delete (participant);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,426 +1,428 @@
 | 
			
		|||
#include "ddsc/dds.h"
 | 
			
		||||
#include "Throughput.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
/*
 | 
			
		||||
 * The Throughput example measures data throughput in bytes per second. The publisher
 | 
			
		||||
 * allows you to specify a payload size in bytes as well as allowing you to specify
 | 
			
		||||
 * whether to send data in bursts. The publisher will continue to send data forever
 | 
			
		||||
 * unless a time out is specified. The subscriber will receive data and output the
 | 
			
		||||
 * total amount received and the data rate in bytes per second. It will also indicate
 | 
			
		||||
 * if any samples were received out of order. A maximum number of cycles can be
 | 
			
		||||
 * specified and once this has been reached the subscriber will terminate and output
 | 
			
		||||
 * totals and averages.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define BYTES_PER_SEC_TO_MEGABITS_PER_SEC 125000
 | 
			
		||||
#define MAX_SAMPLES 100
 | 
			
		||||
 | 
			
		||||
typedef struct HandleEntry
 | 
			
		||||
{
 | 
			
		||||
  dds_instance_handle_t handle;
 | 
			
		||||
  unsigned long long count;
 | 
			
		||||
  struct HandleEntry * next;
 | 
			
		||||
} HandleEntry;
 | 
			
		||||
 | 
			
		||||
typedef struct HandleMap
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry *entries;
 | 
			
		||||
} HandleMap;
 | 
			
		||||
 | 
			
		||||
static unsigned long pollingDelay = 0;
 | 
			
		||||
 | 
			
		||||
static HandleMap * imap;
 | 
			
		||||
static unsigned long long outOfOrder = 0;
 | 
			
		||||
static unsigned long long total_bytes = 0;
 | 
			
		||||
static unsigned long long total_samples = 0;
 | 
			
		||||
 | 
			
		||||
static dds_time_t startTime = 0;
 | 
			
		||||
static dds_time_t time_now = 0;
 | 
			
		||||
static dds_time_t prev_time = 0;
 | 
			
		||||
 | 
			
		||||
static unsigned long payloadSize = 0;
 | 
			
		||||
 | 
			
		||||
static ThroughputModule_DataType data [MAX_SAMPLES];
 | 
			
		||||
static void * samples[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static dds_entity_t waitSet;
 | 
			
		||||
static dds_entity_t pollingWaitset;
 | 
			
		||||
 | 
			
		||||
static bool done = false;
 | 
			
		||||
 | 
			
		||||
/* Forward declarations */
 | 
			
		||||
static HandleMap * HandleMap__alloc (void);
 | 
			
		||||
static void HandleMap__free (HandleMap *map);
 | 
			
		||||
static HandleEntry * store_handle (HandleMap *map, dds_instance_handle_t key);
 | 
			
		||||
static HandleEntry * retrieve_handle (HandleMap *map, dds_instance_handle_t key);
 | 
			
		||||
 | 
			
		||||
static void data_available_handler (dds_entity_t reader, void *arg);
 | 
			
		||||
static int parse_args(int argc, char **argv, unsigned long long *maxCycles, char **partitionName);
 | 
			
		||||
static void process_samples(unsigned long long maxCycles);
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName);
 | 
			
		||||
static void finalize_dds(dds_entity_t participant);
 | 
			
		||||
 | 
			
		||||
/* Functions to handle Ctrl-C presses. */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
static int CtrlHandler (DWORD fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
  done = true;
 | 
			
		||||
  return true; /* Don't let other handlers handle this key */
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
struct sigaction oldAction;
 | 
			
		||||
static void CtrlHandler (int fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
  done = true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main (int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
  unsigned long long maxCycles = 0;
 | 
			
		||||
  char *partitionName = "Throughput example";
 | 
			
		||||
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t reader;
 | 
			
		||||
 | 
			
		||||
  time_now = dds_time ();
 | 
			
		||||
  prev_time = time_now;
 | 
			
		||||
 | 
			
		||||
  /* Register handler for Ctrl-C */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, true);
 | 
			
		||||
#else
 | 
			
		||||
  struct sigaction sat;
 | 
			
		||||
  sat.sa_handler = CtrlHandler;
 | 
			
		||||
  sigemptyset(&sat.sa_mask);
 | 
			
		||||
  sat.sa_flags = 0;
 | 
			
		||||
  sigaction (SIGINT, &sat, &oldAction);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (parse_args(argc, argv, &maxCycles, &partitionName) == EXIT_FAILURE)
 | 
			
		||||
  {
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  printf ("Cycles: %llu | PollingDelay: %lu | Partition: %s\n",
 | 
			
		||||
    maxCycles, pollingDelay, partitionName);
 | 
			
		||||
 | 
			
		||||
  participant = prepare_dds(&reader, partitionName);
 | 
			
		||||
 | 
			
		||||
  printf ("=== [Subscriber] Waiting for samples...\n");
 | 
			
		||||
 | 
			
		||||
  /* Process samples until Ctrl-C is pressed or until maxCycles */
 | 
			
		||||
  /* has been reached (0 = infinite) */
 | 
			
		||||
  process_samples(maxCycles);
 | 
			
		||||
 | 
			
		||||
  /* Finished, disable callbacks */
 | 
			
		||||
  dds_set_enabled_status (reader, 0);
 | 
			
		||||
  HandleMap__free (imap);
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler (0, FALSE);
 | 
			
		||||
#else
 | 
			
		||||
  sigaction (SIGINT, &oldAction, 0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Clean up */
 | 
			
		||||
  finalize_dds(participant);
 | 
			
		||||
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This struct contains all of the entities used in the publisher and subscriber.
 | 
			
		||||
 */
 | 
			
		||||
static HandleMap * HandleMap__alloc (void)
 | 
			
		||||
{
 | 
			
		||||
  HandleMap * map = malloc (sizeof (*map));
 | 
			
		||||
  assert(map);
 | 
			
		||||
  memset (map, 0, sizeof (*map));
 | 
			
		||||
  return map;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void HandleMap__free (HandleMap *map)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry;
 | 
			
		||||
 | 
			
		||||
  while (map->entries)
 | 
			
		||||
  {
 | 
			
		||||
    entry = map->entries;
 | 
			
		||||
    map->entries = entry->next;
 | 
			
		||||
    free (entry);
 | 
			
		||||
  }
 | 
			
		||||
  free (map);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static HandleEntry * store_handle (HandleMap *map, dds_instance_handle_t key)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry = malloc (sizeof (*entry));
 | 
			
		||||
  assert(entry);
 | 
			
		||||
  memset (entry, 0, sizeof (*entry));
 | 
			
		||||
 | 
			
		||||
  entry->handle = key;
 | 
			
		||||
  entry->next = map->entries;
 | 
			
		||||
  map->entries = entry;
 | 
			
		||||
 | 
			
		||||
  return entry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static HandleEntry * retrieve_handle (HandleMap *map, dds_instance_handle_t key)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry = map->entries;
 | 
			
		||||
 | 
			
		||||
  while (entry)
 | 
			
		||||
  {
 | 
			
		||||
    if (entry->handle == key)
 | 
			
		||||
    {
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    entry = entry->next;
 | 
			
		||||
  }
 | 
			
		||||
  return entry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void data_available_handler (dds_entity_t reader, void *arg)
 | 
			
		||||
{
 | 
			
		||||
  int samples_received;
 | 
			
		||||
  dds_sample_info_t info [MAX_SAMPLES];
 | 
			
		||||
  dds_instance_handle_t ph = 0;
 | 
			
		||||
  HandleEntry * current = NULL;
 | 
			
		||||
 | 
			
		||||
  if (startTime == 0)
 | 
			
		||||
  {
 | 
			
		||||
    startTime = dds_time ();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Take samples and iterate through them */
 | 
			
		||||
 | 
			
		||||
  samples_received = dds_take (reader, samples, info, MAX_SAMPLES, MAX_SAMPLES);
 | 
			
		||||
  DDS_ERR_CHECK (samples_received, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  for (int i = 0; !done && i < samples_received; i++)
 | 
			
		||||
  {
 | 
			
		||||
    if (info[i].valid_data)
 | 
			
		||||
    {
 | 
			
		||||
      ph = info[i].publication_handle;
 | 
			
		||||
      current = retrieve_handle (imap, ph);
 | 
			
		||||
      ThroughputModule_DataType * this_sample = &data[i];
 | 
			
		||||
 | 
			
		||||
      if (current == NULL)
 | 
			
		||||
      {
 | 
			
		||||
        current = store_handle (imap, ph);
 | 
			
		||||
        current->count = this_sample->count;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (this_sample->count != current->count)
 | 
			
		||||
      {
 | 
			
		||||
        outOfOrder++;
 | 
			
		||||
      }
 | 
			
		||||
      current->count = this_sample->count + 1;
 | 
			
		||||
 | 
			
		||||
      /* Add the sample payload size to the total received */
 | 
			
		||||
 | 
			
		||||
      payloadSize = this_sample->payload._length;
 | 
			
		||||
      total_bytes += payloadSize + 8;
 | 
			
		||||
      total_samples++;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  time_now = dds_time ();
 | 
			
		||||
  if ((pollingDelay == 0) && (time_now > (prev_time + DDS_SECS (1))))
 | 
			
		||||
  {
 | 
			
		||||
     dds_waitset_set_trigger (pollingWaitset, true);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int parse_args(int argc, char **argv, unsigned long long *maxCycles, char **partitionName)
 | 
			
		||||
{
 | 
			
		||||
  /*
 | 
			
		||||
   * Get the program parameters
 | 
			
		||||
   * Parameters: subscriber [maxCycles] [pollingDelay] [partitionName]
 | 
			
		||||
   */
 | 
			
		||||
  if (argc == 2 && (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0))
 | 
			
		||||
  {
 | 
			
		||||
    printf ("Usage (parameters must be supplied in order):\n");
 | 
			
		||||
    printf ("./subscriber [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]\n");
 | 
			
		||||
    printf ("Defaults:\n");
 | 
			
		||||
    printf ("./subscriber 0 0 \"Throughput example\"\n");
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (argc > 1)
 | 
			
		||||
  {
 | 
			
		||||
    *maxCycles = atoi (argv[1]); /* The number of times to output statistics before terminating */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 2)
 | 
			
		||||
  {
 | 
			
		||||
    pollingDelay = atoi (argv[2]); /* The number of ms to wait between reads (0 = event based) */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 3)
 | 
			
		||||
  {
 | 
			
		||||
    *partitionName = argv[3]; /* The name of the partition */
 | 
			
		||||
  }
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void process_samples(unsigned long long maxCycles)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
  unsigned long long prev_bytes = 0;
 | 
			
		||||
  unsigned long long prev_samples = 0;
 | 
			
		||||
  dds_attach_t wsresults[1];
 | 
			
		||||
  size_t wsresultsize = 1U;
 | 
			
		||||
  dds_time_t deltaTv;
 | 
			
		||||
  bool first_batch = true;
 | 
			
		||||
  unsigned long cycles = 0;
 | 
			
		||||
  double deltaTime = 0;
 | 
			
		||||
 | 
			
		||||
  while (!done && (maxCycles == 0 || cycles < maxCycles))
 | 
			
		||||
  {
 | 
			
		||||
    if (pollingDelay)
 | 
			
		||||
    {
 | 
			
		||||
      dds_sleepfor (DDS_MSECS (pollingDelay));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = dds_waitset_wait (waitSet, wsresults, wsresultsize, DDS_INFINITY);
 | 
			
		||||
      DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
      if ((status > 0 ) && (dds_triggered (pollingWaitset)))
 | 
			
		||||
      {
 | 
			
		||||
        dds_waitset_set_trigger (pollingWaitset, false);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!first_batch)
 | 
			
		||||
    {
 | 
			
		||||
      deltaTv = time_now - prev_time;
 | 
			
		||||
      deltaTime = (double) deltaTv / DDS_NSECS_IN_SEC;
 | 
			
		||||
      prev_time = time_now;
 | 
			
		||||
 | 
			
		||||
      printf
 | 
			
		||||
      (
 | 
			
		||||
        "=== [Subscriber] Payload size: %lu | Total received: %llu samples, %llu bytes | Out of order: %llu samples "
 | 
			
		||||
        "Transfer rate: %.2lf samples/s, %.2lf Mbit/s\n",
 | 
			
		||||
        payloadSize, total_samples, total_bytes, outOfOrder,
 | 
			
		||||
        (deltaTime) ? ((total_samples - prev_samples) / deltaTime) : 0,
 | 
			
		||||
        (deltaTime) ? (((total_bytes - prev_bytes) / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime) : 0
 | 
			
		||||
      );
 | 
			
		||||
      cycles++;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      prev_time = time_now;
 | 
			
		||||
      first_batch = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Update the previous values for next iteration */
 | 
			
		||||
 | 
			
		||||
    prev_bytes = total_bytes;
 | 
			
		||||
    prev_samples = total_samples;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Output totals and averages */
 | 
			
		||||
  deltaTv = time_now - startTime;
 | 
			
		||||
  deltaTime = (double) (deltaTv / DDS_NSECS_IN_SEC);
 | 
			
		||||
  printf ("\nTotal received: %llu samples, %llu bytes\n", total_samples, total_bytes);
 | 
			
		||||
  printf ("Out of order: %llu samples\n", outOfOrder);
 | 
			
		||||
  printf ("Average transfer rate: %.2lf samples/s, ", total_samples / deltaTime);
 | 
			
		||||
  printf ("%.2lf Mbit/s\n", (total_bytes / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
  dds_entity_t topic;
 | 
			
		||||
  dds_entity_t subscriber;
 | 
			
		||||
  dds_listener_t *rd_listener;
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
 | 
			
		||||
  uint32_t maxSamples = 400;
 | 
			
		||||
  const char *subParts[1];
 | 
			
		||||
  dds_qos_t *subQos = dds_qos_create ();
 | 
			
		||||
  dds_qos_t *drQos = dds_qos_create ();
 | 
			
		||||
 | 
			
		||||
  /* A Participant is created for the default domain. */
 | 
			
		||||
 | 
			
		||||
  participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A Topic is created for our sample type on the domain participant. */
 | 
			
		||||
 | 
			
		||||
  topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (topic, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A Subscriber is created on the domain participant. */
 | 
			
		||||
 | 
			
		||||
  subParts[0] = partitionName;
 | 
			
		||||
  dds_qset_partition (subQos, 1, subParts);
 | 
			
		||||
  subscriber = dds_create_subscriber (participant, subQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (subscriber, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (subQos);
 | 
			
		||||
 | 
			
		||||
  /* A Reader is created on the Subscriber & Topic with a modified Qos. */
 | 
			
		||||
 | 
			
		||||
  dds_qset_reliability (drQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
 | 
			
		||||
  dds_qset_history (drQos, DDS_HISTORY_KEEP_ALL, 0);
 | 
			
		||||
  dds_qset_resource_limits (drQos, maxSamples, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
 | 
			
		||||
 | 
			
		||||
  rd_listener = dds_listener_create(NULL);
 | 
			
		||||
  dds_lset_data_available(rd_listener, data_available_handler);
 | 
			
		||||
 | 
			
		||||
  /* A Read Condition is created which is triggered when data is available to read */
 | 
			
		||||
  waitSet = dds_create_waitset (participant);
 | 
			
		||||
  DDS_ERR_CHECK (waitSet, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  pollingWaitset = dds_create_waitset (participant);
 | 
			
		||||
  DDS_ERR_CHECK (pollingWaitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_attach (waitSet, pollingWaitset, pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_attach (waitSet, waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  imap = HandleMap__alloc ();
 | 
			
		||||
 | 
			
		||||
  memset (data, 0, sizeof (data));
 | 
			
		||||
  for (unsigned int i = 0; i < MAX_SAMPLES; i++)
 | 
			
		||||
  {
 | 
			
		||||
    samples[i] = &data[i];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  *reader = dds_create_reader (subscriber, topic, drQos, rd_listener);
 | 
			
		||||
  DDS_ERR_CHECK (*reader, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (drQos);
 | 
			
		||||
  dds_listener_delete(rd_listener);
 | 
			
		||||
 | 
			
		||||
  return participant;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void finalize_dds(dds_entity_t participant)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
 | 
			
		||||
  for (unsigned int i = 0; i < MAX_SAMPLES; i++)
 | 
			
		||||
  {
 | 
			
		||||
    ThroughputModule_DataType_free (&data[i], DDS_FREE_CONTENTS);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_detach (waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_waitset_detach (waitSet, pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (participant);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
}
 | 
			
		||||
#include "ddsc/dds.h"
 | 
			
		||||
#include "Throughput.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
/*
 | 
			
		||||
 * The Throughput example measures data throughput in bytes per second. The publisher
 | 
			
		||||
 * allows you to specify a payload size in bytes as well as allowing you to specify
 | 
			
		||||
 * whether to send data in bursts. The publisher will continue to send data forever
 | 
			
		||||
 * unless a time out is specified. The subscriber will receive data and output the
 | 
			
		||||
 * total amount received and the data rate in bytes per second. It will also indicate
 | 
			
		||||
 * if any samples were received out of order. A maximum number of cycles can be
 | 
			
		||||
 * specified and once this has been reached the subscriber will terminate and output
 | 
			
		||||
 * totals and averages.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define BYTES_PER_SEC_TO_MEGABITS_PER_SEC 125000
 | 
			
		||||
#define MAX_SAMPLES 100
 | 
			
		||||
 | 
			
		||||
typedef struct HandleEntry
 | 
			
		||||
{
 | 
			
		||||
  dds_instance_handle_t handle;
 | 
			
		||||
  unsigned long long count;
 | 
			
		||||
  struct HandleEntry * next;
 | 
			
		||||
} HandleEntry;
 | 
			
		||||
 | 
			
		||||
typedef struct HandleMap
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry *entries;
 | 
			
		||||
} HandleMap;
 | 
			
		||||
 | 
			
		||||
static long pollingDelay = 0;
 | 
			
		||||
 | 
			
		||||
static HandleMap * imap;
 | 
			
		||||
static unsigned long long outOfOrder = 0;
 | 
			
		||||
static unsigned long long total_bytes = 0;
 | 
			
		||||
static unsigned long long total_samples = 0;
 | 
			
		||||
 | 
			
		||||
static dds_time_t startTime = 0;
 | 
			
		||||
static dds_time_t time_now = 0;
 | 
			
		||||
static dds_time_t prev_time = 0;
 | 
			
		||||
 | 
			
		||||
static unsigned long payloadSize = 0;
 | 
			
		||||
 | 
			
		||||
static ThroughputModule_DataType data [MAX_SAMPLES];
 | 
			
		||||
static void * samples[MAX_SAMPLES];
 | 
			
		||||
 | 
			
		||||
static dds_entity_t waitSet;
 | 
			
		||||
static dds_entity_t pollingWaitset;
 | 
			
		||||
 | 
			
		||||
static bool done = false;
 | 
			
		||||
 | 
			
		||||
/* Forward declarations */
 | 
			
		||||
static HandleMap * HandleMap__alloc (void);
 | 
			
		||||
static void HandleMap__free (HandleMap *map);
 | 
			
		||||
static HandleEntry * store_handle (HandleMap *map, dds_instance_handle_t key);
 | 
			
		||||
static HandleEntry * retrieve_handle (HandleMap *map, dds_instance_handle_t key);
 | 
			
		||||
 | 
			
		||||
static void data_available_handler (dds_entity_t reader, void *arg);
 | 
			
		||||
static int parse_args(int argc, char **argv, unsigned long long *maxCycles, char **partitionName);
 | 
			
		||||
static void process_samples(unsigned long long maxCycles);
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName);
 | 
			
		||||
static void finalize_dds(dds_entity_t participant);
 | 
			
		||||
 | 
			
		||||
/* Functions to handle Ctrl-C presses. */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
static int CtrlHandler (DWORD fdwCtrlType)
 | 
			
		||||
{
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
  done = true;
 | 
			
		||||
  return true; /* Don't let other handlers handle this key */
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
struct sigaction oldAction;
 | 
			
		||||
static void CtrlHandler (int sig)
 | 
			
		||||
{
 | 
			
		||||
  (void)sig;
 | 
			
		||||
  dds_waitset_set_trigger (waitSet, true);
 | 
			
		||||
  done = true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int main (int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
  unsigned long long maxCycles = 0;
 | 
			
		||||
  char *partitionName = "Throughput example";
 | 
			
		||||
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
  dds_entity_t reader;
 | 
			
		||||
 | 
			
		||||
  time_now = dds_time ();
 | 
			
		||||
  prev_time = time_now;
 | 
			
		||||
 | 
			
		||||
  /* Register handler for Ctrl-C */
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, true);
 | 
			
		||||
#else
 | 
			
		||||
  struct sigaction sat;
 | 
			
		||||
  sat.sa_handler = CtrlHandler;
 | 
			
		||||
  sigemptyset(&sat.sa_mask);
 | 
			
		||||
  sat.sa_flags = 0;
 | 
			
		||||
  sigaction (SIGINT, &sat, &oldAction);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (parse_args(argc, argv, &maxCycles, &partitionName) == EXIT_FAILURE)
 | 
			
		||||
  {
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  printf ("Cycles: %llu | PollingDelay: %lu | Partition: %s\n",
 | 
			
		||||
    maxCycles, pollingDelay, partitionName);
 | 
			
		||||
 | 
			
		||||
  participant = prepare_dds(&reader, partitionName);
 | 
			
		||||
 | 
			
		||||
  printf ("=== [Subscriber] Waiting for samples...\n");
 | 
			
		||||
 | 
			
		||||
  /* Process samples until Ctrl-C is pressed or until maxCycles */
 | 
			
		||||
  /* has been reached (0 = infinite) */
 | 
			
		||||
  process_samples(maxCycles);
 | 
			
		||||
 | 
			
		||||
  /* Finished, disable callbacks */
 | 
			
		||||
  dds_set_enabled_status (reader, 0);
 | 
			
		||||
  HandleMap__free (imap);
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  SetConsoleCtrlHandler (0, FALSE);
 | 
			
		||||
#else
 | 
			
		||||
  sigaction (SIGINT, &oldAction, 0);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Clean up */
 | 
			
		||||
  finalize_dds(participant);
 | 
			
		||||
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This struct contains all of the entities used in the publisher and subscriber.
 | 
			
		||||
 */
 | 
			
		||||
static HandleMap * HandleMap__alloc (void)
 | 
			
		||||
{
 | 
			
		||||
  HandleMap * map = malloc (sizeof (*map));
 | 
			
		||||
  assert(map);
 | 
			
		||||
  memset (map, 0, sizeof (*map));
 | 
			
		||||
  return map;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void HandleMap__free (HandleMap *map)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry;
 | 
			
		||||
 | 
			
		||||
  while (map->entries)
 | 
			
		||||
  {
 | 
			
		||||
    entry = map->entries;
 | 
			
		||||
    map->entries = entry->next;
 | 
			
		||||
    free (entry);
 | 
			
		||||
  }
 | 
			
		||||
  free (map);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static HandleEntry * store_handle (HandleMap *map, dds_instance_handle_t key)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry = malloc (sizeof (*entry));
 | 
			
		||||
  assert(entry);
 | 
			
		||||
  memset (entry, 0, sizeof (*entry));
 | 
			
		||||
 | 
			
		||||
  entry->handle = key;
 | 
			
		||||
  entry->next = map->entries;
 | 
			
		||||
  map->entries = entry;
 | 
			
		||||
 | 
			
		||||
  return entry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static HandleEntry * retrieve_handle (HandleMap *map, dds_instance_handle_t key)
 | 
			
		||||
{
 | 
			
		||||
  HandleEntry * entry = map->entries;
 | 
			
		||||
 | 
			
		||||
  while (entry)
 | 
			
		||||
  {
 | 
			
		||||
    if (entry->handle == key)
 | 
			
		||||
    {
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    entry = entry->next;
 | 
			
		||||
  }
 | 
			
		||||
  return entry;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void data_available_handler (dds_entity_t reader, void *arg)
 | 
			
		||||
{
 | 
			
		||||
  int samples_received;
 | 
			
		||||
  dds_sample_info_t info [MAX_SAMPLES];
 | 
			
		||||
  dds_instance_handle_t ph = 0;
 | 
			
		||||
  HandleEntry * current = NULL;
 | 
			
		||||
  (void)arg;
 | 
			
		||||
 | 
			
		||||
  if (startTime == 0)
 | 
			
		||||
  {
 | 
			
		||||
    startTime = dds_time ();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Take samples and iterate through them */
 | 
			
		||||
 | 
			
		||||
  samples_received = dds_take (reader, samples, info, MAX_SAMPLES, MAX_SAMPLES);
 | 
			
		||||
  DDS_ERR_CHECK (samples_received, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  for (int i = 0; !done && i < samples_received; i++)
 | 
			
		||||
  {
 | 
			
		||||
    if (info[i].valid_data)
 | 
			
		||||
    {
 | 
			
		||||
      ph = info[i].publication_handle;
 | 
			
		||||
      current = retrieve_handle (imap, ph);
 | 
			
		||||
      ThroughputModule_DataType * this_sample = &data[i];
 | 
			
		||||
 | 
			
		||||
      if (current == NULL)
 | 
			
		||||
      {
 | 
			
		||||
        current = store_handle (imap, ph);
 | 
			
		||||
        current->count = this_sample->count;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (this_sample->count != current->count)
 | 
			
		||||
      {
 | 
			
		||||
        outOfOrder++;
 | 
			
		||||
      }
 | 
			
		||||
      current->count = this_sample->count + 1;
 | 
			
		||||
 | 
			
		||||
      /* Add the sample payload size to the total received */
 | 
			
		||||
 | 
			
		||||
      payloadSize = this_sample->payload._length;
 | 
			
		||||
      total_bytes += payloadSize + 8;
 | 
			
		||||
      total_samples++;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  time_now = dds_time ();
 | 
			
		||||
  if ((pollingDelay == 0) && (time_now > (prev_time + DDS_SECS (1))))
 | 
			
		||||
  {
 | 
			
		||||
     dds_waitset_set_trigger (pollingWaitset, true);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int parse_args(int argc, char **argv, unsigned long long *maxCycles, char **partitionName)
 | 
			
		||||
{
 | 
			
		||||
  /*
 | 
			
		||||
   * Get the program parameters
 | 
			
		||||
   * Parameters: subscriber [maxCycles] [pollingDelay] [partitionName]
 | 
			
		||||
   */
 | 
			
		||||
  if (argc == 2 && (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0))
 | 
			
		||||
  {
 | 
			
		||||
    printf ("Usage (parameters must be supplied in order):\n");
 | 
			
		||||
    printf ("./subscriber [maxCycles (0 = infinite)] [pollingDelay (ms, 0 = event based)] [partitionName]\n");
 | 
			
		||||
    printf ("Defaults:\n");
 | 
			
		||||
    printf ("./subscriber 0 0 \"Throughput example\"\n");
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (argc > 1)
 | 
			
		||||
  {
 | 
			
		||||
    *maxCycles = (unsigned long long) atoi (argv[1]); /* The number of times to output statistics before terminating */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 2)
 | 
			
		||||
  {
 | 
			
		||||
    pollingDelay = atoi (argv[2]); /* The number of ms to wait between reads (0 = event based) */
 | 
			
		||||
  }
 | 
			
		||||
  if (argc > 3)
 | 
			
		||||
  {
 | 
			
		||||
    *partitionName = argv[3]; /* The name of the partition */
 | 
			
		||||
  }
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void process_samples(unsigned long long maxCycles)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
  unsigned long long prev_bytes = 0;
 | 
			
		||||
  unsigned long long prev_samples = 0;
 | 
			
		||||
  dds_attach_t wsresults[1];
 | 
			
		||||
  size_t wsresultsize = 1U;
 | 
			
		||||
  dds_time_t deltaTv;
 | 
			
		||||
  bool first_batch = true;
 | 
			
		||||
  unsigned long cycles = 0;
 | 
			
		||||
  double deltaTime = 0;
 | 
			
		||||
 | 
			
		||||
  while (!done && (maxCycles == 0 || cycles < maxCycles))
 | 
			
		||||
  {
 | 
			
		||||
    if (pollingDelay)
 | 
			
		||||
    {
 | 
			
		||||
      dds_sleepfor (DDS_MSECS (pollingDelay));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = dds_waitset_wait (waitSet, wsresults, wsresultsize, DDS_INFINITY);
 | 
			
		||||
      DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
      if ((status > 0 ) && (dds_triggered (pollingWaitset)))
 | 
			
		||||
      {
 | 
			
		||||
        dds_waitset_set_trigger (pollingWaitset, false);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!first_batch)
 | 
			
		||||
    {
 | 
			
		||||
      deltaTv = time_now - prev_time;
 | 
			
		||||
      deltaTime = (double) deltaTv / DDS_NSECS_IN_SEC;
 | 
			
		||||
      prev_time = time_now;
 | 
			
		||||
 | 
			
		||||
      printf
 | 
			
		||||
      (
 | 
			
		||||
        "=== [Subscriber] Payload size: %lu | Total received: %llu samples, %llu bytes | Out of order: %llu samples "
 | 
			
		||||
        "Transfer rate: %.2lf samples/s, %.2lf Mbit/s\n",
 | 
			
		||||
        payloadSize, total_samples, total_bytes, outOfOrder,
 | 
			
		||||
        (deltaTime != 0.0) ? ((double)(total_samples - prev_samples) / deltaTime) : 0,
 | 
			
		||||
        (deltaTime != 0.0) ? ((double)((total_bytes - prev_bytes) / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime) : 0
 | 
			
		||||
      );
 | 
			
		||||
      cycles++;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      prev_time = time_now;
 | 
			
		||||
      first_batch = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Update the previous values for next iteration */
 | 
			
		||||
 | 
			
		||||
    prev_bytes = total_bytes;
 | 
			
		||||
    prev_samples = total_samples;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Output totals and averages */
 | 
			
		||||
  deltaTv = time_now - startTime;
 | 
			
		||||
  deltaTime = (double) (deltaTv / DDS_NSECS_IN_SEC);
 | 
			
		||||
  printf ("\nTotal received: %llu samples, %llu bytes\n", total_samples, total_bytes);
 | 
			
		||||
  printf ("Out of order: %llu samples\n", outOfOrder);
 | 
			
		||||
  printf ("Average transfer rate: %.2lf samples/s, ", (double)total_samples / deltaTime);
 | 
			
		||||
  printf ("%.2lf Mbit/s\n", (double)(total_bytes / BYTES_PER_SEC_TO_MEGABITS_PER_SEC) / deltaTime);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
  dds_entity_t topic;
 | 
			
		||||
  dds_entity_t subscriber;
 | 
			
		||||
  dds_listener_t *rd_listener;
 | 
			
		||||
  dds_entity_t participant;
 | 
			
		||||
 | 
			
		||||
  int32_t maxSamples = 400;
 | 
			
		||||
  const char *subParts[1];
 | 
			
		||||
  dds_qos_t *subQos = dds_qos_create ();
 | 
			
		||||
  dds_qos_t *drQos = dds_qos_create ();
 | 
			
		||||
 | 
			
		||||
  /* A Participant is created for the default domain. */
 | 
			
		||||
 | 
			
		||||
  participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (participant, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A Topic is created for our sample type on the domain participant. */
 | 
			
		||||
 | 
			
		||||
  topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (topic, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  /* A Subscriber is created on the domain participant. */
 | 
			
		||||
 | 
			
		||||
  subParts[0] = partitionName;
 | 
			
		||||
  dds_qset_partition (subQos, 1, subParts);
 | 
			
		||||
  subscriber = dds_create_subscriber (participant, subQos, NULL);
 | 
			
		||||
  DDS_ERR_CHECK (subscriber, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (subQos);
 | 
			
		||||
 | 
			
		||||
  /* A Reader is created on the Subscriber & Topic with a modified Qos. */
 | 
			
		||||
 | 
			
		||||
  dds_qset_reliability (drQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
 | 
			
		||||
  dds_qset_history (drQos, DDS_HISTORY_KEEP_ALL, 0);
 | 
			
		||||
  dds_qset_resource_limits (drQos, maxSamples, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
 | 
			
		||||
 | 
			
		||||
  rd_listener = dds_listener_create(NULL);
 | 
			
		||||
  dds_lset_data_available(rd_listener, data_available_handler);
 | 
			
		||||
 | 
			
		||||
  /* A Read Condition is created which is triggered when data is available to read */
 | 
			
		||||
  waitSet = dds_create_waitset (participant);
 | 
			
		||||
  DDS_ERR_CHECK (waitSet, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  pollingWaitset = dds_create_waitset (participant);
 | 
			
		||||
  DDS_ERR_CHECK (pollingWaitset, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_attach (waitSet, pollingWaitset, pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_attach (waitSet, waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
 | 
			
		||||
  imap = HandleMap__alloc ();
 | 
			
		||||
 | 
			
		||||
  memset (data, 0, sizeof (data));
 | 
			
		||||
  for (unsigned int i = 0; i < MAX_SAMPLES; i++)
 | 
			
		||||
  {
 | 
			
		||||
    samples[i] = &data[i];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  *reader = dds_create_reader (subscriber, topic, drQos, rd_listener);
 | 
			
		||||
  DDS_ERR_CHECK (*reader, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  dds_qos_delete (drQos);
 | 
			
		||||
  dds_listener_delete(rd_listener);
 | 
			
		||||
 | 
			
		||||
  return participant;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void finalize_dds(dds_entity_t participant)
 | 
			
		||||
{
 | 
			
		||||
  dds_return_t status;
 | 
			
		||||
 | 
			
		||||
  for (unsigned int i = 0; i < MAX_SAMPLES; i++)
 | 
			
		||||
  {
 | 
			
		||||
    ThroughputModule_DataType_free (&data[i], DDS_FREE_CONTENTS);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  status = dds_waitset_detach (waitSet, waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_waitset_detach (waitSet, pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (pollingWaitset);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (waitSet);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
  status = dds_delete (participant);
 | 
			
		||||
  DDS_ERR_CHECK (status, DDS_CHECK_REPORT | DDS_CHECK_EXIT);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ retry:
 | 
			
		|||
    os_atomic_or32(&osinit_status, OSINIT_STATUS_OK);
 | 
			
		||||
  } else {
 | 
			
		||||
    while (v > 1 && !(v & OSINIT_STATUS_OK)) {
 | 
			
		||||
      os_nanoSleep((os_time){10000000});
 | 
			
		||||
      os_nanoSleep((os_time){0, 10000000});
 | 
			
		||||
      v = os_atomic_ld32(&osinit_status);
 | 
			
		||||
    }
 | 
			
		||||
    goto retry;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ struct os_iterNode_s {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
struct os_iter_s {
 | 
			
		||||
    uint32_t length;
 | 
			
		||||
    int32_t length;
 | 
			
		||||
    os_iterNode *head;
 | 
			
		||||
    os_iterNode *tail;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -40,13 +40,13 @@ os__iterIndex(
 | 
			
		|||
        idx = iter->length;
 | 
			
		||||
    } else if (index < 0) {
 | 
			
		||||
        index *= -1;
 | 
			
		||||
        if ((uint32_t)index > iter->length) {
 | 
			
		||||
        if (index > iter->length) {
 | 
			
		||||
            idx = -1;
 | 
			
		||||
        } else {
 | 
			
		||||
            idx = iter->length - index;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        if ((uint32_t)index > iter->length) {
 | 
			
		||||
        if (index > iter->length) {
 | 
			
		||||
            idx = iter->length;
 | 
			
		||||
        } else {
 | 
			
		||||
            idx = index;
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +97,7 @@ os_iterInsert(
 | 
			
		|||
    int32_t cnt, idx = -1;
 | 
			
		||||
    os_iterNode *node, *prev;
 | 
			
		||||
 | 
			
		||||
    assert(iter->length < INT32_MAX);
 | 
			
		||||
    node = os_malloc_0(sizeof *node);
 | 
			
		||||
    node->object = object;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +148,7 @@ os_iterObject(
 | 
			
		|||
    assert(iter != NULL);
 | 
			
		||||
 | 
			
		||||
    idx = os__iterIndex(iter, index);
 | 
			
		||||
    if (idx >= 0 && (uint32_t)idx < iter->length) {
 | 
			
		||||
    if (idx >= 0 && idx < iter->length) {
 | 
			
		||||
        if (idx == (iter->length - 1)) {
 | 
			
		||||
            node = iter->tail;
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +175,7 @@ os_iterTake(
 | 
			
		|||
    assert(iter != NULL);
 | 
			
		||||
 | 
			
		||||
    idx = os__iterIndex(iter, index);
 | 
			
		||||
    if (idx >= 0 && (uint32_t)idx < iter->length) {
 | 
			
		||||
    if (idx >= 0 && idx < iter->length) {
 | 
			
		||||
        prev = NULL;
 | 
			
		||||
        node = iter->head;
 | 
			
		||||
        for (cnt = 0; cnt < idx; cnt++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +205,7 @@ os_iterLength(
 | 
			
		|||
    _In_ const os_iter *__restrict iter)
 | 
			
		||||
{
 | 
			
		||||
    assert(iter != NULL);
 | 
			
		||||
    return iter->length;
 | 
			
		||||
    return (uint32_t)iter->length;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -802,17 +802,12 @@ os__report_stack_unwind(
 | 
			
		|||
    if (valid && (_this->typeset != 0)) {
 | 
			
		||||
        char proc[256], procid[256];
 | 
			
		||||
        char thr[64], thrid[64];
 | 
			
		||||
        os_procId pid;
 | 
			
		||||
        uintmax_t tid;
 | 
			
		||||
 | 
			
		||||
        assert (context != NULL);
 | 
			
		||||
        assert (path != NULL);
 | 
			
		||||
 | 
			
		||||
        file = (char *)path;
 | 
			
		||||
 | 
			
		||||
        pid = os_procIdSelf ();
 | 
			
		||||
        tid = os_threadIdToInteger (os_threadIdSelf ());
 | 
			
		||||
 | 
			
		||||
        os_procNamePid (procid, sizeof (procid));
 | 
			
		||||
        os_procName (proc, sizeof (proc));
 | 
			
		||||
        os_threadFigureIdentity (thrid, sizeof (thrid));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -271,7 +271,7 @@ os_result os_condTimedWait (os_cond *cond, os_mutex *mutex, const os_time *time)
 | 
			
		|||
  (void) gettimeofday (&tv, NULL);
 | 
			
		||||
 | 
			
		||||
  rt.tv_sec = (os_timeSec) tv.tv_sec;
 | 
			
		||||
  rt.tv_nsec = tv.tv_usec*1000;
 | 
			
		||||
  rt.tv_nsec = (int32_t) tv.tv_usec * 1000;
 | 
			
		||||
 | 
			
		||||
  wakeup_time = os_timeAdd (rt, *time);
 | 
			
		||||
  t.tv_sec = wakeup_time.tv_sec;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ os_time os__timeDefaultTimeGet(void)
 | 
			
		|||
  (void) clock_gettime (CLOCK_REALTIME, &t);
 | 
			
		||||
 | 
			
		||||
  rt.tv_sec = (os_timeSec) t.tv_sec + timeshift;
 | 
			
		||||
  rt.tv_nsec = t.tv_nsec;
 | 
			
		||||
  rt.tv_nsec = (int32_t) t.tv_nsec;
 | 
			
		||||
 | 
			
		||||
  return rt;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +49,7 @@ os_time os_timeGetMonotonic (void)
 | 
			
		|||
  (void) clock_gettime (CLOCK_MONOTONIC, &t);
 | 
			
		||||
 | 
			
		||||
  rt.tv_sec = (os_timeSec) t.tv_sec;
 | 
			
		||||
  rt.tv_nsec = t.tv_nsec;
 | 
			
		||||
  rt.tv_nsec = (int32_t) t.tv_nsec;
 | 
			
		||||
 | 
			
		||||
  return rt;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -155,7 +155,6 @@ os_startRoutineWrapper (
 | 
			
		|||
{
 | 
			
		||||
    os_threadContext *context = threadContext;
 | 
			
		||||
    uintptr_t resultValue;
 | 
			
		||||
    os_threadId id;
 | 
			
		||||
 | 
			
		||||
    resultValue = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +172,6 @@ os_startRoutineWrapper (
 | 
			
		|||
    /* allocate an array to store thread private memory references */
 | 
			
		||||
    os_threadMemInit ();
 | 
			
		||||
 | 
			
		||||
    id.v = pthread_self();
 | 
			
		||||
    /* Call the user routine */
 | 
			
		||||
    resultValue = context->startRoutine (context->arguments);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +310,7 @@ os_threadCreate (
 | 
			
		|||
          /* Take over the thread context: name, start routine and argument */
 | 
			
		||||
          threadContext = os_malloc (sizeof (os_threadContext));
 | 
			
		||||
          threadContext->threadName = os_malloc (strlen (name)+1);
 | 
			
		||||
          strncpy (threadContext->threadName, name, strlen (name)+1);
 | 
			
		||||
          strcpy (threadContext->threadName, name);
 | 
			
		||||
          threadContext->startRoutine = start_routine;
 | 
			
		||||
          threadContext->arguments = arg;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -302,53 +302,53 @@ ssize_t os_write(int fd, const void *buf, size_t count)
 | 
			
		|||
 | 
			
		||||
void os_flockfile(FILE *file)
 | 
			
		||||
{
 | 
			
		||||
	/* flockfile is not supported on the VxWorks DKM platform.
 | 
			
		||||
	 * Therefore, this function block is empty on the VxWorks platform. */
 | 
			
		||||
        /* flockfile is not supported on the VxWorks DKM platform.
 | 
			
		||||
         * Therefore, this function block is empty on the VxWorks platform. */
 | 
			
		||||
#ifndef _WRS_KERNEL
 | 
			
		||||
	flockfile (file);
 | 
			
		||||
        flockfile (file);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void os_funlockfile(FILE *file)
 | 
			
		||||
{
 | 
			
		||||
	/* funlockfile is not supported on the VxWorks DKM platform.
 | 
			
		||||
	 * Therefore, this function block is empty on the VxWorks platform. */
 | 
			
		||||
        /* funlockfile is not supported on the VxWorks DKM platform.
 | 
			
		||||
         * Therefore, this function block is empty on the VxWorks platform. */
 | 
			
		||||
#ifndef _WRS_KERNEL
 | 
			
		||||
	funlockfile (file);
 | 
			
		||||
        funlockfile (file);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int os_getopt(int argc, char **argv, const char *opts)
 | 
			
		||||
{
 | 
			
		||||
	return getopt(argc, argv, opts);
 | 
			
		||||
        return getopt(argc, argv, opts);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void os_set_opterr(int err)
 | 
			
		||||
{
 | 
			
		||||
	opterr = err;
 | 
			
		||||
        opterr = err;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int os_get_opterr(void)
 | 
			
		||||
{
 | 
			
		||||
	return opterr;
 | 
			
		||||
        return opterr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void os_set_optind(int index)
 | 
			
		||||
{
 | 
			
		||||
	optind = index;
 | 
			
		||||
        optind = index;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int os_get_optind(void)
 | 
			
		||||
{
 | 
			
		||||
	return optind;
 | 
			
		||||
        return optind;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int os_get_optopt(void)
 | 
			
		||||
{
 | 
			
		||||
	return optopt;
 | 
			
		||||
        return optopt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char * os_get_optarg(void)
 | 
			
		||||
{
 | 
			
		||||
	return optarg;
 | 
			
		||||
        return optarg;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,7 +73,7 @@ os_lcNumericGet(void)
 | 
			
		|||
        /* There could be multiple threads here, but it is still save and works.
 | 
			
		||||
         * Only side effect is that possibly multiple os_reports are traced. */
 | 
			
		||||
        char num[] = { '\0', '\0', '\0', '\0' };
 | 
			
		||||
        (void) snprintf(num, 4, "%3f", 2.2);
 | 
			
		||||
        (void) snprintf(num, 4, "%3.1f", 2.2);
 | 
			
		||||
        lcNumeric = num [1];
 | 
			
		||||
        if (lcNumeric != '.') {
 | 
			
		||||
            OS_WARNING("os_stdlib", 0,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,8 +36,8 @@ static const size_t nof_allocsizes = sizeof allocsizes / sizeof *allocsizes;
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_malloc)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
            size_t s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
 | 
			
		||||
            void *ptr = os_malloc(s);
 | 
			
		||||
            CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_malloc is supposed to abort on failure */
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +50,8 @@ CUnit_Test(os_heap, os_malloc)
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_malloc_0)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
            size_t s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
 | 
			
		||||
            char *ptr = os_malloc_0(s);
 | 
			
		||||
            CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_malloc_0 is supposed to abort on failure */
 | 
			
		||||
| 
						 | 
				
			
			@ -66,11 +66,11 @@ CUnit_Test(os_heap, os_malloc_0)
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_calloc)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
            char *ptr = os_calloc(allocsizes[i], allocsizes[j]);
 | 
			
		||||
            CU_ASSERT_PTR_NOT_EQUAL(ptr, NULL); /* os_calloc is supposed to abort on failure */
 | 
			
		||||
            if(allocsizes[i] * allocsizes[j]) {
 | 
			
		||||
            if(allocsizes[i] * allocsizes[j] > 0) {
 | 
			
		||||
                CU_ASSERT (ptr[0] == 0 && !memcmp(ptr, ptr + 1, (allocsizes[i] * allocsizes[j]) - 1)); /* os_calloc should memset properly */
 | 
			
		||||
            }
 | 
			
		||||
            os_free(ptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -84,8 +84,8 @@ CUnit_Test(os_heap, os_realloc)
 | 
			
		|||
    char *ptr = NULL;
 | 
			
		||||
    size_t unchanged, s, prevs = 0;
 | 
			
		||||
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes; j++) {
 | 
			
		||||
            s = allocsizes[i] * allocsizes[j]; /* Allocates up to 1MB */
 | 
			
		||||
            printf("os_realloc(%p) %zu -> %zu\n", ptr, prevs, s);
 | 
			
		||||
            ptr = os_realloc(ptr, s);
 | 
			
		||||
| 
						 | 
				
			
			@ -107,8 +107,8 @@ static const size_t nof_allocsizes_s = sizeof allocsizes_s / sizeof *allocsizes_
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_malloc_s)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
            size_t s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
 | 
			
		||||
            void *ptr = os_malloc_s(s); /* If s == 0, os_malloc_s should still return a pointer */
 | 
			
		||||
            if(ptr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -126,8 +126,8 @@ CUnit_Test(os_heap, os_malloc_s)
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_malloc_0_s)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
            size_t s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
 | 
			
		||||
            char *ptr = os_malloc_0_s(s); /* If s == 0, os_malloc_0_s should still return a pointer */
 | 
			
		||||
            if(ptr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -147,8 +147,8 @@ CUnit_Test(os_heap, os_malloc_0_s)
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_heap, os_calloc_s)
 | 
			
		||||
{
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
            size_t s = allocsizes_s[i] * allocsizes_s[j];
 | 
			
		||||
            char *ptr = os_calloc_s(allocsizes_s[i], allocsizes_s[j]); /* If either one is 0, os_calloc_s should still return a pointer */
 | 
			
		||||
            if(ptr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -171,8 +171,8 @@ CUnit_Test(os_heap, os_realloc_s)
 | 
			
		|||
    char *newptr, *ptr = NULL;
 | 
			
		||||
    size_t unchanged, s, prevs = 0;
 | 
			
		||||
 | 
			
		||||
    for(int i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(int j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
    for(size_t i = 0; i < nof_allocsizes_s; i++) {
 | 
			
		||||
        for(size_t j = 0; j < nof_allocsizes_s; j++) {
 | 
			
		||||
            s = allocsizes_s[i] * allocsizes_s[j]; /* Allocates up to 8MB */
 | 
			
		||||
            newptr = os_realloc_s(ptr, s);
 | 
			
		||||
            printf("%p = os_realloc_s(%p) %zu -> %zu\n", newptr, ptr, prevs, s);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -179,7 +179,7 @@ CUnit_Test(os_iter, object_indices)
 | 
			
		|||
    OS_WARNING_MSVC_ON(28020);
 | 
			
		||||
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
    num = os_iterObject(iter, os_iterLength(iter));
 | 
			
		||||
    num = os_iterObject(iter, (int32_t)os_iterLength(iter));
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
    num = os_iterObject(iter, -6);
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
| 
						 | 
				
			
			@ -187,7 +187,7 @@ CUnit_Test(os_iter, object_indices)
 | 
			
		|||
    CU_ASSERT_PTR_EQUAL(num, &one);
 | 
			
		||||
    num = os_iterObject(iter, -5);
 | 
			
		||||
    CU_ASSERT_PTR_EQUAL(num, &one);
 | 
			
		||||
    num = os_iterObject(iter, os_iterLength(iter) - 1);
 | 
			
		||||
    num = os_iterObject(iter, (int32_t)os_iterLength(iter) - 1);
 | 
			
		||||
    CU_ASSERT_PTR_EQUAL(num, &five);
 | 
			
		||||
    num = os_iterObject(iter, -1);
 | 
			
		||||
    CU_ASSERT_PTR_EQUAL(num, &five);
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ CUnit_Test(os_iter, take_indices)
 | 
			
		|||
    num = os_iterTake(iter, OS_ITER_LENGTH);
 | 
			
		||||
    OS_WARNING_MSVC_ON(28020);
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
    num = os_iterTake(iter, os_iterLength(iter));
 | 
			
		||||
    num = os_iterTake(iter, (int32_t)os_iterLength(iter));
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
    num = os_iterTake(iter, -6);
 | 
			
		||||
    CU_ASSERT_PTR_NULL(num);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ os_once_parallel_thr(
 | 
			
		|||
        case OS_ONCE_STATE_GO:
 | 
			
		||||
            os_once(&state->init1, &once1_func);
 | 
			
		||||
            os_once(&state->init2, &once2_func);
 | 
			
		||||
            /* Fallthrough intentional */
 | 
			
		||||
            /* FALLS THROUGH */
 | 
			
		||||
        default:
 | 
			
		||||
            done = true;
 | 
			
		||||
            break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,52 +31,52 @@ static FILE *file;
 | 
			
		|||
#define FLOCKFILE_THREAD2_INPUT2 "thread2_flockfile_proc: *** input 2 ***"
 | 
			
		||||
 | 
			
		||||
#define defSignal(signal) \
 | 
			
		||||
	static os_cond signal;\
 | 
			
		||||
	static bool signal##_set = false;
 | 
			
		||||
        static os_cond signal;\
 | 
			
		||||
        static bool signal##_set = false;
 | 
			
		||||
 | 
			
		||||
#define initSignal(signal, mutex) \
 | 
			
		||||
		os_condInit(&signal, &mutex);\
 | 
			
		||||
		signal##_set = false;
 | 
			
		||||
                os_condInit(&signal, &mutex);\
 | 
			
		||||
                signal##_set = false;
 | 
			
		||||
 | 
			
		||||
#define sendSignal(signal, mutex) \
 | 
			
		||||
		os_mutexLock(&mutex);\
 | 
			
		||||
		/* signaling */ \
 | 
			
		||||
		signal##_set = true; \
 | 
			
		||||
		os_condSignal(&signal);\
 | 
			
		||||
		os_mutexUnlock(&mutex);
 | 
			
		||||
                os_mutexLock(&mutex);\
 | 
			
		||||
                /* signaling */ \
 | 
			
		||||
                signal##_set = true; \
 | 
			
		||||
                os_condSignal(&signal);\
 | 
			
		||||
                os_mutexUnlock(&mutex);
 | 
			
		||||
 | 
			
		||||
#define waitForSignal(signal, mutex) \
 | 
			
		||||
		os_mutexLock(&mutex);\
 | 
			
		||||
		while(!signal##_set) { \
 | 
			
		||||
			/* waiting for signal */ \
 | 
			
		||||
			os_condWait(&signal, &mutex);\
 | 
			
		||||
			/* received */ \
 | 
			
		||||
		} /* else already signal received */ \
 | 
			
		||||
		os_mutexUnlock(&mutex);
 | 
			
		||||
                os_mutexLock(&mutex);\
 | 
			
		||||
                while(!signal##_set) { \
 | 
			
		||||
                        /* waiting for signal */ \
 | 
			
		||||
                        os_condWait(&signal, &mutex);\
 | 
			
		||||
                        /* received */ \
 | 
			
		||||
                } /* else already signal received */ \
 | 
			
		||||
                os_mutexUnlock(&mutex);
 | 
			
		||||
 | 
			
		||||
#define timedWaitSignal(signal, mutex, time) \
 | 
			
		||||
		{ \
 | 
			
		||||
			os_time duration = time; \
 | 
			
		||||
			os_time startTime, currentTime; \
 | 
			
		||||
			os_result rc; \
 | 
			
		||||
			os_mutexLock(&mutex); \
 | 
			
		||||
			startTime = os_timeGetElapsed(); \
 | 
			
		||||
			while(!signal##_set) { \
 | 
			
		||||
				/* waiting for signal */ \
 | 
			
		||||
				rc = os_condTimedWait(&signal, &mutex, &duration); \
 | 
			
		||||
				/* signal received or timeout */ \
 | 
			
		||||
				if(rc == os_resultTimeout) { \
 | 
			
		||||
					break; \
 | 
			
		||||
				} else { \
 | 
			
		||||
					currentTime = os_timeGetElapsed(); \
 | 
			
		||||
					if(os_timeCompare(os_timeSub(currentTime, startTime), wait_time_out) >= 0) { \
 | 
			
		||||
						break; \
 | 
			
		||||
					} \
 | 
			
		||||
					duration = os_timeSub(wait_time_out, os_timeSub(currentTime, startTime)); \
 | 
			
		||||
				} \
 | 
			
		||||
			} /* else already signal received */ \
 | 
			
		||||
			os_mutexUnlock(&mutex);\
 | 
			
		||||
		}
 | 
			
		||||
                { \
 | 
			
		||||
                        os_time duration = time; \
 | 
			
		||||
                        os_time startTime, currentTime; \
 | 
			
		||||
                        os_result rc; \
 | 
			
		||||
                        os_mutexLock(&mutex); \
 | 
			
		||||
                        startTime = os_timeGetElapsed(); \
 | 
			
		||||
                        while(!signal##_set) { \
 | 
			
		||||
                                /* waiting for signal */ \
 | 
			
		||||
                                rc = os_condTimedWait(&signal, &mutex, &duration); \
 | 
			
		||||
                                /* signal received or timeout */ \
 | 
			
		||||
                                if(rc == os_resultTimeout) { \
 | 
			
		||||
                                        break; \
 | 
			
		||||
                                } else { \
 | 
			
		||||
                                        currentTime = os_timeGetElapsed(); \
 | 
			
		||||
                                        if(os_timeCompare(os_timeSub(currentTime, startTime), wait_time_out) >= 0) { \
 | 
			
		||||
                                                break; \
 | 
			
		||||
                                        } \
 | 
			
		||||
                                        duration = os_timeSub(wait_time_out, os_timeSub(currentTime, startTime)); \
 | 
			
		||||
                                } \
 | 
			
		||||
                        } /* else already signal received */ \
 | 
			
		||||
                        os_mutexUnlock(&mutex);\
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
static os_mutex mutex;
 | 
			
		||||
static bool do_locking;
 | 
			
		||||
| 
						 | 
				
			
			@ -93,176 +93,178 @@ defSignal(do_action2);
 | 
			
		|||
defSignal(do_action3);
 | 
			
		||||
 | 
			
		||||
static uint32_t thread1_flockfile_proc(void* args) {
 | 
			
		||||
	int result = 0;
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        (void)args;
 | 
			
		||||
 | 
			
		||||
	/* thread1: start */
 | 
			
		||||
	sendSignal(thread1_started, mutex);
 | 
			
		||||
        /* thread1: start */
 | 
			
		||||
        sendSignal(thread1_started, mutex);
 | 
			
		||||
 | 
			
		||||
	waitForSignal(do_action1, mutex);
 | 
			
		||||
	if(do_locking) os_flockfile(file);
 | 
			
		||||
	/* Thread1: writing input 1 to the file */
 | 
			
		||||
	result = fputs(FLOCKFILE_THREAD1_INPUT1, file);
 | 
			
		||||
	CU_ASSERT(result >= 0);
 | 
			
		||||
        waitForSignal(do_action1, mutex);
 | 
			
		||||
        if(do_locking) os_flockfile(file);
 | 
			
		||||
        /* Thread1: writing input 1 to the file */
 | 
			
		||||
        result = fputs(FLOCKFILE_THREAD1_INPUT1, file);
 | 
			
		||||
        CU_ASSERT(result >= 0);
 | 
			
		||||
 | 
			
		||||
	sendSignal(action1_done, mutex);
 | 
			
		||||
        sendSignal(action1_done, mutex);
 | 
			
		||||
 | 
			
		||||
	waitForSignal(do_action3, mutex);
 | 
			
		||||
	/* Thread1: writing input 3 to the file */
 | 
			
		||||
	result = fputs(FLOCKFILE_THREAD1_INPUT3, file);
 | 
			
		||||
	CU_ASSERT(result >= 0);
 | 
			
		||||
	if(do_locking) os_funlockfile(file);
 | 
			
		||||
	/* thread1: end */
 | 
			
		||||
        waitForSignal(do_action3, mutex);
 | 
			
		||||
        /* Thread1: writing input 3 to the file */
 | 
			
		||||
        result = fputs(FLOCKFILE_THREAD1_INPUT3, file);
 | 
			
		||||
        CU_ASSERT(result >= 0);
 | 
			
		||||
        if(do_locking) os_funlockfile(file);
 | 
			
		||||
        /* thread1: end */
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t thread2_flockfile_proc(void* args) {
 | 
			
		||||
	int result = 0;
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        (void)args;
 | 
			
		||||
 | 
			
		||||
	/* thread2: start */
 | 
			
		||||
	sendSignal(thread2_started, mutex);
 | 
			
		||||
        /* thread2: start */
 | 
			
		||||
        sendSignal(thread2_started, mutex);
 | 
			
		||||
 | 
			
		||||
	waitForSignal(do_action2, mutex);
 | 
			
		||||
	/* Thread2: writing input 2 to the file */
 | 
			
		||||
	result = fputs(FLOCKFILE_THREAD2_INPUT2, file);
 | 
			
		||||
	CU_ASSERT(result >= 0);
 | 
			
		||||
        waitForSignal(do_action2, mutex);
 | 
			
		||||
        /* Thread2: writing input 2 to the file */
 | 
			
		||||
        result = fputs(FLOCKFILE_THREAD2_INPUT2, file);
 | 
			
		||||
        CU_ASSERT(result >= 0);
 | 
			
		||||
 | 
			
		||||
	sendSignal(action2_done, mutex);
 | 
			
		||||
	/* thread2: end */
 | 
			
		||||
        sendSignal(action2_done, mutex);
 | 
			
		||||
        /* thread2: end */
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool doFlockfileTest(bool lock) {
 | 
			
		||||
	bool testPassed = true;
 | 
			
		||||
	bool strcmpResult = true;
 | 
			
		||||
	os_result result;
 | 
			
		||||
	os_threadAttr threadAttr;
 | 
			
		||||
	os_threadId thread1;
 | 
			
		||||
	os_threadId thread2;
 | 
			
		||||
	int FLOCKFILE_INPUT_MAX = sizeof(FLOCKFILE_THREAD1_INPUT1);
 | 
			
		||||
        bool testPassed = true;
 | 
			
		||||
        bool strcmpResult = true;
 | 
			
		||||
        os_result result;
 | 
			
		||||
        os_threadAttr threadAttr;
 | 
			
		||||
        os_threadId thread1;
 | 
			
		||||
        os_threadId thread2;
 | 
			
		||||
        int FLOCKFILE_INPUT_MAX = sizeof(FLOCKFILE_THREAD1_INPUT1);
 | 
			
		||||
 | 
			
		||||
	do_locking = lock;
 | 
			
		||||
        do_locking = lock;
 | 
			
		||||
 | 
			
		||||
	char *buffer = os_malloc(sizeof(char) * FLOCKFILE_INPUT_MAX);
 | 
			
		||||
        char *buffer = os_malloc(sizeof(char) * (unsigned)FLOCKFILE_INPUT_MAX);
 | 
			
		||||
 | 
			
		||||
	file = tmpfile();
 | 
			
		||||
        file = tmpfile();
 | 
			
		||||
 | 
			
		||||
	os_mutexInit(&mutex);
 | 
			
		||||
        os_mutexInit(&mutex);
 | 
			
		||||
 | 
			
		||||
	/* initialize all signal conditions */
 | 
			
		||||
	os_mutexLock(&mutex);
 | 
			
		||||
	initSignal(thread1_started, mutex);
 | 
			
		||||
	initSignal(thread2_started, mutex);
 | 
			
		||||
	initSignal(action1_done, mutex);
 | 
			
		||||
	initSignal(action2_done, mutex);
 | 
			
		||||
        /* initialize all signal conditions */
 | 
			
		||||
        os_mutexLock(&mutex);
 | 
			
		||||
        initSignal(thread1_started, mutex);
 | 
			
		||||
        initSignal(thread2_started, mutex);
 | 
			
		||||
        initSignal(action1_done, mutex);
 | 
			
		||||
        initSignal(action2_done, mutex);
 | 
			
		||||
 | 
			
		||||
	initSignal(do_action1, mutex);
 | 
			
		||||
	initSignal(do_action2, mutex);
 | 
			
		||||
	initSignal(do_action3, mutex);
 | 
			
		||||
	os_mutexUnlock(&mutex);
 | 
			
		||||
        initSignal(do_action1, mutex);
 | 
			
		||||
        initSignal(do_action2, mutex);
 | 
			
		||||
        initSignal(do_action3, mutex);
 | 
			
		||||
        os_mutexUnlock(&mutex);
 | 
			
		||||
 | 
			
		||||
	/* create threads... */
 | 
			
		||||
	os_threadAttrInit(&threadAttr);
 | 
			
		||||
        /* create threads... */
 | 
			
		||||
        os_threadAttrInit(&threadAttr);
 | 
			
		||||
 | 
			
		||||
	result = os_threadCreate(
 | 
			
		||||
	            &thread1,
 | 
			
		||||
	            "thread 1",
 | 
			
		||||
				&threadAttr,
 | 
			
		||||
				thread1_flockfile_proc,
 | 
			
		||||
	            NULL);
 | 
			
		||||
	CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
        result = os_threadCreate(
 | 
			
		||||
                    &thread1,
 | 
			
		||||
                    "thread 1",
 | 
			
		||||
                                &threadAttr,
 | 
			
		||||
                                thread1_flockfile_proc,
 | 
			
		||||
                    NULL);
 | 
			
		||||
        CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
	result = os_threadCreate(
 | 
			
		||||
	            &thread2,
 | 
			
		||||
	            "thread 2",
 | 
			
		||||
				&threadAttr,
 | 
			
		||||
				thread2_flockfile_proc,
 | 
			
		||||
	            NULL);
 | 
			
		||||
	CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
        result = os_threadCreate(
 | 
			
		||||
                    &thread2,
 | 
			
		||||
                    "thread 2",
 | 
			
		||||
                                &threadAttr,
 | 
			
		||||
                                thread2_flockfile_proc,
 | 
			
		||||
                    NULL);
 | 
			
		||||
        CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
	/* wait for threads to start */
 | 
			
		||||
	waitForSignal(thread1_started, mutex);
 | 
			
		||||
	waitForSignal(thread2_started, mutex);
 | 
			
		||||
        /* wait for threads to start */
 | 
			
		||||
        waitForSignal(thread1_started, mutex);
 | 
			
		||||
        waitForSignal(thread2_started, mutex);
 | 
			
		||||
 | 
			
		||||
	/* get thread one to do its first thing */
 | 
			
		||||
	sendSignal(do_action1, mutex);
 | 
			
		||||
        /* get thread one to do its first thing */
 | 
			
		||||
        sendSignal(do_action1, mutex);
 | 
			
		||||
 | 
			
		||||
	/* wait for thread 1 to acknowledge */
 | 
			
		||||
	timedWaitSignal(action1_done, mutex, wait_time_out);
 | 
			
		||||
        /* wait for thread 1 to acknowledge */
 | 
			
		||||
        timedWaitSignal(action1_done, mutex, wait_time_out);
 | 
			
		||||
 | 
			
		||||
	/* kick thead 2 */
 | 
			
		||||
	sendSignal(do_action2, mutex);
 | 
			
		||||
        /* kick thead 2 */
 | 
			
		||||
        sendSignal(do_action2, mutex);
 | 
			
		||||
 | 
			
		||||
	/* wait for thread 2 to acknowledge */
 | 
			
		||||
	timedWaitSignal(action2_done, mutex, wait_time_out);
 | 
			
		||||
        /* wait for thread 2 to acknowledge */
 | 
			
		||||
        timedWaitSignal(action2_done, mutex, wait_time_out);
 | 
			
		||||
 | 
			
		||||
	/* kick thread 1, again */
 | 
			
		||||
	sendSignal(do_action3, mutex);
 | 
			
		||||
        /* kick thread 1, again */
 | 
			
		||||
        sendSignal(do_action3, mutex);
 | 
			
		||||
 | 
			
		||||
	/* wait for threads to shutdown */
 | 
			
		||||
	result = os_threadWaitExit(thread1,NULL);
 | 
			
		||||
	CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
        /* wait for threads to shutdown */
 | 
			
		||||
        result = os_threadWaitExit(thread1,NULL);
 | 
			
		||||
        CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
	result = os_threadWaitExit(thread2,NULL);
 | 
			
		||||
	CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
        result = os_threadWaitExit(thread2,NULL);
 | 
			
		||||
        CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
	/* if lock then Expected action order: 1 3 2
 | 
			
		||||
	* else Expected action order: 1 2 3  */
 | 
			
		||||
        /* if lock then Expected action order: 1 3 2
 | 
			
		||||
        * else Expected action order: 1 2 3  */
 | 
			
		||||
 | 
			
		||||
	rewind(file);
 | 
			
		||||
        rewind(file);
 | 
			
		||||
 | 
			
		||||
	if(lock) {
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
		if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > 0) {
 | 
			
		||||
			strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
 | 
			
		||||
			CU_ASSERT(strcmpResult);
 | 
			
		||||
			testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
        if(lock) {
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
        } else {
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT1) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD2_INPUT2) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
                if(fgets(buffer, FLOCKFILE_INPUT_MAX, file) > (char*)0) {
 | 
			
		||||
                        strcmpResult = (strcmp(buffer, FLOCKFILE_THREAD1_INPUT3) == 0);
 | 
			
		||||
                        CU_ASSERT(strcmpResult);
 | 
			
		||||
                        testPassed = testPassed && strcmpResult; /* update flag indicating overall test state */
 | 
			
		||||
                }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
	/* cleanup */
 | 
			
		||||
	os_free(buffer);
 | 
			
		||||
	fclose(file);
 | 
			
		||||
        /* cleanup */
 | 
			
		||||
        os_free(buffer);
 | 
			
		||||
        fclose(file);
 | 
			
		||||
 | 
			
		||||
	os_mutexLock(&mutex);
 | 
			
		||||
	os_condDestroy(&do_action1);
 | 
			
		||||
	os_condDestroy(&do_action2);
 | 
			
		||||
	os_condDestroy(&do_action3);
 | 
			
		||||
        os_mutexLock(&mutex);
 | 
			
		||||
        os_condDestroy(&do_action1);
 | 
			
		||||
        os_condDestroy(&do_action2);
 | 
			
		||||
        os_condDestroy(&do_action3);
 | 
			
		||||
 | 
			
		||||
	os_condDestroy(&thread1_started);
 | 
			
		||||
	os_condDestroy(&thread2_started);
 | 
			
		||||
	os_condDestroy(&action1_done);
 | 
			
		||||
	os_condDestroy(&action2_done);
 | 
			
		||||
	os_mutexUnlock(&mutex);
 | 
			
		||||
	os_mutexDestroy(&mutex);
 | 
			
		||||
	/* doFlockfileTest */
 | 
			
		||||
	return testPassed;
 | 
			
		||||
        os_condDestroy(&thread1_started);
 | 
			
		||||
        os_condDestroy(&thread2_started);
 | 
			
		||||
        os_condDestroy(&action1_done);
 | 
			
		||||
        os_condDestroy(&action2_done);
 | 
			
		||||
        os_mutexUnlock(&mutex);
 | 
			
		||||
        os_mutexDestroy(&mutex);
 | 
			
		||||
        /* doFlockfileTest */
 | 
			
		||||
        return testPassed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
| 
						 | 
				
			
			@ -806,64 +808,64 @@ CUnit_Test(os_stdlib, index)
 | 
			
		|||
 | 
			
		||||
CUnit_Test(os_stdlib, flockfile)
 | 
			
		||||
{
 | 
			
		||||
	bool result = false;
 | 
			
		||||
        bool result = false;
 | 
			
		||||
 | 
			
		||||
	os_osInit();
 | 
			
		||||
        os_osInit();
 | 
			
		||||
 | 
			
		||||
	/* Check writing in a FILE from multiple threads without using os_flockfile. */
 | 
			
		||||
	printf ("Starting os_stdlib_flockfile_001\n");
 | 
			
		||||
	result = doFlockfileTest(false);
 | 
			
		||||
	CU_ASSERT (result);
 | 
			
		||||
        /* Check writing in a FILE from multiple threads without using os_flockfile. */
 | 
			
		||||
        printf ("Starting os_stdlib_flockfile_001\n");
 | 
			
		||||
        result = doFlockfileTest(false);
 | 
			
		||||
        CU_ASSERT (result);
 | 
			
		||||
 | 
			
		||||
	/* Check writing in a FILE from multiple threads using os_flockfile in the first thread. */
 | 
			
		||||
	printf ("Starting os_stdlib_flockfile_002\n");
 | 
			
		||||
	result = doFlockfileTest(true);
 | 
			
		||||
	CU_ASSERT (result);
 | 
			
		||||
        /* Check writing in a FILE from multiple threads using os_flockfile in the first thread. */
 | 
			
		||||
        printf ("Starting os_stdlib_flockfile_002\n");
 | 
			
		||||
        result = doFlockfileTest(true);
 | 
			
		||||
        CU_ASSERT (result);
 | 
			
		||||
 | 
			
		||||
	printf ("Ending os_stdlib_flockfile\n");
 | 
			
		||||
        printf ("Ending os_stdlib_flockfile\n");
 | 
			
		||||
 | 
			
		||||
	os_osExit();
 | 
			
		||||
        os_osExit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CUnit_Test(os_stdlib, getopt)
 | 
			
		||||
{
 | 
			
		||||
	int c = 0;
 | 
			
		||||
	int argc = 3;
 | 
			
		||||
	char *argv001[] = {"", "-a", "-b"};
 | 
			
		||||
	char *argv002[] = {"", "-c", "foo"};
 | 
			
		||||
	char *argv003[] = {"", "-d"};
 | 
			
		||||
        int c = 0;
 | 
			
		||||
        int argc = 3;
 | 
			
		||||
        char *argv001[] = {"", "-a", "-b"};
 | 
			
		||||
        char *argv002[] = {"", "-c", "foo"};
 | 
			
		||||
        char *argv003[] = {"", "-d"};
 | 
			
		||||
 | 
			
		||||
	/* Check correct functioning of os_getopt */
 | 
			
		||||
	printf ("Starting os_stdlib_getopt_001\n");
 | 
			
		||||
	c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
	CU_ASSERT (c == 'a');
 | 
			
		||||
	c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
	CU_ASSERT (c == 'b');
 | 
			
		||||
	c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
	CU_ASSERT (c == -1);
 | 
			
		||||
        /* Check correct functioning of os_getopt */
 | 
			
		||||
        printf ("Starting os_stdlib_getopt_001\n");
 | 
			
		||||
        c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
        CU_ASSERT (c == 'a');
 | 
			
		||||
        c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
        CU_ASSERT (c == 'b');
 | 
			
		||||
        c = os_getopt(argc, argv001, "abc:");
 | 
			
		||||
        CU_ASSERT (c == -1);
 | 
			
		||||
 | 
			
		||||
	/* Check correct functioning of os_set_optind and os_get_optind */
 | 
			
		||||
	printf ("Starting os_stdlib_getopt_002\n");
 | 
			
		||||
	os_set_optind(1);
 | 
			
		||||
	CU_ASSERT (os_get_optind() == 1);
 | 
			
		||||
        /* Check correct functioning of os_set_optind and os_get_optind */
 | 
			
		||||
        printf ("Starting os_stdlib_getopt_002\n");
 | 
			
		||||
        os_set_optind(1);
 | 
			
		||||
        CU_ASSERT (os_get_optind() == 1);
 | 
			
		||||
 | 
			
		||||
	/* Check correct functioning of os_get_optarg */
 | 
			
		||||
	printf ("Starting os_stdlib_getopt_003\n");
 | 
			
		||||
	c = os_getopt (argc, argv002, "c:");
 | 
			
		||||
	CU_ASSERT (c == 'c');
 | 
			
		||||
	CU_ASSERT (strcmp(os_get_optarg(), "foo") == 0);
 | 
			
		||||
	c = os_getopt(argc, argv002, "c:");
 | 
			
		||||
	CU_ASSERT (c == -1);
 | 
			
		||||
        /* Check correct functioning of os_get_optarg */
 | 
			
		||||
        printf ("Starting os_stdlib_getopt_003\n");
 | 
			
		||||
        c = os_getopt (argc, argv002, "c:");
 | 
			
		||||
        CU_ASSERT (c == 'c');
 | 
			
		||||
        CU_ASSERT (strcmp(os_get_optarg(), "foo") == 0);
 | 
			
		||||
        c = os_getopt(argc, argv002, "c:");
 | 
			
		||||
        CU_ASSERT (c == -1);
 | 
			
		||||
 | 
			
		||||
	/* Check correct functioning of os_set_opterr, os_get_opterr and os_get_optopt */
 | 
			
		||||
	printf ("Starting os_stdlib_getopt_004\n");
 | 
			
		||||
	argc = 2;
 | 
			
		||||
	os_set_optind(1);
 | 
			
		||||
	os_set_opterr(0);
 | 
			
		||||
	CU_ASSERT(os_get_opterr() == 0)
 | 
			
		||||
	c = os_getopt (argc, argv003, "c:");
 | 
			
		||||
	CU_ASSERT (c == '?');
 | 
			
		||||
	CU_ASSERT (os_get_optopt() == 'd');
 | 
			
		||||
        /* Check correct functioning of os_set_opterr, os_get_opterr and os_get_optopt */
 | 
			
		||||
        printf ("Starting os_stdlib_getopt_004\n");
 | 
			
		||||
        argc = 2;
 | 
			
		||||
        os_set_optind(1);
 | 
			
		||||
        os_set_opterr(0);
 | 
			
		||||
        CU_ASSERT(os_get_opterr() == 0)
 | 
			
		||||
        c = os_getopt (argc, argv003, "c:");
 | 
			
		||||
        CU_ASSERT (c == '?');
 | 
			
		||||
        CU_ASSERT (os_get_optopt() == 'd');
 | 
			
		||||
 | 
			
		||||
	printf ("Ending os_stdlib_getopt\n");
 | 
			
		||||
        printf ("Ending os_stdlib_getopt\n");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,8 +57,7 @@ uint32_t get_threadExit_thread (void *args)
 | 
			
		|||
{
 | 
			
		||||
    os_threadId * threadId = args;
 | 
			
		||||
    uint32_t id;
 | 
			
		||||
    os_result ret = os_threadWaitExit (*threadId, &id);
 | 
			
		||||
 | 
			
		||||
    (void)os_threadWaitExit (*threadId, &id);
 | 
			
		||||
    return id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,14 +68,6 @@ uint32_t threadIdentity_thread (_In_ void *args)
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t threadMain(_In_opt_ void *args)
 | 
			
		||||
{
 | 
			
		||||
    OS_UNUSED_ARG(args);
 | 
			
		||||
    threadCalled = 1;
 | 
			
		||||
    sleepMsec(500);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t threadMemory_thread (_In_opt_ void *args)
 | 
			
		||||
{
 | 
			
		||||
    OS_UNUSED_ARG(args);
 | 
			
		||||
| 
						 | 
				
			
			@ -137,6 +128,7 @@ CUnit_Suite_Cleanup(os_thread)
 | 
			
		|||
CUnit_Test(os_thread, create)
 | 
			
		||||
{
 | 
			
		||||
    int result;
 | 
			
		||||
    os_result osResult;
 | 
			
		||||
    os_threadId   thread_os_threadId;
 | 
			
		||||
    os_threadAttr thread_os_threadAttr;
 | 
			
		||||
#ifndef WIN32
 | 
			
		||||
| 
						 | 
				
			
			@ -147,16 +139,16 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
       (check thread creation and check argument passing) */
 | 
			
		||||
    printf ("Starting os_thread_create_001\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "ThreadCreate1", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate1", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        taskDelay(1 * sysClkRateGet());
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            result = strcmp (arg_result, "os_threadCreate");
 | 
			
		||||
            CU_ASSERT (result == 0);
 | 
			
		||||
            if (result == 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -176,11 +168,11 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
    printf ("Starting s_thread_create_003\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    thread_os_threadAttr.schedClass = OS_SCHED_DEFAULT;
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "ThreadCreate3", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate3", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
#if !(defined _WRS_KERNEL || defined WIN32)
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
        int policy;
 | 
			
		||||
        struct sched_param sched_param;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -192,8 +184,8 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
        } else {
 | 
			
		||||
            CU_ASSERT (policy == SCHED_OTHER);
 | 
			
		||||
        }
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -205,9 +197,9 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
    printf ("Starting os_thread_create_004\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    thread_os_threadAttr.schedClass = OS_SCHED_TIMESHARE;
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "ThreadCreate4", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate4", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifndef WIN32
 | 
			
		||||
        int policy;
 | 
			
		||||
        struct sched_param sched_param;
 | 
			
		||||
| 
						 | 
				
			
			@ -222,7 +214,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
        }
 | 
			
		||||
#endif /* WIN32 */
 | 
			
		||||
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -241,9 +233,9 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
        os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
        thread_os_threadAttr.schedClass = OS_SCHED_REALTIME;
 | 
			
		||||
        thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_FIFO);
 | 
			
		||||
        result = os_threadCreate (&thread_os_threadId, "ThreadCreate5", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate5", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            int policy;
 | 
			
		||||
            struct sched_param sched_param;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -255,7 +247,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
            } else {
 | 
			
		||||
                printf ("pthread_getschedparam failed\n");
 | 
			
		||||
            }
 | 
			
		||||
            result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
            osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        } else {
 | 
			
		||||
            printf ("os_threadCreate failed\n");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -274,16 +266,16 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
#else
 | 
			
		||||
      thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_OTHER);
 | 
			
		||||
#endif
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "ThreadCreate6", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate6", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
    if (result == os_resultSuccess)
 | 
			
		||||
    if (osResult == os_resultSuccess)
 | 
			
		||||
        printf ("os_threadCreate failed - Expected failure from VXWORKS\n");
 | 
			
		||||
    else
 | 
			
		||||
        printf ("OS_SCHED_TIMESHARE not supported\n");
 | 
			
		||||
#else
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
        int policy;
 | 
			
		||||
        struct sched_param sched_param;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -295,7 +287,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
        } else {
 | 
			
		||||
            printf ("pthread_getschedparam failed\n");
 | 
			
		||||
        }
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -314,17 +306,17 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
#else
 | 
			
		||||
        thread_os_threadAttr.schedPriority = sched_get_priority_max (SCHED_OTHER);
 | 
			
		||||
#endif
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "ThreadCreate7", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate7", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
        printf ("os_threadCreate failed - Expected failure from VXWORKS\n");
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("OS_SCHED_TIMESHARE not supported\n");
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
        int policy;
 | 
			
		||||
        struct sched_param sched_param;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -336,7 +328,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
        } else {
 | 
			
		||||
            printf ("pthread_getschedparam failed\n");
 | 
			
		||||
        }
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -363,10 +355,10 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
#else
 | 
			
		||||
        thread_os_threadAttr.schedPriority = sched_get_priority_min (SCHED_FIFO);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadCreate (&thread_os_threadId, "ThreadCreate8", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate8", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
            TASK_ID id;
 | 
			
		||||
            int pri;
 | 
			
		||||
| 
						 | 
				
			
			@ -390,7 +382,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
                printf ("pthread_getschedparam failed.\n");
 | 
			
		||||
             }
 | 
			
		||||
#endif /* _WRS_KERNEL */
 | 
			
		||||
            result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
            osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        } else {
 | 
			
		||||
            printf ("os_threadCreate failed.\n");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -417,10 +409,10 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
#else
 | 
			
		||||
        thread_os_threadAttr.schedPriority = sched_get_priority_max (SCHED_FIFO);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadCreate (&thread_os_threadId, "ThreadCreate9", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadCreate (&thread_os_threadId, "ThreadCreate9", &thread_os_threadAttr, &new_thread, "os_threadCreate");
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
            int status;
 | 
			
		||||
            sleepSeconds (2);
 | 
			
		||||
| 
						 | 
				
			
			@ -440,7 +432,7 @@ CUnit_Test(os_thread, create)
 | 
			
		|||
                printf ("pthread_getschedparam failed.\n");
 | 
			
		||||
            }
 | 
			
		||||
#endif
 | 
			
		||||
            result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
            osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        } else {
 | 
			
		||||
            printf ("os_threadCreate failed.\n");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -464,23 +456,23 @@ CUnit_Test(os_thread, idself)
 | 
			
		|||
{
 | 
			
		||||
    os_threadId   thread_os_threadId;
 | 
			
		||||
    os_threadAttr thread_os_threadAttr;
 | 
			
		||||
    int result;
 | 
			
		||||
    os_result osResult;
 | 
			
		||||
    uint32_t result_from_thread;
 | 
			
		||||
 | 
			
		||||
    /* Check if own thread ID is correctly provided */
 | 
			
		||||
    printf ("Starting tc_os_threadIdSelf_001\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "OwnThreadId", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "OwnThreadId", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            uintmax_t tmp_thread_os_threadId = os_threadIdToInteger(thread_os_threadId);
 | 
			
		||||
            CU_ASSERT (thread_id_from_thread == tmp_thread_os_threadId);
 | 
			
		||||
            CU_ASSERT (result_from_thread == (uint32_t)tmp_thread_os_threadId);
 | 
			
		||||
| 
						 | 
				
			
			@ -498,24 +490,24 @@ CUnit_Test(os_thread, join)
 | 
			
		|||
{
 | 
			
		||||
    os_threadId   thread_os_threadId;
 | 
			
		||||
    os_threadAttr thread_os_threadAttr;
 | 
			
		||||
    int result;
 | 
			
		||||
    os_result osResult;
 | 
			
		||||
    uint32_t result_from_thread;
 | 
			
		||||
 | 
			
		||||
    /* Wait for thread to terminate and get the return value with Success result,
 | 
			
		||||
       while thread is still running */
 | 
			
		||||
    printf("Starting os_thread_join_001\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, (void *)1);
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, (void *)1);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            CU_ASSERT (thread_id_from_thread == os_threadIdToInteger(thread_os_threadId));
 | 
			
		||||
            CU_ASSERT (result_from_thread == (uint32_t)thread_id_from_thread);
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -529,17 +521,17 @@ CUnit_Test(os_thread, join)
 | 
			
		|||
       while thread is already terminated */
 | 
			
		||||
    printf ("Starting os_thread_join_002\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT(result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, &result_from_thread);
 | 
			
		||||
        CU_ASSERT(osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            CU_ASSERT (thread_id_from_thread == os_threadIdToInteger(thread_os_threadId));
 | 
			
		||||
            CU_ASSERT (result_from_thread == (uint32_t)thread_id_from_thread);
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -552,15 +544,15 @@ CUnit_Test(os_thread, join)
 | 
			
		|||
    /* Get thread return value with Fail result because result is already read */
 | 
			
		||||
    printf ("Starting tc_os_thread_join_003\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -572,23 +564,23 @@ CUnit_Test(os_thread, join)
 | 
			
		|||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    {
 | 
			
		||||
        os_threadId threadWait1;
 | 
			
		||||
        os_result result1;
 | 
			
		||||
        os_result osResult1;
 | 
			
		||||
 | 
			
		||||
        result = os_threadCreate (&thread_os_threadId, "threadToWaitFor", &thread_os_threadAttr, &threadId_thread, (void*) 1);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        result1 = os_threadCreate (&threadWait1, "waitingThread1", &thread_os_threadAttr, &get_threadExit_thread, &thread_os_threadId);
 | 
			
		||||
        CU_ASSERT (result1 == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadCreate (&thread_os_threadId, "threadToWaitFor", &thread_os_threadAttr, &threadId_thread, (void*) 1);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
        osResult1 = os_threadCreate (&threadWait1, "waitingThread1", &thread_os_threadAttr, &get_threadExit_thread, &thread_os_threadId);
 | 
			
		||||
        CU_ASSERT (osResult1 == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess && result1 == os_resultSuccess)
 | 
			
		||||
        if (osResult == os_resultSuccess && osResult1 == os_resultSuccess)
 | 
			
		||||
        {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
            sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
            result1 = os_threadWaitExit (threadWait1, NULL);
 | 
			
		||||
            osResult1 = os_threadWaitExit (threadWait1, NULL);
 | 
			
		||||
 | 
			
		||||
            if (result1 != os_resultSuccess) {
 | 
			
		||||
            if (osResult1 != os_resultSuccess) {
 | 
			
		||||
                printf ("os_threadWaitExit 1 failed\n");
 | 
			
		||||
                CU_ASSERT (result1 == os_resultSuccess);
 | 
			
		||||
                CU_ASSERT (osResult1 == os_resultSuccess);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            printf ("os_threadCreate failed.\n");
 | 
			
		||||
| 
						 | 
				
			
			@ -602,16 +594,16 @@ CUnit_Test(os_thread, join)
 | 
			
		|||
       return value address - not interrested */
 | 
			
		||||
    printf ("Starting tc_os_threadWaitExit_005\n");
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT  (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "threadWaitExit", &thread_os_threadAttr, &threadId_thread, NULL);
 | 
			
		||||
    CU_ASSERT  (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        if (result != os_resultSuccess)
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
        if (osResult != os_resultSuccess)
 | 
			
		||||
            printf ("os_threadWaitExit failed.\n");
 | 
			
		||||
    } else {
 | 
			
		||||
        printf ("os_threadCreate failed.\n");
 | 
			
		||||
| 
						 | 
				
			
			@ -627,7 +619,7 @@ CUnit_Test(os_thread, figure_identity)
 | 
			
		|||
    os_threadAttr thread_os_threadAttr;
 | 
			
		||||
    char threadId[512];
 | 
			
		||||
    char thread_name[512];
 | 
			
		||||
    int result;
 | 
			
		||||
    os_result osResult;
 | 
			
		||||
#endif /* WIN32 */
 | 
			
		||||
 | 
			
		||||
    /* Figure out the identity of the thread, where it's name is known */
 | 
			
		||||
| 
						 | 
				
			
			@ -636,17 +628,17 @@ CUnit_Test(os_thread, figure_identity)
 | 
			
		|||
    /* Untested because the identifier does not contain the name on Windows */
 | 
			
		||||
#else
 | 
			
		||||
    os_threadAttrInit (&thread_os_threadAttr);
 | 
			
		||||
    result = os_threadCreate (&thread_os_threadId, "threadFigureIdentity", &thread_os_threadAttr, &threadIdentity_thread, threadId);
 | 
			
		||||
    CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
    osResult = os_threadCreate (&thread_os_threadId, "threadFigureIdentity", &thread_os_threadAttr, &threadIdentity_thread, threadId);
 | 
			
		||||
    CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
    if (result == os_resultSuccess) {
 | 
			
		||||
    if (osResult == os_resultSuccess) {
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
        sleepSeconds(1);
 | 
			
		||||
#endif
 | 
			
		||||
        result = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (result == os_resultSuccess);
 | 
			
		||||
        osResult = os_threadWaitExit (thread_os_threadId, NULL);
 | 
			
		||||
        CU_ASSERT (osResult == os_resultSuccess);
 | 
			
		||||
 | 
			
		||||
        if (result == os_resultSuccess) {
 | 
			
		||||
        if (osResult == os_resultSuccess) {
 | 
			
		||||
            uintmax_t threadNumeric = 0;
 | 
			
		||||
#ifdef _WRS_KERNEL
 | 
			
		||||
            int dum;
 | 
			
		||||
| 
						 | 
				
			
			@ -714,12 +706,12 @@ CUnit_Test(os_thread, figure_identity)
 | 
			
		|||
   {
 | 
			
		||||
       char threadId[512];
 | 
			
		||||
       char threadIdString[512];
 | 
			
		||||
       unsigned int threadIdLen;
 | 
			
		||||
       int32_t threadIdLen;
 | 
			
		||||
 | 
			
		||||
       (void)snprintf (threadIdString, sizeof(threadIdString), "0x%"PRIxMAX, os_threadIdToInteger(os_threadIdSelf()));
 | 
			
		||||
       threadIdLen = os_threadFigureIdentity (threadId, sizeof(threadId));
 | 
			
		||||
 | 
			
		||||
       CU_ASSERT (threadIdLen == strlen(threadIdString));
 | 
			
		||||
       CU_ASSERT (threadIdLen == (int32_t)strlen(threadIdString));
 | 
			
		||||
   }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,6 @@ static struct topictab{
 | 
			
		|||
 | 
			
		||||
const unsigned int MAX_SAMPLES = 10;
 | 
			
		||||
unsigned int states = DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE;
 | 
			
		||||
int status = 0;
 | 
			
		||||
int reader_wait = 0;
 | 
			
		||||
dds_entity_t participant;
 | 
			
		||||
dds_entity_t subscriber;
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +67,8 @@ dds_sample_info_t info[10];
 | 
			
		|||
dds_qos_t* tqos;
 | 
			
		||||
dds_qos_t* sqos;
 | 
			
		||||
 | 
			
		||||
void _zero(void ** samples, int size) {
 | 
			
		||||
    int i;
 | 
			
		||||
void _zero(void ** samples, size_t size) {
 | 
			
		||||
    size_t i;
 | 
			
		||||
    for(i = 0; i < size;i++) {
 | 
			
		||||
        samples[i] = NULL;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -416,6 +415,7 @@ void print_dcps_topic(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(dcps_topic_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(dcps_topic_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(dcps_topic_reader, (void**)dcps_topic_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -457,6 +457,7 @@ void print_dcps_participant(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(dcps_participant_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(dcps_participant_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(dcps_participant_reader, (void**)dcps_participant_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -484,6 +485,7 @@ void print_dcps_subscription(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(dcps_subscription_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(dcps_subscription_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(dcps_subscription_reader, (void**)dcps_subscription_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -526,6 +528,7 @@ void print_dcps_publication(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(dcps_publication_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(dcps_publication_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(dcps_publication_reader, (void**)dcps_publication_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -569,6 +572,7 @@ void print_cm_participant(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(cm_participant_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(cm_participant_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(cm_participant_reader, (void**)cm_participant_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -596,6 +600,7 @@ void print_cm_publisher(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(cm_publisher_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(cm_publisher_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(cm_publisher_reader, (void**)cm_publisher_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -627,7 +632,8 @@ void print_cm_subscriber(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(cm_subscriber_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        zero(cm_subscriber_samples, MAX_SAMPLES);
 | 
			
		||||
         int status = 0;
 | 
			
		||||
       zero(cm_subscriber_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(cm_subscriber_reader, (void**)cm_subscriber_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
        for(i = 0; i < status; i++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -659,6 +665,7 @@ void print_cm_datawriter(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(cm_datawriter_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(cm_datawriter_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(cm_datawriter_reader, (void**)cm_datawriter_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -691,6 +698,7 @@ void print_cm_datareader(FILE *fp){
 | 
			
		|||
    reader_wait = dds_reader_wait_for_historical_data(cm_datareader_reader, DDS_SECS(5));
 | 
			
		||||
    PRINTD("reader wait status: %d, %s \n", reader_wait, dds_err_str(reader_wait));
 | 
			
		||||
    while(true){
 | 
			
		||||
        int status = 0;
 | 
			
		||||
        zero(cm_datareader_samples, MAX_SAMPLES);
 | 
			
		||||
        status = dds_take_mask(cm_datareader_reader, (void**)cm_datareader_samples, info, MAX_SAMPLES, MAX_SAMPLES, states);
 | 
			
		||||
        PRINTD("DDS reading samples returns %d \n", status);
 | 
			
		||||
| 
						 | 
				
			
			@ -719,7 +727,7 @@ void print_cm_datareader(FILE *fp){
 | 
			
		|||
 | 
			
		||||
void usage(){
 | 
			
		||||
    /*describe the default options*/
 | 
			
		||||
    int tpindex;
 | 
			
		||||
    size_t tpindex;
 | 
			
		||||
    printf("\n OPTIONS:\n");
 | 
			
		||||
    printf("-f <filename> <topics>    -- write to file\n");
 | 
			
		||||
    printf("-a             -- all topics\n");
 | 
			
		||||
| 
						 | 
				
			
			@ -733,7 +741,7 @@ int main(int argc, char **argv){
 | 
			
		|||
    FILE *fp = NULL;
 | 
			
		||||
    int flags = 0;
 | 
			
		||||
    int j;
 | 
			
		||||
    int index;
 | 
			
		||||
    size_t index;
 | 
			
		||||
    char *fname = NULL;
 | 
			
		||||
    if(argc == 1){
 | 
			
		||||
        usage();
 | 
			
		||||
| 
						 | 
				
			
			@ -777,7 +785,7 @@ int main(int argc, char **argv){
 | 
			
		|||
            // it's an option, don't process it...
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        int k;
 | 
			
		||||
        size_t k;
 | 
			
		||||
        bool matched = false;
 | 
			
		||||
        for(k = 0; k < TOPICTAB_SIZE; k++) {
 | 
			
		||||
            if(os_strcasecmp(argv[j], topictab[k].name) == 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -133,7 +133,7 @@ void hist_print(struct hist *h, dds_time_t dt, int reset) {
 | 
			
		|||
    const size_t hist_size = sizeof(char) * h->nbins + 1;
 | 
			
		||||
    char *l = (char *) dds_alloc(l_size);
 | 
			
		||||
    char *hist = (char *) dds_alloc(hist_size);
 | 
			
		||||
    double dt_s = dt / 1e9, avg;
 | 
			
		||||
    double dt_s = (double)dt / 1e9, avg;
 | 
			
		||||
    uint64_t peak = 0, cnt = h->under + h->over;
 | 
			
		||||
    size_t p = 0;
 | 
			
		||||
    hist[h->nbins] = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +160,7 @@ void hist_print(struct hist *h, dds_time_t dt, int reset) {
 | 
			
		|||
        else hist[i] = '@';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    avg = cnt / dt_s;
 | 
			
		||||
    avg = (double)cnt / dt_s;
 | 
			
		||||
    if (avg < 999.5)
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5.3g", avg);
 | 
			
		||||
    else if (avg < 1e6)
 | 
			
		||||
| 
						 | 
				
			
			@ -172,9 +172,9 @@ void hist_print(struct hist *h, dds_time_t dt, int reset) {
 | 
			
		|||
    if (cnt < (uint64_t) 10e3)
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5"PRIu64" ", cnt);
 | 
			
		||||
    else if (cnt < (uint64_t) 1e6)
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5.1fk", cnt / 1e3);
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5.1fk", (double)cnt / 1e3);
 | 
			
		||||
    else
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5.1fM", cnt / 1e6);
 | 
			
		||||
        xsnprintf(l, l_size, &p, "%5.1fM", (double)cnt / 1e6);
 | 
			
		||||
 | 
			
		||||
    xsnprintf(l, l_size, &p, " in %.1fs) ", dt_s);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -395,13 +395,13 @@ static void inapplicable_qos(dds_entity_kind_t qt, const char *n) {
 | 
			
		|||
    fprintf(stderr, "warning: %s entity ignoring inapplicable QoS \"%s\"\n", en, n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define   get_qos_T(qt, q, n) ((qt == DDS_KIND_TOPIC)                                                               ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define   get_qos_R(qt, q, n) ((qt == DDS_KIND_READER)                                                              ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define   get_qos_W(qt, q, n) ((qt == DDS_KIND_WRITER)                                                              ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define  get_qos_TW(qt, q, n) ((qt == DDS_KIND_TOPIC)     || (qt == DDS_KIND_WRITER)                                ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define  get_qos_RW(qt, q, n) ((qt == DDS_KIND_READER)    || (qt == DDS_KIND_WRITER)                                ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define  get_qos_PS(qt, q, n) ((qt == DDS_KIND_PUBLISHER) || (qt == DDS_KIND_SUBSCRIBER)                            ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define get_qos_TRW(qt, q, n) ((qt == DDS_KIND_TOPIC)     || (qt == DDS_KIND_READER)     || (qt == DDS_KIND_WRITER) ? q : (inapplicable_qos((qt), n), NULL))
 | 
			
		||||
#define   get_qos_T(qt, q, n) ((qt == DDS_KIND_TOPIC)                                                               ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define   get_qos_R(qt, q, n) ((qt == DDS_KIND_READER)                                                              ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define   get_qos_W(qt, q, n) ((qt == DDS_KIND_WRITER)                                                              ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define  get_qos_TW(qt, q, n) ((qt == DDS_KIND_TOPIC)     || (qt == DDS_KIND_WRITER)                                ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define  get_qos_RW(qt, q, n) ((qt == DDS_KIND_READER)    || (qt == DDS_KIND_WRITER)                                ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define  get_qos_PS(qt, q, n) ((qt == DDS_KIND_PUBLISHER) || (qt == DDS_KIND_SUBSCRIBER)                            ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
#define get_qos_TRW(qt, q, n) ((qt == DDS_KIND_TOPIC)     || (qt == DDS_KIND_READER)     || (qt == DDS_KIND_WRITER) ? q : (inapplicable_qos((qt), n), (dds_qos_t*)0))
 | 
			
		||||
 | 
			
		||||
void qos_durability(dds_entity_kind_t qt, dds_qos_t *q, const char *arg) {
 | 
			
		||||
    dds_qos_t *qp = get_qos_TRW(qt, q, "durability");
 | 
			
		||||
| 
						 | 
				
			
			@ -484,15 +484,15 @@ static unsigned char gethexchar(const char **str) {
 | 
			
		|||
        switch (**str) {
 | 
			
		||||
        case '0': case '1': case '2': case '3': case '4':
 | 
			
		||||
        case '5': case '6': case '7': case '8': case '9':
 | 
			
		||||
            v = 16 * v + (unsigned char) **str - '0';
 | 
			
		||||
            v = (unsigned char) (16 * v + (unsigned char) **str - '0');
 | 
			
		||||
            (*str)++;
 | 
			
		||||
            break;
 | 
			
		||||
        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
 | 
			
		||||
            v = 16 * v + (unsigned char) **str - 'a' + 10;
 | 
			
		||||
            v = (unsigned char) (16 * v + (unsigned char) **str - 'a' + 10);
 | 
			
		||||
            (*str)++;
 | 
			
		||||
            break;
 | 
			
		||||
        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
 | 
			
		||||
            v = 16 * v + (unsigned char) **str - 'A' + 10;
 | 
			
		||||
            v = (unsigned char) (16 * v + (unsigned char) **str - 'A' + 10);
 | 
			
		||||
            (*str)++;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
| 
						 | 
				
			
			@ -511,7 +511,7 @@ static unsigned char getoctchar(const char **str) {
 | 
			
		|||
    int nseen = 0;
 | 
			
		||||
    while (**str && nseen < 3) {
 | 
			
		||||
        if (**str >= '0' && **str <= '7') {
 | 
			
		||||
            v = 8 * v + (unsigned char) **str - '0';
 | 
			
		||||
            v = (unsigned char) (8 * v + (unsigned char) **str - '0');
 | 
			
		||||
            (*str)++;
 | 
			
		||||
            nseen++;
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -859,6 +859,7 @@ QOS (not all are universally applicable):\n\
 | 
			
		|||
 | 
			
		||||
void set_qosprovider(const char *arg) {
 | 
			
		||||
    //Todo: There is no qosprovider_create in dds.h, yet
 | 
			
		||||
    (void)arg;
 | 
			
		||||
//    int result = DDS_RETCODE_OK;
 | 
			
		||||
//    const char *p = strchr(arg, ',');
 | 
			
		||||
//    const char *xs = strstr(arg, "://");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,11 +74,11 @@ void hist_record(struct hist *h, uint64_t x, unsigned weight);
 | 
			
		|||
void hist_print(struct hist *h, dds_time_t dt, int reset);
 | 
			
		||||
 | 
			
		||||
void error(const char *fmt, ...);
 | 
			
		||||
#define error_abort(rc, fmt, ...) if (rc < DDS_SUCCESS) { error(fmt); DDS_ERR_CHECK(rc, DDS_CHECK_FAIL); }
 | 
			
		||||
#define error_report(rc, fmt, ...) if (rc < DDS_SUCCESS) { error(fmt); DDS_ERR_CHECK(rc, DDS_CHECK_REPORT); }
 | 
			
		||||
#define error_return(rc, fmt, ...) if (rc < DDS_SUCCESS) { error_report(rc, fmt); return; }
 | 
			
		||||
#define error_exit(fmt, ...) { error(fmt); exit(2); }
 | 
			
		||||
#define os_error_exit(osres, fmt, ...) if (osres != os_resultSuccess) { error(fmt); exit(2); }
 | 
			
		||||
#define error_abort(rc, ...) if (rc < DDS_SUCCESS) { error(__VA_ARGS__); DDS_ERR_CHECK(rc, DDS_CHECK_FAIL); }
 | 
			
		||||
#define error_report(rc, ...) if (rc < DDS_SUCCESS) { error(__VA_ARGS__); DDS_ERR_CHECK(rc, DDS_CHECK_REPORT); }
 | 
			
		||||
#define error_return(rc, ...) if (rc < DDS_SUCCESS) { error_report(rc, __VA_ARGS__); return; }
 | 
			
		||||
#define error_exit(...) { error(__VA_ARGS__); exit(2); }
 | 
			
		||||
#define os_error_exit(osres, ...) if (osres != os_resultSuccess) { error(__VA_ARGS__); exit(2); }
 | 
			
		||||
 | 
			
		||||
void save_argv0(const char *argv0);
 | 
			
		||||
int common_init(const char *argv0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -919,6 +919,12 @@ static void print_seq_OU(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd __
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void print_seq_ARB(dds_time_t *tstart, dds_time_t tnow, dds_entity_t rd __attribute__ ((unused)), const char *tag, const dds_sample_info_t *iseq, const void **mseq, const struct tgtopic *tgtp) {
 | 
			
		||||
    (void)tnow;
 | 
			
		||||
    (void)tstart;
 | 
			
		||||
    (void)tag;
 | 
			
		||||
    (void)iseq;
 | 
			
		||||
    (void)mseq;
 | 
			
		||||
    (void)tgtp;
 | 
			
		||||
// TODO ARB type support
 | 
			
		||||
//    unsigned i;
 | 
			
		||||
//    for (i = 0; i < mseq->_length; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -1047,6 +1053,7 @@ static void wr_on_publication_matched(dds_entity_t wr __attribute__((unused)), c
 | 
			
		|||
 | 
			
		||||
static int register_instance_wrapper(dds_entity_t wr, const void *d, const dds_time_t tstamp) {
 | 
			
		||||
    dds_instance_handle_t handle;
 | 
			
		||||
    (void)tstamp;
 | 
			
		||||
    return dds_register_instance(wr, &handle, d);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1221,7 +1228,7 @@ static void pub_do_auto(const struct writerspec *spec) {
 | 
			
		|||
                    t = dds_time();
 | 
			
		||||
                }
 | 
			
		||||
                if (++bi == spec->burstsize) {
 | 
			
		||||
                    while (((ntot / spec->burstsize) / ((t - tfirst0) / 1e9 + 5e-3)) > spec->writerate && !termflag) {
 | 
			
		||||
                    while (((double)(ntot / spec->burstsize) / ((double)(t - tfirst0) / 1e9 + 5e-3)) > spec->writerate && !termflag) {
 | 
			
		||||
                        /* FIXME: only doing this manually because batching is not yet implemented properly */
 | 
			
		||||
                        dds_write_flush(spec->wr);
 | 
			
		||||
                        dds_sleepfor(DDS_MSECS(10));
 | 
			
		||||
| 
						 | 
				
			
			@ -1236,7 +1243,7 @@ static void pub_do_auto(const struct writerspec *spec) {
 | 
			
		|||
    tlast = dds_time();
 | 
			
		||||
    hist_print(hist, tlast - tfirst, 0);
 | 
			
		||||
    hist_free(hist);
 | 
			
		||||
    printf ("total writes: %" PRId64 " (%e/s)\n", ntot, ntot * 1e9 / (tlast - tfirst0));
 | 
			
		||||
    printf ("total writes: %" PRId64 " (%e/s)\n", ntot, (double)ntot * 1e9 / (double)(tlast - tfirst0));
 | 
			
		||||
    if (spec->topicsel == KS) {
 | 
			
		||||
        dds_free(d.ks.baggage._buffer);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1592,7 +1599,7 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
    dds_entity_t stcond = 0;
 | 
			
		||||
    dds_return_t rc;
 | 
			
		||||
    uintptr_t exitcode = 0;
 | 
			
		||||
    char tag[256];
 | 
			
		||||
    char tag[270];
 | 
			
		||||
    char tn[256];
 | 
			
		||||
    size_t nxs = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1680,6 +1687,7 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
            tnow = dds_time();
 | 
			
		||||
            for (gi = 0; gi < (spec->polling ? 1 : nxs); gi++) {
 | 
			
		||||
                dds_entity_t cond = !spec->polling && xs[gi] != 0 ? (dds_entity_t) xs[gi] : 0;
 | 
			
		||||
                dds_return_t nread;
 | 
			
		||||
                int32_t i;
 | 
			
		||||
 | 
			
		||||
                if (cond == termcond)
 | 
			
		||||
| 
						 | 
				
			
			@ -1724,22 +1732,22 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
//                    error ("DDS_Subscriber_begin_access: %d (%s)\n", (int) result, dds_err_str(result));
 | 
			
		||||
 | 
			
		||||
                if (spec->mode == MODE_CHECK || (spec->mode == MODE_DUMP && spec->use_take) || spec->polling) {
 | 
			
		||||
                    rc = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
                    nread = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
                } else if (spec->mode == MODE_DUMP) {
 | 
			
		||||
                    rc = dds_read_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
                    nread = dds_read_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
                } else if (spec->use_take || cond == rdcondD) {
 | 
			
		||||
                    rc = dds_take(cond, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples);
 | 
			
		||||
                    nread = dds_take(cond, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples);
 | 
			
		||||
                } else {
 | 
			
		||||
                    rc = dds_read(cond, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples);
 | 
			
		||||
                    nread = dds_read(cond, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (rc < 1) {
 | 
			
		||||
                    if (spec->polling && rc == 0) {
 | 
			
		||||
                if (nread < 1) {
 | 
			
		||||
                    if (spec->polling && nread == 0) {
 | 
			
		||||
                        ; /* expected */
 | 
			
		||||
                    } else if (spec->mode == MODE_CHECK || spec->mode == MODE_DUMP || spec->polling) {
 | 
			
		||||
                        printf ("%s: %d (%s) on %s\n", (!spec->use_take && spec->mode == MODE_DUMP) ? "read" : "take", (int) rc, dds_err_str(rc), spec->polling ? "poll" : "stcond");
 | 
			
		||||
                        printf ("%s: %d (%s) on %s\n", (!spec->use_take && spec->mode == MODE_DUMP) ? "read" : "take", (int) nread, dds_err_str(nread), spec->polling ? "poll" : "stcond");
 | 
			
		||||
                    } else {
 | 
			
		||||
                        printf ("%s: %d (%s) on rdcond%s\n", spec->use_take ? "take" : "read", (int) rc, dds_err_str(rc), (cond == rdcondA) ? "A" : (cond == rdcondD) ? "D" : "?");
 | 
			
		||||
                        printf ("%s: %d (%s) on rdcond%s\n", spec->use_take ? "take" : "read", (int) nread, dds_err_str(nread), (cond == rdcondA) ? "A" : (cond == rdcondD) ? "D" : "?");
 | 
			
		||||
                    }
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -1753,18 +1761,18 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
                case MODE_DUMP:
 | 
			
		||||
                    switch (spec->topicsel) {
 | 
			
		||||
                    case UNSPEC: assert(0);
 | 
			
		||||
                    case KS:   print_seq_KS(&tstart, tnow, rd, tag, iseq, (KeyedSeq **)mseq, rc); break;
 | 
			
		||||
                    case K32:  print_seq_K32(&tstart, tnow, rd, tag, iseq, (Keyed32 **)mseq, rc); break;
 | 
			
		||||
                    case K64:  print_seq_K64(&tstart, tnow, rd, tag, iseq, (Keyed64 **)mseq, rc); break;
 | 
			
		||||
                    case K128: print_seq_K128(&tstart, tnow, rd, tag, iseq, (Keyed128 **)mseq, rc); break;
 | 
			
		||||
                    case K256: print_seq_K256(&tstart, tnow, rd, tag, iseq, (Keyed256 **)mseq, rc); break;
 | 
			
		||||
                    case OU:   print_seq_OU(&tstart, tnow, rd, tag, iseq, (const OneULong **)mseq, rc); break;
 | 
			
		||||
                    case KS:   print_seq_KS(&tstart, tnow, rd, tag, iseq, (KeyedSeq **)mseq, nread); break;
 | 
			
		||||
                    case K32:  print_seq_K32(&tstart, tnow, rd, tag, iseq, (Keyed32 **)mseq, nread); break;
 | 
			
		||||
                    case K64:  print_seq_K64(&tstart, tnow, rd, tag, iseq, (Keyed64 **)mseq, nread); break;
 | 
			
		||||
                    case K128: print_seq_K128(&tstart, tnow, rd, tag, iseq, (Keyed128 **)mseq, nread); break;
 | 
			
		||||
                    case K256: print_seq_K256(&tstart, tnow, rd, tag, iseq, (Keyed256 **)mseq, nread); break;
 | 
			
		||||
                    case OU:   print_seq_OU(&tstart, tnow, rd, tag, iseq, (const OneULong **)mseq, nread); break;
 | 
			
		||||
                    case ARB:  print_seq_ARB(&tstart, tnow, rd, tag, iseq, (const void **)mseq, spec->tgtp); break;
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case MODE_CHECK:
 | 
			
		||||
                    for (i = 0; i < rc; i++) {
 | 
			
		||||
                    for (i = 0; i < nread; i++) {
 | 
			
		||||
                        int keyval = 0;
 | 
			
		||||
                        unsigned seq = 0;
 | 
			
		||||
                        unsigned size = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -1793,7 +1801,7 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
                            const dds_time_t tdelta_s = tdelta_ns / DDS_NSECS_IN_SEC;
 | 
			
		||||
                            const dds_time_t tdelta_ms = ((tdelta_ns % DDS_NSECS_IN_SEC) + 500000) / DDS_NSECS_IN_MSEC;
 | 
			
		||||
                            const long long ndelta = nreceived - last_nreceived;
 | 
			
		||||
                            const double rate_Mbps = (nreceived_bytes - last_nreceived_bytes) * 8 / 1e6;
 | 
			
		||||
                            const double rate_Mbps = (double)(nreceived_bytes - last_nreceived_bytes) * 8 / 1e6;
 | 
			
		||||
                            printf ("%"PRId64".%03"PRId64" ntot %lld nseq %lld ndelta %lld rate %.2f Mb/s\n",
 | 
			
		||||
                                    tdelta_s, tdelta_ms, nreceived, out_of_seq, ndelta, rate_Mbps);
 | 
			
		||||
                            last_nreceived = nreceived;
 | 
			
		||||
| 
						 | 
				
			
			@ -1807,7 +1815,7 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
                case MODE_ZEROLOAD:
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                rc = dds_return_loan(rd, mseq, spec->read_maxsamples);
 | 
			
		||||
                rc = dds_return_loan(rd, mseq, nread);
 | 
			
		||||
                error_report(rc, "dds_return_loan failed");
 | 
			
		||||
                if (spec->sleep_ns) {
 | 
			
		||||
                    dds_sleepfor(spec->sleep_ns);
 | 
			
		||||
| 
						 | 
				
			
			@ -1822,13 +1830,14 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
//                error ("DDS_Subscriber_begin_access: %d (%s)\n", (int) result, dds_err_str (result));
 | 
			
		||||
 | 
			
		||||
            /* This is the final Read/Take */
 | 
			
		||||
            rc = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
            if (rc == 0) {
 | 
			
		||||
            dds_return_t nread;
 | 
			
		||||
            nread = dds_take_mask(rd, mseq, iseq, spec->read_maxsamples, spec->read_maxsamples, DDS_ANY_STATE);
 | 
			
		||||
            if (nread == 0) {
 | 
			
		||||
                if (!once_mode)
 | 
			
		||||
                    printf ("-- final take: data reader empty --\n");
 | 
			
		||||
                else
 | 
			
		||||
                    exitcode = 1;
 | 
			
		||||
            } else if (rc < DDS_SUCCESS) {
 | 
			
		||||
            } else if (nread < DDS_SUCCESS) {
 | 
			
		||||
                if (!once_mode) {
 | 
			
		||||
                    error_report(rc, "-- final take --\n");
 | 
			
		||||
                } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -1840,12 +1849,12 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
                if (spec->mode == MODE_PRINT || spec->mode == MODE_DUMP) {
 | 
			
		||||
                    switch (spec->topicsel) {
 | 
			
		||||
                    case UNSPEC: assert(0);
 | 
			
		||||
                    case KS:   print_seq_KS(&tstart, dds_time(), rd, tag, iseq, (KeyedSeq **) mseq, rc); break;
 | 
			
		||||
                    case K32:  print_seq_K32(&tstart, dds_time(), rd, tag, iseq, (Keyed32 **) mseq, rc); break;
 | 
			
		||||
                    case K64:  print_seq_K64(&tstart, dds_time(), rd, tag, iseq, (Keyed64 **) mseq, rc); break;
 | 
			
		||||
                    case K128: print_seq_K128(&tstart, dds_time(), rd, tag, iseq, (Keyed128 **) mseq, rc); break;
 | 
			
		||||
                    case K256: print_seq_K256(&tstart, dds_time(), rd, tag, iseq, (Keyed256 **) mseq, rc); break;
 | 
			
		||||
                    case OU:   print_seq_OU(&tstart, dds_time(), rd, tag, iseq, (const OneULong **) mseq, rc); break;
 | 
			
		||||
                    case KS:   print_seq_KS(&tstart, dds_time(), rd, tag, iseq, (KeyedSeq **) mseq, nread); break;
 | 
			
		||||
                    case K32:  print_seq_K32(&tstart, dds_time(), rd, tag, iseq, (Keyed32 **) mseq, nread); break;
 | 
			
		||||
                    case K64:  print_seq_K64(&tstart, dds_time(), rd, tag, iseq, (Keyed64 **) mseq, nread); break;
 | 
			
		||||
                    case K128: print_seq_K128(&tstart, dds_time(), rd, tag, iseq, (Keyed128 **) mseq, nread); break;
 | 
			
		||||
                    case K256: print_seq_K256(&tstart, dds_time(), rd, tag, iseq, (Keyed256 **) mseq, nread); break;
 | 
			
		||||
                    case OU:   print_seq_OU(&tstart, dds_time(), rd, tag, iseq, (const OneULong **) mseq, nread); break;
 | 
			
		||||
                    case ARB:  print_seq_ARB(&tstart, dds_time(), rd, tag, iseq, (const void **) mseq, spec->tgtp); break;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -1853,7 +1862,7 @@ static uint32_t subthread(void *vspec) {
 | 
			
		|||
            // TODO coherency support
 | 
			
		||||
//            if (need_access && (result = DDS_Subscriber_end_access(sub)) != DDS_RETCODE_OK)
 | 
			
		||||
//                error ("DDS_Subscriber_end_access: %d (%s)\n", (int) result, dds_err_str(result));
 | 
			
		||||
            rc = dds_return_loan(rd, mseq, spec->read_maxsamples);
 | 
			
		||||
            rc = dds_return_loan(rd, mseq, nread);
 | 
			
		||||
            error_report(rc, "dds_return_loan failed");
 | 
			
		||||
        }
 | 
			
		||||
        dds_free(iseq);
 | 
			
		||||
| 
						 | 
				
			
			@ -1973,6 +1982,7 @@ static int get_metadata(char **metadata, char **typename, char **keylist, const
 | 
			
		|||
 | 
			
		||||
static dds_entity_t find_topic(dds_entity_t dpFindTopic, const char *name, const dds_duration_t *timeout) {
 | 
			
		||||
    dds_entity_t tp;
 | 
			
		||||
    (void)timeout;
 | 
			
		||||
//    TODO ARB type support
 | 
			
		||||
//    int isbuiltin = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2077,8 +2087,8 @@ static void addspec(unsigned whatfor, unsigned *specsofar, unsigned *specidx, st
 | 
			
		|||
    *specsofar |= whatfor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_print_mode(const char *optarg) {
 | 
			
		||||
    char *copy = dds_string_dup(optarg), *cursor = copy, *tok;
 | 
			
		||||
static void set_print_mode(const char *modestr) {
 | 
			
		||||
    char *copy = dds_string_dup(modestr), *cursor = copy, *tok;
 | 
			
		||||
    while ((tok = os_strsep(&cursor, ",")) != NULL) {
 | 
			
		||||
        int enable;
 | 
			
		||||
        if (strncmp(tok, "no", 2) == 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -2121,7 +2131,7 @@ static void set_print_mode(const char *optarg) {
 | 
			
		|||
                else
 | 
			
		||||
                    print_metadata &= ~tab[i].flag;
 | 
			
		||||
            } else {
 | 
			
		||||
                fprintf (stderr, "-P %s: invalid print mode\n", optarg);
 | 
			
		||||
                fprintf (stderr, "-P %s: invalid print mode\n", modestr);
 | 
			
		||||
                exit(2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -2136,11 +2146,11 @@ int MAIN(int argc, char *argv[]) {
 | 
			
		|||
    dds_listener_t *wrlistener = dds_listener_create(NULL);
 | 
			
		||||
 | 
			
		||||
    dds_qos_t *qos;
 | 
			
		||||
    const char **qtopic = (const char **) dds_alloc(sizeof(char *) * argc);
 | 
			
		||||
    const char **qreader = (const char **) dds_alloc(sizeof(char *) * (2+argc));
 | 
			
		||||
    const char **qwriter = (const char **) dds_alloc(sizeof(char *) * (2+argc));
 | 
			
		||||
    const char **qpublisher = (const char **) dds_alloc(sizeof(char *) * (2+argc));
 | 
			
		||||
    const char **qsubscriber = (const char **) dds_alloc(sizeof(char *) * (2+argc));
 | 
			
		||||
    const char **qtopic = (const char **) dds_alloc(sizeof(char *) * (unsigned)argc);
 | 
			
		||||
    const char **qreader = (const char **) dds_alloc(sizeof(char *) * (2+(unsigned)argc));
 | 
			
		||||
    const char **qwriter = (const char **) dds_alloc(sizeof(char *) * (2+(unsigned)argc));
 | 
			
		||||
    const char **qpublisher = (const char **) dds_alloc(sizeof(char *) * (2+(unsigned)argc));
 | 
			
		||||
    const char **qsubscriber = (const char **) dds_alloc(sizeof(char *) * (2+(unsigned)argc));
 | 
			
		||||
    int nqtopic = 0, nqreader = 0, nqwriter = 0;
 | 
			
		||||
    int nqpublisher = 0, nqsubscriber = 0;
 | 
			
		||||
    int opt, pos;
 | 
			
		||||
| 
						 | 
				
			
			@ -2344,7 +2354,7 @@ int MAIN(int argc, char *argv[]) {
 | 
			
		|||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'n':
 | 
			
		||||
            spec[specidx].rd.read_maxsamples = atoi(os_get_optarg());
 | 
			
		||||
            spec[specidx].rd.read_maxsamples = (uint32_t)atoi(os_get_optarg());
 | 
			
		||||
            break;
 | 
			
		||||
        case 'O':
 | 
			
		||||
            once_mode = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -2503,7 +2513,7 @@ int MAIN(int argc, char *argv[]) {
 | 
			
		|||
    dds_write_set_batch(true); // FIXME: hack (the global batching flag is a hack anyway)
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        char **ps = (char **) dds_alloc(sizeof(char *) * (argc - os_get_optind()));
 | 
			
		||||
        char **ps = (char **) dds_alloc(sizeof(char *) * (uint32_t)(argc - os_get_optind()));
 | 
			
		||||
        for (i = 0; i < (unsigned) (argc - os_get_optind()); i++)
 | 
			
		||||
            ps[i] = expand_envvars(argv[(unsigned) os_get_optind() + i]);
 | 
			
		||||
        if (want_reader) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ typedef struct ut_avlTreedef {
 | 
			
		|||
    size_t avlnodeoffset;
 | 
			
		||||
    size_t keyoffset;
 | 
			
		||||
    union {
 | 
			
		||||
        int (*cmp) (void);
 | 
			
		||||
        int (*cmp) ();
 | 
			
		||||
        ut_avlCompare_t comparekk;
 | 
			
		||||
        ut_avlCompare_r_t comparekk_r;
 | 
			
		||||
    } u;
 | 
			
		||||
| 
						 | 
				
			
			@ -239,14 +239,14 @@ typedef struct ut_avlCIter {
 | 
			
		|||
} ut_avlCIter_t;
 | 
			
		||||
 | 
			
		||||
/* avlnodeoffset and keyoffset must both be in [0,2**31-1] */
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), 0, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_R, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) (void)) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), 0, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_R, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
 | 
			
		||||
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { (avlnodeoffset), (keyoffset), { (int (*) ()) (comparekk) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
 | 
			
		||||
 | 
			
		||||
/* Not maintaining # nodes */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,7 +91,7 @@ static const char *conode_from_node (const ut_avlTreedef_t *td, const ut_avlNode
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void treedef_init_common (ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, int (*cmp) (void), ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
static void treedef_init_common (ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, int (*cmp) (), ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
    assert (avlnodeoffset <= 0x7fffffff);
 | 
			
		||||
    assert (keyoffset <= 0x7fffffff);
 | 
			
		||||
| 
						 | 
				
			
			@ -104,13 +104,13 @@ static void treedef_init_common (ut_avlTreedef_t *td, size_t avlnodeoffset, size
 | 
			
		|||
 | 
			
		||||
void ut_avlTreedefInit (_Out_ ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, _In_ ut_avlCompare_t comparekk, _In_opt_ ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
    treedef_init_common (td, avlnodeoffset, keyoffset, (int (*) (void)) comparekk, augment, flags);
 | 
			
		||||
    treedef_init_common (td, avlnodeoffset, keyoffset, (int (*) ()) comparekk, augment, flags);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ut_avlTreedefInit_r (_Out_ ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, _In_ ut_avlCompare_r_t comparekk_r, _Inout_opt_ void *cmp_arg, ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
    td->cmp_arg = cmp_arg;
 | 
			
		||||
    treedef_init_common (td, avlnodeoffset, keyoffset, (int (*) (void)) comparekk_r, augment, flags | UT_AVL_TREEDEF_FLAG_R);
 | 
			
		||||
    treedef_init_common (td, avlnodeoffset, keyoffset, (int (*) ()) comparekk_r, augment, flags | UT_AVL_TREEDEF_FLAG_R);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ut_avlInit (_In_ const ut_avlTreedef_t *td, _Out_ ut_avlTree_t *tree)
 | 
			
		||||
| 
						 | 
				
			
			@ -948,13 +948,13 @@ _Ret_notnull_ void *ut_avlRootNonEmpty (_In_ const ut_avlTreedef_t *td, _In_ con
 | 
			
		|||
 | 
			
		||||
void ut_avlCTreedefInit (_Out_ ut_avlCTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, _In_ ut_avlCompare_t comparekk, _In_opt_ ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
    treedef_init_common (&td->t, avlnodeoffset, keyoffset, (int (*) (void)) comparekk, augment, flags);
 | 
			
		||||
    treedef_init_common (&td->t, avlnodeoffset, keyoffset, (int (*) ()) comparekk, augment, flags);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ut_avlCTreedefInit_r (_Out_ ut_avlCTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, _In_ ut_avlCompare_r_t comparekk_r, _Inout_opt_ void *cmp_arg, _In_opt_ ut_avlAugment_t augment, uint32_t flags)
 | 
			
		||||
{
 | 
			
		||||
    td->t.cmp_arg = cmp_arg;
 | 
			
		||||
    treedef_init_common (&td->t, avlnodeoffset, keyoffset, (int (*) (void)) comparekk_r, augment, flags | UT_AVL_TREEDEF_FLAG_R);
 | 
			
		||||
    treedef_init_common (&td->t, avlnodeoffset, keyoffset, (int (*) ()) comparekk_r, augment, flags | UT_AVL_TREEDEF_FLAG_R);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ut_avlCInit (_In_ const ut_avlCTreedef_t *td, _Out_ ut_avlCTree_t *tree)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -326,6 +326,7 @@ ut_handle_get_link(
 | 
			
		|||
    ret = lookup_handle(hdl, UT_HANDLE_DONTCARE_KIND, &info);
 | 
			
		||||
    assert(((ret == UT_HANDLE_OK) && (info != NULL)) ||
 | 
			
		||||
           ((ret != UT_HANDLE_OK) && (info == NULL)) );
 | 
			
		||||
    (void)ret;
 | 
			
		||||
    os_mutexUnlock(&hs->mutex);
 | 
			
		||||
 | 
			
		||||
    return info;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue