Clean up sertopic_default definition
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									ad19f571ae
								
							
						
					
					
						commit
						ab7c95e02f
					
				
					 22 changed files with 454 additions and 380 deletions
				
			
		| 
						 | 
					@ -30,7 +30,6 @@ PREPEND(srcs_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
 | 
				
			||||||
    dds_topic.c
 | 
					    dds_topic.c
 | 
				
			||||||
    dds_listener.c
 | 
					    dds_listener.c
 | 
				
			||||||
    dds_read.c
 | 
					    dds_read.c
 | 
				
			||||||
    dds_stream.c
 | 
					 | 
				
			||||||
    dds_waitset.c
 | 
					    dds_waitset.c
 | 
				
			||||||
    dds_readcond.c
 | 
					    dds_readcond.c
 | 
				
			||||||
    dds_guardcond.c
 | 
					    dds_guardcond.c
 | 
				
			||||||
| 
						 | 
					@ -70,7 +69,6 @@ PREPEND(hdrs_private_ddsc "${CMAKE_CURRENT_LIST_DIR}/src"
 | 
				
			||||||
    dds__guardcond.h
 | 
					    dds__guardcond.h
 | 
				
			||||||
    dds__reader.h
 | 
					    dds__reader.h
 | 
				
			||||||
    dds__rhc_default.h
 | 
					    dds__rhc_default.h
 | 
				
			||||||
    dds__stream.h
 | 
					 | 
				
			||||||
    dds__subscriber.h
 | 
					    dds__subscriber.h
 | 
				
			||||||
    dds__topic.h
 | 
					    dds__topic.h
 | 
				
			||||||
    dds__types.h
 | 
					    dds__types.h
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,8 +18,6 @@
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_sample_free_contents (char * data, const uint32_t * ops);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined (__cplusplus)
 | 
					#if defined (__cplusplus)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,9 +9,10 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
					 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#ifndef DDSI_SERDATA_BUILTINTOPIC_H
 | 
					#ifndef DDS__SERDATA_BUILTINTOPIC_H
 | 
				
			||||||
#define DDSI_SERDATA_BUILTINTOPIC_H
 | 
					#define DDS__SERDATA_BUILTINTOPIC_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "dds/dds.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_xqos.h"
 | 
					#include "dds/ddsi/ddsi_xqos.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata.h"
 | 
					#include "dds/ddsi/ddsi_serdata.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_sertopic.h"
 | 
					#include "dds/ddsi/ddsi_sertopic.h"
 | 
				
			||||||
| 
						 | 
					@ -33,7 +34,6 @@ enum ddsi_sertopic_builtintopic_type {
 | 
				
			||||||
  DSBT_WRITER
 | 
					  DSBT_WRITER
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ddsi_domaingv;
 | 
					 | 
				
			||||||
struct ddsi_sertopic_builtintopic {
 | 
					struct ddsi_sertopic_builtintopic {
 | 
				
			||||||
  struct ddsi_sertopic c;
 | 
					  struct ddsi_sertopic c;
 | 
				
			||||||
  enum ddsi_sertopic_builtintopic_type type;
 | 
					  enum ddsi_sertopic_builtintopic_type type;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,21 +13,9 @@
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dds__alloc.h"
 | 
					#include "dds__alloc.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					 | 
				
			||||||
#include "dds/ddsrt/heap.h"
 | 
					#include "dds/ddsrt/heap.h"
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
#define OP_DEBUG_FREE 1
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined OP_DEBUG_FREE
 | 
					 | 
				
			||||||
static const char * stream_op_type[11] =
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  NULL, "1Byte", "2Byte", "4Byte", "8Byte", "String",
 | 
					 | 
				
			||||||
  "BString", "Sequence", "Array", "Union", "Struct"
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static dds_allocator_t dds_allocator_fns = { ddsrt_malloc, ddsrt_realloc, ddsrt_free };
 | 
					static dds_allocator_t dds_allocator_fns = { ddsrt_malloc, ddsrt_realloc, ddsrt_free };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,287 +75,30 @@ void dds_string_free (char * str)
 | 
				
			||||||
  dds_free (str);
 | 
					  dds_free (str);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_sample_free_contents (char *data, const uint32_t * ops)
 | 
					static void dds_sample_free_key (void *vsample, const struct dds_topic_descriptor * desc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  uint32_t op;
 | 
					  char *sample = vsample;
 | 
				
			||||||
  uint32_t type;
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  uint32_t num;
 | 
					 | 
				
			||||||
  uint32_t subtype;
 | 
					 | 
				
			||||||
  char * addr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  while ((op = *ops) != DDS_OP_RTS)
 | 
					 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    switch (DDS_OP_MASK & op)
 | 
					    const uint32_t *op = desc->m_ops + desc->m_keys[i].m_index;
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      case DDS_OP_ADR:
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        type = DDS_OP_TYPE (op);
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
        DDS_TRACE("F-ADR: %s offset %d\n", stream_op_type[type], ops[1]);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        addr = data + ops[1];
 | 
					 | 
				
			||||||
        ops += 2;
 | 
					 | 
				
			||||||
        switch (type)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_1BY:
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_2BY:
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_4BY:
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_8BY:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_STR:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
            DDS_TRACE("F-STR: @ %p %s\n", addr, *((char**) addr));
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
            dds_free (*((char**) addr));
 | 
					 | 
				
			||||||
            *((char**) addr) = NULL;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_SEQ:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            dds_sequence_t * seq = (dds_sequence_t*) addr;
 | 
					 | 
				
			||||||
            subtype = DDS_OP_SUBTYPE (op);
 | 
					 | 
				
			||||||
            num = (seq->_maximum > seq->_length) ? seq->_maximum : seq->_length;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
            DDS_TRACE("F-SEQ: of %s\n", stream_op_type[subtype]);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
            if ((seq->_release && num) || (subtype > DDS_OP_VAL_STR))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              switch (subtype)
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_1BY:
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_2BY:
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_4BY:
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_8BY:
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_BST:
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  ops++;
 | 
					 | 
				
			||||||
                  break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                case DDS_OP_VAL_STR:
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  char ** ptr = (char**) seq->_buffer;
 | 
					 | 
				
			||||||
                  while (num--)
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    dds_free (*ptr++);
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                  break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                default:
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  const uint32_t elem_size = *ops++;
 | 
					 | 
				
			||||||
                  const uint32_t * jsr_ops = ops + DDS_OP_ADR_JSR (*ops) - 3;
 | 
					 | 
				
			||||||
                  const uint32_t jmp = DDS_OP_ADR_JMP (*ops);
 | 
					 | 
				
			||||||
                  char * ptr = (char*) seq->_buffer;
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
                  while (num--)
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    dds_sample_free_contents (ptr, jsr_ops);
 | 
					 | 
				
			||||||
                    ptr += elem_size;
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                  ops += jmp ? (jmp - 3) : 1;
 | 
					 | 
				
			||||||
                  break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (seq->_release)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              dds_free (seq->_buffer);
 | 
					 | 
				
			||||||
              seq->_maximum = 0;
 | 
					 | 
				
			||||||
              seq->_length = 0;
 | 
					 | 
				
			||||||
              seq->_buffer = NULL;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_ARR:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            subtype = DDS_OP_SUBTYPE (op);
 | 
					 | 
				
			||||||
            num = *ops++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
            DDS_TRACE("F-ARR: of %s size %d\n", stream_op_type[subtype], num);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
            switch (subtype)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_1BY:
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_2BY:
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_4BY:
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_8BY:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_STR:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                char ** ptr = (char**) addr;
 | 
					 | 
				
			||||||
                while (num--)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  dds_free (*ptr++);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_BST:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                ops += 2;
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              default:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                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_sample_free_contents (addr, jsr_ops);
 | 
					 | 
				
			||||||
                  addr += elem_size;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                ops += jmp ? (jmp - 3) : 2;
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_UNI:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            const bool has_default = op & DDS_OP_FLAG_DEF;
 | 
					 | 
				
			||||||
            subtype = DDS_OP_SUBTYPE (op);
 | 
					 | 
				
			||||||
            num = ops[0];
 | 
					 | 
				
			||||||
            const uint32_t * jeq_op = ops + DDS_OP_ADR_JSR (ops[1]) - 2;
 | 
					 | 
				
			||||||
            uint32_t disc = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assert (subtype <= DDS_OP_VAL_4BY);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
            DDS_TRACE("F-UNI: switch %s cases %d\n", stream_op_type[subtype], num);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
            /* Get discriminant */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            switch (subtype)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_1BY:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                disc = *((uint8_t*) addr);
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_2BY:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                disc = *((uint16_t*) addr);
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              case DDS_OP_VAL_4BY:
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                disc = *((uint32_t*) addr);
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              default: assert (0);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /* Free case matching discriminant */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            while (num--)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              assert ((DDS_OP_MASK & jeq_op[0]) == DDS_OP_JEQ);
 | 
					 | 
				
			||||||
              if ((jeq_op[1] == disc) || (has_default && (num == 0)))
 | 
					 | 
				
			||||||
              {
 | 
					 | 
				
			||||||
                subtype = DDS_JEQ_TYPE (jeq_op[0]);
 | 
					 | 
				
			||||||
                addr = data + jeq_op[2];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (subtype)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_1BY:
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_2BY:
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_4BY:
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_8BY:
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_BST:
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                  case DDS_OP_VAL_STR:
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    dds_free (*((char**) addr));
 | 
					 | 
				
			||||||
                    *((char**) addr) = NULL;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                  default:
 | 
					 | 
				
			||||||
                  {
 | 
					 | 
				
			||||||
                    dds_sample_free_contents (addr, jeq_op + DDS_OP_ADR_JSR (jeq_op[0]));
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                  }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
              }
 | 
					 | 
				
			||||||
              jeq_op += 3;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /* Jump to next instruction */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ops += DDS_OP_ADR_JMP (ops[1]) - 2;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          case DDS_OP_VAL_BST:
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            ops++;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          default: assert (0);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      case DDS_OP_JSR: /* Implies nested type */
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
        DDS_TRACE("F-JSR: %d\n", DDS_OP_JUMP (op));
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        dds_sample_free_contents (data, ops + DDS_OP_JUMP (op));
 | 
					 | 
				
			||||||
        ops++;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      default: assert (0);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
#ifdef OP_DEBUG_FREE
 | 
					 | 
				
			||||||
  DDS_TRACE("F-RTS:\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void dds_sample_free_key (char * sample, const struct dds_topic_descriptor * desc)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  uint32_t i;
 | 
					 | 
				
			||||||
  const uint32_t * op;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (i = 0; i < desc->m_nkeys; i++)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    op = desc->m_ops + desc->m_keys[i].m_index;
 | 
					 | 
				
			||||||
    if (DDS_OP_TYPE (*op) == DDS_OP_VAL_STR)
 | 
					    if (DDS_OP_TYPE (*op) == DDS_OP_VAL_STR)
 | 
				
			||||||
    {
 | 
					      dds_free (*(char **) (sample + op[1]));
 | 
				
			||||||
      dds_free (*(char**)(sample + op[1]));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op)
 | 
					void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  /* external API, so can't replace the dds_topic_decsriptor type ... */
 | 
				
			||||||
  assert (desc);
 | 
					  assert (desc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (sample)
 | 
					  if (sample)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (op & DDS_FREE_CONTENTS_BIT)
 | 
					    if (op & DDS_FREE_CONTENTS_BIT)
 | 
				
			||||||
    {
 | 
					      dds_stream_free_sample (sample, desc->m_ops);
 | 
				
			||||||
      dds_sample_free_contents ((char*) sample, desc->m_ops);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else if (op & DDS_FREE_KEY_BIT)
 | 
					    else if (op & DDS_FREE_KEY_BIT)
 | 
				
			||||||
    {
 | 
					      dds_sample_free_key (sample, desc);
 | 
				
			||||||
      dds_sample_free_key ((char*) sample, desc);
 | 
					
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (op & DDS_FREE_ALL_BIT)
 | 
					    if (op & DDS_FREE_ALL_BIT)
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      dds_free (sample);
 | 
					      dds_free (sample);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,6 @@
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
#include "dds/ddsi/q_freelist.h"
 | 
					#include "dds/ddsi/q_freelist.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_plist.h"
 | 
					#include "dds/ddsi/ddsi_plist.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					 | 
				
			||||||
#include "dds__serdata_builtintopic.h"
 | 
					#include "dds__serdata_builtintopic.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_tkmap.h"
 | 
					#include "dds/ddsi/ddsi_tkmap.h"
 | 
				
			||||||
#include "dds/ddsi/q_entity.h"
 | 
					#include "dds/ddsi/q_entity.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ static bool sertopic_builtin_equal (const struct ddsi_sertopic *acmn, const stru
 | 
				
			||||||
static uint32_t sertopic_builtin_hash (const struct ddsi_sertopic *tpcmn)
 | 
					static uint32_t sertopic_builtin_hash (const struct ddsi_sertopic *tpcmn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct ddsi_sertopic_builtintopic *tp = (struct ddsi_sertopic_builtintopic *) tpcmn;
 | 
					  const struct ddsi_sertopic_builtintopic *tp = (struct ddsi_sertopic_builtintopic *) tpcmn;
 | 
				
			||||||
  return tp->type;
 | 
					  return (uint32_t) tp->type;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void free_pp (void *vsample)
 | 
					static void free_pp (void *vsample)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,6 @@
 | 
				
			||||||
#include "dds__topic.h"
 | 
					#include "dds__topic.h"
 | 
				
			||||||
#include "dds__listener.h"
 | 
					#include "dds__listener.h"
 | 
				
			||||||
#include "dds__participant.h"
 | 
					#include "dds__participant.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					 | 
				
			||||||
#include "dds__init.h"
 | 
					#include "dds__init.h"
 | 
				
			||||||
#include "dds__domain.h"
 | 
					#include "dds__domain.h"
 | 
				
			||||||
#include "dds__get_status.h"
 | 
					#include "dds__get_status.h"
 | 
				
			||||||
| 
						 | 
					@ -32,6 +31,7 @@
 | 
				
			||||||
#include "dds/ddsi/ddsi_iid.h"
 | 
					#include "dds/ddsi/ddsi_iid.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_plist.h"
 | 
					#include "dds/ddsi/ddsi_plist.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_domaingv.h"
 | 
					#include "dds/ddsi/ddsi_domaingv.h"
 | 
				
			||||||
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds__serdata_builtintopic.h"
 | 
					#include "dds__serdata_builtintopic.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_topic)
 | 
					DECL_ENTITY_LOCK_UNLOCK (extern inline, dds_topic)
 | 
				
			||||||
| 
						 | 
					@ -399,13 +399,19 @@ dds_entity_t dds_create_topic (dds_entity_t participant, const dds_topic_descrip
 | 
				
			||||||
  ddsi_sertopic_init (&st->c, name, desc->m_typename, &ddsi_sertopic_ops_default, desc->m_nkeys ? &ddsi_serdata_ops_cdr : &ddsi_serdata_ops_cdr_nokey, (desc->m_nkeys == 0));
 | 
					  ddsi_sertopic_init (&st->c, name, desc->m_typename, &ddsi_sertopic_ops_default, desc->m_nkeys ? &ddsi_serdata_ops_cdr : &ddsi_serdata_ops_cdr_nokey, (desc->m_nkeys == 0));
 | 
				
			||||||
  st->native_encoding_identifier = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? CDR_LE : CDR_BE);
 | 
					  st->native_encoding_identifier = (DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN ? CDR_LE : CDR_BE);
 | 
				
			||||||
  st->serpool = ppent->m_domain->gv.serpool;
 | 
					  st->serpool = ppent->m_domain->gv.serpool;
 | 
				
			||||||
  st->type = (void*) desc;
 | 
					  st->type.m_size = desc->m_size;
 | 
				
			||||||
  st->nkeys = desc->m_nkeys;
 | 
					  st->type.m_align = desc->m_align;
 | 
				
			||||||
  st->keys = desc->m_keys;
 | 
					  st->type.m_flagset = desc->m_flagset;
 | 
				
			||||||
 | 
					  st->type.m_nkeys = desc->m_nkeys;
 | 
				
			||||||
 | 
					  st->type.m_keys = ddsrt_malloc (st->type.m_nkeys  * sizeof (*st->type.m_keys));
 | 
				
			||||||
 | 
					  for (uint32_t i = 0; i < st->type.m_nkeys; i++)
 | 
				
			||||||
 | 
					    st->type.m_keys[i] = desc->m_keys[i].m_index;
 | 
				
			||||||
 | 
					  st->type.m_nops = dds_stream_countops (desc->m_ops);
 | 
				
			||||||
 | 
					  st->type.m_ops = ddsrt_memdup (desc->m_ops, st->type.m_nops * sizeof (*st->type.m_ops));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Check if topic cannot be optimised (memcpy marshal) */
 | 
					  /* Check if topic cannot be optimised (memcpy marshal) */
 | 
				
			||||||
  if (!(desc->m_flagset & DDS_TOPIC_NO_OPTIMIZE)) {
 | 
					  if (!(st->type.m_flagset & DDS_TOPIC_NO_OPTIMIZE)) {
 | 
				
			||||||
    st->opt_size = dds_stream_check_optimize (desc);
 | 
					    st->opt_size = dds_stream_check_optimize (&st->type);
 | 
				
			||||||
    DDS_CTRACE (&ppent->m_domain->gv.logconfig, "Marshalling for type: %s is %soptimised\n", desc->m_typename, st->opt_size ? "" : "not ");
 | 
					    DDS_CTRACE (&ppent->m_domain->gv.logconfig, "Marshalling for type: %s is %soptimised\n", desc->m_typename, st->opt_size ? "" : "not ");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@
 | 
				
			||||||
#include "dds/ddsi/q_xmsg.h"
 | 
					#include "dds/ddsi/q_xmsg.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_rhc.h"
 | 
					#include "dds/ddsi/ddsi_rhc.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata.h"
 | 
					#include "dds/ddsi/ddsi_serdata.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds/ddsi/q_transmit.h"
 | 
					#include "dds/ddsi/q_transmit.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_entity_index.h"
 | 
					#include "dds/ddsi/ddsi_entity_index.h"
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,7 +125,6 @@ static const dds_topic_descriptor_t type_uni_desc =
 | 
				
			||||||
    DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY, 0u, 4,
 | 
					    DDS_OP_ADR | DDS_OP_TYPE_ARR | DDS_OP_SUBTYPE_4BY, 0u, 4,
 | 
				
			||||||
    DDS_OP_RTS,
 | 
					    DDS_OP_RTS,
 | 
				
			||||||
    DDS_OP_RTS
 | 
					    DDS_OP_RTS
 | 
				
			||||||
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  .m_meta = "" /* this is on its way out anyway */
 | 
					  .m_meta = "" /* this is on its way out anyway */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,6 +33,7 @@ PREPEND(srcs_ddsi "${CMAKE_CURRENT_LIST_DIR}/src"
 | 
				
			||||||
    ddsi_deadline.c
 | 
					    ddsi_deadline.c
 | 
				
			||||||
    ddsi_deliver_locally.c
 | 
					    ddsi_deliver_locally.c
 | 
				
			||||||
    ddsi_plist.c
 | 
					    ddsi_plist.c
 | 
				
			||||||
 | 
					    ddsi_cdrstream.c
 | 
				
			||||||
    q_addrset.c
 | 
					    q_addrset.c
 | 
				
			||||||
    q_bitset_inlines.c
 | 
					    q_bitset_inlines.c
 | 
				
			||||||
    q_bswap.c
 | 
					    q_bswap.c
 | 
				
			||||||
| 
						 | 
					@ -97,6 +98,7 @@ PREPEND(hdrs_private_ddsi "${CMAKE_CURRENT_LIST_DIR}/include/dds/ddsi"
 | 
				
			||||||
    ddsi_domaingv.h
 | 
					    ddsi_domaingv.h
 | 
				
			||||||
    ddsi_plist.h
 | 
					    ddsi_plist.h
 | 
				
			||||||
    ddsi_xqos.h
 | 
					    ddsi_xqos.h
 | 
				
			||||||
 | 
					    ddsi_cdrstream.h
 | 
				
			||||||
    q_addrset.h
 | 
					    q_addrset.h
 | 
				
			||||||
    q_bitset.h
 | 
					    q_bitset.h
 | 
				
			||||||
    q_bswap.h
 | 
					    q_bswap.h
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,8 +9,8 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
					 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#ifndef _DDS_STREAM_H_
 | 
					#ifndef DDSI_CDRSTREAM_H
 | 
				
			||||||
#define _DDS_STREAM_H_
 | 
					#define DDSI_CDRSTREAM_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata.h"
 | 
					#include "dds/ddsi/ddsi_serdata.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata_default.h"
 | 
					#include "dds/ddsi/ddsi_serdata_default.h"
 | 
				
			||||||
| 
						 | 
					@ -44,8 +44,10 @@ bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, co
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
 | 
					void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
 | 
				
			||||||
void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
 | 
					void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct ddsi_sertopic_default * __restrict topic);
 | 
				
			||||||
 | 
					void dds_stream_free_sample (void *data, const uint32_t * ops);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t dds_stream_check_optimize (const dds_topic_descriptor_t * __restrict desc);
 | 
					uint32_t dds_stream_countops (const uint32_t * __restrict ops);
 | 
				
			||||||
 | 
					size_t dds_stream_check_optimize (const struct ddsi_sertopic_default_desc * __restrict desc);
 | 
				
			||||||
void dds_istream_from_serdata_default (dds_istream_t * __restrict s, const struct ddsi_serdata_default * __restrict d);
 | 
					void dds_istream_from_serdata_default (dds_istream_t * __restrict s, const struct ddsi_serdata_default * __restrict d);
 | 
				
			||||||
void dds_ostream_from_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default * __restrict d);
 | 
					void dds_ostream_from_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default * __restrict d);
 | 
				
			||||||
void dds_ostream_add_to_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default ** __restrict d);
 | 
					void dds_ostream_add_to_serdata_default (dds_ostream_t * __restrict s, struct ddsi_serdata_default ** __restrict d);
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,6 @@
 | 
				
			||||||
#include "dds/ddsi/ddsi_sertopic.h"
 | 
					#include "dds/ddsi/ddsi_sertopic.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dds/dds.h"
 | 
					#include "dds/dds.h"
 | 
				
			||||||
#include "dds__topic.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined (__cplusplus)
 | 
					#if defined (__cplusplus)
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
| 
						 | 
					@ -95,41 +94,28 @@ struct ddsi_serdata_default {
 | 
				
			||||||
#undef DDSI_SERDATA_DEFAULT_PREPAD
 | 
					#undef DDSI_SERDATA_DEFAULT_PREPAD
 | 
				
			||||||
#undef DDSI_SERDATA_DEFAULT_FIXED_FIELD
 | 
					#undef DDSI_SERDATA_DEFAULT_FIXED_FIELD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dds_key_descriptor;
 | 
					 | 
				
			||||||
struct dds_topic_descriptor;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
					#ifndef DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
				
			||||||
#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
					#define DDS_TOPIC_INTERN_FILTER_FN_DEFINED
 | 
				
			||||||
typedef bool (*dds_topic_intern_filter_fn) (const void * sample, void *ctx);
 | 
					typedef bool (*dds_topic_intern_filter_fn) (const void * sample, void *ctx);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Reduced version of dds_topic_descriptor_t */
 | 
				
			||||||
 | 
					struct ddsi_sertopic_default_desc {
 | 
				
			||||||
 | 
					  uint32_t m_size;    /* Size of topic type */
 | 
				
			||||||
 | 
					  uint32_t m_align;   /* Alignment of topic type */
 | 
				
			||||||
 | 
					  uint32_t m_flagset; /* Flags */
 | 
				
			||||||
 | 
					  uint32_t m_nkeys;   /* Number of keys (can be 0) */
 | 
				
			||||||
 | 
					  uint32_t *m_keys;   /* Key descriptors (NULL iff m_nkeys 0) */
 | 
				
			||||||
 | 
					  uint32_t m_nops;    /* Number of words in m_ops (which >= number of ops stored in preproc output) */
 | 
				
			||||||
 | 
					  uint32_t *m_ops;    /* Marshalling meta data */
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ddsi_sertopic_default {
 | 
					struct ddsi_sertopic_default {
 | 
				
			||||||
  struct ddsi_sertopic c;
 | 
					  struct ddsi_sertopic c;
 | 
				
			||||||
  uint16_t native_encoding_identifier; /* (PL_)?CDR_(LE|BE) */
 | 
					  uint16_t native_encoding_identifier; /* (PL_)?CDR_(LE|BE) */
 | 
				
			||||||
  struct serdatapool *serpool;
 | 
					  struct serdatapool *serpool;
 | 
				
			||||||
 | 
					  struct ddsi_sertopic_default_desc type;
 | 
				
			||||||
  struct dds_topic_descriptor * type;
 | 
					 | 
				
			||||||
  unsigned nkeys;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  uint32_t flags;
 | 
					 | 
				
			||||||
  size_t opt_size;
 | 
					  size_t opt_size;
 | 
				
			||||||
  dds_topic_intern_filter_fn filter_fn;
 | 
					 | 
				
			||||||
  void * filter_sample;
 | 
					 | 
				
			||||||
  void * filter_ctx;
 | 
					 | 
				
			||||||
  const struct dds_key_descriptor * keys;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
    Array of keys, represented as offset in the OpenSplice internal
 | 
					 | 
				
			||||||
    format data blob. Keys must be stored in the order visited by
 | 
					 | 
				
			||||||
    serializer (so that the serializer can simply compare the current
 | 
					 | 
				
			||||||
    offset with the next key offset). Also: keys[nkeys].off =def=
 | 
					 | 
				
			||||||
    ~0u, which won't equal any real offset so that there is no need
 | 
					 | 
				
			||||||
    to test for the end of the array.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Offsets work 'cos only primitive types, enums and strings are
 | 
					 | 
				
			||||||
    accepted as keys. So there is no ambiguity if a key happens to
 | 
					 | 
				
			||||||
    be inside a nested struct.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct ddsi_plist_sample {
 | 
					struct ddsi_plist_sample {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,6 @@ struct ddsi_sertopic {
 | 
				
			||||||
  bool topickind_no_key;
 | 
					  bool topickind_no_key;
 | 
				
			||||||
  char *name;
 | 
					  char *name;
 | 
				
			||||||
  char *type_name;
 | 
					  char *type_name;
 | 
				
			||||||
  uint64_t iid;
 | 
					 | 
				
			||||||
  struct ddsi_domaingv *gv;
 | 
					  struct ddsi_domaingv *gv;
 | 
				
			||||||
  ddsrt_atomic_uint32_t refc; /* counts refs from entities (topic, reader, writer), not from data */
 | 
					  ddsrt_atomic_uint32_t refc; /* counts refs from entities (topic, reader, writer), not from data */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@
 | 
				
			||||||
#include "dds/ddsrt/heap.h"
 | 
					#include "dds/ddsrt/heap.h"
 | 
				
			||||||
#include "dds/ddsi/q_bswap.h"
 | 
					#include "dds/ddsi/q_bswap.h"
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds__alloc.h"
 | 
					#include "dds__alloc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
 | 
					#if DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN
 | 
				
			||||||
| 
						 | 
					@ -210,7 +210,7 @@ static uint32_t get_type_size (enum dds_stream_typecode type)
 | 
				
			||||||
  return (uint32_t)1 << ((uint32_t) type - 1);
 | 
					  return (uint32_t)1 << ((uint32_t) type - 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static size_t dds_stream_check_optimize1 (const dds_topic_descriptor_t * __restrict desc)
 | 
					static size_t dds_stream_check_optimize1 (const struct ddsi_sertopic_default_desc * __restrict desc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const uint32_t *ops = desc->m_ops;
 | 
					  const uint32_t *ops = desc->m_ops;
 | 
				
			||||||
  uint32_t insn;
 | 
					  uint32_t insn;
 | 
				
			||||||
| 
						 | 
					@ -251,11 +251,141 @@ static size_t dds_stream_check_optimize1 (const dds_topic_descriptor_t * __restr
 | 
				
			||||||
  return desc->m_size;
 | 
					  return desc->m_size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t dds_stream_check_optimize (const dds_topic_descriptor_t * __restrict desc)
 | 
					size_t dds_stream_check_optimize (const struct ddsi_sertopic_default_desc * __restrict desc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return dds_stream_check_optimize1 (desc);
 | 
					  return dds_stream_check_optimize1 (desc);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void dds_stream_countops1 (const uint32_t * __restrict ops, const uint32_t **ops_end);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const uint32_t *dds_stream_countops_seq (const uint32_t * __restrict ops, uint32_t insn, const uint32_t **ops_end)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const enum dds_stream_typecode subtype = DDS_OP_SUBTYPE (insn);
 | 
				
			||||||
 | 
					  switch (subtype)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_1BY: case DDS_OP_VAL_2BY: case DDS_OP_VAL_4BY: case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					      ops += 2;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					      ops += 3;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_SEQ: case DDS_OP_VAL_ARR: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: {
 | 
				
			||||||
 | 
					      const uint32_t jmp = DDS_OP_ADR_JMP (ops[3]);
 | 
				
			||||||
 | 
					      uint32_t const * const jsr_ops = ops + DDS_OP_ADR_JSR (ops[3]);
 | 
				
			||||||
 | 
					      if (ops + 4 > *ops_end)
 | 
				
			||||||
 | 
					        *ops_end = ops + 4;
 | 
				
			||||||
 | 
					      dds_stream_countops1 (jsr_ops, ops_end);
 | 
				
			||||||
 | 
					      ops += (jmp ? jmp : 4); /* FIXME: why would jmp be 0? */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (ops > *ops_end)
 | 
				
			||||||
 | 
					    *ops_end = ops;
 | 
				
			||||||
 | 
					  return ops;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const uint32_t *dds_stream_countops_arr (const uint32_t * __restrict ops, uint32_t insn, const uint32_t **ops_end)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const enum dds_stream_typecode subtype = DDS_OP_SUBTYPE (insn);
 | 
				
			||||||
 | 
					  switch (subtype)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_1BY: case DDS_OP_VAL_2BY: case DDS_OP_VAL_4BY: case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					      ops += 3;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					      ops += 5;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case DDS_OP_VAL_SEQ: case DDS_OP_VAL_ARR: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: {
 | 
				
			||||||
 | 
					      const uint32_t jmp = DDS_OP_ADR_JMP (ops[3]);
 | 
				
			||||||
 | 
					      const uint32_t *jsr_ops = ops + DDS_OP_ADR_JSR (ops[3]);
 | 
				
			||||||
 | 
					      if (ops + 5 > *ops_end)
 | 
				
			||||||
 | 
					        *ops_end = ops + 5;
 | 
				
			||||||
 | 
					      dds_stream_countops1 (jsr_ops, ops_end);
 | 
				
			||||||
 | 
					      ops += (jmp ? jmp : 5);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (ops > *ops_end)
 | 
				
			||||||
 | 
					    *ops_end = ops;
 | 
				
			||||||
 | 
					  return ops;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const uint32_t *dds_stream_countops_uni (const uint32_t * __restrict ops, const uint32_t **ops_end)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const uint32_t numcases = ops[2];
 | 
				
			||||||
 | 
					  const uint32_t *jeq_op = ops + DDS_OP_ADR_JSR (ops[3]);
 | 
				
			||||||
 | 
					  for (uint32_t i = 0; i < numcases; i++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const enum dds_stream_typecode valtype = DDS_JEQ_TYPE (jeq_op[0]);
 | 
				
			||||||
 | 
					    switch (valtype)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_1BY:
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_2BY:
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_4BY:
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      case DDS_OP_VAL_BST: case DDS_OP_VAL_SEQ: case DDS_OP_VAL_ARR: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU:
 | 
				
			||||||
 | 
					        dds_stream_countops1 (jeq_op + DDS_OP_ADR_JSR (jeq_op[0]), ops_end);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    jeq_op += 3;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (jeq_op > *ops_end)
 | 
				
			||||||
 | 
					    *ops_end = jeq_op;
 | 
				
			||||||
 | 
					  ops += DDS_OP_ADR_JMP (ops[3]);
 | 
				
			||||||
 | 
					  if (ops > *ops_end)
 | 
				
			||||||
 | 
					    *ops_end = ops;
 | 
				
			||||||
 | 
					  return ops;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void dds_stream_countops1 (const uint32_t * __restrict ops, const uint32_t **ops_end)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  uint32_t insn;
 | 
				
			||||||
 | 
					  while ((insn = *ops) != DDS_OP_RTS)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    switch (DDS_OP (insn))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      case DDS_OP_ADR: {
 | 
				
			||||||
 | 
					        switch (DDS_OP_TYPE (insn))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_1BY: case DDS_OP_VAL_2BY: case DDS_OP_VAL_4BY: case DDS_OP_VAL_8BY: case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					            ops += 2;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					            ops += 3;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_SEQ: ops = dds_stream_countops_seq (ops, insn, ops_end); break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_ARR: ops = dds_stream_countops_arr (ops, insn, ops_end); break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_UNI: ops = dds_stream_countops_uni (ops, ops_end); break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_STU: abort (); break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      case DDS_OP_JSR: {
 | 
				
			||||||
 | 
					        dds_stream_countops1 (ops + DDS_OP_JUMP (insn), ops_end);
 | 
				
			||||||
 | 
					        ops++;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      case DDS_OP_RTS: case DDS_OP_JEQ: {
 | 
				
			||||||
 | 
					        abort ();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  ++ops; /* skip RTS op */
 | 
				
			||||||
 | 
					  if (ops > *ops_end)
 | 
				
			||||||
 | 
					    *ops_end = ops;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint32_t dds_stream_countops (const uint32_t * __restrict ops)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const uint32_t *ops_end = ops;
 | 
				
			||||||
 | 
					  dds_stream_countops1 (ops, &ops_end);
 | 
				
			||||||
 | 
					  return (uint32_t) (ops_end - ops);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void dds_stream_reuse_string_bound (dds_istream_t * __restrict is, char * __restrict str, const uint32_t bound)
 | 
					static void dds_stream_reuse_string_bound (dds_istream_t * __restrict is, char * __restrict str, const uint32_t bound)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const uint32_t length = dds_is_get4 (is);
 | 
					  const uint32_t length = dds_is_get4 (is);
 | 
				
			||||||
| 
						 | 
					@ -1039,12 +1169,12 @@ static bool stream_normalize (char * __restrict data, uint32_t * __restrict off,
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool stream_normalize_key (void * __restrict data, uint32_t size, bool bswap, const struct dds_topic_descriptor * __restrict desc)
 | 
					static bool stream_normalize_key (void * __restrict data, uint32_t size, bool bswap, const struct ddsi_sertopic_default_desc * __restrict desc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  uint32_t off = 0;
 | 
					  uint32_t off = 0;
 | 
				
			||||||
  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const uint32_t *op = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    const uint32_t *op = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    assert (insn_key_ok_p (*op));
 | 
					    assert (insn_key_ok_p (*op));
 | 
				
			||||||
    switch (DDS_OP_TYPE (*op))
 | 
					    switch (DDS_OP_TYPE (*op))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -1068,14 +1198,211 @@ bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, co
 | 
				
			||||||
  if (size > CDR_SIZE_MAX)
 | 
					  if (size > CDR_SIZE_MAX)
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  if (just_key)
 | 
					  if (just_key)
 | 
				
			||||||
    return stream_normalize_key (data, size, bswap, topic->type);
 | 
					    return stream_normalize_key (data, size, bswap, &topic->type);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    uint32_t off = 0;
 | 
					    uint32_t off = 0;
 | 
				
			||||||
    return stream_normalize (data, &off, size, bswap, topic->type->m_ops);
 | 
					    return stream_normalize (data, &off, size, bswap, topic->type.m_ops);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*******************************************************************************************
 | 
				
			||||||
 | 
					 **
 | 
				
			||||||
 | 
					 **  Freeing samples
 | 
				
			||||||
 | 
					 **
 | 
				
			||||||
 | 
					 *******************************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//#define OP_DEBUG_FREE 1
 | 
				
			||||||
 | 
					void dds_stream_free_sample (void *vdata, const uint32_t * ops)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if defined OP_DEBUG_FREE
 | 
				
			||||||
 | 
					  static const char *stream_op_type[11] = {
 | 
				
			||||||
 | 
					    NULL, "1Byte", "2Byte", "4Byte", "8Byte", "String", "BString", "Sequence", "Array", "Union", "Struct"
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  char *data = vdata;
 | 
				
			||||||
 | 
					  uint32_t op;
 | 
				
			||||||
 | 
					  uint32_t type;
 | 
				
			||||||
 | 
					  uint32_t num;
 | 
				
			||||||
 | 
					  uint32_t subtype;
 | 
				
			||||||
 | 
					  char *addr;
 | 
				
			||||||
 | 
					  while ((op = *ops) != DDS_OP_RTS)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    switch (DDS_OP_MASK & op)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      case DDS_OP_ADR:
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        type = DDS_OP_TYPE (op);
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					        DDS_TRACE("F-ADR: %s offset %d\n", stream_op_type[type], ops[1]);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        addr = data + ops[1];
 | 
				
			||||||
 | 
					        switch (type)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_1BY:
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_2BY:
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_4BY:
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					            ops += 2;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					            DDS_TRACE("F-STR: @ %p %s\n", addr, *((char **) addr));
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            ops += 2;
 | 
				
			||||||
 | 
					            dds_free (*((char **) addr));
 | 
				
			||||||
 | 
					            *((char **) addr) = NULL;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_SEQ: {
 | 
				
			||||||
 | 
					            dds_sequence_t * seq = (dds_sequence_t *) addr;
 | 
				
			||||||
 | 
					            ops += 2;
 | 
				
			||||||
 | 
					            subtype = DDS_OP_SUBTYPE (op);
 | 
				
			||||||
 | 
					            num = (seq->_maximum > seq->_length) ? seq->_maximum : seq->_length;
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					            DDS_TRACE("F-SEQ: of %s\n", stream_op_type[subtype]);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            if ((seq->_release && num) || (subtype > DDS_OP_VAL_STR))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              switch (subtype)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_1BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_2BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_4BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					                  ops++;
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_STR: {
 | 
				
			||||||
 | 
					                  char **ptr = (char **) seq->_buffer;
 | 
				
			||||||
 | 
					                  while (num--)
 | 
				
			||||||
 | 
					                    dds_free (*ptr++);
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                default: {
 | 
				
			||||||
 | 
					                  const uint32_t elem_size = *ops++;
 | 
				
			||||||
 | 
					                  const uint32_t *jsr_ops = ops + DDS_OP_ADR_JSR (*ops) - 3;
 | 
				
			||||||
 | 
					                  const uint32_t jmp = DDS_OP_ADR_JMP (*ops);
 | 
				
			||||||
 | 
					                  char *ptr = (char *) seq->_buffer;
 | 
				
			||||||
 | 
					                  while (num--)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    dds_stream_free_sample (ptr, jsr_ops);
 | 
				
			||||||
 | 
					                    ptr += elem_size;
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					                  ops += jmp ? (jmp - 3) : 1;
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (seq->_release)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              dds_free (seq->_buffer);
 | 
				
			||||||
 | 
					              seq->_maximum = 0;
 | 
				
			||||||
 | 
					              seq->_length = 0;
 | 
				
			||||||
 | 
					              seq->_buffer = NULL;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_ARR: {
 | 
				
			||||||
 | 
					            ops += 2;
 | 
				
			||||||
 | 
					            subtype = DDS_OP_SUBTYPE (op);
 | 
				
			||||||
 | 
					            num = *ops++;
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					            DDS_TRACE("F-ARR: of %s size %d\n", stream_op_type[subtype], num);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            switch (subtype)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_1BY:
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_2BY:
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_4BY:
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_STR: {
 | 
				
			||||||
 | 
					                char **ptr = (char **) addr;
 | 
				
			||||||
 | 
					                while (num--)
 | 
				
			||||||
 | 
					                  dds_free (*ptr++);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					                ops += 2;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              default: {
 | 
				
			||||||
 | 
					                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_free_sample (addr, jsr_ops);
 | 
				
			||||||
 | 
					                  addr += elem_size;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ops += jmp ? (jmp - 3) : 2;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_UNI: {
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					            DDS_TRACE("F-UNI: switch %s\n", stream_op_type[subtype]);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					            /* Get discriminant */
 | 
				
			||||||
 | 
					            uint32_t disc = 0;
 | 
				
			||||||
 | 
					            switch (DDS_OP_SUBTYPE (op))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_1BY: disc = *((uint8_t *) addr); break;
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_2BY: disc = *((uint16_t *) addr); break;
 | 
				
			||||||
 | 
					              case DDS_OP_VAL_4BY: disc = *((uint32_t *) addr); break;
 | 
				
			||||||
 | 
					              default: assert (0);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            uint32_t const * const jeq_op = find_union_case (ops, disc);
 | 
				
			||||||
 | 
					            ops += DDS_OP_ADR_JMP (ops[3]);
 | 
				
			||||||
 | 
					            if (jeq_op)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              subtype = DDS_JEQ_TYPE (jeq_op[0]);
 | 
				
			||||||
 | 
					              addr = data + jeq_op[2];
 | 
				
			||||||
 | 
					              switch (subtype)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_1BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_2BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_4BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_8BY:
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                case DDS_OP_VAL_STR:
 | 
				
			||||||
 | 
					                  dds_free (*((char **) addr));
 | 
				
			||||||
 | 
					                  *((char **) addr) = NULL;
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                  dds_stream_free_sample (addr, jeq_op + DDS_OP_ADR_JSR (jeq_op[0]));
 | 
				
			||||||
 | 
					                  break;
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          case DDS_OP_VAL_BST:
 | 
				
			||||||
 | 
					            ops += 3;
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					          default:
 | 
				
			||||||
 | 
					            assert (0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      case DDS_OP_JSR: /* Implies nested type */
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					        DDS_TRACE("F-JSR: %d\n", DDS_OP_JUMP (op));
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					        dds_stream_free_sample (data, ops + DDS_OP_JUMP (op));
 | 
				
			||||||
 | 
					        ops++;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      default:
 | 
				
			||||||
 | 
					        assert (0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					#ifdef OP_DEBUG_FREE
 | 
				
			||||||
 | 
					  DDS_TRACE("F-RTS:\n");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*******************************************************************************************
 | 
					/*******************************************************************************************
 | 
				
			||||||
 **
 | 
					 **
 | 
				
			||||||
 **  Read/write of samples and keys -- i.e., DDSI payloads.
 | 
					 **  Read/write of samples and keys -- i.e., DDSI payloads.
 | 
				
			||||||
| 
						 | 
					@ -1084,7 +1411,7 @@ bool dds_stream_normalize (void * __restrict data, uint32_t size, bool bswap, co
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict data, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct dds_topic_descriptor *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  if (topic->opt_size)
 | 
					  if (topic->opt_size)
 | 
				
			||||||
    dds_is_get_bytes (is, data, desc->m_size, 1);
 | 
					    dds_is_get_bytes (is, data, desc->m_size, 1);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
| 
						 | 
					@ -1097,7 +1424,7 @@ void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict da
 | 
				
			||||||
         make any preallocated buffers go to waste, but it does allow reusing the message
 | 
					         make any preallocated buffers go to waste, but it does allow reusing the message
 | 
				
			||||||
         from read-to-read, at the somewhat reasonable price of a slower deserialization
 | 
					         from read-to-read, at the somewhat reasonable price of a slower deserialization
 | 
				
			||||||
         and not being able to use preallocated sequences in topics containing unions. */
 | 
					         and not being able to use preallocated sequences in topics containing unions. */
 | 
				
			||||||
      dds_sample_free_contents (data, desc->m_ops);
 | 
					      dds_stream_free_sample (data, desc->m_ops);
 | 
				
			||||||
      memset (data, 0, desc->m_size);
 | 
					      memset (data, 0, desc->m_size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    dds_stream_read (is, data, desc->m_ops);
 | 
					    dds_stream_read (is, data, desc->m_ops);
 | 
				
			||||||
| 
						 | 
					@ -1106,7 +1433,7 @@ void dds_stream_read_sample (dds_istream_t * __restrict is, void * __restrict da
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __restrict data, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __restrict data, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct dds_topic_descriptor *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  if (topic->opt_size && desc->m_align && (os->m_index % desc->m_align) == 0)
 | 
					  if (topic->opt_size && desc->m_align && (os->m_index % desc->m_align) == 0)
 | 
				
			||||||
    dds_os_put_bytes (os, data, desc->m_size);
 | 
					    dds_os_put_bytes (os, data, desc->m_size);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
| 
						 | 
					@ -1115,10 +1442,10 @@ void dds_stream_write_sample (dds_ostream_t * __restrict os, const void * __rest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const uint32_t *op = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    const uint32_t *op = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    char *dst = sample + op[1];
 | 
					    char *dst = sample + op[1];
 | 
				
			||||||
    assert (insn_key_ok_p (*op));
 | 
					    assert (insn_key_ok_p (*op));
 | 
				
			||||||
    switch (DDS_OP_TYPE (*op))
 | 
					    switch (DDS_OP_TYPE (*op))
 | 
				
			||||||
| 
						 | 
					@ -1141,10 +1468,10 @@ void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sampl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_write_key (dds_ostream_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_write_key (dds_ostream_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct dds_topic_descriptor *desc = (const struct dds_topic_descriptor *) topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const uint32_t *insnp = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    const uint32_t *insnp = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    const void *src = sample + insnp[1];
 | 
					    const void *src = sample + insnp[1];
 | 
				
			||||||
    assert (insn_key_ok_p (*insnp));
 | 
					    assert (insn_key_ok_p (*insnp));
 | 
				
			||||||
    switch (DDS_OP_TYPE (*insnp))
 | 
					    switch (DDS_OP_TYPE (*insnp))
 | 
				
			||||||
| 
						 | 
					@ -1201,10 +1528,10 @@ static void dds_stream_swap_insitu (void * __restrict vbuf, uint32_t size, uint3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_write_keyBE (dds_ostreamBE_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_write_keyBE (dds_ostreamBE_t * __restrict os, const char * __restrict sample, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct dds_topic_descriptor *desc = (const struct dds_topic_descriptor *) topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const uint32_t *insnp = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    const uint32_t *insnp = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    const void *src = sample + insnp[1];
 | 
					    const void *src = sample + insnp[1];
 | 
				
			||||||
    assert (insn_key_ok_p (*insnp));
 | 
					    assert (insn_key_ok_p (*insnp));
 | 
				
			||||||
    switch (DDS_OP_TYPE (*insnp))
 | 
					    switch (DDS_OP_TYPE (*insnp))
 | 
				
			||||||
| 
						 | 
					@ -1362,10 +1689,10 @@ static void dds_stream_extract_keyBE_from_key_prim_op (dds_istream_t * __restric
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void dds_stream_extract_keyBE_from_key (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
					static void dds_stream_extract_keyBE_from_key (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    uint32_t const * const op = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    uint32_t const * const op = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    dds_stream_extract_keyBE_from_key_prim_op (is, os, op);
 | 
					    dds_stream_extract_keyBE_from_key_prim_op (is, os, op);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1565,21 +1892,21 @@ static void dds_stream_extract_keyBE_from_data1 (dds_istream_t * __restrict is,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_extract_key_from_data (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_extract_key_from_data (dds_istream_t * __restrict is, dds_ostream_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  uint32_t keys_remaining = desc->m_nkeys;
 | 
					  uint32_t keys_remaining = desc->m_nkeys;
 | 
				
			||||||
  dds_stream_extract_key_from_data1 (is, os, desc->m_ops, &keys_remaining);
 | 
					  dds_stream_extract_key_from_data1 (is, os, desc->m_ops, &keys_remaining);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_extract_keyBE_from_data (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
					void dds_stream_extract_keyBE_from_data (dds_istream_t * __restrict is, dds_ostreamBE_t * __restrict os, const struct ddsi_sertopic_default * __restrict topic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  uint32_t keys_remaining = desc->m_nkeys;
 | 
					  uint32_t keys_remaining = desc->m_nkeys;
 | 
				
			||||||
  dds_stream_extract_keyBE_from_data1 (is, os, desc->m_ops, &keys_remaining);
 | 
					  dds_stream_extract_keyBE_from_data1 (is, os, desc->m_ops, &keys_remaining);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dds_stream_extract_keyhash (dds_istream_t * __restrict is, dds_keyhash_t * __restrict kh, const struct ddsi_sertopic_default * __restrict topic, const bool just_key)
 | 
					void dds_stream_extract_keyhash (dds_istream_t * __restrict is, dds_keyhash_t * __restrict kh, const struct ddsi_sertopic_default * __restrict topic, const bool just_key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  kh->m_set = 1;
 | 
					  kh->m_set = 1;
 | 
				
			||||||
  if (desc->m_nkeys == 0)
 | 
					  if (desc->m_nkeys == 0)
 | 
				
			||||||
    kh->m_iskey = 1;
 | 
					    kh->m_iskey = 1;
 | 
				
			||||||
| 
						 | 
					@ -1869,17 +2196,17 @@ static bool dds_stream_print_sample1 (char * __restrict *buf, size_t * __restric
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct ddsi_sertopic_default * __restrict topic, char * __restrict buf, size_t bufsize)
 | 
					size_t dds_stream_print_sample (dds_istream_t * __restrict is, const struct ddsi_sertopic_default * __restrict topic, char * __restrict buf, size_t bufsize)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  (void) dds_stream_print_sample1 (&buf, &bufsize, is, topic->type->m_ops, true);
 | 
					  (void) dds_stream_print_sample1 (&buf, &bufsize, is, topic->type.m_ops, true);
 | 
				
			||||||
  return bufsize;
 | 
					  return bufsize;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct ddsi_sertopic_default * __restrict topic, char * __restrict buf, size_t bufsize)
 | 
					size_t dds_stream_print_key (dds_istream_t * __restrict is, const struct ddsi_sertopic_default * __restrict topic, char * __restrict buf, size_t bufsize)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const dds_topic_descriptor_t *desc = topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  bool cont = prtf (&buf, &bufsize, ":k:{");
 | 
					  bool cont = prtf (&buf, &bufsize, ":k:{");
 | 
				
			||||||
  for (uint32_t i = 0; cont && i < desc->m_nkeys; i++)
 | 
					  for (uint32_t i = 0; cont && i < desc->m_nkeys; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const uint32_t *op = desc->m_ops + desc->m_keys[i].m_index;
 | 
					    const uint32_t *op = desc->m_ops + desc->m_keys[i];
 | 
				
			||||||
    assert (insn_key_ok_p (*op));
 | 
					    assert (insn_key_ok_p (*op));
 | 
				
			||||||
    switch (DDS_OP_TYPE (*op))
 | 
					    switch (DDS_OP_TYPE (*op))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
#include "dds/ddsi/q_freelist.h"
 | 
					#include "dds/ddsi/q_freelist.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_tkmap.h"
 | 
					#include "dds/ddsi/ddsi_tkmap.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds/ddsi/q_radmin.h"
 | 
					#include "dds/ddsi/q_radmin.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_domaingv.h"
 | 
					#include "dds/ddsi/ddsi_domaingv.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata_default.h"
 | 
					#include "dds/ddsi/ddsi_serdata_default.h"
 | 
				
			||||||
| 
						 | 
					@ -349,7 +349,7 @@ static struct ddsi_serdata *ddsi_serdata_from_keyhash_cdr (const struct ddsi_ser
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  /* FIXME: not quite sure this is correct, though a check against a specially hacked OpenSplice suggests it is */
 | 
					  /* FIXME: not quite sure this is correct, though a check against a specially hacked OpenSplice suggests it is */
 | 
				
			||||||
  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)tpcmn;
 | 
					  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)tpcmn;
 | 
				
			||||||
  if (!(tp->type->m_flagset & DDS_TOPIC_FIXED_KEY))
 | 
					  if (!(tp->type.m_flagset & DDS_TOPIC_FIXED_KEY))
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    /* keyhash is MD5 of a key value, so impossible to turn into a key value */
 | 
					    /* keyhash is MD5 of a key value, so impossible to turn into a key value */
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
| 
						 | 
					@ -386,7 +386,7 @@ static struct ddsi_serdata *ddsi_serdata_from_keyhash_cdr_nokey (const struct dd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void gen_keyhash_from_sample (const struct ddsi_sertopic_default *topic, dds_keyhash_t *kh, const char *sample)
 | 
					static void gen_keyhash_from_sample (const struct ddsi_sertopic_default *topic, dds_keyhash_t *kh, const char *sample)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct dds_topic_descriptor *desc = (const struct dds_topic_descriptor *) topic->type;
 | 
					  const struct ddsi_sertopic_default_desc *desc = &topic->type;
 | 
				
			||||||
  kh->m_set = 1;
 | 
					  kh->m_set = 1;
 | 
				
			||||||
  if (desc->m_nkeys == 0)
 | 
					  if (desc->m_nkeys == 0)
 | 
				
			||||||
    kh->m_iskey = 1;
 | 
					    kh->m_iskey = 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,8 @@ bool ddsi_sertopic_equal (const struct ddsi_sertopic *a, const struct ddsi_serto
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  if (a->serdata_ops != b->serdata_ops)
 | 
					  if (a->serdata_ops != b->serdata_ops)
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->topickind_no_key != b->topickind_no_key)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
  return a->ops->equal (a, b);
 | 
					  return a->ops->equal (a, b);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +49,7 @@ uint32_t ddsi_sertopic_hash (const struct ddsi_sertopic *a)
 | 
				
			||||||
  uint32_t h;
 | 
					  uint32_t h;
 | 
				
			||||||
  h = ddsrt_mh3 (a->name, strlen (a->name), a->serdata_basehash);
 | 
					  h = ddsrt_mh3 (a->name, strlen (a->name), a->serdata_basehash);
 | 
				
			||||||
  h = ddsrt_mh3 (a->type_name, strlen (a->type_name), h);
 | 
					  h = ddsrt_mh3 (a->type_name, strlen (a->type_name), h);
 | 
				
			||||||
 | 
					  h ^= a->serdata_basehash ^ (uint32_t) a->topickind_no_key;
 | 
				
			||||||
  return h ^ a->ops->hash (a);
 | 
					  return h ^ a->ops->hash (a);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,10 +66,7 @@ struct ddsi_sertopic *ddsi_sertopic_lookup_locked (struct ddsi_domaingv *gv, con
 | 
				
			||||||
  struct ddsi_sertopic *sertopic = ddsrt_hh_lookup (gv->sertopics, sertopic_template);
 | 
					  struct ddsi_sertopic *sertopic = ddsrt_hh_lookup (gv->sertopics, sertopic_template);
 | 
				
			||||||
#ifndef NDEBUG
 | 
					#ifndef NDEBUG
 | 
				
			||||||
  if (sertopic != NULL)
 | 
					  if (sertopic != NULL)
 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    assert (sertopic->gv != NULL);
 | 
					    assert (sertopic->gv != NULL);
 | 
				
			||||||
    assert (sertopic->iid != 0);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  return ddsi_sertopic_ref (sertopic);
 | 
					  return ddsi_sertopic_ref (sertopic);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -74,12 +74,10 @@ struct ddsi_sertopic *ddsi_sertopic_lookup_locked (struct ddsi_domaingv *gv, con
 | 
				
			||||||
void ddsi_sertopic_register_locked (struct ddsi_domaingv *gv, struct ddsi_sertopic *sertopic)
 | 
					void ddsi_sertopic_register_locked (struct ddsi_domaingv *gv, struct ddsi_sertopic *sertopic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  assert (sertopic->gv == NULL);
 | 
					  assert (sertopic->gv == NULL);
 | 
				
			||||||
  assert (sertopic->iid == 0);
 | 
					 | 
				
			||||||
  assert (ddsrt_atomic_ld32 (&sertopic->refc) == 1);
 | 
					  assert (ddsrt_atomic_ld32 (&sertopic->refc) == 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  (void) ddsi_sertopic_ref (sertopic);
 | 
					  (void) ddsi_sertopic_ref (sertopic);
 | 
				
			||||||
  sertopic->gv = gv;
 | 
					  sertopic->gv = gv;
 | 
				
			||||||
  sertopic->iid = ddsi_iid_gen ();
 | 
					 | 
				
			||||||
  int x = ddsrt_hh_add (gv->sertopics, sertopic);
 | 
					  int x = ddsrt_hh_add (gv->sertopics, sertopic);
 | 
				
			||||||
  assert (x);
 | 
					  assert (x);
 | 
				
			||||||
  (void) x;
 | 
					  (void) x;
 | 
				
			||||||
| 
						 | 
					@ -98,7 +96,6 @@ void ddsi_sertopic_unref (struct ddsi_sertopic *sertopic)
 | 
				
			||||||
        (void) ddsrt_hh_remove (sertopic->gv->sertopics, sertopic);
 | 
					        (void) ddsrt_hh_remove (sertopic->gv->sertopics, sertopic);
 | 
				
			||||||
        ddsrt_mutex_unlock (&sertopic->gv->sertopics_lock);
 | 
					        ddsrt_mutex_unlock (&sertopic->gv->sertopics_lock);
 | 
				
			||||||
        sertopic->gv = NULL;
 | 
					        sertopic->gv = NULL;
 | 
				
			||||||
        sertopic->iid = 0;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      ddsi_sertopic_free (sertopic);
 | 
					      ddsi_sertopic_free (sertopic);
 | 
				
			||||||
| 
						 | 
					@ -116,7 +113,6 @@ void ddsi_sertopic_init (struct ddsi_sertopic *tp, const char *name, const char
 | 
				
			||||||
  tp->serdata_basehash = ddsi_sertopic_compute_serdata_basehash (tp->serdata_ops);
 | 
					  tp->serdata_basehash = ddsi_sertopic_compute_serdata_basehash (tp->serdata_ops);
 | 
				
			||||||
  tp->topickind_no_key = topickind_no_key;
 | 
					  tp->topickind_no_key = topickind_no_key;
 | 
				
			||||||
  /* set later, on registration */
 | 
					  /* set later, on registration */
 | 
				
			||||||
  tp->iid = 0;
 | 
					 | 
				
			||||||
  tp->gv = NULL;
 | 
					  tp->gv = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,7 @@
 | 
				
			||||||
#include "dds/ddsi/q_bswap.h"
 | 
					#include "dds/ddsi/q_bswap.h"
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
#include "dds/ddsi/q_freelist.h"
 | 
					#include "dds/ddsi/q_freelist.h"
 | 
				
			||||||
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_sertopic.h"
 | 
					#include "dds/ddsi/ddsi_sertopic.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata_default.h"
 | 
					#include "dds/ddsi/ddsi_serdata_default.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,37 +28,58 @@ static bool sertopic_default_equal (const struct ddsi_sertopic *acmn, const stru
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct ddsi_sertopic_default *a = (struct ddsi_sertopic_default *) acmn;
 | 
					  const struct ddsi_sertopic_default *a = (struct ddsi_sertopic_default *) acmn;
 | 
				
			||||||
  const struct ddsi_sertopic_default *b = (struct ddsi_sertopic_default *) bcmn;
 | 
					  const struct ddsi_sertopic_default *b = (struct ddsi_sertopic_default *) bcmn;
 | 
				
			||||||
  return a->type == b->type;
 | 
					  if (a->native_encoding_identifier != b->native_encoding_identifier)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->type.m_size != b->type.m_size)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->type.m_align != b->type.m_align)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->type.m_flagset != b->type.m_flagset)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->type.m_nkeys != b->type.m_nkeys)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (memcmp (a->type.m_keys, b->type.m_keys, a->type.m_nkeys * sizeof (*a->type.m_keys)) != 0)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (a->type.m_nops != b->type.m_nops)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (memcmp (a->type.m_ops, b->type.m_ops, a->type.m_nops * sizeof (*a->type.m_ops)) != 0)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  assert (a->opt_size == b->opt_size);
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static uint32_t sertopic_default_hash (const struct ddsi_sertopic *tpcmn)
 | 
					static uint32_t sertopic_default_hash (const struct ddsi_sertopic *tpcmn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct ddsi_sertopic_default *tp = (struct ddsi_sertopic_default *) tpcmn;
 | 
					  const struct ddsi_sertopic_default *tp = (struct ddsi_sertopic_default *) tpcmn;
 | 
				
			||||||
  if (tp->type == NULL)
 | 
					  uint32_t h = 0;
 | 
				
			||||||
    return 0;
 | 
					  h = ddsrt_mh3 (&tp->native_encoding_identifier, sizeof (tp->native_encoding_identifier), 0);
 | 
				
			||||||
  else
 | 
					  h = ddsrt_mh3 (&tp->type.m_size, sizeof (tp->type.m_size), h);
 | 
				
			||||||
  {
 | 
					  h = ddsrt_mh3 (&tp->type.m_align, sizeof (tp->type.m_align), h);
 | 
				
			||||||
    return ddsrt_mh3 (tp->type->m_keys, tp->type->m_nkeys * sizeof (*tp->type->m_keys),
 | 
					  h = ddsrt_mh3 (&tp->type.m_flagset, sizeof (tp->type.m_flagset), h);
 | 
				
			||||||
                      ddsrt_mh3 (tp->type->m_ops, tp->type->m_nops * sizeof (*tp->type->m_ops), 0));
 | 
					  h = ddsrt_mh3 (tp->type.m_keys, tp->type.m_nkeys * sizeof (*tp->type.m_keys), h);
 | 
				
			||||||
  }
 | 
					  h = ddsrt_mh3 (tp->type.m_ops, tp->type.m_nops * sizeof (*tp->type.m_ops), h);
 | 
				
			||||||
 | 
					  return h;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sertopic_default_free (struct ddsi_sertopic *tp)
 | 
					static void sertopic_default_free (struct ddsi_sertopic *tpcmn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ddsi_sertopic_fini (tp);
 | 
					  struct ddsi_sertopic_default *tp = (struct ddsi_sertopic_default *) tpcmn;
 | 
				
			||||||
 | 
					  ddsrt_free (tp->type.m_keys);
 | 
				
			||||||
 | 
					  ddsrt_free (tp->type.m_ops);
 | 
				
			||||||
 | 
					  ddsi_sertopic_fini (&tp->c);
 | 
				
			||||||
  ddsrt_free (tp);
 | 
					  ddsrt_free (tp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sertopic_default_zero_samples (const struct ddsi_sertopic *sertopic_common, void *sample, size_t count)
 | 
					static void sertopic_default_zero_samples (const struct ddsi_sertopic *sertopic_common, void *sample, size_t count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
					  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
				
			||||||
  memset (sample, 0, tp->type->m_size * count);
 | 
					  memset (sample, 0, tp->type.m_size * count);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sertopic_default_realloc_samples (void **ptrs, const struct ddsi_sertopic *sertopic_common, void *old, size_t oldcount, size_t count)
 | 
					static void sertopic_default_realloc_samples (void **ptrs, const struct ddsi_sertopic *sertopic_common, void *old, size_t oldcount, size_t count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
					  const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
				
			||||||
  const size_t size = tp->type->m_size;
 | 
					  const size_t size = tp->type.m_size;
 | 
				
			||||||
  char *new = (oldcount == count) ? old : dds_realloc (old, size * count);
 | 
					  char *new = (oldcount == count) ? old : dds_realloc (old, size * count);
 | 
				
			||||||
  if (new && count > oldcount)
 | 
					  if (new && count > oldcount)
 | 
				
			||||||
    memset (new + size * oldcount, 0, size * (count - oldcount));
 | 
					    memset (new + size * oldcount, 0, size * (count - oldcount));
 | 
				
			||||||
| 
						 | 
					@ -73,7 +95,7 @@ static void sertopic_default_free_samples (const struct ddsi_sertopic *sertopic_
 | 
				
			||||||
  if (count > 0)
 | 
					  if (count > 0)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
					    const struct ddsi_sertopic_default *tp = (const struct ddsi_sertopic_default *)sertopic_common;
 | 
				
			||||||
    const struct dds_topic_descriptor *type = tp->type;
 | 
					    const struct ddsi_sertopic_default_desc *type = &tp->type;
 | 
				
			||||||
    const size_t size = type->m_size;
 | 
					    const size_t size = type->m_size;
 | 
				
			||||||
#ifndef NDEBUG
 | 
					#ifndef NDEBUG
 | 
				
			||||||
    for (size_t i = 0, off = 0; i < count; i++, off += size)
 | 
					    for (size_t i = 0, off = 0; i < count; i++, off += size)
 | 
				
			||||||
| 
						 | 
					@ -84,7 +106,7 @@ static void sertopic_default_free_samples (const struct ddsi_sertopic *sertopic_
 | 
				
			||||||
      char *ptr = ptrs[0];
 | 
					      char *ptr = ptrs[0];
 | 
				
			||||||
      for (size_t i = 0; i < count; i++)
 | 
					      for (size_t i = 0; i < count; i++)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        dds_sample_free (ptr, type, DDS_FREE_CONTENTS);
 | 
					        dds_stream_free_sample (ptr, type->m_ops);
 | 
				
			||||||
        ptr += size;
 | 
					        ptr += size;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,9 +22,9 @@
 | 
				
			||||||
#include "dds/ddsi/q_config.h"
 | 
					#include "dds/ddsi/q_config.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_iid.h"
 | 
					#include "dds/ddsi/ddsi_iid.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_tkmap.h"
 | 
					#include "dds/ddsi/ddsi_tkmap.h"
 | 
				
			||||||
#include "dds/ddsrt/hopscotch.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata.h"
 | 
					#include "dds/ddsi/ddsi_serdata.h"
 | 
				
			||||||
 | 
					#include "dds/ddsrt/hopscotch.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define REFC_DELETE 0x80000000
 | 
					#define REFC_DELETE 0x80000000
 | 
				
			||||||
#define REFC_MASK   0x0fffffff
 | 
					#define REFC_MASK   0x0fffffff
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -782,7 +782,6 @@ static struct ddsi_sertopic *make_special_topic (const char *name, struct serdat
 | 
				
			||||||
  ddsi_sertopic_init (&st->c, name, name, &ddsi_sertopic_ops_default, ops, false);
 | 
					  ddsi_sertopic_init (&st->c, name, name, &ddsi_sertopic_ops_default, ops, false);
 | 
				
			||||||
  st->native_encoding_identifier = enc_id;
 | 
					  st->native_encoding_identifier = enc_id;
 | 
				
			||||||
  st->serpool = serpool;
 | 
					  st->serpool = serpool;
 | 
				
			||||||
  st->nkeys = 1;
 | 
					 | 
				
			||||||
  return (struct ddsi_sertopic *) st;
 | 
					  return (struct ddsi_sertopic *) st;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@
 | 
				
			||||||
#include "dds/ddsrt/static_assert.h"
 | 
					#include "dds/ddsrt/static_assert.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dds/ddsrt/avl.h"
 | 
					#include "dds/ddsrt/avl.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
#include "dds/ddsi/q_protocol.h"
 | 
					#include "dds/ddsi/q_protocol.h"
 | 
				
			||||||
#include "dds/ddsi/q_rtps.h"
 | 
					#include "dds/ddsi/q_rtps.h"
 | 
				
			||||||
#include "dds/ddsi/q_misc.h"
 | 
					#include "dds/ddsi/q_misc.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,8 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
cmake_minimum_required(VERSION 3.5)
 | 
					cmake_minimum_required(VERSION 3.5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					find_package(CycloneDDS COMPONENTS idlc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_compile_options("-I${PROJECT_SOURCE_DIR}/src/ddsrt/include")
 | 
					add_compile_options("-I${PROJECT_SOURCE_DIR}/src/ddsrt/include")
 | 
				
			||||||
add_compile_options("-I${PROJECT_SOURCE_DIR}/src/core/ddsc/include")
 | 
					add_compile_options("-I${PROJECT_SOURCE_DIR}/src/core/ddsc/include")
 | 
				
			||||||
add_compile_options("-I${PROJECT_SOURCE_DIR}/src/core/ddsc/src")
 | 
					add_compile_options("-I${PROJECT_SOURCE_DIR}/src/core/ddsc/src")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ print CYC <<EOF;
 | 
				
			||||||
#include "dds/ddsrt/random.h"
 | 
					#include "dds/ddsrt/random.h"
 | 
				
			||||||
#include "dds/ddsrt/sockets.h"
 | 
					#include "dds/ddsrt/sockets.h"
 | 
				
			||||||
#include "dds/ddsi/ddsi_serdata_default.h"
 | 
					#include "dds/ddsi/ddsi_serdata_default.h"
 | 
				
			||||||
#include "dds__stream.h"
 | 
					#include "dds/ddsi/ddsi_cdrstream.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "c_base.h"
 | 
					#include "c_base.h"
 | 
				
			||||||
#include "sd_cdr.h"
 | 
					#include "sd_cdr.h"
 | 
				
			||||||
| 
						 | 
					@ -116,7 +116,15 @@ EOF
 | 
				
			||||||
  ;
 | 
					  ;
 | 
				
			||||||
  print CYC gencmp ($t);
 | 
					  print CYC gencmp ($t);
 | 
				
			||||||
  print CYC <<EOF;
 | 
					  print CYC <<EOF;
 | 
				
			||||||
  ddd.type = (struct dds_topic_descriptor *) &$t->[1]_desc;
 | 
					  ddd.type = (struct ddsi_sertopic_default_desc) {
 | 
				
			||||||
 | 
					    .m_size = $t->[1]_desc.m_size,
 | 
				
			||||||
 | 
					    .m_align = $t->[1]_desc.m_align,
 | 
				
			||||||
 | 
					    .m_flagset = $t->[1]_desc.m_flagset,
 | 
				
			||||||
 | 
					    .m_nkeys = 0,
 | 
				
			||||||
 | 
					    .m_keys = NULL,
 | 
				
			||||||
 | 
					    .m_nops = dds_stream_countops ($t->[1]_desc.m_ops),
 | 
				
			||||||
 | 
					    .m_ops = (uint32_t *) $t->[1]_desc.m_ops
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
  for (uint32_t i = 0; i < 1000; i++) {
 | 
					  for (uint32_t i = 0; i < 1000; i++) {
 | 
				
			||||||
    for (size_t j = 0; j < sizeof (garbage); j++)
 | 
					    for (size_t j = 0; j < sizeof (garbage); j++)
 | 
				
			||||||
      garbage[j] = (unsigned char) ddsrt_random ();
 | 
					      garbage[j] = (unsigned char) ddsrt_random ();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue