Relax constraints on topic entities

This commit changes the implementation of topics so that multiple topic
entities can exist in a single participant for the same topic.
Different entities may refer to different topic implementations
(sertopics, akin to a type support in the DDS specification).  All
entities (for the same participant) always have the same QoS, via the
new "ktopic" table in the participant.

Readers and writers are bound to a topic entity and inherit its
properties.  If a topic comes in two definitions, say one for C and one
for C++, one can have a single participant with a reader delivering the
data in C representation and another reader delivering it in C++
representation.

This changes the behaviour of create_topic and find_topic: these now (on
successful return) always return a new entity (and thus with a unique
handle), where previously these would simply return a existing one when
possible.

This also requires some small additions to the sertopic/serdata
interface.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2020-01-28 21:29:14 +01:00 committed by eboasson
parent 08c9db0934
commit 27d7c72626
29 changed files with 946 additions and 530 deletions

View file

@ -111,6 +111,7 @@ list(APPEND headers
"${include_path}/dds/ddsrt/endian.h"
"${include_path}/dds/ddsrt/arch.h"
"${include_path}/dds/ddsrt/misc.h"
"${include_path}/dds/ddsrt/mh3.h"
"${include_path}/dds/ddsrt/io.h"
"${include_path}/dds/ddsrt/process.h"
"${include_path}/dds/ddsrt/strtod.h"
@ -127,6 +128,7 @@ list(APPEND sources
"${source_path}/retcode.c"
"${source_path}/strtod.c"
"${source_path}/strtol.c"
"${source_path}/mh3.c"
"${source_path}/avl.c"
"${source_path}/expand_envvars.c"
"${source_path}/fibheap.c"

View file

@ -0,0 +1,34 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDSRT_MH3_H
#define DDSRT_MH3_H
#include <stdint.h>
#include <stddef.h>
#include "dds/export.h"
#if defined(__cplusplus)
extern "C" {
#endif
DDS_EXPORT uint32_t
ddsrt_mh3(
const void *key,
size_t len,
uint32_t seed);
#if defined(__cplusplus)
}
#endif
#endif /* DDSRT_MH3_H */

69
src/ddsrt/src/mh3.c Normal file
View file

@ -0,0 +1,69 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/ddsrt/mh3.h"
#define DDSRT_MH3_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
/* Really
http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp,
MurmurHash3_x86_32
*/
uint32_t ddsrt_mh3 (const void *key, size_t len, uint32_t seed)
{
const uint8_t *data = (const uint8_t *) key;
const intptr_t nblocks = (intptr_t) (len / 4);
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
uint32_t h1 = seed;
const uint32_t *blocks = (const uint32_t *) (data + nblocks * 4);
for (intptr_t i = -nblocks; i; i++)
{
uint32_t k1 = blocks[i];
k1 *= c1;
k1 = DDSRT_MH3_ROTL32 (k1, 15);
k1 *= c2;
h1 ^= k1;
h1 = DDSRT_MH3_ROTL32 (h1, 13);
h1 = h1 * 5 + 0xe6546b64;
}
const uint8_t *tail = data + nblocks * 4;
uint32_t k1 = 0;
switch (len & 3)
{
case 3:
k1 ^= (uint32_t) tail[2] << 16;
/* FALLS THROUGH */
case 2:
k1 ^= (uint32_t) tail[1] << 8;
/* FALLS THROUGH */
case 1:
k1 ^= (uint32_t) tail[0];
k1 *= c1;
k1 = DDSRT_MH3_ROTL32 (k1, 15);
k1 *= c2;
h1 ^= k1;
/* FALLS THROUGH */
};
/* finalization */
h1 ^= (uint32_t) len;
h1 ^= h1 >> 16;
h1 *= 0x85ebca6b;
h1 ^= h1 >> 13;
h1 *= 0xc2b2ae35;
h1 ^= h1 >> 16;
return h1;
}