move util library into ddsrt

As was the plan with the introduction of ddsrt; this includes renaming
the identifiers to match the capitalization style and removes old junk.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-04-16 10:23:32 +02:00 committed by eboasson
parent e965df5db7
commit 6c171a890d
62 changed files with 1702 additions and 1869 deletions

View file

@ -22,10 +22,6 @@ but does offer a neat way to separate features logically.
| | ddsi | RTPS-DDSI specification. | | ddsi | RTPS-DDSI specification.
| | | | | |
| |---------| | |---------|
| | | util is a collection of snippets that do not require
| | util | per-target implementations and may be used by the ddsc
| | | and ddsi targets. util will be merged into ddsrt.
| |---------|
| | ddsrt offers target agnostic implementations of | | ddsrt offers target agnostic implementations of
| ddsrt | functionality required by the ddsc and ddsi targets, but | ddsrt | functionality required by the ddsc and ddsi targets, but
| | also exports a subset of the dds\_ api directly. e.g. | | also exports a subset of the dds\_ api directly. e.g.

View file

@ -173,7 +173,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
add_subdirectory(idlc) add_subdirectory(idlc)
add_subdirectory(ddsrt) add_subdirectory(ddsrt)
add_subdirectory(etc) add_subdirectory(etc)
add_subdirectory(util)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(tools) add_subdirectory(tools)
add_subdirectory(scripts) add_subdirectory(scripts)

View file

@ -50,16 +50,13 @@ endif()
include(ddsi/CMakeLists.txt) include(ddsi/CMakeLists.txt)
include(ddsc/CMakeLists.txt) include(ddsc/CMakeLists.txt)
target_link_libraries(ddsc PRIVATE util)
target_link_libraries(ddsc PRIVATE ddsrt) target_link_libraries(ddsc PRIVATE ddsrt)
target_compile_definitions( target_compile_definitions(
ddsc PUBLIC ddsc PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_COMPILE_DEFINITIONS>> $<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_COMPILE_DEFINITIONS>>)
$<BUILD_INTERFACE:$<TARGET_PROPERTY:util,INTERFACE_COMPILE_DEFINITIONS>>)
target_include_directories( target_include_directories(
ddsc PUBLIC ddsc PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_INCLUDE_DIRECTORIES>> $<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_INCLUDE_DIRECTORIES>>)
$<BUILD_INTERFACE:$<TARGET_PROPERTY:util,INTERFACE_INCLUDE_DIRECTORIES>>)
# SOVERSION should increase on incompatible ABI change # SOVERSION should increase on incompatible ABI change
set_target_properties(ddsc PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) set_target_properties(ddsc PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})

View file

@ -18,7 +18,7 @@
extern "C" { extern "C" {
#endif #endif
extern DDS_EXPORT const ut_avlTreedef_t dds_domaintree_def; extern DDS_EXPORT const ddsrt_avl_treedef_t dds_domaintree_def;
DDS_EXPORT dds_domain * dds_domain_create (dds_domainid_t id); DDS_EXPORT dds_domain * dds_domain_create (dds_domainid_t id);
DDS_EXPORT void dds_domain_free (dds_domain * domain); DDS_EXPORT void dds_domain_free (dds_domain * domain);

View file

@ -94,9 +94,9 @@ dds_handle_server_fini(void);
* user data. * user data.
* *
* A kind value != 0 has to be provided, just to make sure that no 0 handles * A kind value != 0 has to be provided, just to make sure that no 0 handles
* will be created. It should also fit the UT_HANDLE_KIND_MASK. * will be created. It should also fit the DDSRT_HANDLE_KIND_MASK.
* In other words handle creation will fail if * In other words handle creation will fail if
* ((kind & ~UT_HANDLE_KIND_MASK != 0) || (kind & UT_HANDLE_KIND_MASK == 0)). * ((kind & ~DDSRT_HANDLE_KIND_MASK != 0) || (kind & DDSRT_HANDLE_KIND_MASK == 0)).
* *
* It has to do something clever to make sure that a deleted handle is not * It has to do something clever to make sure that a deleted handle is not
* re-issued very quickly after it was deleted. * re-issued very quickly after it was deleted.

View file

@ -17,7 +17,7 @@
#include "dds/dds.h" #include "dds/dds.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsi/q_rtps.h" #include "dds/ddsi/q_rtps.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds__handles.h" #include "dds__handles.h"
#if defined (__cplusplus) #if defined (__cplusplus)
@ -94,9 +94,9 @@ struct dds_listener {
typedef struct dds_domain typedef struct dds_domain
{ {
ut_avlNode_t m_node; ddsrt_avl_node_t m_node;
dds_domainid_t m_id; dds_domainid_t m_id;
ut_avlTree_t m_topics; ddsrt_avl_tree_t m_topics;
uint32_t m_refc; uint32_t m_refc;
} }
dds_domain; dds_domain;
@ -151,7 +151,7 @@ typedef struct dds_entity
} }
dds_entity; dds_entity;
extern const ut_avlTreedef_t dds_topictree_def; extern const ddsrt_avl_treedef_t dds_topictree_def;
typedef struct dds_subscriber typedef struct dds_subscriber
{ {
@ -283,7 +283,7 @@ typedef struct dds_globals
int (*m_dur_wait) (struct dds_reader * reader, dds_duration_t timeout); int (*m_dur_wait) (struct dds_reader * reader, dds_duration_t timeout);
void (*m_dur_init) (void); void (*m_dur_init) (void);
void (*m_dur_fini) (void); void (*m_dur_fini) (void);
ut_avlTree_t m_domains; ddsrt_avl_tree_t m_domains;
ddsrt_mutex_t m_mutex; ddsrt_mutex_t m_mutex;
} }
dds_globals; dds_globals;

View file

@ -17,7 +17,7 @@ static int dds_domain_compare (const int32_t * a, const int32_t * b)
return (*a == *b) ? 0 : (*a < *b) ? -1 : 1; return (*a == *b) ? 0 : (*a < *b) ? -1 : 1;
} }
const ut_avlTreedef_t dds_domaintree_def = UT_AVL_TREEDEF_INITIALIZER const ddsrt_avl_treedef_t dds_domaintree_def = DDSRT_AVL_TREEDEF_INITIALIZER
( (
offsetof (dds_domain, m_node), offsetof (dds_domain, m_node),
offsetof (dds_domain, m_id), offsetof (dds_domain, m_id),
@ -27,7 +27,7 @@ const ut_avlTreedef_t dds_domaintree_def = UT_AVL_TREEDEF_INITIALIZER
dds_domain * dds_domain_find_locked (dds_domainid_t id) dds_domain * dds_domain_find_locked (dds_domainid_t id)
{ {
return ut_avlLookup (&dds_domaintree_def, &dds_global.m_domains, &id); return ddsrt_avl_lookup (&dds_domaintree_def, &dds_global.m_domains, &id);
} }
dds_domain * dds_domain_create (dds_domainid_t id) dds_domain * dds_domain_create (dds_domainid_t id)
@ -39,8 +39,8 @@ dds_domain * dds_domain_create (dds_domainid_t id)
{ {
domain = dds_alloc (sizeof (*domain)); domain = dds_alloc (sizeof (*domain));
domain->m_id = id; domain->m_id = id;
ut_avlInit (&dds_topictree_def, &domain->m_topics); ddsrt_avl_init (&dds_topictree_def, &domain->m_topics);
ut_avlInsert (&dds_domaintree_def, &dds_global.m_domains, domain); ddsrt_avl_insert (&dds_domaintree_def, &dds_global.m_domains, domain);
} }
domain->m_refc++; domain->m_refc++;
ddsrt_mutex_unlock (&dds_global.m_mutex); ddsrt_mutex_unlock (&dds_global.m_mutex);
@ -52,7 +52,7 @@ void dds_domain_free (dds_domain * domain)
ddsrt_mutex_lock (&dds_global.m_mutex); ddsrt_mutex_lock (&dds_global.m_mutex);
if (--domain->m_refc == 0) if (--domain->m_refc == 0)
{ {
ut_avlDelete (&dds_domaintree_def, &dds_global.m_domains, domain); ddsrt_avl_delete (&dds_domaintree_def, &dds_global.m_domains, domain);
dds_free (domain); dds_free (domain);
} }
ddsrt_mutex_unlock (&dds_global.m_mutex); ddsrt_mutex_unlock (&dds_global.m_mutex);

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/random.h" #include "dds/ddsrt/random.h"
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#include "dds/ddsi/q_thread.h" #include "dds/ddsi/q_thread.h"
#include "dds__handles.h" #include "dds__handles.h"
#include "dds__types.h" #include "dds__types.h"
@ -40,9 +40,9 @@
struct dds_handle_server { struct dds_handle_server {
#if USE_CHH #if USE_CHH
struct ut_chh *ht; struct ddsrt_chh *ht;
#else #else
struct ut_hh *ht; struct ddsrt_hh *ht;
#endif #endif
size_t count; size_t count;
ddsrt_mutex_t lock; ddsrt_mutex_t lock;
@ -68,9 +68,9 @@ static int handle_equal (const void *va, const void *vb)
dds_return_t dds_handle_server_init (void (*free_via_gc) (void *x)) dds_return_t dds_handle_server_init (void (*free_via_gc) (void *x))
{ {
#if USE_CHH #if USE_CHH
handles.ht = ut_chhNew (128, handle_hash, handle_equal, free_via_gc); handles.ht = ddsrt_chh_new (128, handle_hash, handle_equal, free_via_gc);
#else #else
handles.ht = ut_hhNew (128, handle_hash, handle_equal); handles.ht = ddsrt_hh_new (128, handle_hash, handle_equal);
(void) free_via_gc; (void) free_via_gc;
#endif #endif
handles.count = 0; handles.count = 0;
@ -83,16 +83,16 @@ void dds_handle_server_fini (void)
{ {
#if USE_CHH #if USE_CHH
#ifndef NDEBUG #ifndef NDEBUG
struct ut_chhIter it; struct ddsrt_chh_iter it;
assert (ut_chhIterFirst (handles.ht, &it) == NULL); assert (ddsrt_chh_iter_first (handles.ht, &it) == NULL);
#endif #endif
ut_chhFree (handles.ht); ddsrt_chh_free (handles.ht);
#else /* USE_CHH */ #else /* USE_CHH */
#ifndef NDEBUG #ifndef NDEBUG
struct ut_hhIter it; struct ddsrt_hh_iter it;
assert (ut_hhIterFirst (handles.ht, &it) == NULL); assert (ddsrt_hh_iter_first (handles.ht, &it) == NULL);
#endif #endif
ut_hhFree (handles.ht); ddsrt_hh_free (handles.ht);
#endif /* USE_CHH */ #endif /* USE_CHH */
ddsrt_cond_destroy (&handles.cond); ddsrt_cond_destroy (&handles.cond);
ddsrt_mutex_destroy (&handles.lock); ddsrt_mutex_destroy (&handles.lock);
@ -100,9 +100,9 @@ void dds_handle_server_fini (void)
} }
#if USE_CHH #if USE_CHH
static bool hhadd (struct ut_chh *ht, void *elem) { return ut_chhAdd (ht, elem); } static bool hhadd (struct ddsrt_chh *ht, void *elem) { return ddsrt_chh_add (ht, elem); }
#else #else
static bool hhadd (struct ut_hh *ht, void *elem) { return ut_hhAdd (ht, elem); } static bool hhadd (struct ddsrt_hh *ht, void *elem) { return ddsrt_hh_add (ht, elem); }
#endif #endif
static dds_handle_t dds_handle_create_int (struct dds_handle_link *link) static dds_handle_t dds_handle_create_int (struct dds_handle_link *link)
{ {
@ -176,10 +176,10 @@ int32_t dds_handle_delete (struct dds_handle_link *link, dds_duration_t timeout)
} }
#if USE_CHH #if USE_CHH
thread_state_awake (ts1); thread_state_awake (ts1);
int x = ut_chhRemove (handles.ht, link); int x = ddsrt_chh_remove (handles.ht, link);
thread_state_asleep (ts1); thread_state_asleep (ts1);
#else #else
int x = ut_hhRemove (handles.ht, link); int x = ddsrt_hh_remove (handles.ht, link);
#endif #endif
assert(x); assert(x);
(void)x; (void)x;
@ -209,10 +209,10 @@ int32_t dds_handle_claim (dds_handle_t hdl, struct dds_handle_link **link)
#if USE_CHH #if USE_CHH
thread_state_awake (ts1); thread_state_awake (ts1);
*link = ut_chhLookup (handles.ht, &dummy); *link = ddsrt_chh_lookup (handles.ht, &dummy);
#else #else
ddsrt_mutex_lock (&handles.lock); ddsrt_mutex_lock (&handles.lock);
*link = ut_hhLookup (handles.ht, &dummy); *link = ddsrt_hh_lookup (handles.ht, &dummy);
#endif #endif
if (*link == NULL) if (*link == NULL)
rc = DDS_RETCODE_BAD_PARAMETER; rc = DDS_RETCODE_BAD_PARAMETER;

View file

@ -123,7 +123,7 @@ dds_init(dds_domainid_t domain)
} }
upgrade_main_thread(); upgrade_main_thread();
ut_avlInit(&dds_domaintree_def, &dds_global.m_domains); ddsrt_avl_init(&dds_domaintree_def, &dds_global.m_domains);
/* Start monitoring the liveliness of all threads. */ /* Start monitoring the liveliness of all threads. */
if (!config.liveliness_monitoring) if (!config.liveliness_monitoring)

View file

@ -532,14 +532,14 @@ void dds_reader_ddsi2direct (dds_entity_t entity, ddsi2direct_directread_cb_t cb
rd->ddsi2direct_cb = cb; rd->ddsi2direct_cb = cb;
rd->ddsi2direct_cbarg = cbarg; rd->ddsi2direct_cbarg = cbarg;
while ((m = ut_avlLookupSuccEq (&rd_writers_treedef, &rd->writers, &pwrguid)) != NULL) while ((m = ddsrt_avl_lookup_succ_eq (&rd_writers_treedef, &rd->writers, &pwrguid)) != NULL)
{ {
/* have to be careful walking the tree -- pretty is different, but /* have to be careful walking the tree -- pretty is different, but
I want to check this before I write a lookup_succ function. */ I want to check this before I write a lookup_succ function. */
struct rd_pwr_match *m_next; struct rd_pwr_match *m_next;
nn_guid_t pwrguid_next; nn_guid_t pwrguid_next;
pwrguid = m->pwr_guid; pwrguid = m->pwr_guid;
if ((m_next = ut_avlFindSucc (&rd_writers_treedef, &rd->writers, m)) != NULL) if ((m_next = ddsrt_avl_find_succ (&rd_writers_treedef, &rd->writers, m)) != NULL)
pwrguid_next = m_next->pwr_guid; pwrguid_next = m_next->pwr_guid;
else else
{ {

View file

@ -27,8 +27,8 @@
#include "dds__reader.h" #include "dds__reader.h"
#include "dds__rhc.h" #include "dds__rhc.h"
#include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_tkmap.h"
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_xqos.h" #include "dds/ddsi/q_xqos.h"
#include "dds/ddsi/q_error.h" #include "dds/ddsi/q_error.h"
#include "dds/ddsi/q_unused.h" #include "dds/ddsi/q_unused.h"
@ -174,7 +174,7 @@ struct lwreg
struct lwregs struct lwregs
{ {
struct ut_ehh * regs; struct ddsrt_ehh * regs;
}; };
static uint32_t lwreg_hash (const void *vl) static uint32_t lwreg_hash (const void *vl)
@ -192,36 +192,36 @@ static int lwreg_equals (const void *va, const void *vb)
static void lwregs_init (struct lwregs *rt) static void lwregs_init (struct lwregs *rt)
{ {
rt->regs = ut_ehhNew (sizeof (struct lwreg), 1, lwreg_hash, lwreg_equals); rt->regs = ddsrt_ehh_new (sizeof (struct lwreg), 1, lwreg_hash, lwreg_equals);
} }
static void lwregs_fini (struct lwregs *rt) static void lwregs_fini (struct lwregs *rt)
{ {
ut_ehhFree (rt->regs); ddsrt_ehh_free (rt->regs);
} }
static int lwregs_contains (struct lwregs *rt, uint64_t iid, uint64_t wr_iid) static int lwregs_contains (struct lwregs *rt, uint64_t iid, uint64_t wr_iid)
{ {
struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid }; struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid };
return ut_ehhLookup (rt->regs, &dummy) != NULL; return ddsrt_ehh_lookup (rt->regs, &dummy) != NULL;
} }
static int lwregs_add (struct lwregs *rt, uint64_t iid, uint64_t wr_iid) static int lwregs_add (struct lwregs *rt, uint64_t iid, uint64_t wr_iid)
{ {
struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid }; struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid };
return ut_ehhAdd (rt->regs, &dummy); return ddsrt_ehh_add (rt->regs, &dummy);
} }
static int lwregs_delete (struct lwregs *rt, uint64_t iid, uint64_t wr_iid) static int lwregs_delete (struct lwregs *rt, uint64_t iid, uint64_t wr_iid)
{ {
struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid }; struct lwreg dummy = { .iid = iid, .wr_iid = wr_iid };
return ut_ehhRemove (rt->regs, &dummy); return ddsrt_ehh_remove (rt->regs, &dummy);
} }
void lwregs_dump (struct lwregs *rt) void lwregs_dump (struct lwregs *rt)
{ {
struct ut_ehhIter it; struct ddsrt_ehh_iter it;
for (struct lwreg *r = ut_ehhIterFirst(rt->regs, &it); r; r = ut_ehhIterNext(&it)) for (struct lwreg *r = ddsrt_ehh_iter_first(rt->regs, &it); r; r = ddsrt_ehh_iter_next(&it))
printf("iid=%"PRIu64" wr_iid=%"PRIu64"\n", r->iid, r->wr_iid); printf("iid=%"PRIu64" wr_iid=%"PRIu64"\n", r->iid, r->wr_iid);
} }
@ -271,7 +271,7 @@ typedef enum rhc_store_result {
} rhc_store_result_t; } rhc_store_result_t;
struct rhc { struct rhc {
struct ut_hh *instances; struct ddsrt_hh *instances;
struct rhc_instance *nonempty_instances; /* circular, points to most recently added one, NULL if none */ struct rhc_instance *nonempty_instances; /* circular, points to most recently added one, NULL if none */
struct lwregs registrations; /* should be a global one (with lock-free lookups) */ struct lwregs registrations; /* should be a global one (with lock-free lookups) */
@ -458,7 +458,7 @@ struct rhc * dds_rhc_new (dds_reader * reader, const struct ddsi_sertopic * topi
lwregs_init (&rhc->registrations); lwregs_init (&rhc->registrations);
ddsrt_mutex_init (&rhc->lock); ddsrt_mutex_init (&rhc->lock);
rhc->instances = ut_hhNew (1, instance_iid_hash, instance_iid_eq); rhc->instances = ddsrt_hh_new (1, instance_iid_hash, instance_iid_eq);
rhc->topic = topic; rhc->topic = topic;
rhc->reader = reader; rhc->reader = reader;
@ -620,9 +620,9 @@ static void free_instance_rhc_free_wrap (void *vnode, void *varg)
void dds_rhc_free (struct rhc *rhc) void dds_rhc_free (struct rhc *rhc)
{ {
assert (rhc_check_counts_locked (rhc, true, true)); assert (rhc_check_counts_locked (rhc, true, true));
ut_hhEnum (rhc->instances, free_instance_rhc_free_wrap, rhc); ddsrt_hh_enum (rhc->instances, free_instance_rhc_free_wrap, rhc);
assert (rhc->nonempty_instances == NULL); assert (rhc->nonempty_instances == NULL);
ut_hhFree (rhc->instances); ddsrt_hh_free (rhc->instances);
lwregs_fini (&rhc->registrations); lwregs_fini (&rhc->registrations);
if (rhc->qcond_eval_samplebuf != NULL) if (rhc->qcond_eval_samplebuf != NULL)
ddsi_sertopic_free_sample (rhc->topic, rhc->qcond_eval_samplebuf, DDS_FREE_ALL); ddsi_sertopic_free_sample (rhc->topic, rhc->qcond_eval_samplebuf, DDS_FREE_ALL);
@ -848,7 +848,7 @@ static void drop_instance_noupdate_no_writers (struct rhc *rhc, struct rhc_insta
rhc->n_instances--; rhc->n_instances--;
ret = ut_hhRemove (rhc->instances, inst); ret = ddsrt_hh_remove (rhc->instances, inst);
assert (ret); assert (ret);
(void) ret; (void) ret;
@ -1198,7 +1198,7 @@ static rhc_store_result_t rhc_store_new_instance (struct rhc_instance **out_inst
} }
account_for_empty_to_nonempty_transition (rhc, inst); account_for_empty_to_nonempty_transition (rhc, inst);
ret = ut_hhAdd (rhc->instances, inst); ret = ddsrt_hh_add (rhc->instances, inst);
assert (ret); assert (ret);
(void) ret; (void) ret;
rhc->n_instances++; rhc->n_instances++;
@ -1248,7 +1248,7 @@ bool dds_rhc_store (struct rhc * __restrict rhc, const struct proxy_writer_info
ddsrt_mutex_lock (&rhc->lock); ddsrt_mutex_lock (&rhc->lock);
inst = ut_hhLookup (rhc->instances, &dummy_instance); inst = ddsrt_hh_lookup (rhc->instances, &dummy_instance);
if (inst == NULL) if (inst == NULL)
{ {
/* New instance for this reader. If no data content -- not (also) /* New instance for this reader. If no data content -- not (also)
@ -1492,13 +1492,13 @@ void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writ
bool trigger_waitsets = false; bool trigger_waitsets = false;
bool notify_data_available = false; bool notify_data_available = false;
struct rhc_instance *inst; struct rhc_instance *inst;
struct ut_hhIter iter; struct ddsrt_hh_iter iter;
const uint64_t wr_iid = pwr_info->iid; const uint64_t wr_iid = pwr_info->iid;
const int auto_dispose = pwr_info->auto_dispose; const int auto_dispose = pwr_info->auto_dispose;
ddsrt_mutex_lock (&rhc->lock); ddsrt_mutex_lock (&rhc->lock);
TRACE ("rhc_unregister_wr_iid(%"PRIx64",%d:\n", wr_iid, auto_dispose); TRACE ("rhc_unregister_wr_iid(%"PRIx64",%d:\n", wr_iid, auto_dispose);
for (inst = ut_hhIterFirst (rhc->instances, &iter); inst; inst = ut_hhIterNext (&iter)) for (inst = ddsrt_hh_iter_first (rhc->instances, &iter); inst; inst = ddsrt_hh_iter_next (&iter))
{ {
if ((inst->wr_iid_islive && inst->wr_iid == wr_iid) || lwregs_contains (&rhc->registrations, inst->iid, wr_iid)) if ((inst->wr_iid_islive && inst->wr_iid == wr_iid) || lwregs_contains (&rhc->registrations, inst->iid, wr_iid))
{ {
@ -1558,10 +1558,10 @@ void dds_rhc_unregister_wr (struct rhc * __restrict rhc, const struct proxy_writ
void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid) void dds_rhc_relinquish_ownership (struct rhc * __restrict rhc, const uint64_t wr_iid)
{ {
struct rhc_instance *inst; struct rhc_instance *inst;
struct ut_hhIter iter; struct ddsrt_hh_iter iter;
ddsrt_mutex_lock (&rhc->lock); ddsrt_mutex_lock (&rhc->lock);
TRACE ("rhc_relinquish_ownership(%"PRIx64":\n", wr_iid); TRACE ("rhc_relinquish_ownership(%"PRIx64":\n", wr_iid);
for (inst = ut_hhIterFirst (rhc->instances, &iter); inst; inst = ut_hhIterNext (&iter)) for (inst = ddsrt_hh_iter_first (rhc->instances, &iter); inst; inst = ddsrt_hh_iter_next (&iter))
{ {
if (inst->wr_iid_islive && inst->wr_iid == wr_iid) if (inst->wr_iid_islive && inst->wr_iid == wr_iid)
{ {
@ -2234,7 +2234,7 @@ bool dds_rhc_add_readcondition (dds_readcond *cond)
between those attached to a waitset or not. */ between those attached to a waitset or not. */
struct rhc *rhc = cond->m_rhc; struct rhc *rhc = cond->m_rhc;
struct ut_hhIter it; struct ddsrt_hh_iter it;
assert ((dds_entity_kind (&cond->m_entity) == DDS_KIND_COND_READ && cond->m_query.m_filter == 0) || assert ((dds_entity_kind (&cond->m_entity) == DDS_KIND_COND_READ && cond->m_query.m_filter == 0) ||
(dds_entity_kind (&cond->m_entity) == DDS_KIND_COND_QUERY && cond->m_query.m_filter != 0)); (dds_entity_kind (&cond->m_entity) == DDS_KIND_COND_QUERY && cond->m_query.m_filter != 0));
@ -2296,7 +2296,7 @@ bool dds_rhc_add_readcondition (dds_readcond *cond)
samples, except for those that match the predicate. */ samples, except for those that match the predicate. */
const dds_querycond_mask_t qcmask = cond->m_query.m_qcmask; const dds_querycond_mask_t qcmask = cond->m_query.m_qcmask;
uint32_t trigger = 0; uint32_t trigger = 0;
for (struct rhc_instance *inst = ut_hhIterFirst (rhc->instances, &it); inst != NULL; inst = ut_hhIterNext (&it)) for (struct rhc_instance *inst = ddsrt_hh_iter_first (rhc->instances, &it); inst != NULL; inst = ddsrt_hh_iter_next (&it))
{ {
const bool instmatch = eval_predicate_invsample (rhc, inst, cond->m_query.m_filter);; const bool instmatch = eval_predicate_invsample (rhc, inst, cond->m_query.m_filter);;
uint32_t matches = 0; uint32_t matches = 0;
@ -2612,7 +2612,7 @@ static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds, bool chec
unsigned cond_match_count[CHECK_MAX_CONDS]; unsigned cond_match_count[CHECK_MAX_CONDS];
dds_querycond_mask_t enabled_qcmask = 0; dds_querycond_mask_t enabled_qcmask = 0;
struct rhc_instance *inst; struct rhc_instance *inst;
struct ut_hhIter iter; struct ddsrt_hh_iter iter;
dds_readcond *rciter; dds_readcond *rciter;
uint32_t i; uint32_t i;
@ -2628,7 +2628,7 @@ static int rhc_check_counts_locked (struct rhc *rhc, bool check_conds, bool chec
enabled_qcmask |= rciter->m_query.m_qcmask; enabled_qcmask |= rciter->m_query.m_qcmask;
} }
for (inst = ut_hhIterFirst (rhc->instances, &iter); inst; inst = ut_hhIterNext (&iter)) for (inst = ddsrt_hh_iter_first (rhc->instances, &iter); inst; inst = ddsrt_hh_iter_next (&iter))
{ {
unsigned n_vsamples_in_instance = 0, n_read_vsamples_in_instance = 0; unsigned n_vsamples_in_instance = 0, n_read_vsamples_in_instance = 0;
bool a_sample_free = true; bool a_sample_free = true;

View file

@ -32,7 +32,7 @@ DECL_ENTITY_LOCK_UNLOCK(extern inline, dds_topic)
#define DDS_TOPIC_STATUS_MASK \ #define DDS_TOPIC_STATUS_MASK \
DDS_INCONSISTENT_TOPIC_STATUS DDS_INCONSISTENT_TOPIC_STATUS
const ut_avlTreedef_t dds_topictree_def = UT_AVL_TREEDEF_INITIALIZER_INDKEY const ddsrt_avl_treedef_t dds_topictree_def = DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY
( (
offsetof (struct ddsi_sertopic, avlnode), offsetof (struct ddsi_sertopic, avlnode),
offsetof (struct ddsi_sertopic, name_typename), offsetof (struct ddsi_sertopic, name_typename),
@ -118,17 +118,17 @@ dds_topic_lookup_locked(
const char *name) const char *name)
{ {
struct ddsi_sertopic *st = NULL; struct ddsi_sertopic *st = NULL;
ut_avlIter_t iter; ddsrt_avl_iter_t iter;
assert (domain); assert (domain);
assert (name); assert (name);
st = ut_avlIterFirst (&dds_topictree_def, &domain->m_topics, &iter); st = ddsrt_avl_iter_first (&dds_topictree_def, &domain->m_topics, &iter);
while (st) { while (st) {
if (strcmp (st->name, name) == 0) { if (strcmp (st->name, name) == 0) {
break; break;
} }
st = ut_avlIterNext (&iter); st = ddsrt_avl_iter_next (&iter);
} }
return st; return st;
} }
@ -155,9 +155,9 @@ dds_topic_free(
assert (st); assert (st);
ddsrt_mutex_lock (&dds_global.m_mutex); ddsrt_mutex_lock (&dds_global.m_mutex);
domain = ut_avlLookup (&dds_domaintree_def, &dds_global.m_domains, &domainid); domain = ddsrt_avl_lookup (&dds_domaintree_def, &dds_global.m_domains, &domainid);
if (domain != NULL) { if (domain != NULL) {
ut_avlDelete (&dds_topictree_def, &domain->m_topics, st); ddsrt_avl_delete (&dds_topictree_def, &domain->m_topics, st);
} }
ddsrt_mutex_unlock (&dds_global.m_mutex); ddsrt_mutex_unlock (&dds_global.m_mutex);
st->status_cb_entity = NULL; st->status_cb_entity = NULL;
@ -172,7 +172,7 @@ dds_topic_add_locked(
dds_domain * dom; dds_domain * dom;
dom = dds_domain_find_locked (id); dom = dds_domain_find_locked (id);
assert (dom); assert (dom);
ut_avlInsert (&dds_topictree_def, &dom->m_topics, st); ddsrt_avl_insert (&dds_topictree_def, &dom->m_topics, st);
} }
DDS_EXPORT dds_entity_t DDS_EXPORT dds_entity_t

View file

@ -22,8 +22,8 @@
#include "dds__whc.h" #include "dds__whc.h"
#include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_tkmap.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#include "dds/ddsi/q_time.h" #include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_rtps.h" #include "dds/ddsi/q_rtps.h"
#include "dds/ddsi/q_freelist.h" #include "dds/ddsi/q_freelist.h"
@ -47,7 +47,7 @@ struct whc_node {
}; };
struct whc_intvnode { struct whc_intvnode {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
seqno_t min; seqno_t min;
seqno_t maxp1; seqno_t maxp1;
struct whc_node *first; /* linked list of seqs with contiguous sequence numbers [min,maxp1) */ struct whc_node *first; /* linked list of seqs with contiguous sequence numbers [min,maxp1) */
@ -89,12 +89,12 @@ struct whc_impl {
struct whc_node *maxseq_node; /* NULL if empty; if not in open_intv, open_intv is empty */ struct whc_node *maxseq_node; /* NULL if empty; if not in open_intv, open_intv is empty */
struct nn_freelist freelist; /* struct whc_node *; linked via whc_node::next_seq */ struct nn_freelist freelist; /* struct whc_node *; linked via whc_node::next_seq */
#if USE_EHH #if USE_EHH
struct ut_ehh *seq_hash; struct ddsrt_ehh *seq_hash;
#else #else
struct ut_hh *seq_hash; struct ddsrt_hh *seq_hash;
#endif #endif
struct ut_hh *idx_hash; struct ddsrt_hh *idx_hash;
ut_avlTree_t seq; ddsrt_avl_tree_t seq;
}; };
struct whc_sample_iter_impl { struct whc_sample_iter_impl {
@ -140,8 +140,8 @@ static void whc_default_sample_iter_init (const struct whc *whc, struct whc_samp
static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample); static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample);
static void whc_default_free (struct whc *whc); static void whc_default_free (struct whc *whc);
static const ut_avlTreedef_t whc_seq_treedef = static const ddsrt_avl_treedef_t whc_seq_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct whc_intvnode, avlnode), offsetof (struct whc_intvnode, min), compare_seq, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct whc_intvnode, avlnode), offsetof (struct whc_intvnode, min), compare_seq, 0);
static const struct whc_ops whc_ops = { static const struct whc_ops whc_ops = {
.insert = whc_default_insert, .insert = whc_default_insert,
@ -225,7 +225,7 @@ static struct whc_node *whc_findmax_procedurally (const struct whc_impl *whc)
} }
else else
{ {
struct whc_intvnode *intv = ut_avlFindPred (&whc_seq_treedef, &whc->seq, whc->open_intv); struct whc_intvnode *intv = ddsrt_avl_find_pred (&whc_seq_treedef, &whc->seq, whc->open_intv);
assert (intv && intv->first); assert (intv && intv->first);
return intv->last; return intv->last;
} }
@ -239,8 +239,8 @@ static void check_whc (const struct whc_impl *whc)
contiguous; all samples in seq & in seqhash; tlidx \subseteq seq; contiguous; all samples in seq & in seqhash; tlidx \subseteq seq;
seq-number ordered list correct; &c. */ seq-number ordered list correct; &c. */
assert (whc->open_intv != NULL); assert (whc->open_intv != NULL);
assert (whc->open_intv == ut_avlFindMax (&whc_seq_treedef, &whc->seq)); assert (whc->open_intv == ddsrt_avl_find_max (&whc_seq_treedef, &whc->seq));
assert (ut_avlFindSucc (&whc_seq_treedef, &whc->seq, whc->open_intv) == NULL); assert (ddsrt_avl_find_succ (&whc_seq_treedef, &whc->seq, whc->open_intv) == NULL);
if (whc->maxseq_node) if (whc->maxseq_node)
{ {
assert (whc->maxseq_node->next_seq == NULL); assert (whc->maxseq_node->next_seq == NULL);
@ -264,7 +264,7 @@ static void check_whc (const struct whc_impl *whc)
struct whc_intvnode *firstintv; struct whc_intvnode *firstintv;
struct whc_node *cur; struct whc_node *cur;
seqno_t prevseq = 0; seqno_t prevseq = 0;
firstintv = ut_avlFindMin (&whc_seq_treedef, &whc->seq); firstintv = ddsrt_avl_find_min (&whc_seq_treedef, &whc->seq);
assert (firstintv); assert (firstintv);
cur = firstintv->first; cur = firstintv->first;
while (cur) while (cur)
@ -283,10 +283,10 @@ static void insert_whcn_in_hash (struct whc_impl *whc, struct whc_node *whcn)
/* precondition: whcn is not in hash */ /* precondition: whcn is not in hash */
#if USE_EHH #if USE_EHH
struct whc_seq_entry e = { .seq = whcn->seq, .whcn = whcn }; struct whc_seq_entry e = { .seq = whcn->seq, .whcn = whcn };
if (!ut_ehhAdd (whc->seq_hash, &e)) if (!ddsrt_ehh_add (whc->seq_hash, &e))
assert(0); assert(0);
#else #else
if (!ut_hhAdd (whc->seq_hash, whcn)) if (!ddsrt_hh_add (whc->seq_hash, whcn))
assert(0); assert(0);
#endif #endif
} }
@ -296,10 +296,10 @@ static void remove_whcn_from_hash (struct whc_impl *whc, struct whc_node *whcn)
/* precondition: whcn is in hash */ /* precondition: whcn is in hash */
#if USE_EHH #if USE_EHH
struct whc_seq_entry e = { .seq = whcn->seq }; struct whc_seq_entry e = { .seq = whcn->seq };
if (!ut_ehhRemove(whc->seq_hash, &e)) if (!ddsrt_ehh_remove(whc->seq_hash, &e))
assert(0); assert(0);
#else #else
if (!ut_hhRemove(whc->seq_hash, whcn)) if (!ddsrt_hh_remove(whc->seq_hash, whcn))
assert(0); assert(0);
#endif #endif
} }
@ -308,14 +308,14 @@ static struct whc_node *whc_findseq (const struct whc_impl *whc, seqno_t seq)
{ {
#if USE_EHH #if USE_EHH
struct whc_seq_entry e = { .seq = seq }, *r; struct whc_seq_entry e = { .seq = seq }, *r;
if ((r = ut_ehhLookup(whc->seq_hash, &e)) != NULL) if ((r = ddsrt_ehh_lookup(whc->seq_hash, &e)) != NULL)
return r->whcn; return r->whcn;
else else
return NULL; return NULL;
#else #else
struct whc_node template; struct whc_node template;
template.seq = seq; template.seq = seq;
return ut_hhLookup(whc->seq_hash, &template); return ddsrt_hh_lookup(whc->seq_hash, &template);
#endif #endif
} }
@ -328,7 +328,7 @@ static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct dd
struct whc_idxnode *n; struct whc_idxnode *n;
check_whc (whc); check_whc (whc);
template.idxn.iid = ddsi_tkmap_lookup(gv.m_tkmap, serdata_key); template.idxn.iid = ddsi_tkmap_lookup(gv.m_tkmap, serdata_key);
n = ut_hhLookup (whc->idx_hash, &template.idxn); n = ddsrt_hh_lookup (whc->idx_hash, &template.idxn);
if (n == NULL) if (n == NULL)
return NULL; return NULL;
else else
@ -359,22 +359,22 @@ struct whc *whc_new (int is_transient_local, unsigned hdepth, unsigned tldepth)
whc->total_bytes = 0; whc->total_bytes = 0;
whc->sample_overhead = sample_overhead; whc->sample_overhead = sample_overhead;
#if USE_EHH #if USE_EHH
whc->seq_hash = ut_ehhNew (sizeof (struct whc_seq_entry), 32, whc_seq_entry_hash, whc_seq_entry_eq); whc->seq_hash = ddsrt_ehh_new (sizeof (struct whc_seq_entry), 32, whc_seq_entry_hash, whc_seq_entry_eq);
#else #else
whc->seq_hash = ut_hhNew(32, whc_node_hash, whc_node_eq); whc->seq_hash = ddsrt_hh_new(32, whc_node_hash, whc_node_eq);
#endif #endif
if (whc->idxdepth > 0) if (whc->idxdepth > 0)
whc->idx_hash = ut_hhNew(32, whc_idxnode_hash_key, whc_idxnode_eq_key); whc->idx_hash = ddsrt_hh_new(32, whc_idxnode_hash_key, whc_idxnode_eq_key);
else else
whc->idx_hash = NULL; whc->idx_hash = NULL;
/* seq interval tree: always has an "open" node */ /* seq interval tree: always has an "open" node */
ut_avlInit (&whc_seq_treedef, &whc->seq); ddsrt_avl_init (&whc_seq_treedef, &whc->seq);
intv = ddsrt_malloc (sizeof (*intv)); intv = ddsrt_malloc (sizeof (*intv));
intv->min = intv->maxp1 = 1; intv->min = intv->maxp1 = 1;
intv->first = intv->last = NULL; intv->first = intv->last = NULL;
ut_avlInsert (&whc_seq_treedef, &whc->seq, intv); ddsrt_avl_insert (&whc_seq_treedef, &whc->seq, intv);
whc->open_intv = intv; whc->open_intv = intv;
whc->maxseq_node = NULL; whc->maxseq_node = NULL;
@ -402,11 +402,11 @@ void whc_default_free (struct whc *whc_generic)
if (whc->idx_hash) if (whc->idx_hash)
{ {
struct ut_hhIter it; struct ddsrt_hh_iter it;
struct whc_idxnode *n; struct whc_idxnode *n;
for (n = ut_hhIterFirst(whc->idx_hash, &it); n != NULL; n = ut_hhIterNext(&it)) for (n = ddsrt_hh_iter_first(whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next(&it))
ddsrt_free(n); ddsrt_free(n);
ut_hhFree(whc->idx_hash); ddsrt_hh_free(whc->idx_hash);
} }
{ {
@ -423,13 +423,13 @@ DDSRT_WARNING_MSVC_ON(6001);
} }
} }
ut_avlFree (&whc_seq_treedef, &whc->seq, ddsrt_free); ddsrt_avl_free (&whc_seq_treedef, &whc->seq, ddsrt_free);
nn_freelist_fini (&whc->freelist, ddsrt_free); nn_freelist_fini (&whc->freelist, ddsrt_free);
#if USE_EHH #if USE_EHH
ut_ehhFree (whc->seq_hash); ddsrt_ehh_free (whc->seq_hash);
#else #else
ut_hhFree (whc->seq_hash); ddsrt_hh_free (whc->seq_hash);
#endif #endif
ddsrt_mutex_destroy (&whc->lock); ddsrt_mutex_destroy (&whc->lock);
ddsrt_free (whc); ddsrt_free (whc);
@ -445,7 +445,7 @@ static void get_state_locked(const struct whc_impl *whc, struct whc_state *st)
else else
{ {
const struct whc_intvnode *intv; const struct whc_intvnode *intv;
intv = ut_avlFindMin (&whc_seq_treedef, &whc->seq); intv = ddsrt_avl_find_min (&whc_seq_treedef, &whc->seq);
/* not empty, open node may be anything but is (by definition) /* not empty, open node may be anything but is (by definition)
findmax, and whc is claimed to be non-empty, so min interval findmax, and whc is claimed to be non-empty, so min interval
can't be empty */ can't be empty */
@ -476,12 +476,12 @@ static struct whc_node *find_nextseq_intv (struct whc_intvnode **p_intv, const s
SEQ < Y can't exist */ SEQ < Y can't exist */
#ifndef NDEBUG #ifndef NDEBUG
{ {
struct whc_intvnode *predintv = ut_avlLookupPredEq (&whc_seq_treedef, &whc->seq, &seq); struct whc_intvnode *predintv = ddsrt_avl_lookup_pred_eq (&whc_seq_treedef, &whc->seq, &seq);
assert (predintv == NULL || predintv->maxp1 <= seq); assert (predintv == NULL || predintv->maxp1 <= seq);
} }
#endif #endif
if ((intv = ut_avlLookupSuccEq (&whc_seq_treedef, &whc->seq, &seq)) == NULL) { if ((intv = ddsrt_avl_lookup_succ_eq (&whc_seq_treedef, &whc->seq, &seq)) == NULL) {
assert (ut_avlLookupPredEq (&whc_seq_treedef, &whc->seq, &seq) == whc->open_intv); assert (ddsrt_avl_lookup_pred_eq (&whc_seq_treedef, &whc->seq, &seq) == whc->open_intv);
return NULL; return NULL;
} else if (intv->min < intv->maxp1) { /* only if not empty interval */ } else if (intv->min < intv->maxp1) { /* only if not empty interval */
assert (intv->min > seq); assert (intv->min > seq);
@ -502,7 +502,7 @@ static struct whc_node *find_nextseq_intv (struct whc_intvnode **p_intv, const s
assert (whc->maxseq_node != NULL); assert (whc->maxseq_node != NULL);
assert (n->seq < whc->maxseq_node->seq); assert (n->seq < whc->maxseq_node->seq);
n = n->next_seq; n = n->next_seq;
*p_intv = ut_avlLookupPredEq (&whc_seq_treedef, &whc->seq, &n->seq); *p_intv = ddsrt_avl_lookup_pred_eq (&whc_seq_treedef, &whc->seq, &n->seq);
return n; return n;
} }
} }
@ -538,7 +538,7 @@ static void delete_one_sample_from_idx (struct whc_impl *whc, struct whc_node *w
for (i = 0; i < whc->idxdepth; i++) for (i = 0; i < whc->idxdepth; i++)
assert (i == idxn->headidx || idxn->hist[i] == NULL); assert (i == idxn->headidx || idxn->hist[i] == NULL);
#endif #endif
if (!ut_hhRemove (whc->idx_hash, idxn)) if (!ddsrt_hh_remove (whc->idx_hash, idxn))
assert (0); assert (0);
ddsi_tkmap_instance_unref(idxn->tk); ddsi_tkmap_instance_unref(idxn->tk);
ddsrt_free (idxn); ddsrt_free (idxn);
@ -568,7 +568,7 @@ static void free_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_s
static void delete_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_idxnode *idxn) static void delete_one_instance_from_idx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_idxnode *idxn)
{ {
if (!ut_hhRemove (whc->idx_hash, idxn)) if (!ddsrt_hh_remove (whc->idx_hash, idxn))
assert (0); assert (0);
free_one_instance_from_idx (whc, max_drop_seq, idxn); free_one_instance_from_idx (whc, max_drop_seq, idxn);
} }
@ -612,11 +612,11 @@ static unsigned whc_default_downgrade_to_volatile (struct whc *whc_generic, stru
whc->tldepth = 0; whc->tldepth = 0;
if (whc->hdepth == 0) if (whc->hdepth == 0)
{ {
struct ut_hhIter it; struct ddsrt_hh_iter it;
struct whc_idxnode *n; struct whc_idxnode *n;
for (n = ut_hhIterFirst(whc->idx_hash, &it); n != NULL; n = ut_hhIterNext(&it)) for (n = ddsrt_hh_iter_first(whc->idx_hash, &it); n != NULL; n = ddsrt_hh_iter_next(&it))
free_one_instance_from_idx (whc, 0, n); free_one_instance_from_idx (whc, 0, n);
ut_hhFree(whc->idx_hash); ddsrt_hh_free(whc->idx_hash);
whc->idxdepth = 0; whc->idxdepth = 0;
whc->idx_hash = NULL; whc->idx_hash = NULL;
} }
@ -680,9 +680,9 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
if (whcn == intv->last && intv != whc->open_intv) if (whcn == intv->last && intv != whc->open_intv)
{ {
struct whc_intvnode *tmp = intv; struct whc_intvnode *tmp = intv;
*p_intv = ut_avlFindSucc (&whc_seq_treedef, &whc->seq, intv); *p_intv = ddsrt_avl_find_succ (&whc_seq_treedef, &whc->seq, intv);
/* only sample in interval and not the open interval => delete interval */ /* only sample in interval and not the open interval => delete interval */
ut_avlDelete (&whc_seq_treedef, &whc->seq, tmp); ddsrt_avl_delete (&whc_seq_treedef, &whc->seq, tmp);
ddsrt_free (tmp); ddsrt_free (tmp);
} }
else else
@ -703,7 +703,7 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
assert (whcn->prev_seq->seq + 1 == whcn->seq); assert (whcn->prev_seq->seq + 1 == whcn->seq);
intv->last = whcn->prev_seq; intv->last = whcn->prev_seq;
intv->maxp1--; intv->maxp1--;
*p_intv = ut_avlFindSucc (&whc_seq_treedef, &whc->seq, intv); *p_intv = ddsrt_avl_find_succ (&whc_seq_treedef, &whc->seq, intv);
} }
else else
{ {
@ -712,7 +712,7 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
issue only, and so we can (for now) get away with splitting issue only, and so we can (for now) get away with splitting
it greedily */ it greedily */
struct whc_intvnode *new_intv; struct whc_intvnode *new_intv;
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
new_intv = ddsrt_malloc (sizeof (*new_intv)); new_intv = ddsrt_malloc (sizeof (*new_intv));
@ -730,9 +730,9 @@ static void whc_delete_one_intv (struct whc_impl *whc, struct whc_intvnode **p_i
/* insert new node & continue the loop with intv set to the /* insert new node & continue the loop with intv set to the
new interval */ new interval */
if (ut_avlLookupIPath (&whc_seq_treedef, &whc->seq, &new_intv->min, &path) != NULL) if (ddsrt_avl_lookup_ipath (&whc_seq_treedef, &whc->seq, &new_intv->min, &path) != NULL)
assert (0); assert (0);
ut_avlInsertIPath (&whc_seq_treedef, &whc->seq, new_intv, &path); ddsrt_avl_insert_ipath (&whc_seq_treedef, &whc->seq, new_intv, &path);
if (intv == whc->open_intv) if (intv == whc->open_intv)
whc->open_intv = new_intv; whc->open_intv = new_intv;
@ -744,7 +744,7 @@ static void whc_delete_one (struct whc_impl *whc, struct whc_node *whcn)
{ {
struct whc_intvnode *intv; struct whc_intvnode *intv;
struct whc_node *whcn_tmp = whcn; struct whc_node *whcn_tmp = whcn;
intv = ut_avlLookupPredEq (&whc_seq_treedef, &whc->seq, &whcn->seq); intv = ddsrt_avl_lookup_pred_eq (&whc_seq_treedef, &whc->seq, &whcn->seq);
assert (intv != NULL); assert (intv != NULL);
whc_delete_one_intv (whc, &intv, &whcn); whc_delete_one_intv (whc, &intv, &whcn);
if (whcn_tmp->prev_seq) if (whcn_tmp->prev_seq)
@ -804,7 +804,7 @@ static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, s
#ifndef NDEBUG #ifndef NDEBUG
whcn = find_nextseq_intv (&intv, whc, whc->max_drop_seq); whcn = find_nextseq_intv (&intv, whc, whc->max_drop_seq);
assert (whcn == NULL || whcn->prev_seq == NULL); assert (whcn == NULL || whcn->prev_seq == NULL);
assert (ut_avlIsSingleton (&whc->seq)); assert (ddsrt_avl_is_singleton (&whc->seq));
#endif #endif
intv = whc->open_intv; intv = whc->open_intv;
@ -894,7 +894,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
} }
if (whcn == intv->last) if (whcn == intv->last)
intv = ut_avlFindSucc (&whc_seq_treedef, &whc->seq, intv); intv = ddsrt_avl_find_succ (&whc_seq_treedef, &whc->seq, intv);
if (prev_seq) if (prev_seq)
prev_seq->next_seq = whcn; prev_seq->next_seq = whcn;
whcn->prev_seq = prev_seq; whcn->prev_seq = prev_seq;
@ -975,7 +975,7 @@ static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, se
DDS_LOG(DDS_LC_WHC, " del %p %"PRId64, (void *) oldn, oldn->seq); DDS_LOG(DDS_LC_WHC, " del %p %"PRId64, (void *) oldn, oldn->seq);
whc_delete_one (whc, oldn); whc_delete_one (whc, oldn);
#ifndef NDEBUG #ifndef NDEBUG
assert(ut_hhLookup(whc->idx_hash, &template) == idxn); assert(ddsrt_hh_lookup(whc->idx_hash, &template) == idxn);
ddsi_serdata_unref(whcn_template.serdata); ddsi_serdata_unref(whcn_template.serdata);
#endif #endif
} }
@ -1069,14 +1069,14 @@ static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t ma
{ {
/* gap => need new open_intv */ /* gap => need new open_intv */
struct whc_intvnode *intv1; struct whc_intvnode *intv1;
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
intv1 = ddsrt_malloc (sizeof (*intv1)); intv1 = ddsrt_malloc (sizeof (*intv1));
intv1->min = seq; intv1->min = seq;
intv1->maxp1 = seq + 1; intv1->maxp1 = seq + 1;
intv1->first = intv1->last = newn; intv1->first = intv1->last = newn;
if (ut_avlLookupIPath (&whc_seq_treedef, &whc->seq, &seq, &path) != NULL) if (ddsrt_avl_lookup_ipath (&whc_seq_treedef, &whc->seq, &seq, &path) != NULL)
assert (0); assert (0);
ut_avlInsertIPath (&whc_seq_treedef, &whc->seq, intv1, &path); ddsrt_avl_insert_ipath (&whc_seq_treedef, &whc->seq, intv1, &path);
whc->open_intv = intv1; whc->open_intv = intv1;
} }
@ -1128,7 +1128,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
} }
template.idxn.iid = tk->m_iid; template.idxn.iid = tk->m_iid;
if ((idxn = ut_hhLookup (whc->idx_hash, &template)) != NULL) if ((idxn = ddsrt_hh_lookup (whc->idx_hash, &template)) != NULL)
{ {
/* Unregisters cause deleting of index entry, non-unregister of adding/overwriting in history */ /* Unregisters cause deleting of index entry, non-unregister of adding/overwriting in history */
DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn); DDS_LOG(DDS_LC_WHC, " idxn %p", (void *)idxn);
@ -1203,7 +1203,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
idxn->hist[i] = NULL; idxn->hist[i] = NULL;
newn->idxnode = idxn; newn->idxnode = idxn;
newn->idxnode_pos = 0; newn->idxnode_pos = 0;
if (!ut_hhAdd (whc->idx_hash, idxn)) if (!ddsrt_hh_add (whc->idx_hash, idxn))
assert (0); assert (0);
} }
else else

View file

@ -123,14 +123,14 @@ static dds_return_t deliver_locally (struct writer *wr, struct ddsi_serdata *pay
we fall back to using the GUIDs so that we can deliver all we fall back to using the GUIDs so that we can deliver all
samples we received from it. As writer being deleted any samples we received from it. As writer being deleted any
reliable samples that are rejected are simply discarded. */ reliable samples that are rejected are simply discarded. */
ut_avlIter_t it; ddsrt_avl_iter_t it;
struct pwr_rd_match *m; struct pwr_rd_match *m;
struct proxy_writer_info pwr_info; struct proxy_writer_info pwr_info;
dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time); dds_duration_t max_block_ms = nn_from_ddsi_duration (wr->xqos->reliability.max_blocking_time);
ddsrt_mutex_unlock (&wr->rdary.rdary_lock); ddsrt_mutex_unlock (&wr->rdary.rdary_lock);
make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos); make_proxy_writer_info (&pwr_info, &wr->e, wr->xqos);
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
for (m = ut_avlIterFirst (&wr_local_readers_treedef, &wr->local_readers, &it); m != NULL; m = ut_avlIterNext (&it)) for (m = ddsrt_avl_iter_first (&wr_local_readers_treedef, &wr->local_readers, &it); m != NULL; m = ddsrt_avl_iter_next (&it))
{ {
struct reader *rd; struct reader *rd;
if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL) if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL)

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/endian.h" #include "dds/ddsrt/endian.h"
#include "dds/ddsi/q_plist.h" /* for nn_prismtech_writer_info */ #include "dds/ddsi/q_plist.h" /* for nn_prismtech_writer_info */
#include "dds/ddsi/q_freelist.h" #include "dds/ddsi/q_freelist.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.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"

View file

@ -13,7 +13,7 @@
#define DDSI_SERTOPIC_H #define DDSI_SERTOPIC_H
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsc/dds_public_alloc.h" #include "dds/ddsc/dds_public_alloc.h"
struct ddsi_serdata; struct ddsi_serdata;
@ -25,7 +25,7 @@ typedef void (*topic_cb_t) (struct dds_topic * topic);
struct ddsi_sertopic_ops; struct ddsi_sertopic_ops;
struct ddsi_sertopic { struct ddsi_sertopic {
ut_avlNode_t avlnode; /* index on name_typename */ ddsrt_avl_node_t avlnode; /* index on name_typename */
const struct ddsi_sertopic_ops *ops; const struct ddsi_sertopic_ops *ops;
const struct ddsi_serdata_ops *serdata_ops; const struct ddsi_serdata_ops *serdata_ops;
uint32_t serdata_basehash; uint32_t serdata_basehash;

View file

@ -13,7 +13,7 @@
#define NN_ADDRSET_H #define NN_ADDRSET_H
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_protocol.h"
#include "dds/ddsi/q_feature_check.h" #include "dds/ddsi/q_feature_check.h"
@ -23,14 +23,14 @@ extern "C" {
#endif #endif
typedef struct addrset_node { typedef struct addrset_node {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_locator_t loc; nn_locator_t loc;
} * addrset_node_t; } * addrset_node_t;
struct addrset { struct addrset {
ddsrt_mutex_t lock; ddsrt_mutex_t lock;
ddsrt_atomic_uint32_t refc; ddsrt_atomic_uint32_t refc;
ut_avlCTree_t ucaddrs, mcaddrs; ddsrt_avl_ctree_t ucaddrs, mcaddrs;
}; };
typedef void (*addrset_forall_fun_t) (const nn_locator_t *loc, void *arg); typedef void (*addrset_forall_fun_t) (const nn_locator_t *loc, void *arg);

View file

@ -13,7 +13,7 @@
#define Q_ENTITY_H #define Q_ENTITY_H
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_rtps.h" #include "dds/ddsi/q_rtps.h"
#include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_protocol.h"
#include "dds/ddsi/q_lat_estim.h" #include "dds/ddsi/q_lat_estim.h"
@ -54,12 +54,12 @@ status_cb_data_t;
typedef void (*status_cb_t) (void *entity, const status_cb_data_t *data); typedef void (*status_cb_t) (void *entity, const status_cb_data_t *data);
struct prd_wr_match { struct prd_wr_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t wr_guid; nn_guid_t wr_guid;
}; };
struct rd_pwr_match { struct rd_pwr_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t pwr_guid; nn_guid_t pwr_guid;
#ifdef DDSI_INCLUDE_SSM #ifdef DDSI_INCLUDE_SSM
nn_locator_t ssm_mc_loc; nn_locator_t ssm_mc_loc;
@ -68,17 +68,17 @@ struct rd_pwr_match {
}; };
struct wr_rd_match { struct wr_rd_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t rd_guid; nn_guid_t rd_guid;
}; };
struct rd_wr_match { struct rd_wr_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t wr_guid; nn_guid_t wr_guid;
}; };
struct wr_prd_match { struct wr_prd_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t prd_guid; /* guid of the proxy reader */ nn_guid_t prd_guid; /* guid of the proxy reader */
unsigned assumed_in_sync: 1; /* set to 1 upon receipt of ack not nack'ing msgs */ unsigned assumed_in_sync: 1; /* set to 1 upon receipt of ack not nack'ing msgs */
unsigned has_replied_to_hb: 1; /* we must keep sending HBs until all readers have this set */ unsigned has_replied_to_hb: 1; /* we must keep sending HBs until all readers have this set */
@ -105,7 +105,7 @@ enum pwr_rd_match_syncstate {
}; };
struct pwr_rd_match { struct pwr_rd_match {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t rd_guid; nn_guid_t rd_guid;
nn_mtime_t tcreate; nn_mtime_t tcreate;
nn_count_t count; /* most recent acknack sequence number */ nn_count_t count; /* most recent acknack sequence number */
@ -247,8 +247,8 @@ struct writer
nn_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */ nn_etime_t t_rexmit_end; /* time of last 1->0 transition of "retransmitting" */
nn_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */ nn_etime_t t_whc_high_upd; /* time "whc_high" was last updated for controlled ramp-up of throughput */
int num_reliable_readers; /* number of matching reliable PROXY readers */ int num_reliable_readers; /* number of matching reliable PROXY readers */
ut_avlTree_t readers; /* all matching PROXY readers, see struct wr_prd_match */ ddsrt_avl_tree_t readers; /* all matching PROXY readers, see struct wr_prd_match */
ut_avlTree_t local_readers; /* all matching LOCAL readers, see struct wr_rd_match */ ddsrt_avl_tree_t local_readers; /* all matching LOCAL readers, see struct wr_rd_match */
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
uint32_t partition_id; uint32_t partition_id;
#endif #endif
@ -280,8 +280,8 @@ struct reader
struct addrset *as; struct addrset *as;
#endif #endif
const struct ddsi_sertopic * topic; /* topic is NULL for built-in readers */ const struct ddsi_sertopic * topic; /* topic is NULL for built-in readers */
ut_avlTree_t writers; /* all matching PROXY writers, see struct rd_pwr_match */ ddsrt_avl_tree_t writers; /* all matching PROXY writers, see struct rd_pwr_match */
ut_avlTree_t local_writers; /* all matching LOCAL writers, see struct rd_wr_match */ ddsrt_avl_tree_t local_writers; /* all matching LOCAL writers, see struct rd_wr_match */
ddsi2direct_directread_cb_t ddsi2direct_cb; ddsi2direct_directread_cb_t ddsi2direct_cb;
void *ddsi2direct_cbarg; void *ddsi2direct_cbarg;
}; };
@ -299,7 +299,7 @@ struct proxy_participant
struct addrset *as_default; /* default address set to use for user data traffic */ struct addrset *as_default; /* default address set to use for user data traffic */
struct addrset *as_meta; /* default address set to use for discovery traffic */ struct addrset *as_meta; /* default address set to use for discovery traffic */
struct proxy_endpoint_common *endpoints; /* all proxy endpoints can be reached from here */ struct proxy_endpoint_common *endpoints; /* all proxy endpoints can be reached from here */
ut_avlTree_t groups; /* table of all groups (publisher, subscriber), see struct proxy_group */ ddsrt_avl_tree_t groups; /* table of all groups (publisher, subscriber), see struct proxy_group */
unsigned kernel_sequence_numbers : 1; /* whether this proxy participant generates OSPL kernel sequence numbers */ unsigned kernel_sequence_numbers : 1; /* whether this proxy participant generates OSPL kernel sequence numbers */
unsigned implicitly_created : 1; /* participants are implicitly created for Cloud/Fog discovered endpoints */ unsigned implicitly_created : 1; /* participants are implicitly created for Cloud/Fog discovered endpoints */
unsigned is_ddsi2_pp: 1; /* if this is the federation-leader on the remote node */ unsigned is_ddsi2_pp: 1; /* if this is the federation-leader on the remote node */
@ -318,7 +318,7 @@ struct proxy_participant
tables, but "groups" only live in the context of a proxy tables, but "groups" only live in the context of a proxy
participant. */ participant. */
struct proxy_group { struct proxy_group {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t guid; nn_guid_t guid;
char *name; char *name;
struct proxy_participant *proxypp; /* uncounted backref to proxy participant */ struct proxy_participant *proxypp; /* uncounted backref to proxy participant */
@ -340,7 +340,7 @@ struct proxy_endpoint_common
struct proxy_writer { struct proxy_writer {
struct entity_common e; struct entity_common e;
struct proxy_endpoint_common c; struct proxy_endpoint_common c;
ut_avlTree_t readers; /* matching LOCAL readers, see pwr_rd_match */ ddsrt_avl_tree_t readers; /* matching LOCAL readers, see pwr_rd_match */
int n_reliable_readers; /* number of those that are reliable */ int n_reliable_readers; /* number of those that are reliable */
int n_readers_out_of_sync; /* number of those that require special handling (accepting historical data, waiting for historical data set to become complete) */ int n_readers_out_of_sync; /* number of those that require special handling (accepting historical data, waiting for historical data set to become complete) */
seqno_t last_seq; /* highest known seq published by the writer, not last delivered */ seqno_t last_seq; /* highest known seq published by the writer, not last delivered */
@ -373,16 +373,16 @@ struct proxy_reader {
#ifdef DDSI_INCLUDE_SSM #ifdef DDSI_INCLUDE_SSM
unsigned favours_ssm: 1; /* iff 1, this proxy reader favours SSM when available */ unsigned favours_ssm: 1; /* iff 1, this proxy reader favours SSM when available */
#endif #endif
ut_avlTree_t writers; /* matching LOCAL writers */ ddsrt_avl_tree_t writers; /* matching LOCAL writers */
}; };
extern const ut_avlTreedef_t wr_readers_treedef; extern const ddsrt_avl_treedef_t wr_readers_treedef;
extern const ut_avlTreedef_t wr_local_readers_treedef; extern const ddsrt_avl_treedef_t wr_local_readers_treedef;
extern const ut_avlTreedef_t rd_writers_treedef; extern const ddsrt_avl_treedef_t rd_writers_treedef;
extern const ut_avlTreedef_t rd_local_writers_treedef; extern const ddsrt_avl_treedef_t rd_local_writers_treedef;
extern const ut_avlTreedef_t pwr_readers_treedef; extern const ddsrt_avl_treedef_t pwr_readers_treedef;
extern const ut_avlTreedef_t prd_writers_treedef; extern const ddsrt_avl_treedef_t prd_writers_treedef;
extern const ut_avlTreedef_t deleted_participants_treedef; extern const ddsrt_avl_treedef_t deleted_participants_treedef;
#define DPG_LOCAL 1 #define DPG_LOCAL 1
#define DPG_REMOTE 2 #define DPG_REMOTE 2

View file

@ -12,7 +12,7 @@
#ifndef Q_EPHASH_H #ifndef Q_EPHASH_H
#define Q_EPHASH_H #define Q_EPHASH_H
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#if defined (__cplusplus) #if defined (__cplusplus)
extern "C" { extern "C" {
@ -39,7 +39,7 @@ struct nn_guid;
struct ephash_enum struct ephash_enum
{ {
struct ut_chhIter it; struct ddsrt_chh_iter it;
enum entity_kind kind; enum entity_kind kind;
struct entity_common *cur; struct entity_common *cur;
}; };

View file

@ -18,7 +18,7 @@
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/sockets.h" #include "dds/ddsrt/sockets.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_fibheap.h" #include "dds/ddsrt/fibheap.h"
#include "dds/ddsi/q_plist.h" #include "dds/ddsi/q_plist.h"
#include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_protocol.h"
@ -47,7 +47,7 @@ struct lease;
struct ddsi_tran_conn; struct ddsi_tran_conn;
struct ddsi_tran_listener; struct ddsi_tran_listener;
struct ddsi_tran_factory; struct ddsi_tran_factory;
struct ut_thread_pool_s; struct ddsrt_thread_pool_s;
struct debug_monitor; struct debug_monitor;
struct ddsi_tkmap; struct ddsi_tkmap;
@ -110,7 +110,7 @@ struct q_globals {
/* Lease junk */ /* Lease junk */
ddsrt_mutex_t leaseheap_lock; ddsrt_mutex_t leaseheap_lock;
ddsrt_mutex_t lease_locks[N_LEASE_LOCKS]; ddsrt_mutex_t lease_locks[N_LEASE_LOCKS];
ut_fibheap_t leaseheap; ddsrt_fibheap_t leaseheap;
/* Transport factory */ /* Transport factory */
@ -133,7 +133,7 @@ struct q_globals {
/* Thread pool */ /* Thread pool */
struct ut_thread_pool_s * thread_pool; struct ddsrt_thread_pool_s * thread_pool;
/* In many sockets mode, the receive threads maintain a local array /* In many sockets mode, the receive threads maintain a local array
with participant GUIDs and sockets, participant_set_generation is with participant GUIDs and sockets, participant_set_generation is

View file

@ -12,14 +12,14 @@
#ifndef NN_INVERSE_UINT32_SET_H #ifndef NN_INVERSE_UINT32_SET_H
#define NN_INVERSE_UINT32_SET_H #define NN_INVERSE_UINT32_SET_H
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
struct inverse_uint32_set_node { struct inverse_uint32_set_node {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
uint32_t min, max; uint32_t min, max;
}; };
struct inverse_uint32_set { struct inverse_uint32_set {
ut_avlTree_t ids; ddsrt_avl_tree_t ids;
uint32_t cursor; uint32_t cursor;
uint32_t min, max; uint32_t min, max;
}; };

View file

@ -20,10 +20,10 @@
#include "dds/ddsi/ddsi_mcgroup.h" #include "dds/ddsi/ddsi_mcgroup.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
struct nn_group_membership_node { struct nn_group_membership_node {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
ddsi_tran_conn_t conn; ddsi_tran_conn_t conn;
nn_locator_t srcloc; nn_locator_t srcloc;
nn_locator_t mcloc; nn_locator_t mcloc;
@ -32,7 +32,7 @@ struct nn_group_membership_node {
struct nn_group_membership { struct nn_group_membership {
ddsrt_mutex_t lock; ddsrt_mutex_t lock;
ut_avlTree_t mships; ddsrt_avl_tree_t mships;
}; };
static int locator_compare_no_port (const nn_locator_t *as, const nn_locator_t *bs) static int locator_compare_no_port (const nn_locator_t *as, const nn_locator_t *bs)
@ -60,19 +60,19 @@ static int cmp_group_membership (const void *va, const void *vb)
return 0; return 0;
} }
static ut_avlTreedef_t mship_td = UT_AVL_TREEDEF_INITIALIZER(offsetof (struct nn_group_membership_node, avlnode), 0, cmp_group_membership, 0); static ddsrt_avl_treedef_t mship_td = DDSRT_AVL_TREEDEF_INITIALIZER(offsetof (struct nn_group_membership_node, avlnode), 0, cmp_group_membership, 0);
struct nn_group_membership *new_group_membership (void) struct nn_group_membership *new_group_membership (void)
{ {
struct nn_group_membership *mship = ddsrt_malloc (sizeof (*mship)); struct nn_group_membership *mship = ddsrt_malloc (sizeof (*mship));
ddsrt_mutex_init (&mship->lock); ddsrt_mutex_init (&mship->lock);
ut_avlInit (&mship_td, &mship->mships); ddsrt_avl_init (&mship_td, &mship->mships);
return mship; return mship;
} }
void free_group_membership (struct nn_group_membership *mship) void free_group_membership (struct nn_group_membership *mship)
{ {
ut_avlFree (&mship_td, &mship->mships, ddsrt_free); ddsrt_avl_free (&mship_td, &mship->mships, ddsrt_free);
ddsrt_mutex_destroy (&mship->lock); ddsrt_mutex_destroy (&mship->lock);
ddsrt_free (mship); ddsrt_free (mship);
} }
@ -80,7 +80,7 @@ void free_group_membership (struct nn_group_membership *mship)
static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc) static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc)
{ {
struct nn_group_membership_node key, *n; struct nn_group_membership_node key, *n;
ut_avlIPath_t ip; ddsrt_avl_ipath_t ip;
int isnew; int isnew;
key.conn = conn; key.conn = conn;
if (srcloc) if (srcloc)
@ -88,7 +88,7 @@ static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_co
else else
memset (&key.srcloc, 0, sizeof (key.srcloc)); memset (&key.srcloc, 0, sizeof (key.srcloc));
key.mcloc = *mcloc; key.mcloc = *mcloc;
if ((n = ut_avlLookupIPath (&mship_td, &mship->mships, &key, &ip)) != NULL) { if ((n = ddsrt_avl_lookup_ipath (&mship_td, &mship->mships, &key, &ip)) != NULL) {
isnew = 0; isnew = 0;
n->count++; n->count++;
} else { } else {
@ -98,7 +98,7 @@ static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_co
n->srcloc = key.srcloc; n->srcloc = key.srcloc;
n->mcloc = key.mcloc; n->mcloc = key.mcloc;
n->count = 1; n->count = 1;
ut_avlInsertIPath (&mship_td, &mship->mships, n, &ip); ddsrt_avl_insert_ipath (&mship_td, &mship->mships, n, &ip);
} }
return isnew; return isnew;
} }
@ -106,7 +106,7 @@ static int reg_group_membership (struct nn_group_membership *mship, ddsi_tran_co
static int unreg_group_membership (struct nn_group_membership *mship, ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc) static int unreg_group_membership (struct nn_group_membership *mship, ddsi_tran_conn_t conn, const nn_locator_t *srcloc, const nn_locator_t *mcloc)
{ {
struct nn_group_membership_node key, *n; struct nn_group_membership_node key, *n;
ut_avlDPath_t dp; ddsrt_avl_dpath_t dp;
int mustdel; int mustdel;
key.conn = conn; key.conn = conn;
if (srcloc) if (srcloc)
@ -114,7 +114,7 @@ static int unreg_group_membership (struct nn_group_membership *mship, ddsi_tran_
else else
memset (&key.srcloc, 0, sizeof (key.srcloc)); memset (&key.srcloc, 0, sizeof (key.srcloc));
key.mcloc = *mcloc; key.mcloc = *mcloc;
n = ut_avlLookupDPath (&mship_td, &mship->mships, &key, &dp); n = ddsrt_avl_lookup_dpath (&mship_td, &mship->mships, &key, &dp);
assert (n != NULL); assert (n != NULL);
assert (n->count > 0); assert (n->count > 0);
if (--n->count > 0) if (--n->count > 0)
@ -122,7 +122,7 @@ static int unreg_group_membership (struct nn_group_membership *mship, ddsi_tran_
else else
{ {
mustdel = 1; mustdel = 1;
ut_avlDeleteDPath (&mship_td, &mship->mships, n, &dp); ddsrt_avl_delete_dpath (&mship_td, &mship->mships, n, &dp);
ddsrt_free (n); ddsrt_free (n);
} }
return mustdel; return mustdel;
@ -268,13 +268,13 @@ void ddsi_transfer_group_membership (ddsi_tran_conn_t conn, ddsi_tran_conn_t new
are neither 0 nor maximum representable, min and max define the range of key values that relate to are neither 0 nor maximum representable, min and max define the range of key values that relate to
oldsock */ oldsock */
ddsrt_mutex_lock (&gv.mship->lock); ddsrt_mutex_lock (&gv.mship->lock);
n = ut_avlLookupSuccEq (&mship_td, &gv.mship->mships, &min); n = ddsrt_avl_lookup_succ_eq (&mship_td, &gv.mship->mships, &min);
while (n != NULL && cmp_group_membership (n, &max) <= 0) while (n != NULL && cmp_group_membership (n, &max) <= 0)
{ {
struct nn_group_membership_node * const nn = ut_avlFindSucc (&mship_td, &gv.mship->mships, n); struct nn_group_membership_node * const nn = ddsrt_avl_find_succ (&mship_td, &gv.mship->mships, n);
ut_avlDelete (&mship_td, &gv.mship->mships, n); ddsrt_avl_delete (&mship_td, &gv.mship->mships, n);
n->conn = newconn; n->conn = newconn;
ut_avlInsert (&mship_td, &gv.mship->mships, n); ddsrt_avl_insert (&mship_td, &gv.mship->mships, n);
n = nn; n = nn;
} }
ddsrt_mutex_unlock (&gv.mship->lock); ddsrt_mutex_unlock (&gv.mship->lock);
@ -283,13 +283,13 @@ void ddsi_transfer_group_membership (ddsi_tran_conn_t conn, ddsi_tran_conn_t new
int ddsi_rejoin_transferred_mcgroups (ddsi_tran_conn_t conn) int ddsi_rejoin_transferred_mcgroups (ddsi_tran_conn_t conn)
{ {
struct nn_group_membership_node *n, min, max; struct nn_group_membership_node *n, min, max;
ut_avlIter_t it; ddsrt_avl_iter_t it;
int ret = 0; int ret = 0;
memset(&min, 0, sizeof(min)); memset(&min, 0, sizeof(min));
memset(&max, 0xff, sizeof(max)); memset(&max, 0xff, sizeof(max));
min.conn = max.conn = conn; min.conn = max.conn = conn;
ddsrt_mutex_lock (&gv.mship->lock); ddsrt_mutex_lock (&gv.mship->lock);
for (n = ut_avlIterSuccEq (&mship_td, &gv.mship->mships, &it, &min); n != NULL && ret >= 0 && cmp_group_membership(n, &max) <= 0; n = ut_avlIterNext (&it)) for (n = ddsrt_avl_iter_succ_eq (&mship_td, &gv.mship->mships, &it, &min); n != NULL && ret >= 0 && cmp_group_membership(n, &max) <= 0; n = ddsrt_avl_iter_next (&it))
{ {
int have_srcloc = (memcmp(&n->srcloc, &min.srcloc, sizeof(n->srcloc)) != 0); int have_srcloc = (memcmp(&n->srcloc, &min.srcloc, sizeof(n->srcloc)) != 0);
assert (n->conn == conn); assert (n->conn == conn);

View file

@ -20,7 +20,7 @@
#include "dds/ddsi/ddsi_tran.h" #include "dds/ddsi/ddsi_tran.h"
#include "dds/ddsi/ddsi_tcp.h" #include "dds/ddsi/ddsi_tcp.h"
#include "dds/ddsi/ddsi_ipaddr.h" #include "dds/ddsi/ddsi_ipaddr.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_nwif.h" #include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
@ -93,12 +93,12 @@ static int ddsi_tcp_cmp_conn_wrap (const void *a, const void *b)
typedef struct ddsi_tcp_node typedef struct ddsi_tcp_node
{ {
ut_avlNode_t m_avlnode; ddsrt_avl_node_t m_avlnode;
ddsi_tcp_conn_t m_conn; ddsi_tcp_conn_t m_conn;
} }
* ddsi_tcp_node_t; * ddsi_tcp_node_t;
static const ut_avlTreedef_t ddsi_tcp_treedef = UT_AVL_TREEDEF_INITIALIZER_INDKEY static const ddsrt_avl_treedef_t ddsi_tcp_treedef = DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY
( (
offsetof (struct ddsi_tcp_node, m_avlnode), offsetof (struct ddsi_tcp_node, m_avlnode),
offsetof (struct ddsi_tcp_node, m_conn), offsetof (struct ddsi_tcp_node, m_conn),
@ -107,7 +107,7 @@ static const ut_avlTreedef_t ddsi_tcp_treedef = UT_AVL_TREEDEF_INITIALIZER_INDKE
); );
static ddsrt_mutex_t ddsi_tcp_cache_lock_g; static ddsrt_mutex_t ddsi_tcp_cache_lock_g;
static ut_avlTree_t ddsi_tcp_cache_g; static ddsrt_avl_tree_t ddsi_tcp_cache_g;
static struct ddsi_tran_factory ddsi_tcp_factory_g; static struct ddsi_tran_factory ddsi_tcp_factory_g;
static ddsi_tcp_conn_t ddsi_tcp_new_conn (ddsrt_socket_t, bool, struct sockaddr *); static ddsi_tcp_conn_t ddsi_tcp_new_conn (ddsrt_socket_t, bool, struct sockaddr *);
@ -125,11 +125,11 @@ static char *sockaddr_to_string_with_port (char *dst, size_t sizeof_dst, const s
static void ddsi_tcp_cache_dump (void) static void ddsi_tcp_cache_dump (void)
{ {
char buff[64]; char buff[64];
ut_avlIter_t iter; ddsrt_avl_iter_t iter;
ddsi_tcp_node_t n; ddsi_tcp_node_t n;
unsigned i = 0; unsigned i = 0;
n = ut_avlIterFirst (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, &iter); n = ddsrt_avl_iter_first (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, &iter);
while (n) while (n)
{ {
os_sockaddrAddressPortToString ((const os_sockaddr *) &n->m_conn->m_peer_addr, buff, sizeof (buff)); os_sockaddrAddressPortToString ((const os_sockaddr *) &n->m_conn->m_peer_addr, buff, sizeof (buff));
@ -140,7 +140,7 @@ static void ddsi_tcp_cache_dump (void)
ddsi_name, i++, n->m_conn->m_base.m_server ? "server" : "client", ddsi_name, i++, n->m_conn->m_base.m_server ? "server" : "client",
n->m_conn->m_sock, n->m_conn->m_base.m_base.m_port, buff n->m_conn->m_sock, n->m_conn->m_base.m_base.m_port, buff
); );
n = ut_avlIterNext (&iter); n = ddsrt_avl_iter_next (&iter);
} }
} }
*/ */
@ -242,7 +242,7 @@ static void ddsi_tcp_conn_connect (ddsi_tcp_conn_t conn, const ddsrt_msghdr_t *
} }
} }
static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path) static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ddsrt_avl_ipath_t * path)
{ {
const char * action = "added"; const char * action = "added";
ddsi_tcp_node_t node; ddsi_tcp_node_t node;
@ -255,11 +255,11 @@ static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path)
{ {
node = ddsrt_malloc (sizeof (*node)); node = ddsrt_malloc (sizeof (*node));
node->m_conn = conn; node->m_conn = conn;
ut_avlInsertIPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, path); ddsrt_avl_insert_ipath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, path);
} }
else else
{ {
node = ut_avlLookup (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, conn); node = ddsrt_avl_lookup (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, conn);
if (node) if (node)
{ {
/* Replace connection in cache */ /* Replace connection in cache */
@ -272,7 +272,7 @@ static void ddsi_tcp_cache_add (ddsi_tcp_conn_t conn, ut_avlIPath_t * path)
{ {
node = ddsrt_malloc (sizeof (*node)); node = ddsrt_malloc (sizeof (*node));
node->m_conn = conn; node->m_conn = conn;
ut_avlInsert (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node); ddsrt_avl_insert (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node);
} }
} }
@ -284,15 +284,15 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
{ {
char buff[DDSI_LOCSTRLEN]; char buff[DDSI_LOCSTRLEN];
ddsi_tcp_node_t node; ddsi_tcp_node_t node;
ut_avlDPath_t path; ddsrt_avl_dpath_t path;
ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g); ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g);
node = ut_avlLookupDPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, conn, &path); node = ddsrt_avl_lookup_dpath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, conn, &path);
if (node) if (node)
{ {
sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr); sockaddr_to_string_with_port(buff, sizeof(buff), (struct sockaddr *)&conn->m_peer_addr);
DDS_LOG(DDS_LC_TCP, "%s cache removed socket %"PRIdSOCK" to %s\n", ddsi_name, conn->m_sock, buff); DDS_LOG(DDS_LC_TCP, "%s cache removed socket %"PRIdSOCK" to %s\n", ddsi_name, conn->m_sock, buff);
ut_avlDeleteDPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, &path); ddsrt_avl_delete_dpath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node, &path);
ddsi_tcp_node_free (node); ddsi_tcp_node_free (node);
} }
ddsrt_mutex_unlock (&ddsi_tcp_cache_lock_g); ddsrt_mutex_unlock (&ddsi_tcp_cache_lock_g);
@ -305,7 +305,7 @@ static void ddsi_tcp_cache_remove (ddsi_tcp_conn_t conn)
static ddsi_tcp_conn_t ddsi_tcp_cache_find (const ddsrt_msghdr_t * msg) static ddsi_tcp_conn_t ddsi_tcp_cache_find (const ddsrt_msghdr_t * msg)
{ {
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
ddsi_tcp_node_t node; ddsi_tcp_node_t node;
struct ddsi_tcp_conn key; struct ddsi_tcp_conn key;
ddsi_tcp_conn_t ret = NULL; ddsi_tcp_conn_t ret = NULL;
@ -317,12 +317,12 @@ static ddsi_tcp_conn_t ddsi_tcp_cache_find (const ddsrt_msghdr_t * msg)
/* Check cache for existing connection to target */ /* Check cache for existing connection to target */
ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g); ddsrt_mutex_lock (&ddsi_tcp_cache_lock_g);
node = ut_avlLookupIPath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, &key, &path); node = ddsrt_avl_lookup_ipath (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, &key, &path);
if (node) if (node)
{ {
if (node->m_conn->m_base.m_closed) if (node->m_conn->m_base.m_closed)
{ {
ut_avlDelete (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node); ddsrt_avl_delete (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, node);
ddsi_tcp_node_free (node); ddsi_tcp_node_free (node);
} }
else else
@ -1010,7 +1010,7 @@ static void ddsi_tcp_release_listener (ddsi_tran_listener_t listener)
static void ddsi_tcp_release_factory (void) static void ddsi_tcp_release_factory (void)
{ {
if (ddsrt_atomic_dec32_nv (&ddsi_tcp_init_g) == 0) { if (ddsrt_atomic_dec32_nv (&ddsi_tcp_init_g) == 0) {
ut_avlFree (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, ddsi_tcp_node_free); ddsrt_avl_free (&ddsi_tcp_treedef, &ddsi_tcp_cache_g, ddsi_tcp_node_free);
ddsrt_mutex_destroy (&ddsi_tcp_cache_lock_g); ddsrt_mutex_destroy (&ddsi_tcp_cache_lock_g);
#ifdef DDSI_INCLUDE_SSL #ifdef DDSI_INCLUDE_SSL
if (ddsi_tcp_ssl_plugin.fini) if (ddsi_tcp_ssl_plugin.fini)
@ -1095,7 +1095,7 @@ int ddsi_tcp_init (void)
} }
#endif #endif
ut_avlInit (&ddsi_tcp_treedef, &ddsi_tcp_cache_g); ddsrt_avl_init (&ddsi_tcp_treedef, &ddsi_tcp_cache_g);
ddsrt_mutex_init (&ddsi_tcp_cache_lock_g); ddsrt_mutex_init (&ddsi_tcp_cache_lock_g);
DDS_LOG(DDS_LC_CONFIG, "%s initialized\n", ddsi_name); DDS_LOG(DDS_LC_CONFIG, "%s initialized\n", ddsi_name);

View file

@ -22,7 +22,7 @@
#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/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#include "dds__stream.h" #include "dds__stream.h"
#include "dds/ddsi/ddsi_serdata.h" #include "dds/ddsi/ddsi_serdata.h"
@ -31,7 +31,7 @@
struct ddsi_tkmap struct ddsi_tkmap
{ {
struct ut_chh * m_hh; struct ddsrt_chh * m_hh;
ddsrt_mutex_t m_lock; ddsrt_mutex_t m_lock;
ddsrt_cond_t m_cond; ddsrt_cond_t m_cond;
}; };
@ -87,7 +87,7 @@ static int dds_tk_equals_void (const void *a, const void *b)
struct ddsi_tkmap *ddsi_tkmap_new (void) struct ddsi_tkmap *ddsi_tkmap_new (void)
{ {
struct ddsi_tkmap *tkmap = dds_alloc (sizeof (*tkmap)); struct ddsi_tkmap *tkmap = dds_alloc (sizeof (*tkmap));
tkmap->m_hh = ut_chhNew (1, dds_tk_hash_void, dds_tk_equals_void, gc_buckets); tkmap->m_hh = ddsrt_chh_new (1, dds_tk_hash_void, dds_tk_equals_void, gc_buckets);
ddsrt_mutex_init (&tkmap->m_lock); ddsrt_mutex_init (&tkmap->m_lock);
ddsrt_cond_init (&tkmap->m_cond); ddsrt_cond_init (&tkmap->m_cond);
return tkmap; return tkmap;
@ -102,8 +102,8 @@ static void free_tkmap_instance (void *vtk, UNUSED_ARG(void *f_arg))
void ddsi_tkmap_free (struct ddsi_tkmap * map) void ddsi_tkmap_free (struct ddsi_tkmap * map)
{ {
ut_chhEnumUnsafe (map->m_hh, free_tkmap_instance, NULL); ddsrt_chh_enum_unsafe (map->m_hh, free_tkmap_instance, NULL);
ut_chhFree (map->m_hh); ddsrt_chh_free (map->m_hh);
ddsrt_cond_destroy (&map->m_cond); ddsrt_cond_destroy (&map->m_cond);
ddsrt_mutex_destroy (&map->m_lock); ddsrt_mutex_destroy (&map->m_lock);
dds_free (map); dds_free (map);
@ -115,18 +115,18 @@ uint64_t ddsi_tkmap_lookup (struct ddsi_tkmap * map, const struct ddsi_serdata *
struct ddsi_tkmap_instance * tk; struct ddsi_tkmap_instance * tk;
assert (thread_is_awake ()); assert (thread_is_awake ());
dummy.m_sample = (struct ddsi_serdata *) sd; dummy.m_sample = (struct ddsi_serdata *) sd;
tk = ut_chhLookup (map->m_hh, &dummy); tk = ddsrt_chh_lookup (map->m_hh, &dummy);
return (tk) ? tk->m_iid : DDS_HANDLE_NIL; return (tk) ? tk->m_iid : DDS_HANDLE_NIL;
} }
struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (struct ddsi_tkmap *map, uint64_t iid) struct ddsi_tkmap_instance *ddsi_tkmap_find_by_id (struct ddsi_tkmap *map, uint64_t iid)
{ {
/* This is not a function that should be used liberally, as it linearly scans the key-to-iid map. */ /* This is not a function that should be used liberally, as it linearly scans the key-to-iid map. */
struct ut_chhIter it; struct ddsrt_chh_iter it;
struct ddsi_tkmap_instance *tk; struct ddsi_tkmap_instance *tk;
uint32_t refc; uint32_t refc;
assert (thread_is_awake ()); assert (thread_is_awake ());
for (tk = ut_chhIterFirst (map->m_hh, &it); tk; tk = ut_chhIterNext (&it)) for (tk = ddsrt_chh_iter_first (map->m_hh, &it); tk; tk = ddsrt_chh_iter_next (&it))
if (tk->m_iid == iid) if (tk->m_iid == iid)
break; break;
if (tk == NULL) if (tk == NULL)
@ -165,7 +165,7 @@ ddsi_tkmap_find(
assert (thread_is_awake ()); assert (thread_is_awake ());
dummy.m_sample = sd; dummy.m_sample = sd;
retry: retry:
if ((tk = ut_chhLookup(map->m_hh, &dummy)) != NULL) if ((tk = ddsrt_chh_lookup(map->m_hh, &dummy)) != NULL)
{ {
uint32_t new; uint32_t new;
new = ddsrt_atomic_inc32_nv(&tk->m_refc); new = ddsrt_atomic_inc32_nv(&tk->m_refc);
@ -178,7 +178,7 @@ retry:
we can block until someone signals some entry is removed from the map if we take we can block until someone signals some entry is removed from the map if we take
some lock & wait for some condition */ some lock & wait for some condition */
ddsrt_mutex_lock(&map->m_lock); ddsrt_mutex_lock(&map->m_lock);
while ((tk = ut_chhLookup(map->m_hh, &dummy)) != NULL && (ddsrt_atomic_ld32(&tk->m_refc) & REFC_DELETE)) while ((tk = ddsrt_chh_lookup(map->m_hh, &dummy)) != NULL && (ddsrt_atomic_ld32(&tk->m_refc) & REFC_DELETE))
ddsrt_cond_wait(&map->m_cond, &map->m_lock); ddsrt_cond_wait(&map->m_cond, &map->m_lock);
ddsrt_mutex_unlock(&map->m_lock); ddsrt_mutex_unlock(&map->m_lock);
goto retry; goto retry;
@ -192,7 +192,7 @@ retry:
tk->m_sample = ddsi_serdata_to_topicless (sd); tk->m_sample = ddsi_serdata_to_topicless (sd);
ddsrt_atomic_st32 (&tk->m_refc, 1); ddsrt_atomic_st32 (&tk->m_refc, 1);
tk->m_iid = ddsi_iid_gen (); tk->m_iid = ddsi_iid_gen ();
if (!ut_chhAdd (map->m_hh, tk)) if (!ddsrt_chh_add (map->m_hh, tk))
{ {
/* Lost a race from another thread, retry */ /* Lost a race from another thread, retry */
ddsi_serdata_unref (tk->m_sample); ddsi_serdata_unref (tk->m_sample);
@ -237,7 +237,7 @@ void ddsi_tkmap_instance_unref (struct ddsi_tkmap_instance * tk)
struct ddsi_tkmap *map = gv.m_tkmap; struct ddsi_tkmap *map = gv.m_tkmap;
/* Remove from hash table */ /* Remove from hash table */
int removed = ut_chhRemove(map->m_hh, tk); int removed = ddsrt_chh_remove(map->m_hh, tk);
assert (removed); assert (removed);
(void)removed; (void)removed;

View file

@ -17,7 +17,7 @@
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_misc.h" #include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
@ -39,8 +39,8 @@
static int compare_locators_vwrap (const void *va, const void *vb); static int compare_locators_vwrap (const void *va, const void *vb);
static const ut_avlCTreedef_t addrset_treedef = static const ddsrt_avl_ctreedef_t addrset_treedef =
UT_AVL_CTREEDEF_INITIALIZER (offsetof (struct addrset_node, avlnode), offsetof (struct addrset_node, loc), compare_locators_vwrap, 0); DDSRT_AVL_CTREEDEF_INITIALIZER (offsetof (struct addrset_node, avlnode), offsetof (struct addrset_node, loc), compare_locators_vwrap, 0);
static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int port_mode, const char *msgtag, int req_mc, int mcgen_base, int mcgen_count, int mcgen_idx) static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int port_mode, const char *msgtag, int req_mc, int mcgen_base, int mcgen_count, int mcgen_idx)
{ {
@ -203,8 +203,8 @@ struct addrset *new_addrset (void)
struct addrset *as = ddsrt_malloc (sizeof (*as)); struct addrset *as = ddsrt_malloc (sizeof (*as));
ddsrt_atomic_st32 (&as->refc, 1); ddsrt_atomic_st32 (&as->refc, 1);
ddsrt_mutex_init (&as->lock); ddsrt_mutex_init (&as->lock);
ut_avlCInit (&addrset_treedef, &as->ucaddrs); ddsrt_avl_cinit (&addrset_treedef, &as->ucaddrs);
ut_avlCInit (&addrset_treedef, &as->mcaddrs); ddsrt_avl_cinit (&addrset_treedef, &as->mcaddrs);
return as; return as;
} }
@ -221,8 +221,8 @@ void unref_addrset (struct addrset *as)
{ {
if ((as != NULL) && (ddsrt_atomic_dec32_ov (&as->refc) == 1)) if ((as != NULL) && (ddsrt_atomic_dec32_ov (&as->refc) == 1))
{ {
ut_avlCFree (&addrset_treedef, &as->ucaddrs, ddsrt_free); ddsrt_avl_cfree (&addrset_treedef, &as->ucaddrs, ddsrt_free);
ut_avlCFree (&addrset_treedef, &as->mcaddrs, ddsrt_free); ddsrt_avl_cfree (&addrset_treedef, &as->mcaddrs, ddsrt_free);
ddsrt_mutex_destroy (&as->lock); ddsrt_mutex_destroy (&as->lock);
ddsrt_free (as); ddsrt_free (as);
} }
@ -247,9 +247,9 @@ int is_unspec_locator (const nn_locator_t *loc)
int addrset_contains_ssm (const struct addrset *as) int addrset_contains_ssm (const struct addrset *as)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (as); LOCK (as);
for (n = ut_avlCIterFirst (&addrset_treedef, &as->mcaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &as->mcaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
{ {
if (ddsi_is_ssm_mcaddr (&n->loc)) if (ddsi_is_ssm_mcaddr (&n->loc))
{ {
@ -264,9 +264,9 @@ int addrset_contains_ssm (const struct addrset *as)
int addrset_any_ssm (const struct addrset *as, nn_locator_t *dst) int addrset_any_ssm (const struct addrset *as, nn_locator_t *dst)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (as); LOCK (as);
for (n = ut_avlCIterFirst (&addrset_treedef, &as->mcaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &as->mcaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
{ {
if (ddsi_is_ssm_mcaddr (&n->loc)) if (ddsi_is_ssm_mcaddr (&n->loc))
{ {
@ -282,9 +282,9 @@ int addrset_any_ssm (const struct addrset *as, nn_locator_t *dst)
int addrset_any_non_ssm_mc (const struct addrset *as, nn_locator_t *dst) int addrset_any_non_ssm_mc (const struct addrset *as, nn_locator_t *dst)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (as); LOCK (as);
for (n = ut_avlCIterFirst (&addrset_treedef, &as->mcaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &as->mcaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
{ {
if (!ddsi_is_ssm_mcaddr (&n->loc)) if (!ddsi_is_ssm_mcaddr (&n->loc))
{ {
@ -301,8 +301,8 @@ int addrset_any_non_ssm_mc (const struct addrset *as, nn_locator_t *dst)
int addrset_purge (struct addrset *as) int addrset_purge (struct addrset *as)
{ {
LOCK (as); LOCK (as);
ut_avlCFree (&addrset_treedef, &as->ucaddrs, ddsrt_free); ddsrt_avl_cfree (&addrset_treedef, &as->ucaddrs, ddsrt_free);
ut_avlCFree (&addrset_treedef, &as->mcaddrs, ddsrt_free); ddsrt_avl_cfree (&addrset_treedef, &as->mcaddrs, ddsrt_free);
UNLOCK (as); UNLOCK (as);
return 0; return 0;
} }
@ -311,14 +311,14 @@ void add_to_addrset (struct addrset *as, const nn_locator_t *loc)
{ {
if (!is_unspec_locator (loc)) if (!is_unspec_locator (loc))
{ {
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
ut_avlCTree_t *tree = ddsi_is_mcaddr (loc) ? &as->mcaddrs : &as->ucaddrs; ddsrt_avl_ctree_t *tree = ddsi_is_mcaddr (loc) ? &as->mcaddrs : &as->ucaddrs;
LOCK (as); LOCK (as);
if (ut_avlCLookupIPath (&addrset_treedef, tree, loc, &path) == NULL) if (ddsrt_avl_clookup_ipath (&addrset_treedef, tree, loc, &path) == NULL)
{ {
struct addrset_node *n = ddsrt_malloc (sizeof (*n)); struct addrset_node *n = ddsrt_malloc (sizeof (*n));
n->loc = *loc; n->loc = *loc;
ut_avlCInsertIPath (&addrset_treedef, tree, n, &path); ddsrt_avl_cinsert_ipath (&addrset_treedef, tree, n, &path);
} }
UNLOCK (as); UNLOCK (as);
} }
@ -326,13 +326,13 @@ void add_to_addrset (struct addrset *as, const nn_locator_t *loc)
void remove_from_addrset (struct addrset *as, const nn_locator_t *loc) void remove_from_addrset (struct addrset *as, const nn_locator_t *loc)
{ {
ut_avlDPath_t path; ddsrt_avl_dpath_t path;
ut_avlCTree_t *tree = ddsi_is_mcaddr (loc) ? &as->mcaddrs : &as->ucaddrs; ddsrt_avl_ctree_t *tree = ddsi_is_mcaddr (loc) ? &as->mcaddrs : &as->ucaddrs;
struct addrset_node *n; struct addrset_node *n;
LOCK (as); LOCK (as);
if ((n = ut_avlCLookupDPath (&addrset_treedef, tree, loc, &path)) != NULL) if ((n = ddsrt_avl_clookup_dpath (&addrset_treedef, tree, loc, &path)) != NULL)
{ {
ut_avlCDeleteDPath (&addrset_treedef, tree, n, &path); ddsrt_avl_cdelete_dpath (&addrset_treedef, tree, n, &path);
ddsrt_free (n); ddsrt_free (n);
} }
UNLOCK (as); UNLOCK (as);
@ -341,9 +341,9 @@ void remove_from_addrset (struct addrset *as, const nn_locator_t *loc)
void copy_addrset_into_addrset_uc (struct addrset *as, const struct addrset *asadd) void copy_addrset_into_addrset_uc (struct addrset *as, const struct addrset *asadd)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (asadd); LOCK (asadd);
for (n = ut_avlCIterFirst (&addrset_treedef, &asadd->ucaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &asadd->ucaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
add_to_addrset (as, &n->loc); add_to_addrset (as, &n->loc);
UNLOCK (asadd); UNLOCK (asadd);
} }
@ -351,9 +351,9 @@ void copy_addrset_into_addrset_uc (struct addrset *as, const struct addrset *asa
void copy_addrset_into_addrset_mc (struct addrset *as, const struct addrset *asadd) void copy_addrset_into_addrset_mc (struct addrset *as, const struct addrset *asadd)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (asadd); LOCK (asadd);
for (n = ut_avlCIterFirst (&addrset_treedef, &asadd->mcaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &asadd->mcaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
add_to_addrset (as, &n->loc); add_to_addrset (as, &n->loc);
UNLOCK (asadd); UNLOCK (asadd);
} }
@ -368,9 +368,9 @@ void copy_addrset_into_addrset (struct addrset *as, const struct addrset *asadd)
void copy_addrset_into_addrset_no_ssm_mc (struct addrset *as, const struct addrset *asadd) void copy_addrset_into_addrset_no_ssm_mc (struct addrset *as, const struct addrset *asadd)
{ {
struct addrset_node *n; struct addrset_node *n;
ut_avlCIter_t it; ddsrt_avl_citer_t it;
LOCK (asadd); LOCK (asadd);
for (n = ut_avlCIterFirst (&addrset_treedef, &asadd->mcaddrs, &it); n; n = ut_avlCIterNext (&it)) for (n = ddsrt_avl_citer_first (&addrset_treedef, &asadd->mcaddrs, &it); n; n = ddsrt_avl_citer_next (&it))
{ {
if (!ddsi_is_ssm_mcaddr (&n->loc)) if (!ddsi_is_ssm_mcaddr (&n->loc))
add_to_addrset (as, &n->loc); add_to_addrset (as, &n->loc);
@ -389,14 +389,14 @@ void addrset_purge_ssm (struct addrset *as)
{ {
struct addrset_node *n; struct addrset_node *n;
LOCK (as); LOCK (as);
n = ut_avlCFindMin (&addrset_treedef, &as->mcaddrs); n = ddsrt_avl_cfind_min (&addrset_treedef, &as->mcaddrs);
while (n) while (n)
{ {
struct addrset_node *n1 = n; struct addrset_node *n1 = n;
n = ut_avlCFindSucc (&addrset_treedef, &as->mcaddrs, n); n = ddsrt_avl_cfind_succ (&addrset_treedef, &as->mcaddrs, n);
if (ddsi_is_ssm_mcaddr (&n1->loc)) if (ddsi_is_ssm_mcaddr (&n1->loc))
{ {
ut_avlCDelete (&addrset_treedef, &as->mcaddrs, n1); ddsrt_avl_cdelete (&addrset_treedef, &as->mcaddrs, n1);
ddsrt_free (n1); ddsrt_free (n1);
} }
} }
@ -412,7 +412,7 @@ size_t addrset_count (const struct addrset *as)
{ {
size_t count; size_t count;
LOCK (as); LOCK (as);
count = ut_avlCCount (&as->ucaddrs) + ut_avlCCount (&as->mcaddrs); count = ddsrt_avl_ccount (&as->ucaddrs) + ddsrt_avl_ccount (&as->mcaddrs);
UNLOCK (as); UNLOCK (as);
return count; return count;
} }
@ -426,7 +426,7 @@ size_t addrset_count_uc (const struct addrset *as)
{ {
size_t count; size_t count;
LOCK (as); LOCK (as);
count = ut_avlCCount (&as->ucaddrs); count = ddsrt_avl_ccount (&as->ucaddrs);
UNLOCK (as); UNLOCK (as);
return count; return count;
} }
@ -440,7 +440,7 @@ size_t addrset_count_mc (const struct addrset *as)
{ {
size_t count; size_t count;
LOCK (as); LOCK (as);
count = ut_avlCCount (&as->mcaddrs); count = ddsrt_avl_ccount (&as->mcaddrs);
UNLOCK (as); UNLOCK (as);
return count; return count;
} }
@ -450,7 +450,7 @@ int addrset_empty_uc (const struct addrset *as)
{ {
int isempty; int isempty;
LOCK (as); LOCK (as);
isempty = ut_avlCIsEmpty (&as->ucaddrs); isempty = ddsrt_avl_cis_empty (&as->ucaddrs);
UNLOCK (as); UNLOCK (as);
return isempty; return isempty;
} }
@ -459,7 +459,7 @@ int addrset_empty_mc (const struct addrset *as)
{ {
int isempty; int isempty;
LOCK (as); LOCK (as);
isempty = ut_avlCIsEmpty (&as->mcaddrs); isempty = ddsrt_avl_cis_empty (&as->mcaddrs);
UNLOCK (as); UNLOCK (as);
return isempty; return isempty;
} }
@ -468,7 +468,7 @@ int addrset_empty (const struct addrset *as)
{ {
int isempty; int isempty;
LOCK (as); LOCK (as);
isempty = ut_avlCIsEmpty (&as->ucaddrs) && ut_avlCIsEmpty (&as->mcaddrs); isempty = ddsrt_avl_cis_empty (&as->ucaddrs) && ddsrt_avl_cis_empty (&as->mcaddrs);
UNLOCK (as); UNLOCK (as);
return isempty; return isempty;
} }
@ -476,14 +476,14 @@ int addrset_empty (const struct addrset *as)
int addrset_any_uc (const struct addrset *as, nn_locator_t *dst) int addrset_any_uc (const struct addrset *as, nn_locator_t *dst)
{ {
LOCK (as); LOCK (as);
if (ut_avlCIsEmpty (&as->ucaddrs)) if (ddsrt_avl_cis_empty (&as->ucaddrs))
{ {
UNLOCK (as); UNLOCK (as);
return 0; return 0;
} }
else else
{ {
const struct addrset_node *n = ut_avlCRootNonEmpty (&addrset_treedef, &as->ucaddrs); const struct addrset_node *n = ddsrt_avl_croot_non_empty (&addrset_treedef, &as->ucaddrs);
*dst = n->loc; *dst = n->loc;
UNLOCK (as); UNLOCK (as);
return 1; return 1;
@ -493,14 +493,14 @@ int addrset_any_uc (const struct addrset *as, nn_locator_t *dst)
int addrset_any_mc (const struct addrset *as, nn_locator_t *dst) int addrset_any_mc (const struct addrset *as, nn_locator_t *dst)
{ {
LOCK (as); LOCK (as);
if (ut_avlCIsEmpty (&as->mcaddrs)) if (ddsrt_avl_cis_empty (&as->mcaddrs))
{ {
UNLOCK (as); UNLOCK (as);
return 0; return 0;
} }
else else
{ {
const struct addrset_node *n = ut_avlCRootNonEmpty (&addrset_treedef, &as->mcaddrs); const struct addrset_node *n = ddsrt_avl_croot_non_empty (&addrset_treedef, &as->mcaddrs);
*dst = n->loc; *dst = n->loc;
UNLOCK (as); UNLOCK (as);
return 1; return 1;
@ -527,9 +527,9 @@ size_t addrset_forall_count (struct addrset *as, addrset_forall_fun_t f, void *a
arg1.f = f; arg1.f = f;
arg1.arg = arg; arg1.arg = arg;
LOCK (as); LOCK (as);
ut_avlCWalk (&addrset_treedef, &as->mcaddrs, addrset_forall_helper, &arg1); ddsrt_avl_cwalk (&addrset_treedef, &as->mcaddrs, addrset_forall_helper, &arg1);
ut_avlCWalk (&addrset_treedef, &as->ucaddrs, addrset_forall_helper, &arg1); ddsrt_avl_cwalk (&addrset_treedef, &as->ucaddrs, addrset_forall_helper, &arg1);
count = ut_avlCCount (&as->ucaddrs) + ut_avlCCount (&as->mcaddrs); count = ddsrt_avl_ccount (&as->ucaddrs) + ddsrt_avl_ccount (&as->mcaddrs);
UNLOCK (as); UNLOCK (as);
return count; return count;
} }
@ -543,22 +543,22 @@ int addrset_forone (struct addrset *as, addrset_forone_fun_t f, void *arg)
{ {
unsigned i; unsigned i;
addrset_node_t n; addrset_node_t n;
ut_avlCTree_t *trees[2]; ddsrt_avl_ctree_t *trees[2];
ut_avlCIter_t iter; ddsrt_avl_citer_t iter;
trees[0] = &as->mcaddrs; trees[0] = &as->mcaddrs;
trees[1] = &as->ucaddrs; trees[1] = &as->ucaddrs;
for (i = 0; i < 2u; i++) for (i = 0; i < 2u; i++)
{ {
n = (addrset_node_t) ut_avlCIterFirst (&addrset_treedef, trees[i], &iter); n = (addrset_node_t) ddsrt_avl_citer_first (&addrset_treedef, trees[i], &iter);
while (n) while (n)
{ {
if ((f) (&n->loc, arg) > 0) if ((f) (&n->loc, arg) > 0)
{ {
return 0; return 0;
} }
n = (addrset_node_t) ut_avlCIterNext (&iter); n = (addrset_node_t) ddsrt_avl_citer_next (&iter);
} }
} }
return -1; return -1;
@ -588,14 +588,14 @@ void nn_log_addrset (uint32_t tf, const char *prefix, const struct addrset *as)
} }
} }
static int addrset_eq_onesidederr1 (const ut_avlCTree_t *at, const ut_avlCTree_t *bt) static int addrset_eq_onesidederr1 (const ddsrt_avl_ctree_t *at, const ddsrt_avl_ctree_t *bt)
{ {
/* Just checking the root */ /* Just checking the root */
if (ut_avlCIsEmpty (at) && ut_avlCIsEmpty (bt)) { if (ddsrt_avl_cis_empty (at) && ddsrt_avl_cis_empty (bt)) {
return 1; return 1;
} else if (ut_avlCIsSingleton (at) && ut_avlCIsSingleton (bt)) { } else if (ddsrt_avl_cis_singleton (at) && ddsrt_avl_cis_singleton (bt)) {
const struct addrset_node *a = ut_avlCRootNonEmpty (&addrset_treedef, at); const struct addrset_node *a = ddsrt_avl_croot_non_empty (&addrset_treedef, at);
const struct addrset_node *b = ut_avlCRootNonEmpty (&addrset_treedef, bt); const struct addrset_node *b = ddsrt_avl_croot_non_empty (&addrset_treedef, bt);
return compare_locators (&a->loc, &b->loc) == 0; return compare_locators (&a->loc, &b->loc) == 0;
} else { } else {
return 0; return 0;

View file

@ -24,15 +24,15 @@
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_unused.h" #include "dds/ddsi/q_unused.h"
#include "dds/ddsi/q_misc.h" #include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_addrset.h" #include "dds/ddsi/q_addrset.h"
#include "dds/ddsi/q_nwif.h" #include "dds/ddsi/q_nwif.h"
#include "dds/ddsi/q_error.h" #include "dds/ddsi/q_error.h"
#include "dds/util/ut_xmlparser.h" #include "dds/ddsrt/xmlparser.h"
#include "dds/util/ut_expand_envvars.h" #include "dds/ddsrt/expand_envvars.h"
#include "dds/version.h" #include "dds/version.h"
@ -77,7 +77,7 @@ struct cfgst_nodekey {
}; };
struct cfgst_node { struct cfgst_node {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
struct cfgst_nodekey key; struct cfgst_nodekey key;
int count; int count;
int failed; int failed;
@ -85,7 +85,7 @@ struct cfgst_node {
}; };
struct cfgst { struct cfgst {
ut_avlTree_t found; ddsrt_avl_tree_t found;
struct config *cfg; struct config *cfg;
/* error flag set so that we can continue parsing for some errors and still fail properly */ /* error flag set so that we can continue parsing for some errors and still fail properly */
int error; int error;
@ -119,8 +119,8 @@ the configuration, so we update this variable instead. */
static uint32_t enabled_logcats; static uint32_t enabled_logcats;
static int cfgst_node_cmp(const void *va, const void *vb); static int cfgst_node_cmp(const void *va, const void *vb);
static const ut_avlTreedef_t cfgst_found_treedef = static const ddsrt_avl_treedef_t cfgst_found_treedef =
UT_AVL_TREEDEF_INITIALIZER(offsetof(struct cfgst_node, avlnode), offsetof(struct cfgst_node, key), cfgst_node_cmp, 0); DDSRT_AVL_TREEDEF_INITIALIZER(offsetof(struct cfgst_node, avlnode), offsetof(struct cfgst_node, key), cfgst_node_cmp, 0);
#define DU(fname) static int uf_##fname (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value) #define DU(fname) static int uf_##fname (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value)
#define PF(fname) static void pf_##fname (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default) #define PF(fname) static void pf_##fname (struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
@ -2067,10 +2067,10 @@ static int do_update(struct cfgst *cfgst, update_fun_t upd, void *parent, struct
{ {
struct cfgst_node *n; struct cfgst_node *n;
struct cfgst_nodekey key; struct cfgst_nodekey key;
ut_avlIPath_t np; ddsrt_avl_ipath_t np;
int ok; int ok;
key.e = cfgelem; key.e = cfgelem;
if ( (n = ut_avlLookupIPath(&cfgst_found_treedef, &cfgst->found, &key, &np)) == NULL ) { if ( (n = ddsrt_avl_lookup_ipath(&cfgst_found_treedef, &cfgst->found, &key, &np)) == NULL ) {
if ( (n = ddsrt_malloc(sizeof(*n))) == NULL ) if ( (n = ddsrt_malloc(sizeof(*n))) == NULL )
return cfg_error(cfgst, "out of memory"); return cfg_error(cfgst, "out of memory");
@ -2078,7 +2078,7 @@ static int do_update(struct cfgst *cfgst, update_fun_t upd, void *parent, struct
n->count = 0; n->count = 0;
n->failed = 0; n->failed = 0;
n->is_default = is_default; n->is_default = is_default;
ut_avlInsertIPath(&cfgst_found_treedef, &cfgst->found, n, &np); ddsrt_avl_insert_ipath(&cfgst_found_treedef, &cfgst->found, n, &np);
} }
if ( cfgelem->multiplicity == 0 || n->count < cfgelem->multiplicity ) if ( cfgelem->multiplicity == 0 || n->count < cfgelem->multiplicity )
ok = upd(cfgst, parent, cfgelem, (n->count == n->failed), value); ok = upd(cfgst, parent, cfgelem, (n->count == n->failed), value);
@ -2108,7 +2108,7 @@ static int set_defaults(struct cfgst *cfgst, void *parent, int isattr, struct cf
key.e = ce; key.e = ce;
cfgst_push(cfgst, isattr, ce, parent); cfgst_push(cfgst, isattr, ce, parent);
if ( ce->multiplicity == 1 ) { if ( ce->multiplicity == 1 ) {
if ( ut_avlLookup(&cfgst_found_treedef, &cfgst->found, &key) == NULL ) { if ( ddsrt_avl_lookup(&cfgst_found_treedef, &cfgst->found, &key) == NULL ) {
if ( ce->update ) { if ( ce->update ) {
int ok1; int ok1;
cfgst_push(cfgst, 0, NULL, NULL); cfgst_push(cfgst, 0, NULL, NULL);
@ -2117,9 +2117,9 @@ static int set_defaults(struct cfgst *cfgst, void *parent, int isattr, struct cf
ok = ok && ok1; ok = ok && ok1;
} }
} }
if ( (n = ut_avlLookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) { if ( (n = ddsrt_avl_lookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) {
if ( clear_found ) { if ( clear_found ) {
ut_avlDelete(&cfgst_found_treedef, &cfgst->found, n); ddsrt_avl_delete(&cfgst_found_treedef, &cfgst->found, n);
ddsrt_free(n); ddsrt_free(n);
} }
} }
@ -2419,7 +2419,7 @@ static void print_configitems(struct cfgst *cfgst, void *parent, int isattr, str
key.e = ce; key.e = ce;
cfgst_push(cfgst, isattr, ce, parent); cfgst_push(cfgst, isattr, ce, parent);
if ( ce->multiplicity == 1 ) { if ( ce->multiplicity == 1 ) {
if ( (n = ut_avlLookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) { if ( (n = ddsrt_avl_lookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) {
cfgst_push(cfgst, 0, NULL, NULL); cfgst_push(cfgst, 0, NULL, NULL);
ce->print(cfgst, parent, ce, n->is_default); ce->print(cfgst, parent, ce, n->is_default);
cfgst_pop(cfgst); cfgst_pop(cfgst);
@ -2496,7 +2496,7 @@ static void free_configured_elements(struct cfgst *cfgst, void *parent, struct c
if ( ce->name[0] == '>' ) /* moved, so don't care */ if ( ce->name[0] == '>' ) /* moved, so don't care */
continue; continue;
key.e = ce; key.e = ce;
if ( (n = ut_avlLookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) { if ( (n = ddsrt_avl_lookup(&cfgst_found_treedef, &cfgst->found, &key)) != NULL ) {
if ( ce->free && n->count > n->failed ) if ( ce->free && n->count > n->failed )
ce->free(cfgst, parent, ce); ce->free(cfgst, parent, ce);
} }
@ -2646,7 +2646,7 @@ static int proc_attr(void *varg, UNUSED_ARG(uintptr_t eleminfo), const char *nam
return cfg_error(cfgst, "%s: unknown attribute", name); return cfg_error(cfgst, "%s: unknown attribute", name);
else { else {
void *parent = cfgst_parent(cfgst); void *parent = cfgst_parent(cfgst);
char *xvalue = ut_expand_envvars(value); char *xvalue = ddsrt_expand_envvars(value);
int ok; int ok;
cfgst_push(cfgst, 1, cfg_attr, parent); cfgst_push(cfgst, 1, cfg_attr, parent);
ok = do_update(cfgst, cfg_attr->update, parent, cfg_attr, xvalue, 0); ok = do_update(cfgst, cfg_attr->update, parent, cfg_attr, xvalue, 0);
@ -2666,7 +2666,7 @@ static int proc_elem_data(void *varg, UNUSED_ARG(uintptr_t eleminfo), const char
return cfg_error(cfgst, "%s: no data expected", value); return cfg_error(cfgst, "%s: no data expected", value);
else { else {
void *parent = cfgst_parent(cfgst); void *parent = cfgst_parent(cfgst);
char *xvalue = ut_expand_envvars(value); char *xvalue = ddsrt_expand_envvars(value);
int ok; int ok;
cfgst_push(cfgst, 0, NULL, parent); cfgst_push(cfgst, 0, NULL, parent);
ok = do_update(cfgst, cfgelem->update, parent, cfgelem, xvalue, 0); ok = do_update(cfgst, cfgelem->update, parent, cfgelem, xvalue, 0);
@ -2802,14 +2802,14 @@ struct cfgst * config_init (const char *configfile)
cfgst = ddsrt_malloc(sizeof(*cfgst)); cfgst = ddsrt_malloc(sizeof(*cfgst));
memset(cfgst, 0, sizeof(*cfgst)); memset(cfgst, 0, sizeof(*cfgst));
ut_avlInit(&cfgst_found_treedef, &cfgst->found); ddsrt_avl_init(&cfgst_found_treedef, &cfgst->found);
cfgst->cfg = &config; cfgst->cfg = &config;
cfgst->error = 0; cfgst->error = 0;
/* configfile == NULL will get you the default configuration */ /* configfile == NULL will get you the default configuration */
if (configfile) { if (configfile) {
char *copy = ddsrt_strdup(configfile), *cursor = copy; char *copy = ddsrt_strdup(configfile), *cursor = copy;
struct ut_xmlpCallbacks cb; struct ddsrt_xmlp_callbacks cb;
cb.attr = proc_attr; cb.attr = proc_attr;
cb.elem_close = proc_elem_close; cb.elem_close = proc_elem_close;
@ -2818,14 +2818,14 @@ struct cfgst * config_init (const char *configfile)
cb.error = proc_error; cb.error = proc_error;
while (ok && cursor && cursor[0]) { while (ok && cursor && cursor[0]) {
struct ut_xmlpState *qx; struct ddsrt_xmlp_state *qx;
FILE *fp; FILE *fp;
char *tok; char *tok;
tok = cursor; tok = cursor;
if (tok[0] == '<') { if (tok[0] == '<') {
/* Read XML directly from input string */ /* Read XML directly from input string */
qx = ut_xmlpNewString (tok, cfgst, &cb); qx = ddsrt_xmlp_new_string (tok, cfgst, &cb);
ut_xmlpSetRequireEOF (qx, 0); ddsrt_xmlp_set_requireEOF (qx, 0);
fp = NULL; fp = NULL;
} else { } else {
char *comma; char *comma;
@ -2845,11 +2845,11 @@ struct cfgst * config_init (const char *configfile)
} }
} }
DDSRT_WARNING_MSVC_ON(4996); DDSRT_WARNING_MSVC_ON(4996);
qx = ut_xmlpNewFile(fp, cfgst, &cb); qx = ddsrt_xmlp_new_file(fp, cfgst, &cb);
} }
cfgst_push(cfgst, 0, &root_cfgelem, &config); cfgst_push(cfgst, 0, &root_cfgelem, &config);
ok = (ut_xmlpParse(qx) >= 0) && !cfgst->error; ok = (ddsrt_xmlp_parse(qx) >= 0) && !cfgst->error;
/* Pop until stack empty: error handling is rather brutal */ /* Pop until stack empty: error handling is rather brutal */
assert(!ok || cfgst->path_depth == 1); assert(!ok || cfgst->path_depth == 1);
while (cfgst->path_depth > 0) { while (cfgst->path_depth > 0) {
@ -2858,9 +2858,9 @@ struct cfgst * config_init (const char *configfile)
if (fp) { if (fp) {
fclose(fp); fclose(fp);
} else if (ok) { } else if (ok) {
cursor = tok + ut_xmlpGetBufpos (qx); cursor = tok + ddsrt_xmlp_get_bufpos (qx);
} }
ut_xmlpFree(qx); ddsrt_xmlp_free(qx);
while (cursor && cursor[0] == ',') { while (cursor && cursor[0] == ',') {
cursor++; cursor++;
} }
@ -3019,7 +3019,7 @@ struct cfgst * config_init (const char *configfile)
config.valid = 1; config.valid = 1;
return cfgst; return cfgst;
} else { } else {
ut_avlFree(&cfgst_found_treedef, &cfgst->found, ddsrt_free); ddsrt_avl_free(&cfgst_found_treedef, &cfgst->found, ddsrt_free);
ddsrt_free(cfgst); ddsrt_free(cfgst);
return NULL; return NULL;
} }
@ -3047,7 +3047,7 @@ void config_fini(struct cfgst *cfgst)
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
config.valid = 0; config.valid = 0;
ut_avlFree(&cfgst_found_treedef, &cfgst->found, ddsrt_free); ddsrt_avl_free(&cfgst_found_treedef, &cfgst->found, ddsrt_free);
ddsrt_free(cfgst); ddsrt_free(cfgst);
} }

View file

@ -20,7 +20,7 @@
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/md5.h" #include "dds/ddsrt/md5.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.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"
@ -1767,7 +1767,7 @@ int builtins_dqueue_handler (const struct nn_rsample_info *sampleinfo, const str
statusinfo = (qos.present & PP_STATUSINFO) ? qos.statusinfo : 0; statusinfo = (qos.present & PP_STATUSINFO) ? qos.statusinfo : 0;
} }
if (pwr && ut_avlIsEmpty (&pwr->readers)) if (pwr && ddsrt_avl_is_empty (&pwr->readers))
{ {
/* Wasn't empty when enqueued, but needn't still be; SPDP has no /* Wasn't empty when enqueued, but needn't still be; SPDP has no
proxy writer, and is always accepted */ proxy writer, and is always accepted */

View file

@ -18,7 +18,7 @@
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_entity.h" #include "dds/ddsi/q_entity.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
@ -161,7 +161,7 @@ static int print_participants (struct thread_state1 * const ts1, ddsi_tran_conn_
ephash_enum_reader_init (&er); ephash_enum_reader_init (&er);
while ((r = ephash_enum_reader_next (&er)) != NULL) while ((r = ephash_enum_reader_next (&er)) != NULL)
{ {
ut_avlIter_t writ; ddsrt_avl_iter_t writ;
struct rd_pwr_match *m; struct rd_pwr_match *m;
if (r->c.pp != p) if (r->c.pp != p)
continue; continue;
@ -170,7 +170,7 @@ static int print_participants (struct thread_state1 * const ts1, ddsi_tran_conn_
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS #ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
x += print_addrset_if_notempty (conn, " as", r->as, "\n"); x += print_addrset_if_notempty (conn, " as", r->as, "\n");
#endif #endif
for (m = ut_avlIterFirst (&rd_writers_treedef, &r->writers, &writ); m; m = ut_avlIterNext (&writ)) for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
x += cpf (conn, " pwr %x:%x:%x:%x\n", PGUID (m->pwr_guid)); x += cpf (conn, " pwr %x:%x:%x:%x\n", PGUID (m->pwr_guid));
ddsrt_mutex_unlock (&r->e.lock); ddsrt_mutex_unlock (&r->e.lock);
} }
@ -183,7 +183,7 @@ static int print_participants (struct thread_state1 * const ts1, ddsi_tran_conn_
ephash_enum_writer_init (&ew); ephash_enum_writer_init (&ew);
while ((w = ephash_enum_writer_next (&ew)) != NULL) while ((w = ephash_enum_writer_next (&ew)) != NULL)
{ {
ut_avlIter_t rdit; ddsrt_avl_iter_t rdit;
struct wr_prd_match *m; struct wr_prd_match *m;
struct whc_state whcst; struct whc_state whcst;
if (w->c.pp != p) if (w->c.pp != p)
@ -207,7 +207,7 @@ static int print_participants (struct thread_state1 * const ts1, ddsi_tran_conn_
x += cpf (conn, " max-drop-seq %lld\n", writer_max_drop_seq (w)); x += cpf (conn, " max-drop-seq %lld\n", writer_max_drop_seq (w));
} }
x += print_addrset_if_notempty (conn, " as", w->as, "\n"); x += print_addrset_if_notempty (conn, " as", w->as, "\n");
for (m = ut_avlIterFirst (&wr_readers_treedef, &w->readers, &rdit); m; m = ut_avlIterNext (&rdit)) for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
{ {
char wr_prd_flags[4]; char wr_prd_flags[4];
wr_prd_flags[0] = m->is_reliable ? 'R' : 'U'; wr_prd_flags[0] = m->is_reliable ? 'R' : 'U';
@ -248,13 +248,13 @@ static int print_proxy_participants (struct thread_state1 * const ts1, ddsi_tran
ephash_enum_proxy_reader_init (&er); ephash_enum_proxy_reader_init (&er);
while ((r = ephash_enum_proxy_reader_next (&er)) != NULL) while ((r = ephash_enum_proxy_reader_next (&er)) != NULL)
{ {
ut_avlIter_t writ; ddsrt_avl_iter_t writ;
struct prd_wr_match *m; struct prd_wr_match *m;
if (r->c.proxypp != p) if (r->c.proxypp != p)
continue; continue;
ddsrt_mutex_lock (&r->e.lock); ddsrt_mutex_lock (&r->e.lock);
print_proxy_endpoint_common (conn, "prd", &r->e, &r->c); print_proxy_endpoint_common (conn, "prd", &r->e, &r->c);
for (m = ut_avlIterFirst (&rd_writers_treedef, &r->writers, &writ); m; m = ut_avlIterNext (&writ)) for (m = ddsrt_avl_iter_first (&rd_writers_treedef, &r->writers, &writ); m; m = ddsrt_avl_iter_next (&writ))
x += cpf (conn, " wr %x:%x:%x:%x\n", PGUID (m->wr_guid)); x += cpf (conn, " wr %x:%x:%x:%x\n", PGUID (m->wr_guid));
ddsrt_mutex_unlock (&r->e.lock); ddsrt_mutex_unlock (&r->e.lock);
} }
@ -267,14 +267,14 @@ static int print_proxy_participants (struct thread_state1 * const ts1, ddsi_tran
ephash_enum_proxy_writer_init (&ew); ephash_enum_proxy_writer_init (&ew);
while ((w = ephash_enum_proxy_writer_next (&ew)) != NULL) while ((w = ephash_enum_proxy_writer_next (&ew)) != NULL)
{ {
ut_avlIter_t rdit; ddsrt_avl_iter_t rdit;
struct pwr_rd_match *m; struct pwr_rd_match *m;
if (w->c.proxypp != p) if (w->c.proxypp != p)
continue; continue;
ddsrt_mutex_lock (&w->e.lock); ddsrt_mutex_lock (&w->e.lock);
print_proxy_endpoint_common (conn, "pwr", &w->e, &w->c); print_proxy_endpoint_common (conn, "pwr", &w->e, &w->c);
x += cpf (conn, " last_seq %lld last_fragnum %u\n", w->last_seq, w->last_fragnum); x += cpf (conn, " last_seq %lld last_fragnum %u\n", w->last_seq, w->last_fragnum);
for (m = ut_avlIterFirst (&wr_readers_treedef, &w->readers, &rdit); m; m = ut_avlIterNext (&rdit)) for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &w->readers, &rdit); m; m = ddsrt_avl_iter_next (&rdit))
{ {
x += cpf (conn, " rd %x:%x:%x:%x (nack %lld %lld)\n", x += cpf (conn, " rd %x:%x:%x:%x (nack %lld %lld)\n",
PGUID (m->rd_guid), m->seq_last_nack, m->t_last_nack); PGUID (m->rd_guid), m->seq_last_nack, m->t_last_nack);

View file

@ -25,7 +25,7 @@
#include "dds/ddsi/q_time.h" #include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_misc.h" #include "dds/ddsi/q_misc.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_plist.h" #include "dds/ddsi/q_plist.h"
#include "dds/ddsi/q_lease.h" #include "dds/ddsi/q_lease.h"
#include "dds/ddsi/q_qosmatch.h" #include "dds/ddsi/q_qosmatch.h"
@ -49,34 +49,34 @@
#include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_tkmap.h"
struct deleted_participant { struct deleted_participant {
ut_avlNode_t avlnode; ddsrt_avl_node_t avlnode;
nn_guid_t guid; nn_guid_t guid;
unsigned for_what; unsigned for_what;
nn_mtime_t t_prune; nn_mtime_t t_prune;
}; };
static ddsrt_mutex_t deleted_participants_lock; static ddsrt_mutex_t deleted_participants_lock;
static ut_avlTree_t deleted_participants; static ddsrt_avl_tree_t deleted_participants;
static int compare_guid (const void *va, const void *vb); static int compare_guid (const void *va, const void *vb);
static void augment_wr_prd_match (void *vnode, const void *vleft, const void *vright); static void augment_wr_prd_match (void *vnode, const void *vleft, const void *vright);
const ut_avlTreedef_t wr_readers_treedef = const ddsrt_avl_treedef_t wr_readers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct wr_prd_match, avlnode), offsetof (struct wr_prd_match, prd_guid), compare_guid, augment_wr_prd_match); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct wr_prd_match, avlnode), offsetof (struct wr_prd_match, prd_guid), compare_guid, augment_wr_prd_match);
const ut_avlTreedef_t wr_local_readers_treedef = const ddsrt_avl_treedef_t wr_local_readers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct wr_rd_match, avlnode), offsetof (struct wr_rd_match, rd_guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct wr_rd_match, avlnode), offsetof (struct wr_rd_match, rd_guid), compare_guid, 0);
const ut_avlTreedef_t rd_writers_treedef = const ddsrt_avl_treedef_t rd_writers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct rd_pwr_match, avlnode), offsetof (struct rd_pwr_match, pwr_guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct rd_pwr_match, avlnode), offsetof (struct rd_pwr_match, pwr_guid), compare_guid, 0);
const ut_avlTreedef_t rd_local_writers_treedef = const ddsrt_avl_treedef_t rd_local_writers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct rd_wr_match, avlnode), offsetof (struct rd_wr_match, wr_guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct rd_wr_match, avlnode), offsetof (struct rd_wr_match, wr_guid), compare_guid, 0);
const ut_avlTreedef_t pwr_readers_treedef = const ddsrt_avl_treedef_t pwr_readers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct pwr_rd_match, avlnode), offsetof (struct pwr_rd_match, rd_guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct pwr_rd_match, avlnode), offsetof (struct pwr_rd_match, rd_guid), compare_guid, 0);
const ut_avlTreedef_t prd_writers_treedef = const ddsrt_avl_treedef_t prd_writers_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct prd_wr_match, avlnode), offsetof (struct prd_wr_match, wr_guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct prd_wr_match, avlnode), offsetof (struct prd_wr_match, wr_guid), compare_guid, 0);
const ut_avlTreedef_t deleted_participants_treedef = const ddsrt_avl_treedef_t deleted_participants_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct deleted_participant, avlnode), offsetof (struct deleted_participant, guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct deleted_participant, avlnode), offsetof (struct deleted_participant, guid), compare_guid, 0);
const ut_avlTreedef_t proxypp_groups_treedef = const ddsrt_avl_treedef_t proxypp_groups_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct proxy_group, avlnode), offsetof (struct proxy_group, guid), compare_guid, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct proxy_group, avlnode), offsetof (struct proxy_group, guid), compare_guid, 0);
static const unsigned builtin_writers_besmask = static const unsigned builtin_writers_besmask =
NN_DISC_BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER | NN_DISC_BUILTIN_ENDPOINT_PARTICIPANT_ANNOUNCER |
@ -267,13 +267,13 @@ nn_vendorid_t get_entity_vendorid (const struct entity_common *e)
int deleted_participants_admin_init (void) int deleted_participants_admin_init (void)
{ {
ddsrt_mutex_init (&deleted_participants_lock); ddsrt_mutex_init (&deleted_participants_lock);
ut_avlInit (&deleted_participants_treedef, &deleted_participants); ddsrt_avl_init (&deleted_participants_treedef, &deleted_participants);
return 0; return 0;
} }
void deleted_participants_admin_fini (void) void deleted_participants_admin_fini (void)
{ {
ut_avlFree (&deleted_participants_treedef, &deleted_participants, ddsrt_free); ddsrt_avl_free (&deleted_participants_treedef, &deleted_participants, ddsrt_free);
ddsrt_mutex_destroy (&deleted_participants_lock); ddsrt_mutex_destroy (&deleted_participants_lock);
} }
@ -283,13 +283,13 @@ static void prune_deleted_participant_guids_unlocked (nn_mtime_t tnow)
all circumstances, but I expect the tree to be very small at all all circumstances, but I expect the tree to be very small at all
times, so a full scan is fine, too ... */ times, so a full scan is fine, too ... */
struct deleted_participant *dpp; struct deleted_participant *dpp;
dpp = ut_avlFindMin (&deleted_participants_treedef, &deleted_participants); dpp = ddsrt_avl_find_min (&deleted_participants_treedef, &deleted_participants);
while (dpp) while (dpp)
{ {
struct deleted_participant *dpp1 = ut_avlFindSucc (&deleted_participants_treedef, &deleted_participants, dpp); struct deleted_participant *dpp1 = ddsrt_avl_find_succ (&deleted_participants_treedef, &deleted_participants, dpp);
if (dpp->t_prune.v < tnow.v) if (dpp->t_prune.v < tnow.v)
{ {
ut_avlDelete (&deleted_participants_treedef, &deleted_participants, dpp); ddsrt_avl_delete (&deleted_participants_treedef, &deleted_participants, dpp);
ddsrt_free (dpp); ddsrt_free (dpp);
} }
dpp = dpp1; dpp = dpp1;
@ -306,16 +306,16 @@ static void prune_deleted_participant_guids (nn_mtime_t tnow)
static void remember_deleted_participant_guid (const struct nn_guid *guid) static void remember_deleted_participant_guid (const struct nn_guid *guid)
{ {
struct deleted_participant *n; struct deleted_participant *n;
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
ddsrt_mutex_lock (&deleted_participants_lock); ddsrt_mutex_lock (&deleted_participants_lock);
if (ut_avlLookupIPath (&deleted_participants_treedef, &deleted_participants, guid, &path) == NULL) if (ddsrt_avl_lookup_ipath (&deleted_participants_treedef, &deleted_participants, guid, &path) == NULL)
{ {
if ((n = ddsrt_malloc (sizeof (*n))) != NULL) if ((n = ddsrt_malloc (sizeof (*n))) != NULL)
{ {
n->guid = *guid; n->guid = *guid;
n->t_prune.v = T_NEVER; n->t_prune.v = T_NEVER;
n->for_what = DPG_LOCAL | DPG_REMOTE; n->for_what = DPG_LOCAL | DPG_REMOTE;
ut_avlInsertIPath (&deleted_participants_treedef, &deleted_participants, n, &path); ddsrt_avl_insert_ipath (&deleted_participants_treedef, &deleted_participants, n, &path);
} }
} }
ddsrt_mutex_unlock (&deleted_participants_lock); ddsrt_mutex_unlock (&deleted_participants_lock);
@ -327,7 +327,7 @@ int is_deleted_participant_guid (const struct nn_guid *guid, unsigned for_what)
int known; int known;
ddsrt_mutex_lock (&deleted_participants_lock); ddsrt_mutex_lock (&deleted_participants_lock);
prune_deleted_participant_guids_unlocked (now_mt()); prune_deleted_participant_guids_unlocked (now_mt());
if ((n = ut_avlLookup (&deleted_participants_treedef, &deleted_participants, guid)) == NULL) if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &deleted_participants, guid)) == NULL)
known = 0; known = 0;
else else
known = ((n->for_what & for_what) != 0); known = ((n->for_what & for_what) != 0);
@ -340,7 +340,7 @@ static void remove_deleted_participant_guid (const struct nn_guid *guid, unsigne
struct deleted_participant *n; struct deleted_participant *n;
DDS_LOG(DDS_LC_DISCOVERY, "remove_deleted_participant_guid(%x:%x:%x:%x for_what=%x)\n", PGUID (*guid), for_what); DDS_LOG(DDS_LC_DISCOVERY, "remove_deleted_participant_guid(%x:%x:%x:%x for_what=%x)\n", PGUID (*guid), for_what);
ddsrt_mutex_lock (&deleted_participants_lock); ddsrt_mutex_lock (&deleted_participants_lock);
if ((n = ut_avlLookup (&deleted_participants_treedef, &deleted_participants, guid)) != NULL) if ((n = ddsrt_avl_lookup (&deleted_participants_treedef, &deleted_participants, guid)) != NULL)
{ {
if (config.prune_deleted_ppant.enforce_delay) if (config.prune_deleted_ppant.enforce_delay)
{ {
@ -357,7 +357,7 @@ static void remove_deleted_participant_guid (const struct nn_guid *guid, unsigne
} }
else else
{ {
ut_avlDelete (&deleted_participants_treedef, &deleted_participants, n); ddsrt_avl_delete (&deleted_participants_treedef, &deleted_participants, n);
ddsrt_free (n); ddsrt_free (n);
} }
} }
@ -971,13 +971,13 @@ static struct addrset *rebuild_make_all_addrs (int *nreaders, struct writer *wr)
{ {
struct addrset *all_addrs = new_addrset(); struct addrset *all_addrs = new_addrset();
struct wr_prd_match *m; struct wr_prd_match *m;
ut_avlIter_t it; ddsrt_avl_iter_t it;
#ifdef DDSI_INCLUDE_SSM #ifdef DDSI_INCLUDE_SSM
if (wr->supports_ssm && wr->ssm_as) if (wr->supports_ssm && wr->ssm_as)
copy_addrset_into_addrset_mc (all_addrs, wr->ssm_as); copy_addrset_into_addrset_mc (all_addrs, wr->ssm_as);
#endif #endif
*nreaders = 0; *nreaders = 0;
for (m = ut_avlIterFirst (&wr_readers_treedef, &wr->readers, &it); m; m = ut_avlIterNext (&it)) for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &wr->readers, &it); m; m = ddsrt_avl_iter_next (&it))
{ {
struct proxy_reader *prd; struct proxy_reader *prd;
if ((prd = ephash_lookup_proxy_reader_guid (&m->prd_guid)) == NULL) if ((prd = ephash_lookup_proxy_reader_guid (&m->prd_guid)) == NULL)
@ -1030,7 +1030,7 @@ static void rebuild_make_covered(int8_t **covered, const struct writer *wr, int
{ {
struct rebuild_flatten_locs_arg flarg; struct rebuild_flatten_locs_arg flarg;
struct wr_prd_match *m; struct wr_prd_match *m;
ut_avlIter_t it; ddsrt_avl_iter_t it;
int rdidx, i, j; int rdidx, i, j;
int8_t *cov = ddsrt_malloc((size_t) *nreaders * (size_t) nlocs * sizeof (*cov)); int8_t *cov = ddsrt_malloc((size_t) *nreaders * (size_t) nlocs * sizeof (*cov));
for (i = 0; i < *nreaders * nlocs; i++) for (i = 0; i < *nreaders * nlocs; i++)
@ -1040,7 +1040,7 @@ static void rebuild_make_covered(int8_t **covered, const struct writer *wr, int
#ifndef NDEBUG #ifndef NDEBUG
flarg.size = nlocs; flarg.size = nlocs;
#endif #endif
for (m = ut_avlIterFirst (&wr_readers_treedef, &wr->readers, &it); m; m = ut_avlIterNext (&it)) for (m = ddsrt_avl_iter_first (&wr_readers_treedef, &wr->readers, &it); m; m = ddsrt_avl_iter_next (&it))
{ {
struct proxy_reader *prd; struct proxy_reader *prd;
struct addrset *ass[] = { NULL, NULL, NULL }; struct addrset *ass[] = { NULL, NULL, NULL };
@ -1337,10 +1337,10 @@ static void writer_drop_connection (const struct nn_guid * wr_guid, const struct
struct whc_node *deferred_free_list = NULL; struct whc_node *deferred_free_list = NULL;
struct wr_prd_match *m; struct wr_prd_match *m;
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if ((m = ut_avlLookup (&wr_readers_treedef, &wr->readers, &prd->e.guid)) != NULL) if ((m = ddsrt_avl_lookup (&wr_readers_treedef, &wr->readers, &prd->e.guid)) != NULL)
{ {
struct whc_state whcst; struct whc_state whcst;
ut_avlDelete (&wr_readers_treedef, &wr->readers, m); ddsrt_avl_delete (&wr_readers_treedef, &wr->readers, m);
rebuild_writer_addrset (wr); rebuild_writer_addrset (wr);
remove_acked_messages (wr, &whcst, &deferred_free_list); remove_acked_messages (wr, &whcst, &deferred_free_list);
wr->num_reliable_readers -= m->is_reliable; wr->num_reliable_readers -= m->is_reliable;
@ -1368,9 +1368,9 @@ static void writer_drop_local_connection (const struct nn_guid *wr_guid, struct
struct wr_rd_match *m; struct wr_rd_match *m;
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if ((m = ut_avlLookup (&wr_local_readers_treedef, &wr->local_readers, &rd->e.guid)) != NULL) if ((m = ddsrt_avl_lookup (&wr_local_readers_treedef, &wr->local_readers, &rd->e.guid)) != NULL)
{ {
ut_avlDelete (&wr_local_readers_treedef, &wr->local_readers, m); ddsrt_avl_delete (&wr_local_readers_treedef, &wr->local_readers, m);
local_reader_ary_remove (&wr->rdary, rd); local_reader_ary_remove (&wr->rdary, rd);
} }
ddsrt_mutex_unlock (&wr->e.lock); ddsrt_mutex_unlock (&wr->e.lock);
@ -1393,8 +1393,8 @@ static void reader_drop_connection (const struct nn_guid *rd_guid, const struct
{ {
struct rd_pwr_match *m; struct rd_pwr_match *m;
ddsrt_mutex_lock (&rd->e.lock); ddsrt_mutex_lock (&rd->e.lock);
if ((m = ut_avlLookup (&rd_writers_treedef, &rd->writers, &pwr->e.guid)) != NULL) if ((m = ddsrt_avl_lookup (&rd_writers_treedef, &rd->writers, &pwr->e.guid)) != NULL)
ut_avlDelete (&rd_writers_treedef, &rd->writers, m); ddsrt_avl_delete (&rd_writers_treedef, &rd->writers, m);
ddsrt_mutex_unlock (&rd->e.lock); ddsrt_mutex_unlock (&rd->e.lock);
free_rd_pwr_match (m); free_rd_pwr_match (m);
@ -1427,8 +1427,8 @@ static void reader_drop_local_connection (const struct nn_guid *rd_guid, const s
{ {
struct rd_wr_match *m; struct rd_wr_match *m;
ddsrt_mutex_lock (&rd->e.lock); ddsrt_mutex_lock (&rd->e.lock);
if ((m = ut_avlLookup (&rd_local_writers_treedef, &rd->local_writers, &wr->e.guid)) != NULL) if ((m = ddsrt_avl_lookup (&rd_local_writers_treedef, &rd->local_writers, &wr->e.guid)) != NULL)
ut_avlDelete (&rd_local_writers_treedef, &rd->local_writers, m); ddsrt_avl_delete (&rd_local_writers_treedef, &rd->local_writers, m);
ddsrt_mutex_unlock (&rd->e.lock); ddsrt_mutex_unlock (&rd->e.lock);
free_rd_wr_match (m); free_rd_wr_match (m);
@ -1486,9 +1486,9 @@ static void proxy_writer_drop_connection (const struct nn_guid *pwr_guid, struct
struct pwr_rd_match *m; struct pwr_rd_match *m;
ddsrt_mutex_lock (&pwr->e.lock); ddsrt_mutex_lock (&pwr->e.lock);
if ((m = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &rd->e.guid)) != NULL) if ((m = ddsrt_avl_lookup (&pwr_readers_treedef, &pwr->readers, &rd->e.guid)) != NULL)
{ {
ut_avlDelete (&pwr_readers_treedef, &pwr->readers, m); ddsrt_avl_delete (&pwr_readers_treedef, &pwr->readers, m);
if (m->in_sync != PRMSS_SYNC) if (m->in_sync != PRMSS_SYNC)
pwr->n_readers_out_of_sync--; pwr->n_readers_out_of_sync--;
if (rd->reliable) if (rd->reliable)
@ -1512,10 +1512,10 @@ static void proxy_reader_drop_connection
{ {
struct prd_wr_match *m; struct prd_wr_match *m;
ddsrt_mutex_lock (&prd->e.lock); ddsrt_mutex_lock (&prd->e.lock);
m = ut_avlLookup (&prd_writers_treedef, &prd->writers, &wr->e.guid); m = ddsrt_avl_lookup (&prd_writers_treedef, &prd->writers, &wr->e.guid);
if (m) if (m)
{ {
ut_avlDelete (&prd_writers_treedef, &prd->writers, m); ddsrt_avl_delete (&prd_writers_treedef, &prd->writers, m);
} }
ddsrt_mutex_unlock (&prd->e.lock); ddsrt_mutex_unlock (&prd->e.lock);
free_prd_wr_match (m); free_prd_wr_match (m);
@ -1525,7 +1525,7 @@ static void proxy_reader_drop_connection
static void writer_add_connection (struct writer *wr, struct proxy_reader *prd) static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
{ {
struct wr_prd_match *m = ddsrt_malloc (sizeof (*m)); struct wr_prd_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
int pretend_everything_acked; int pretend_everything_acked;
m->prd_guid = prd->e.guid; m->prd_guid = prd->e.guid;
m->is_reliable = (prd->c.xqos->reliability.kind > NN_BEST_EFFORT_RELIABILITY_QOS); m->is_reliable = (prd->c.xqos->reliability.kind > NN_BEST_EFFORT_RELIABILITY_QOS);
@ -1564,7 +1564,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
m->seq = MAX_SEQ_NUMBER; m->seq = MAX_SEQ_NUMBER;
else else
m->seq = wr->seq; m->seq = wr->seq;
if (ut_avlLookupIPath (&wr_readers_treedef, &wr->readers, &prd->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&wr_readers_treedef, &wr->readers, &prd->e.guid, &path))
{ {
DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (prd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (prd->e.guid));
ddsrt_mutex_unlock (&wr->e.lock); ddsrt_mutex_unlock (&wr->e.lock);
@ -1574,7 +1574,7 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
else else
{ {
DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - ack seq %"PRId64"\n", PGUID (wr->e.guid), PGUID (prd->e.guid), m->seq); DDS_LOG(DDS_LC_DISCOVERY, " writer_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - ack seq %"PRId64"\n", PGUID (wr->e.guid), PGUID (prd->e.guid), m->seq);
ut_avlInsertIPath (&wr_readers_treedef, &wr->readers, m, &path); ddsrt_avl_insert_ipath (&wr_readers_treedef, &wr->readers, m, &path);
rebuild_writer_addrset (wr); rebuild_writer_addrset (wr);
wr->num_reliable_readers += m->is_reliable; wr->num_reliable_readers += m->is_reliable;
ddsrt_mutex_unlock (&wr->e.lock); ddsrt_mutex_unlock (&wr->e.lock);
@ -1618,10 +1618,10 @@ static void writer_add_connection (struct writer *wr, struct proxy_reader *prd)
static void writer_add_local_connection (struct writer *wr, struct reader *rd) static void writer_add_local_connection (struct writer *wr, struct reader *rd)
{ {
struct wr_rd_match *m = ddsrt_malloc (sizeof (*m)); struct wr_rd_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if (ut_avlLookupIPath (&wr_local_readers_treedef, &wr->local_readers, &rd->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&wr_local_readers_treedef, &wr->local_readers, &rd->e.guid, &path))
{ {
DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid));
ddsrt_mutex_unlock (&wr->e.lock); ddsrt_mutex_unlock (&wr->e.lock);
@ -1631,7 +1631,7 @@ static void writer_add_local_connection (struct writer *wr, struct reader *rd)
DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)", PGUID (wr->e.guid), PGUID (rd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, " writer_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)", PGUID (wr->e.guid), PGUID (rd->e.guid));
m->rd_guid = rd->e.guid; m->rd_guid = rd->e.guid;
ut_avlInsertIPath (&wr_local_readers_treedef, &wr->local_readers, m, &path); ddsrt_avl_insert_ipath (&wr_local_readers_treedef, &wr->local_readers, m, &path);
local_reader_ary_insert (&wr->rdary, rd); local_reader_ary_insert (&wr->rdary, rd);
/* Store available data into the late joining reader when it is reliable (we don't do /* Store available data into the late joining reader when it is reliable (we don't do
@ -1672,7 +1672,7 @@ static void writer_add_local_connection (struct writer *wr, struct reader *rd)
static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr, nn_count_t *init_count) static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr, nn_count_t *init_count)
{ {
struct rd_pwr_match *m = ddsrt_malloc (sizeof (*m)); struct rd_pwr_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
m->pwr_guid = pwr->e.guid; m->pwr_guid = pwr->e.guid;
@ -1687,7 +1687,7 @@ static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr,
DDS_LOG(DDS_LC_DISCOVERY, " reader %x:%x:%x:%x init_acknack_count = %d\n", PGUID (rd->e.guid), rd->init_acknack_count); DDS_LOG(DDS_LC_DISCOVERY, " reader %x:%x:%x:%x init_acknack_count = %d\n", PGUID (rd->e.guid), rd->init_acknack_count);
*init_count = rd->init_acknack_count; *init_count = rd->init_acknack_count;
if (ut_avlLookupIPath (&rd_writers_treedef, &rd->writers, &pwr->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&rd_writers_treedef, &rd->writers, &pwr->e.guid, &path))
{ {
DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n",
PGUID (pwr->e.guid), PGUID (rd->e.guid)); PGUID (pwr->e.guid), PGUID (rd->e.guid));
@ -1698,7 +1698,7 @@ static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr,
{ {
DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)\n", DDS_LOG(DDS_LC_DISCOVERY, " reader_add_connection(pwr %x:%x:%x:%x rd %x:%x:%x:%x)\n",
PGUID (pwr->e.guid), PGUID (rd->e.guid)); PGUID (pwr->e.guid), PGUID (rd->e.guid));
ut_avlInsertIPath (&rd_writers_treedef, &rd->writers, m, &path); ddsrt_avl_insert_ipath (&rd_writers_treedef, &rd->writers, m, &path);
ddsrt_mutex_unlock (&rd->e.lock); ddsrt_mutex_unlock (&rd->e.lock);
#ifdef DDSI_INCLUDE_SSM #ifdef DDSI_INCLUDE_SSM
@ -1736,13 +1736,13 @@ static void reader_add_connection (struct reader *rd, struct proxy_writer *pwr,
static void reader_add_local_connection (struct reader *rd, struct writer *wr) static void reader_add_local_connection (struct reader *rd, struct writer *wr)
{ {
struct rd_wr_match *m = ddsrt_malloc (sizeof (*m)); struct rd_wr_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
m->wr_guid = wr->e.guid; m->wr_guid = wr->e.guid;
ddsrt_mutex_lock (&rd->e.lock); ddsrt_mutex_lock (&rd->e.lock);
if (ut_avlLookupIPath (&rd_local_writers_treedef, &rd->local_writers, &wr->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&rd_local_writers_treedef, &rd->local_writers, &wr->e.guid, &path))
{ {
DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x) - already connected\n", PGUID (wr->e.guid), PGUID (rd->e.guid));
ddsrt_mutex_unlock (&rd->e.lock); ddsrt_mutex_unlock (&rd->e.lock);
@ -1751,7 +1751,7 @@ static void reader_add_local_connection (struct reader *rd, struct writer *wr)
else else
{ {
DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)\n", PGUID (wr->e.guid), PGUID (rd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, " reader_add_local_connection(wr %x:%x:%x:%x rd %x:%x:%x:%x)\n", PGUID (wr->e.guid), PGUID (rd->e.guid));
ut_avlInsertIPath (&rd_local_writers_treedef, &rd->local_writers, m, &path); ddsrt_avl_insert_ipath (&rd_local_writers_treedef, &rd->local_writers, m, &path);
ddsrt_mutex_unlock (&rd->e.lock); ddsrt_mutex_unlock (&rd->e.lock);
if (rd->status_cb) if (rd->status_cb)
@ -1772,11 +1772,11 @@ static void reader_add_local_connection (struct reader *rd, struct writer *wr)
static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader *rd, nn_mtime_t tnow, nn_count_t init_count) static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader *rd, nn_mtime_t tnow, nn_count_t init_count)
{ {
struct pwr_rd_match *m = ddsrt_malloc (sizeof (*m)); struct pwr_rd_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
seqno_t last_deliv_seq; seqno_t last_deliv_seq;
ddsrt_mutex_lock (&pwr->e.lock); ddsrt_mutex_lock (&pwr->e.lock);
if (ut_avlLookupIPath (&pwr_readers_treedef, &pwr->readers, &rd->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&pwr_readers_treedef, &pwr->readers, &rd->e.guid, &path))
goto already_matched; goto already_matched;
if (pwr->c.topic == NULL && rd->topic) if (pwr->c.topic == NULL && rd->topic)
@ -1816,7 +1816,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
{ {
m->in_sync = PRMSS_SYNC; m->in_sync = PRMSS_SYNC;
} }
else if (!config.conservative_builtin_reader_startup && is_builtin_entityid (rd->e.guid.entityid, NN_VENDORID_ECLIPSE) && !ut_avlIsEmpty (&pwr->readers)) else if (!config.conservative_builtin_reader_startup && is_builtin_entityid (rd->e.guid.entityid, NN_VENDORID_ECLIPSE) && !ddsrt_avl_is_empty (&pwr->readers))
{ {
/* builtins really don't care about multiple copies */ /* builtins really don't care about multiple copies */
m->in_sync = PRMSS_SYNC; m->in_sync = PRMSS_SYNC;
@ -1860,7 +1860,7 @@ static void proxy_writer_add_connection (struct proxy_writer *pwr, struct reader
nn_reorder_new (NN_REORDER_MODE_MONOTONICALLY_INCREASING, config.secondary_reorder_maxsamples); nn_reorder_new (NN_REORDER_MODE_MONOTONICALLY_INCREASING, config.secondary_reorder_maxsamples);
} }
ut_avlInsertIPath (&pwr_readers_treedef, &pwr->readers, m, &path); ddsrt_avl_insert_ipath (&pwr_readers_treedef, &pwr->readers, m, &path);
local_reader_ary_insert(&pwr->rdary, rd); local_reader_ary_insert(&pwr->rdary, rd);
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
qxev_pwr_entityid (pwr, &rd->e.guid.prefix); qxev_pwr_entityid (pwr, &rd->e.guid.prefix);
@ -1890,13 +1890,13 @@ already_matched:
static void proxy_reader_add_connection (struct proxy_reader *prd, struct writer *wr) static void proxy_reader_add_connection (struct proxy_reader *prd, struct writer *wr)
{ {
struct prd_wr_match *m = ddsrt_malloc (sizeof (*m)); struct prd_wr_match *m = ddsrt_malloc (sizeof (*m));
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
m->wr_guid = wr->e.guid; m->wr_guid = wr->e.guid;
ddsrt_mutex_lock (&prd->e.lock); ddsrt_mutex_lock (&prd->e.lock);
if (prd->c.topic == NULL) if (prd->c.topic == NULL)
prd->c.topic = ddsi_sertopic_ref (wr->topic); prd->c.topic = ddsi_sertopic_ref (wr->topic);
if (ut_avlLookupIPath (&prd_writers_treedef, &prd->writers, &wr->e.guid, &path)) if (ddsrt_avl_lookup_ipath (&prd_writers_treedef, &prd->writers, &wr->e.guid, &path))
{ {
DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n", DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x) - already connected\n",
PGUID (wr->e.guid), PGUID (prd->e.guid)); PGUID (wr->e.guid), PGUID (prd->e.guid));
@ -1907,7 +1907,7 @@ static void proxy_reader_add_connection (struct proxy_reader *prd, struct writer
{ {
DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x)\n", DDS_LOG(DDS_LC_DISCOVERY, " proxy_reader_add_connection(wr %x:%x:%x:%x prd %x:%x:%x:%x)\n",
PGUID (wr->e.guid), PGUID (prd->e.guid)); PGUID (wr->e.guid), PGUID (prd->e.guid));
ut_avlInsertIPath (&prd_writers_treedef, &prd->writers, m, &path); ddsrt_avl_insert_ipath (&prd_writers_treedef, &prd->writers, m, &path);
ddsrt_mutex_unlock (&prd->e.lock); ddsrt_mutex_unlock (&prd->e.lock);
qxev_prd_entityid (prd, &wr->e.guid.prefix); qxev_prd_entityid (prd, &wr->e.guid.prefix);
} }
@ -2539,15 +2539,15 @@ static void augment_wr_prd_match (void *vnode, const void *vleft, const void *vr
seqno_t writer_max_drop_seq (const struct writer *wr) seqno_t writer_max_drop_seq (const struct writer *wr)
{ {
const struct wr_prd_match *n; const struct wr_prd_match *n;
if (ut_avlIsEmpty (&wr->readers)) if (ddsrt_avl_is_empty (&wr->readers))
return wr->seq; return wr->seq;
n = ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers); n = ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers);
return (n->min_seq == MAX_SEQ_NUMBER) ? wr->seq : n->min_seq; return (n->min_seq == MAX_SEQ_NUMBER) ? wr->seq : n->min_seq;
} }
int writer_must_have_hb_scheduled (const struct writer *wr, const struct whc_state *whcst) int writer_must_have_hb_scheduled (const struct writer *wr, const struct whc_state *whcst)
{ {
if (ut_avlIsEmpty (&wr->readers) || whcst->max_seq < 0) if (ddsrt_avl_is_empty (&wr->readers) || whcst->max_seq < 0)
{ {
/* Can't transmit a valid heartbeat if there is no data; and it /* Can't transmit a valid heartbeat if there is no data; and it
wouldn't actually be sent anywhere if there are no readers, so wouldn't actually be sent anywhere if there are no readers, so
@ -2558,7 +2558,7 @@ int writer_must_have_hb_scheduled (const struct writer *wr, const struct whc_sta
a heartbeat if no data is available. */ a heartbeat if no data is available. */
return 0; return 0;
} }
else if (!((const struct wr_prd_match *) ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb) else if (!((const struct wr_prd_match *) ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb)
{ {
/* Labouring under the belief that heartbeats must be sent /* Labouring under the belief that heartbeats must be sent
regardless of ack state */ regardless of ack state */
@ -2800,8 +2800,8 @@ static void new_writer_guid_common_init (struct writer *wr, const struct ddsi_se
assert (!is_builtin_entityid(wr->e.guid.entityid, NN_VENDORID_ECLIPSE) || (wr->whc_low == wr->whc_high && wr->whc_low == INT32_MAX)); assert (!is_builtin_entityid(wr->e.guid.entityid, NN_VENDORID_ECLIPSE) || (wr->whc_low == wr->whc_high && wr->whc_low == INT32_MAX));
/* Connection admin */ /* Connection admin */
ut_avlInit (&wr_readers_treedef, &wr->readers); ddsrt_avl_init (&wr_readers_treedef, &wr->readers);
ut_avlInit (&wr_local_readers_treedef, &wr->local_readers); ddsrt_avl_init (&wr_local_readers_treedef, &wr->local_readers);
local_reader_ary_init (&wr->rdary); local_reader_ary_init (&wr->rdary);
} }
@ -2917,17 +2917,17 @@ static void gc_delete_writer (struct gcreq *gcreq)
us now, because we can't be found via guid_hash anymore. We us now, because we can't be found via guid_hash anymore. We
therefore need not take lock. */ therefore need not take lock. */
while (!ut_avlIsEmpty (&wr->readers)) while (!ddsrt_avl_is_empty (&wr->readers))
{ {
struct wr_prd_match *m = ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers); struct wr_prd_match *m = ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers);
ut_avlDelete (&wr_readers_treedef, &wr->readers, m); ddsrt_avl_delete (&wr_readers_treedef, &wr->readers, m);
proxy_reader_drop_connection (&m->prd_guid, wr); proxy_reader_drop_connection (&m->prd_guid, wr);
free_wr_prd_match (m); free_wr_prd_match (m);
} }
while (!ut_avlIsEmpty (&wr->local_readers)) while (!ddsrt_avl_is_empty (&wr->local_readers))
{ {
struct wr_rd_match *m = ut_avlRootNonEmpty (&wr_local_readers_treedef, &wr->local_readers); struct wr_rd_match *m = ddsrt_avl_root_non_empty (&wr_local_readers_treedef, &wr->local_readers);
ut_avlDelete (&wr_local_readers_treedef, &wr->local_readers, m); ddsrt_avl_delete (&wr_local_readers_treedef, &wr->local_readers, m);
reader_drop_local_connection (&m->rd_guid, wr); reader_drop_local_connection (&m->rd_guid, wr);
free_wr_rd_match (m); free_wr_rd_match (m);
} }
@ -3324,8 +3324,8 @@ static dds_retcode_t new_reader_guid
#endif #endif
#endif #endif
ut_avlInit (&rd_writers_treedef, &rd->writers); ddsrt_avl_init (&rd_writers_treedef, &rd->writers);
ut_avlInit (&rd_local_writers_treedef, &rd->local_writers); ddsrt_avl_init (&rd_local_writers_treedef, &rd->local_writers);
ddsrt_mutex_lock (&rd->e.lock); ddsrt_mutex_lock (&rd->e.lock);
ephash_insert_reader_guid (rd); ephash_insert_reader_guid (rd);
@ -3371,17 +3371,17 @@ static void gc_delete_reader (struct gcreq *gcreq)
DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (rd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (rd->e.guid));
gcreq_free (gcreq); gcreq_free (gcreq);
while (!ut_avlIsEmpty (&rd->writers)) while (!ddsrt_avl_is_empty (&rd->writers))
{ {
struct rd_pwr_match *m = ut_avlRootNonEmpty (&rd_writers_treedef, &rd->writers); struct rd_pwr_match *m = ddsrt_avl_root_non_empty (&rd_writers_treedef, &rd->writers);
ut_avlDelete (&rd_writers_treedef, &rd->writers, m); ddsrt_avl_delete (&rd_writers_treedef, &rd->writers, m);
proxy_writer_drop_connection (&m->pwr_guid, rd); proxy_writer_drop_connection (&m->pwr_guid, rd);
free_rd_pwr_match (m); free_rd_pwr_match (m);
} }
while (!ut_avlIsEmpty (&rd->local_writers)) while (!ddsrt_avl_is_empty (&rd->local_writers))
{ {
struct rd_wr_match *m = ut_avlRootNonEmpty (&rd_local_writers_treedef, &rd->local_writers); struct rd_wr_match *m = ddsrt_avl_root_non_empty (&rd_local_writers_treedef, &rd->local_writers);
ut_avlDelete (&rd_local_writers_treedef, &rd->local_writers, m); ddsrt_avl_delete (&rd_local_writers_treedef, &rd->local_writers, m);
writer_drop_local_connection (&m->wr_guid, rd); writer_drop_local_connection (&m->wr_guid, rd);
free_rd_wr_match (m); free_rd_wr_match (m);
} }
@ -3552,7 +3552,7 @@ void new_proxy_participant
proxypp->as_meta = as_meta; proxypp->as_meta = as_meta;
proxypp->endpoints = NULL; proxypp->endpoints = NULL;
proxypp->plist = nn_plist_dup (plist); proxypp->plist = nn_plist_dup (plist);
ut_avlInit (&proxypp_groups_treedef, &proxypp->groups); ddsrt_avl_init (&proxypp_groups_treedef, &proxypp->groups);
if (custom_flags & CF_INC_KERNEL_SEQUENCE_NUMBERS) if (custom_flags & CF_INC_KERNEL_SEQUENCE_NUMBERS)
@ -3851,8 +3851,8 @@ static void delete_ppt (struct proxy_participant * proxypp, nn_wctime_t timestam
proxypp->lease_expired = 1; proxypp->lease_expired = 1;
DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting groups\n", PGUID (proxypp->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting groups\n", PGUID (proxypp->e.guid));
while (!ut_avlIsEmpty (&proxypp->groups)) while (!ddsrt_avl_is_empty (&proxypp->groups))
delete_proxy_group_locked (ut_avlRoot (&proxypp_groups_treedef, &proxypp->groups), timestamp, isimplicit); delete_proxy_group_locked (ddsrt_avl_root (&proxypp_groups_treedef, &proxypp->groups), timestamp, isimplicit);
DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting endpoints\n", PGUID (proxypp->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, "delete_ppt(%x:%x:%x:%x) - deleting endpoints\n", PGUID (proxypp->e.guid));
c = proxypp->endpoints; c = proxypp->endpoints;
@ -3965,7 +3965,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct
else else
{ {
struct proxy_group *pgroup; struct proxy_group *pgroup;
ut_avlIPath_t ipath; ddsrt_avl_ipath_t ipath;
int is_sub; int is_sub;
switch (guid->entityid.u & (NN_ENTITYID_SOURCE_MASK | NN_ENTITYID_KIND_MASK)) switch (guid->entityid.u & (NN_ENTITYID_SOURCE_MASK | NN_ENTITYID_KIND_MASK))
{ {
@ -3980,7 +3980,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct
return Q_ERR_INVALID_DATA; return Q_ERR_INVALID_DATA;
} }
ddsrt_mutex_lock (&proxypp->e.lock); ddsrt_mutex_lock (&proxypp->e.lock);
if ((pgroup = ut_avlLookupIPath (&proxypp_groups_treedef, &proxypp->groups, guid, &ipath)) != NULL) if ((pgroup = ddsrt_avl_lookup_ipath (&proxypp_groups_treedef, &proxypp->groups, guid, &ipath)) != NULL)
{ {
/* Complete proxy group definition if it was a partial /* Complete proxy group definition if it was a partial
definition made by creating a proxy reader or writer, definition made by creating a proxy reader or writer,
@ -3997,7 +3997,7 @@ int new_proxy_group (const struct nn_guid *guid, const char *name, const struct
pgroup->proxypp = proxypp; pgroup->proxypp = proxypp;
pgroup->name = NULL; pgroup->name = NULL;
pgroup->xqos = NULL; pgroup->xqos = NULL;
ut_avlInsertIPath (&proxypp_groups_treedef, &proxypp->groups, pgroup, &ipath); ddsrt_avl_insert_ipath (&proxypp_groups_treedef, &proxypp->groups, pgroup, &ipath);
} }
if (name) if (name)
{ {
@ -4021,7 +4021,7 @@ static void delete_proxy_group_locked (struct proxy_group *pgroup, nn_wctime_t t
(void)isimplicit; (void)isimplicit;
assert ((pgroup->xqos != NULL) == (pgroup->name != NULL)); assert ((pgroup->xqos != NULL) == (pgroup->name != NULL));
DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_group_locked %x:%x:%x:%x\n", PGUID (pgroup->guid)); DDS_LOG(DDS_LC_DISCOVERY, "delete_proxy_group_locked %x:%x:%x:%x\n", PGUID (pgroup->guid));
ut_avlDelete (&proxypp_groups_treedef, &proxypp->groups, pgroup); ddsrt_avl_delete (&proxypp_groups_treedef, &proxypp->groups, pgroup);
/* Publish corresponding built-in topic only if it is not a place /* Publish corresponding built-in topic only if it is not a place
holder: in that case we haven't announced its presence and holder: in that case we haven't announced its presence and
therefore don't need to dispose it, and this saves us from having therefore don't need to dispose it, and this saves us from having
@ -4046,7 +4046,7 @@ void delete_proxy_group (const nn_guid_t *guid, nn_wctime_t timestamp, int isimp
{ {
struct proxy_group *pgroup; struct proxy_group *pgroup;
ddsrt_mutex_lock (&proxypp->e.lock); ddsrt_mutex_lock (&proxypp->e.lock);
if ((pgroup = ut_avlLookup (&proxypp_groups_treedef, &proxypp->groups, guid)) != NULL) if ((pgroup = ddsrt_avl_lookup (&proxypp_groups_treedef, &proxypp->groups, guid)) != NULL)
delete_proxy_group_locked (pgroup, timestamp, isimplicit); delete_proxy_group_locked (pgroup, timestamp, isimplicit);
ddsrt_mutex_unlock (&proxypp->e.lock); ddsrt_mutex_unlock (&proxypp->e.lock);
} }
@ -4112,7 +4112,7 @@ int new_proxy_writer (const struct nn_guid *ppguid, const struct nn_guid *guid,
pwr = ddsrt_malloc (sizeof (*pwr)); pwr = ddsrt_malloc (sizeof (*pwr));
proxy_endpoint_common_init (&pwr->e, &pwr->c, EK_PROXY_WRITER, guid, timestamp, proxypp, as, plist); proxy_endpoint_common_init (&pwr->e, &pwr->c, EK_PROXY_WRITER, guid, timestamp, proxypp, as, plist);
ut_avlInit (&pwr_readers_treedef, &pwr->readers); ddsrt_avl_init (&pwr_readers_treedef, &pwr->readers);
pwr->n_reliable_readers = 0; pwr->n_reliable_readers = 0;
pwr->n_readers_out_of_sync = 0; pwr->n_readers_out_of_sync = 0;
pwr->last_seq = 0; pwr->last_seq = 0;
@ -4195,7 +4195,7 @@ void update_proxy_writer (struct proxy_writer * pwr, struct addrset * as)
{ {
struct reader * rd; struct reader * rd;
struct pwr_rd_match * m; struct pwr_rd_match * m;
ut_avlIter_t iter; ddsrt_avl_iter_t iter;
/* Update proxy writer endpoints (from SEDP alive) */ /* Update proxy writer endpoints (from SEDP alive) */
@ -4208,7 +4208,7 @@ void update_proxy_writer (struct proxy_writer * pwr, struct addrset * as)
unref_addrset (pwr->c.as); unref_addrset (pwr->c.as);
ref_addrset (as); ref_addrset (as);
pwr->c.as = as; pwr->c.as = as;
m = ut_avlIterFirst (&pwr_readers_treedef, &pwr->readers, &iter); m = ddsrt_avl_iter_first (&pwr_readers_treedef, &pwr->readers, &iter);
while (m) while (m)
{ {
rd = ephash_lookup_reader_guid (&m->rd_guid); rd = ephash_lookup_reader_guid (&m->rd_guid);
@ -4216,7 +4216,7 @@ void update_proxy_writer (struct proxy_writer * pwr, struct addrset * as)
{ {
qxev_pwr_entityid (pwr, &rd->e.guid.prefix); qxev_pwr_entityid (pwr, &rd->e.guid.prefix);
} }
m = ut_avlIterNext (&iter); m = ddsrt_avl_iter_next (&iter);
} }
} }
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
@ -4240,14 +4240,14 @@ void update_proxy_reader (struct proxy_reader * prd, struct addrset * as)
/* Rebuild writer endpoints */ /* Rebuild writer endpoints */
while ((m = ut_avlLookupSuccEq (&prd_writers_treedef, &prd->writers, &wrguid)) != NULL) while ((m = ddsrt_avl_lookup_succ_eq (&prd_writers_treedef, &prd->writers, &wrguid)) != NULL)
{ {
struct prd_wr_match *next; struct prd_wr_match *next;
nn_guid_t guid_next; nn_guid_t guid_next;
struct writer * wr; struct writer * wr;
wrguid = m->wr_guid; wrguid = m->wr_guid;
next = ut_avlFindSucc (&prd_writers_treedef, &prd->writers, m); next = ddsrt_avl_find_succ (&prd_writers_treedef, &prd->writers, m);
if (next) if (next)
{ {
guid_next = next->wr_guid; guid_next = next->wr_guid;
@ -4280,10 +4280,10 @@ static void gc_delete_proxy_writer (struct gcreq *gcreq)
DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_writer(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (pwr->e.guid));
gcreq_free (gcreq); gcreq_free (gcreq);
while (!ut_avlIsEmpty (&pwr->readers)) while (!ddsrt_avl_is_empty (&pwr->readers))
{ {
struct pwr_rd_match *m = ut_avlRootNonEmpty (&pwr_readers_treedef, &pwr->readers); struct pwr_rd_match *m = ddsrt_avl_root_non_empty (&pwr_readers_treedef, &pwr->readers);
ut_avlDelete (&pwr_readers_treedef, &pwr->readers, m); ddsrt_avl_delete (&pwr_readers_treedef, &pwr->readers, m);
reader_drop_connection (&m->rd_guid, pwr); reader_drop_connection (&m->rd_guid, pwr);
update_reader_init_acknack_count (&m->rd_guid, m->count); update_reader_init_acknack_count (&m->rd_guid, m->count);
free_pwr_rd_match (m); free_pwr_rd_match (m);
@ -4353,7 +4353,7 @@ int new_proxy_reader (const struct nn_guid *ppguid, const struct nn_guid *guid,
"real" participant, rather than the thing we use for endpoints discovered via the DS */ "real" participant, rather than the thing we use for endpoints discovered via the DS */
prd->assert_pp_lease = (unsigned) !!config.arrival_of_data_asserts_pp_and_ep_liveliness; prd->assert_pp_lease = (unsigned) !!config.arrival_of_data_asserts_pp_and_ep_liveliness;
ut_avlInit (&prd_writers_treedef, &prd->writers); ddsrt_avl_init (&prd_writers_treedef, &prd->writers);
/* locking the entity prevents matching while the built-in topic hasn't been published yet */ /* locking the entity prevents matching while the built-in topic hasn't been published yet */
ddsrt_mutex_lock (&prd->e.lock); ddsrt_mutex_lock (&prd->e.lock);
@ -4374,14 +4374,14 @@ static void proxy_reader_set_delete_and_ack_all_messages (struct proxy_reader *p
memset (&wrguid, 0, sizeof (wrguid)); memset (&wrguid, 0, sizeof (wrguid));
ddsrt_mutex_lock (&prd->e.lock); ddsrt_mutex_lock (&prd->e.lock);
prd->deleting = 1; prd->deleting = 1;
while ((m = ut_avlLookupSuccEq (&prd_writers_treedef, &prd->writers, &wrguid)) != NULL) while ((m = ddsrt_avl_lookup_succ_eq (&prd_writers_treedef, &prd->writers, &wrguid)) != NULL)
{ {
/* have to be careful walking the tree -- pretty is different, but /* have to be careful walking the tree -- pretty is different, but
I want to check this before I write a lookup_succ function. */ I want to check this before I write a lookup_succ function. */
struct prd_wr_match *m_a_next; struct prd_wr_match *m_a_next;
nn_guid_t wrguid_next; nn_guid_t wrguid_next;
wrguid = m->wr_guid; wrguid = m->wr_guid;
if ((m_a_next = ut_avlFindSucc (&prd_writers_treedef, &prd->writers, m)) != NULL) if ((m_a_next = ddsrt_avl_find_succ (&prd_writers_treedef, &prd->writers, m)) != NULL)
wrguid_next = m_a_next->wr_guid; wrguid_next = m_a_next->wr_guid;
else else
{ {
@ -4395,11 +4395,11 @@ static void proxy_reader_set_delete_and_ack_all_messages (struct proxy_reader *p
struct whc_node *deferred_free_list = NULL; struct whc_node *deferred_free_list = NULL;
struct wr_prd_match *m_wr; struct wr_prd_match *m_wr;
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if ((m_wr = ut_avlLookup (&wr_readers_treedef, &wr->readers, &prd->e.guid)) != NULL) if ((m_wr = ddsrt_avl_lookup (&wr_readers_treedef, &wr->readers, &prd->e.guid)) != NULL)
{ {
struct whc_state whcst; struct whc_state whcst;
m_wr->seq = MAX_SEQ_NUMBER; m_wr->seq = MAX_SEQ_NUMBER;
ut_avlAugmentUpdate (&wr_readers_treedef, m_wr); ddsrt_avl_augment_update (&wr_readers_treedef, m_wr);
(void)remove_acked_messages (wr, &whcst, &deferred_free_list); (void)remove_acked_messages (wr, &whcst, &deferred_free_list);
writer_clear_retransmitting (wr); writer_clear_retransmitting (wr);
} }
@ -4419,10 +4419,10 @@ static void gc_delete_proxy_reader (struct gcreq *gcreq)
DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (prd->e.guid)); DDS_LOG(DDS_LC_DISCOVERY, "gc_delete_proxy_reader(%p, %x:%x:%x:%x)\n", (void *) gcreq, PGUID (prd->e.guid));
gcreq_free (gcreq); gcreq_free (gcreq);
while (!ut_avlIsEmpty (&prd->writers)) while (!ddsrt_avl_is_empty (&prd->writers))
{ {
struct prd_wr_match *m = ut_avlRootNonEmpty (&prd_writers_treedef, &prd->writers); struct prd_wr_match *m = ddsrt_avl_root_non_empty (&prd_writers_treedef, &prd->writers);
ut_avlDelete (&prd_writers_treedef, &prd->writers, m); ddsrt_avl_delete (&prd_writers_treedef, &prd->writers, m);
writer_drop_connection (&m->wr_guid, prd); writer_drop_connection (&m->wr_guid, prd);
free_prd_wr_match (m); free_prd_wr_match (m);
} }

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#include "dds/ddsi/q_ephash.h" #include "dds/ddsi/q_ephash.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_globals.h" #include "dds/ddsi/q_globals.h"
@ -25,7 +25,7 @@
#include "dds/ddsi/q_thread.h" /* for assert(thread is awake) */ #include "dds/ddsi/q_thread.h" /* for assert(thread is awake) */
struct ephash { struct ephash {
struct ut_chh *hash; struct ddsrt_chh *hash;
}; };
static const uint64_t unihashconsts[] = { static const uint64_t unihashconsts[] = {
@ -80,7 +80,7 @@ struct ephash *ephash_new (void)
{ {
struct ephash *ephash; struct ephash *ephash;
ephash = ddsrt_malloc (sizeof (*ephash)); ephash = ddsrt_malloc (sizeof (*ephash));
ephash->hash = ut_chhNew (32, hash_entity_guid_wrapper, entity_guid_eq_wrapper, gc_buckets); ephash->hash = ddsrt_chh_new (32, hash_entity_guid_wrapper, entity_guid_eq_wrapper, gc_buckets);
if (ephash->hash == NULL) { if (ephash->hash == NULL) {
ddsrt_free (ephash); ddsrt_free (ephash);
return NULL; return NULL;
@ -91,7 +91,7 @@ struct ephash *ephash_new (void)
void ephash_free (struct ephash *ephash) void ephash_free (struct ephash *ephash)
{ {
ut_chhFree (ephash->hash); ddsrt_chh_free (ephash->hash);
ephash->hash = NULL; ephash->hash = NULL;
ddsrt_free (ephash); ddsrt_free (ephash);
} }
@ -101,7 +101,7 @@ static void ephash_guid_insert (struct entity_common *e)
int x; int x;
assert(gv.guid_hash); assert(gv.guid_hash);
assert(gv.guid_hash->hash); assert(gv.guid_hash->hash);
x = ut_chhAdd (gv.guid_hash->hash, e); x = ddsrt_chh_add (gv.guid_hash->hash, e);
(void)x; (void)x;
assert (x); assert (x);
} }
@ -111,7 +111,7 @@ static void ephash_guid_remove (struct entity_common *e)
int x; int x;
assert(gv.guid_hash); assert(gv.guid_hash);
assert(gv.guid_hash->hash); assert(gv.guid_hash->hash);
x = ut_chhRemove (gv.guid_hash->hash, e); x = ddsrt_chh_remove (gv.guid_hash->hash, e);
(void)x; (void)x;
assert (x); assert (x);
} }
@ -121,7 +121,7 @@ void *ephash_lookup_guid_untyped (const struct nn_guid *guid)
/* FIXME: could (now) require guid to be first in entity_common; entity_common already is first in entity */ /* FIXME: could (now) require guid to be first in entity_common; entity_common already is first in entity */
struct entity_common e; struct entity_common e;
e.guid = *guid; e.guid = *guid;
return ut_chhLookup (gv.guid_hash->hash, &e); return ddsrt_chh_lookup (gv.guid_hash->hash, &e);
} }
static void *ephash_lookup_guid_int (const struct ephash *ephash, const struct nn_guid *guid, enum entity_kind kind) static void *ephash_lookup_guid_int (const struct ephash *ephash, const struct nn_guid *guid, enum entity_kind kind)
@ -246,9 +246,9 @@ struct proxy_reader *ephash_lookup_proxy_reader_guid (const struct nn_guid *guid
static void ephash_enum_init_int (struct ephash_enum *st, struct ephash *ephash, enum entity_kind kind) static void ephash_enum_init_int (struct ephash_enum *st, struct ephash *ephash, enum entity_kind kind)
{ {
st->kind = kind; st->kind = kind;
st->cur = ut_chhIterFirst (ephash->hash, &st->it); st->cur = ddsrt_chh_iter_first (ephash->hash, &st->it);
while (st->cur && st->cur->kind != st->kind) while (st->cur && st->cur->kind != st->kind)
st->cur = ut_chhIterNext (&st->it); st->cur = ddsrt_chh_iter_next (&st->it);
} }
void ephash_enum_init (struct ephash_enum *st, enum entity_kind kind) void ephash_enum_init (struct ephash_enum *st, enum entity_kind kind)
@ -291,9 +291,9 @@ void *ephash_enum_next (struct ephash_enum *st)
void *res = st->cur; void *res = st->cur;
if (st->cur) if (st->cur)
{ {
st->cur = ut_chhIterNext (&st->it); st->cur = ddsrt_chh_iter_next (&st->it);
while (st->cur && st->cur->kind != st->kind) while (st->cur && st->cur->kind != st->kind)
st->cur = ut_chhIterNext (&st->it); st->cur = ddsrt_chh_iter_next (&st->it);
} }
return res; return res;
} }

View file

@ -19,8 +19,8 @@
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/util/ut_thread_pool.h" #include "dds/ddsrt/thread_pool.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"
@ -895,7 +895,7 @@ int rtps_init (void)
if (config.tp_enable) if (config.tp_enable)
{ {
gv.thread_pool = ut_thread_pool_new gv.thread_pool = ddsrt_thread_pool_new
(config.tp_threads, config.tp_max_threads, 0, NULL); (config.tp_threads, config.tp_max_threads, 0, NULL);
} }
@ -1357,7 +1357,7 @@ err_find_own_ip:
ddsi_tran_factories_fini (); ddsi_tran_factories_fini ();
err_udp_tcp_init: err_udp_tcp_init:
if (config.tp_enable) if (config.tp_enable)
ut_thread_pool_free (gv.thread_pool); ddsrt_thread_pool_free (gv.thread_pool);
return -1; return -1;
} }
@ -1609,7 +1609,7 @@ void rtps_fini (void)
} }
#endif #endif
ut_thread_pool_free (gv.thread_pool); ddsrt_thread_pool_free (gv.thread_pool);
(void) joinleave_spdp_defmcip (0); (void) joinleave_spdp_defmcip (0);

View file

@ -12,14 +12,14 @@
#include <assert.h> #include <assert.h>
#include <stddef.h> #include <stddef.h>
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_config.h" #include "dds/ddsi/q_config.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
#include "dds/ddsi/q_inverse_uint32_set.h" #include "dds/ddsi/q_inverse_uint32_set.h"
static int uint32_t_cmp(const void *va, const void *vb); static int uint32_t_cmp(const void *va, const void *vb);
static ut_avlTreedef_t inverse_uint32_set_td = UT_AVL_TREEDEF_INITIALIZER(offsetof(struct inverse_uint32_set_node, avlnode), offsetof(struct inverse_uint32_set_node, min), uint32_t_cmp, 0); static ddsrt_avl_treedef_t inverse_uint32_set_td = DDSRT_AVL_TREEDEF_INITIALIZER(offsetof(struct inverse_uint32_set_node, avlnode), offsetof(struct inverse_uint32_set_node, min), uint32_t_cmp, 0);
static int uint32_t_cmp(const void *va, const void *vb) static int uint32_t_cmp(const void *va, const void *vb)
{ {
@ -31,12 +31,12 @@ static int uint32_t_cmp(const void *va, const void *vb)
static void check(const struct inverse_uint32_set *set) static void check(const struct inverse_uint32_set *set)
{ {
#ifndef NDEBUG #ifndef NDEBUG
ut_avlIter_t it; ddsrt_avl_iter_t it;
struct inverse_uint32_set_node *pn = NULL, *n; struct inverse_uint32_set_node *pn = NULL, *n;
assert(set->min <= set->max); assert(set->min <= set->max);
assert(set->cursor >= set->min); assert(set->cursor >= set->min);
assert(set->cursor <= set->max); assert(set->cursor <= set->max);
for (n = ut_avlIterFirst(&inverse_uint32_set_td, &set->ids, &it); n; pn = n, n = ut_avlIterNext(&it)) for (n = ddsrt_avl_iter_first(&inverse_uint32_set_td, &set->ids, &it); n; pn = n, n = ddsrt_avl_iter_next(&it))
{ {
assert(n->min <= n->max); assert(n->min <= n->max);
assert(n->min >= set->min); assert(n->min >= set->min);
@ -51,20 +51,20 @@ static void check(const struct inverse_uint32_set *set)
void inverse_uint32_set_init(struct inverse_uint32_set *set, uint32_t min, uint32_t max) void inverse_uint32_set_init(struct inverse_uint32_set *set, uint32_t min, uint32_t max)
{ {
struct inverse_uint32_set_node *n; struct inverse_uint32_set_node *n;
ut_avlInit(&inverse_uint32_set_td, &set->ids); ddsrt_avl_init(&inverse_uint32_set_td, &set->ids);
set->cursor = min; set->cursor = min;
set->min = min; set->min = min;
set->max = max; set->max = max;
n = ddsrt_malloc(sizeof(*n)); n = ddsrt_malloc(sizeof(*n));
n->min = min; n->min = min;
n->max = max; n->max = max;
ut_avlInsert(&inverse_uint32_set_td, &set->ids, n); ddsrt_avl_insert(&inverse_uint32_set_td, &set->ids, n);
check(set); check(set);
} }
void inverse_uint32_set_fini(struct inverse_uint32_set *set) void inverse_uint32_set_fini(struct inverse_uint32_set *set)
{ {
ut_avlFree(&inverse_uint32_set_td, &set->ids, ddsrt_free); ddsrt_avl_free(&inverse_uint32_set_td, &set->ids, ddsrt_free);
} }
static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set, struct inverse_uint32_set_node *n) static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set, struct inverse_uint32_set_node *n)
@ -72,7 +72,7 @@ static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set,
const uint32_t id = n->min; const uint32_t id = n->min;
if (n->min == n->max) if (n->min == n->max)
{ {
ut_avlDelete(&inverse_uint32_set_td, &set->ids, n); ddsrt_avl_delete(&inverse_uint32_set_td, &set->ids, n);
ddsrt_free(n); ddsrt_free(n);
} }
else else
@ -86,7 +86,7 @@ static uint32_t inverse_uint32_set_alloc_use_min(struct inverse_uint32_set *set,
int inverse_uint32_set_alloc(uint32_t * const id, struct inverse_uint32_set *set) int inverse_uint32_set_alloc(uint32_t * const id, struct inverse_uint32_set *set)
{ {
struct inverse_uint32_set_node *n; struct inverse_uint32_set_node *n;
if ((n = ut_avlLookupPredEq(&inverse_uint32_set_td, &set->ids, &set->cursor)) != NULL && set->cursor <= n->max) { if ((n = ddsrt_avl_lookup_pred_eq(&inverse_uint32_set_td, &set->ids, &set->cursor)) != NULL && set->cursor <= n->max) {
/* n is [a,b] s.t. a <= C <= b, so C is available */ /* n is [a,b] s.t. a <= C <= b, so C is available */
*id = set->cursor; *id = set->cursor;
if (n->min == set->cursor) if (n->min == set->cursor)
@ -105,15 +105,15 @@ int inverse_uint32_set_alloc(uint32_t * const id, struct inverse_uint32_set *set
n1->min = set->cursor + 1; n1->min = set->cursor + 1;
n1->max = n->max; n1->max = n->max;
n->max = set->cursor - 1; n->max = set->cursor - 1;
ut_avlInsert(&inverse_uint32_set_td, &set->ids, n1); ddsrt_avl_insert(&inverse_uint32_set_td, &set->ids, n1);
} }
} }
else if ((n = ut_avlLookupSucc(&inverse_uint32_set_td, &set->ids, &set->cursor)) != NULL) else if ((n = ddsrt_avl_lookup_succ(&inverse_uint32_set_td, &set->ids, &set->cursor)) != NULL)
{ {
/* n is [a,b] s.t. a > C and all intervals [a',b'] in tree have a' <= C */ /* n is [a,b] s.t. a > C and all intervals [a',b'] in tree have a' <= C */
*id = inverse_uint32_set_alloc_use_min(set, n); *id = inverse_uint32_set_alloc_use_min(set, n);
} }
else if ((n = ut_avlFindMin(&inverse_uint32_set_td, &set->ids)) != NULL) else if ((n = ddsrt_avl_find_min(&inverse_uint32_set_td, &set->ids)) != NULL)
{ {
/* no available ids >= cursor: wrap around and use the first available */ /* no available ids >= cursor: wrap around and use the first available */
assert(n->max < set->cursor); assert(n->max < set->cursor);
@ -133,8 +133,8 @@ void inverse_uint32_set_free(struct inverse_uint32_set *set, uint32_t id)
{ {
struct inverse_uint32_set_node *n; struct inverse_uint32_set_node *n;
const uint32_t idp1 = id + 1; const uint32_t idp1 = id + 1;
ut_avlIPath_t ip; ddsrt_avl_ipath_t ip;
if ((n = ut_avlLookupPredEq(&inverse_uint32_set_td, &set->ids, &id)) != NULL && id <= n->max + 1) { if ((n = ddsrt_avl_lookup_pred_eq(&inverse_uint32_set_td, &set->ids, &id)) != NULL && id <= n->max + 1) {
if (id <= n->max) if (id <= n->max)
{ {
/* n is [a,b] s.t. a <= I <= b: so it is already in the set */ /* n is [a,b] s.t. a <= I <= b: so it is already in the set */
@ -143,18 +143,18 @@ void inverse_uint32_set_free(struct inverse_uint32_set *set, uint32_t id)
else else
{ {
struct inverse_uint32_set_node *n1; struct inverse_uint32_set_node *n1;
ut_avlDPath_t dp; ddsrt_avl_dpath_t dp;
/* grow the interval, possibly coalesce with next */ /* grow the interval, possibly coalesce with next */
if ((n1 = ut_avlLookupDPath(&inverse_uint32_set_td, &set->ids, &idp1, &dp)) == NULL) { if ((n1 = ddsrt_avl_lookup_dpath(&inverse_uint32_set_td, &set->ids, &idp1, &dp)) == NULL) {
n->max = id; n->max = id;
} else { } else {
n->max = n1->max; n->max = n1->max;
ut_avlDeleteDPath(&inverse_uint32_set_td, &set->ids, n1, &dp); ddsrt_avl_delete_dpath(&inverse_uint32_set_td, &set->ids, n1, &dp);
ddsrt_free(n1); ddsrt_free(n1);
} }
} }
} }
else if ((n = ut_avlLookupIPath(&inverse_uint32_set_td, &set->ids, &idp1, &ip)) != NULL) { else if ((n = ddsrt_avl_lookup_ipath(&inverse_uint32_set_td, &set->ids, &idp1, &ip)) != NULL) {
/* changing the key in-place here: the key value may be changing, but the structure of the tree is not or the previous case would have applied */ /* changing the key in-place here: the key value may be changing, but the structure of the tree is not or the previous case would have applied */
n->min = id; n->min = id;
} }
@ -163,7 +163,7 @@ void inverse_uint32_set_free(struct inverse_uint32_set *set, uint32_t id)
/* no adjacent interval */ /* no adjacent interval */
n = ddsrt_malloc(sizeof(*n)); n = ddsrt_malloc(sizeof(*n));
n->min = n->max = id; n->min = n->max = id;
ut_avlInsertIPath(&inverse_uint32_set_td, &set->ids, n, &ip); ddsrt_avl_insert_ipath(&inverse_uint32_set_td, &set->ids, n, &ip);
} }
check(set); check(set);
} }

View file

@ -16,7 +16,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_fibheap.h" #include "dds/ddsrt/fibheap.h"
#include "dds/ddsi/ddsi_serdata_default.h" #include "dds/ddsi/ddsi_serdata_default.h"
#include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_protocol.h"
@ -44,7 +44,7 @@
#define TSCHED_NOT_ON_HEAP INT64_MIN #define TSCHED_NOT_ON_HEAP INT64_MIN
struct lease { struct lease {
ut_fibheapNode_t heapnode; ddsrt_fibheap_node_t heapnode;
nn_etime_t tsched; /* access guarded by leaseheap_lock */ nn_etime_t tsched; /* access guarded by leaseheap_lock */
nn_etime_t tend; /* access guarded by lock_lease/unlock_lease */ nn_etime_t tend; /* access guarded by lock_lease/unlock_lease */
int64_t tdur; /* constant (renew depends on it) */ int64_t tdur; /* constant (renew depends on it) */
@ -53,7 +53,7 @@ struct lease {
static int compare_lease_tsched (const void *va, const void *vb); static int compare_lease_tsched (const void *va, const void *vb);
static const ut_fibheapDef_t lease_fhdef = UT_FIBHEAPDEF_INITIALIZER(offsetof (struct lease, heapnode), compare_lease_tsched); static const ddsrt_fibheap_def_t lease_fhdef = DDSRT_FIBHEAPDEF_INITIALIZER(offsetof (struct lease, heapnode), compare_lease_tsched);
static void force_lease_check (void) static void force_lease_check (void)
{ {
@ -73,13 +73,13 @@ void lease_management_init (void)
ddsrt_mutex_init (&gv.leaseheap_lock); ddsrt_mutex_init (&gv.leaseheap_lock);
for (i = 0; i < N_LEASE_LOCKS; i++) for (i = 0; i < N_LEASE_LOCKS; i++)
ddsrt_mutex_init (&gv.lease_locks[i]); ddsrt_mutex_init (&gv.lease_locks[i]);
ut_fibheapInit (&lease_fhdef, &gv.leaseheap); ddsrt_fibheap_init (&lease_fhdef, &gv.leaseheap);
} }
void lease_management_term (void) void lease_management_term (void)
{ {
int i; int i;
assert (ut_fibheapMin (&lease_fhdef, &gv.leaseheap) == NULL); assert (ddsrt_fibheap_min (&lease_fhdef, &gv.leaseheap) == NULL);
for (i = 0; i < N_LEASE_LOCKS; i++) for (i = 0; i < N_LEASE_LOCKS; i++)
ddsrt_mutex_destroy (&gv.lease_locks[i]); ddsrt_mutex_destroy (&gv.lease_locks[i]);
ddsrt_mutex_destroy (&gv.leaseheap_lock); ddsrt_mutex_destroy (&gv.leaseheap_lock);
@ -125,7 +125,7 @@ void lease_register (struct lease *l)
if (l->tend.v != T_NEVER) if (l->tend.v != T_NEVER)
{ {
l->tsched = l->tend; l->tsched = l->tend;
ut_fibheapInsert (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_insert (&lease_fhdef, &gv.leaseheap, l);
} }
unlock_lease (l); unlock_lease (l);
ddsrt_mutex_unlock (&gv.leaseheap_lock); ddsrt_mutex_unlock (&gv.leaseheap_lock);
@ -139,7 +139,7 @@ void lease_free (struct lease *l)
DDS_TRACE("lease_free(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid)); DDS_TRACE("lease_free(l %p guid %x:%x:%x:%x)\n", (void *) l, PGUID (l->entity->guid));
ddsrt_mutex_lock (&gv.leaseheap_lock); ddsrt_mutex_lock (&gv.leaseheap_lock);
if (l->tsched.v != TSCHED_NOT_ON_HEAP) if (l->tsched.v != TSCHED_NOT_ON_HEAP)
ut_fibheapDelete (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_delete (&lease_fhdef, &gv.leaseheap, l);
ddsrt_mutex_unlock (&gv.leaseheap_lock); ddsrt_mutex_unlock (&gv.leaseheap_lock);
ddsrt_free (l); ddsrt_free (l);
@ -187,14 +187,14 @@ void lease_set_expiry (struct lease *l, nn_etime_t when)
/* moved forward and currently scheduled (by virtue of /* moved forward and currently scheduled (by virtue of
TSCHED_NOT_ON_HEAP == INT64_MIN) */ TSCHED_NOT_ON_HEAP == INT64_MIN) */
l->tsched = l->tend; l->tsched = l->tend;
ut_fibheapDecreaseKey (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_decrease_key (&lease_fhdef, &gv.leaseheap, l);
trigger = true; trigger = true;
} }
else if (l->tsched.v == TSCHED_NOT_ON_HEAP && l->tend.v < T_NEVER) else if (l->tsched.v == TSCHED_NOT_ON_HEAP && l->tend.v < T_NEVER)
{ {
/* not currently scheduled, with a finite new expiry time */ /* not currently scheduled, with a finite new expiry time */
l->tsched = l->tend; l->tsched = l->tend;
ut_fibheapInsert (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_insert (&lease_fhdef, &gv.leaseheap, l);
trigger = true; trigger = true;
} }
unlock_lease (l); unlock_lease (l);
@ -210,13 +210,13 @@ int64_t check_and_handle_lease_expiration (nn_etime_t tnowE)
struct lease *l; struct lease *l;
int64_t delay; int64_t delay;
ddsrt_mutex_lock (&gv.leaseheap_lock); ddsrt_mutex_lock (&gv.leaseheap_lock);
while ((l = ut_fibheapMin (&lease_fhdef, &gv.leaseheap)) != NULL && l->tsched.v <= tnowE.v) while ((l = ddsrt_fibheap_min (&lease_fhdef, &gv.leaseheap)) != NULL && l->tsched.v <= tnowE.v)
{ {
nn_guid_t g = l->entity->guid; nn_guid_t g = l->entity->guid;
enum entity_kind k = l->entity->kind; enum entity_kind k = l->entity->kind;
assert (l->tsched.v != TSCHED_NOT_ON_HEAP); assert (l->tsched.v != TSCHED_NOT_ON_HEAP);
ut_fibheapExtractMin (&lease_fhdef, &gv.leaseheap); ddsrt_fibheap_extract_min (&lease_fhdef, &gv.leaseheap);
lock_lease (l); lock_lease (l);
if (tnowE.v < l->tend.v) if (tnowE.v < l->tend.v)
@ -228,7 +228,7 @@ int64_t check_and_handle_lease_expiration (nn_etime_t tnowE)
} else { } else {
l->tsched = l->tend; l->tsched = l->tend;
unlock_lease (l); unlock_lease (l);
ut_fibheapInsert (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_insert (&lease_fhdef, &gv.leaseheap, l);
} }
continue; continue;
} }
@ -270,7 +270,7 @@ int64_t check_and_handle_lease_expiration (nn_etime_t tnowE)
PGUID (proxypp->privileged_pp_guid)); PGUID (proxypp->privileged_pp_guid));
l->tsched = l->tend = add_duration_to_etime (tnowE, 200 * T_MILLISECOND); l->tsched = l->tend = add_duration_to_etime (tnowE, 200 * T_MILLISECOND);
unlock_lease (l); unlock_lease (l);
ut_fibheapInsert (&lease_fhdef, &gv.leaseheap, l); ddsrt_fibheap_insert (&lease_fhdef, &gv.leaseheap, l);
continue; continue;
} }
} }

View file

@ -31,7 +31,7 @@
#include "dds/ddsi/q_addrset.h" /* unspec locator */ #include "dds/ddsi/q_addrset.h" /* unspec locator */
#include "dds/ddsi/q_feature_check.h" #include "dds/ddsi/q_feature_check.h"
#include "dds/ddsi/ddsi_ipaddr.h" #include "dds/ddsi/ddsi_ipaddr.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
static void print_sockerror (const char *msg) static void print_sockerror (const char *msg)
{ {

View file

@ -32,7 +32,7 @@
#include "dds/ddsi/q_radmin.h" /* for nn_plist_quickscan */ #include "dds/ddsi/q_radmin.h" /* for nn_plist_quickscan */
#include "dds/ddsi/q_static_assert.h" #include "dds/ddsi/q_static_assert.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_misc.h" /* for vendor_is_... */ #include "dds/ddsi/q_misc.h" /* for vendor_is_... */
/* These are internal to the parameter list processing. We never /* These are internal to the parameter list processing. We never

View file

@ -28,7 +28,7 @@
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.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"
@ -812,7 +812,7 @@ static void nn_rdata_unref (struct nn_rdata *rdata)
anyway). */ anyway). */
struct nn_defrag_iv { struct nn_defrag_iv {
ut_avlNode_t avlnode; /* for nn_rsample.defrag::fragtree */ ddsrt_avl_node_t avlnode; /* for nn_rsample.defrag::fragtree */
uint32_t min, maxp1; uint32_t min, maxp1;
struct nn_rdata *first; struct nn_rdata *first;
struct nn_rdata *last; struct nn_rdata *last;
@ -821,14 +821,14 @@ struct nn_defrag_iv {
struct nn_rsample { struct nn_rsample {
union { union {
struct nn_rsample_defrag { struct nn_rsample_defrag {
ut_avlNode_t avlnode; /* for nn_defrag::sampletree */ ddsrt_avl_node_t avlnode; /* for nn_defrag::sampletree */
ut_avlTree_t fragtree; ddsrt_avl_tree_t fragtree;
struct nn_defrag_iv *lastfrag; struct nn_defrag_iv *lastfrag;
struct nn_rsample_info *sampleinfo; struct nn_rsample_info *sampleinfo;
seqno_t seq; seqno_t seq;
} defrag; } defrag;
struct nn_rsample_reorder { struct nn_rsample_reorder {
ut_avlNode_t avlnode; /* for nn_reorder::sampleivtree, if head of a chain */ ddsrt_avl_node_t avlnode; /* for nn_reorder::sampleivtree, if head of a chain */
struct nn_rsample_chain sc; /* this interval's samples, covering ... */ struct nn_rsample_chain sc; /* this interval's samples, covering ... */
seqno_t min, maxp1; /* ... seq nos: [min,maxp1), but possibly with holes in it */ seqno_t min, maxp1; /* ... seq nos: [min,maxp1), but possibly with holes in it */
uint32_t n_samples; /* so this is the actual length of the chain */ uint32_t n_samples; /* so this is the actual length of the chain */
@ -837,7 +837,7 @@ struct nn_rsample {
}; };
struct nn_defrag { struct nn_defrag {
ut_avlTree_t sampletree; ddsrt_avl_tree_t sampletree;
struct nn_rsample *max_sample; /* = max(sampletree) */ struct nn_rsample *max_sample; /* = max(sampletree) */
uint32_t n_samples; uint32_t n_samples;
uint32_t max_samples; uint32_t max_samples;
@ -847,8 +847,8 @@ struct nn_defrag {
static int compare_uint32 (const void *va, const void *vb); static int compare_uint32 (const void *va, const void *vb);
static int compare_seqno (const void *va, const void *vb); static int compare_seqno (const void *va, const void *vb);
static const ut_avlTreedef_t defrag_sampletree_treedef = UT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_rsample, u.defrag.avlnode), offsetof (struct nn_rsample, u.defrag.seq), compare_seqno, 0); static const ddsrt_avl_treedef_t defrag_sampletree_treedef = DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_rsample, u.defrag.avlnode), offsetof (struct nn_rsample, u.defrag.seq), compare_seqno, 0);
static const ut_avlTreedef_t rsample_defrag_fragtree_treedef = UT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_defrag_iv, avlnode), offsetof (struct nn_defrag_iv, min), compare_uint32, 0); static const ddsrt_avl_treedef_t rsample_defrag_fragtree_treedef = DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_defrag_iv, avlnode), offsetof (struct nn_defrag_iv, min), compare_uint32, 0);
static int compare_uint32 (const void *va, const void *vb) static int compare_uint32 (const void *va, const void *vb)
{ {
@ -870,7 +870,7 @@ struct nn_defrag *nn_defrag_new (enum nn_defrag_drop_mode drop_mode, uint32_t ma
assert (max_samples >= 1); assert (max_samples >= 1);
if ((d = ddsrt_malloc (sizeof (*d))) == NULL) if ((d = ddsrt_malloc (sizeof (*d))) == NULL)
return NULL; return NULL;
ut_avlInit (&defrag_sampletree_treedef, &d->sampletree); ddsrt_avl_init (&defrag_sampletree_treedef, &d->sampletree);
d->drop_mode = drop_mode; d->drop_mode = drop_mode;
d->max_samples = max_samples; d->max_samples = max_samples;
d->n_samples = 0; d->n_samples = 0;
@ -903,25 +903,25 @@ static void defrag_rsample_drop (struct nn_defrag *defrag, struct nn_rsample *rs
So we need to walk the fragments while guaranteeing strict So we need to walk the fragments while guaranteeing strict
"forward progress" in the memory accesses, which this particular "forward progress" in the memory accesses, which this particular
inorder treewalk does provide. */ inorder treewalk does provide. */
ut_avlIter_t iter; ddsrt_avl_iter_t iter;
struct nn_defrag_iv *iv; struct nn_defrag_iv *iv;
DDS_LOG(DDS_LC_RADMIN, " defrag_rsample_drop (%p, %p)\n", (void *) defrag, (void *) rsample); DDS_LOG(DDS_LC_RADMIN, " defrag_rsample_drop (%p, %p)\n", (void *) defrag, (void *) rsample);
ut_avlDelete (&defrag_sampletree_treedef, &defrag->sampletree, rsample); ddsrt_avl_delete (&defrag_sampletree_treedef, &defrag->sampletree, rsample);
assert (defrag->n_samples > 0); assert (defrag->n_samples > 0);
defrag->n_samples--; defrag->n_samples--;
for (iv = ut_avlIterFirst (&rsample_defrag_fragtree_treedef, &rsample->u.defrag.fragtree, &iter); iv; iv = ut_avlIterNext (&iter)) for (iv = ddsrt_avl_iter_first (&rsample_defrag_fragtree_treedef, &rsample->u.defrag.fragtree, &iter); iv; iv = ddsrt_avl_iter_next (&iter))
nn_fragchain_rmbias (iv->first); nn_fragchain_rmbias (iv->first);
} }
void nn_defrag_free (struct nn_defrag *defrag) void nn_defrag_free (struct nn_defrag *defrag)
{ {
struct nn_rsample *s; struct nn_rsample *s;
s = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); s = ddsrt_avl_find_min (&defrag_sampletree_treedef, &defrag->sampletree);
while (s) while (s)
{ {
DDS_LOG(DDS_LC_RADMIN, "defrag_free(%p, sample %p seq %"PRId64")\n", (void *) defrag, (void *) s, s->u.defrag.seq); DDS_LOG(DDS_LC_RADMIN, "defrag_free(%p, sample %p seq %"PRId64")\n", (void *) defrag, (void *) s, s->u.defrag.seq);
defrag_rsample_drop (defrag, s); defrag_rsample_drop (defrag, s);
s = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); s = ddsrt_avl_find_min (&defrag_sampletree_treedef, &defrag->sampletree);
} }
assert (defrag->n_samples == 0); assert (defrag->n_samples == 0);
ddsrt_free (defrag); ddsrt_free (defrag);
@ -940,7 +940,7 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct
return 0; return 0;
} }
succ = ut_avlFindSucc (&rsample_defrag_fragtree_treedef, &sample->fragtree, node); succ = ddsrt_avl_find_succ (&rsample_defrag_fragtree_treedef, &sample->fragtree, node);
assert (succ != NULL); assert (succ != NULL);
DDS_LOG(DDS_LC_RADMIN, " succ is %p [%u..%u)\n", (void *) succ, succ->min, succ->maxp1); DDS_LOG(DDS_LC_RADMIN, " succ is %p [%u..%u)\n", (void *) succ, succ->min, succ->maxp1);
if (succ->min > node->maxp1) if (succ->min > node->maxp1)
@ -955,7 +955,7 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct
/* no longer a gap between node & succ => succ will be removed /* no longer a gap between node & succ => succ will be removed
from the interval tree and therefore node will become the from the interval tree and therefore node will become the
last interval if succ currently is */ last interval if succ currently is */
ut_avlDelete (&rsample_defrag_fragtree_treedef, &sample->fragtree, succ); ddsrt_avl_delete (&rsample_defrag_fragtree_treedef, &sample->fragtree, succ);
if (sample->lastfrag == succ) if (sample->lastfrag == succ)
{ {
DDS_LOG(DDS_LC_RADMIN, " succ is lastfrag\n"); DDS_LOG(DDS_LC_RADMIN, " succ is lastfrag\n");
@ -987,7 +987,7 @@ static int defrag_try_merge_with_succ (struct nn_rsample_defrag *sample, struct
} }
} }
static void defrag_rsample_addiv (struct nn_rsample_defrag *sample, struct nn_rdata *rdata, ut_avlIPath_t *path) static void defrag_rsample_addiv (struct nn_rsample_defrag *sample, struct nn_rdata *rdata, ddsrt_avl_ipath_t *path)
{ {
struct nn_defrag_iv *newiv; struct nn_defrag_iv *newiv;
if ((newiv = nn_rmsg_alloc (rdata->rmsg, sizeof (*newiv))) == NULL) if ((newiv = nn_rmsg_alloc (rdata->rmsg, sizeof (*newiv))) == NULL)
@ -997,7 +997,7 @@ static void defrag_rsample_addiv (struct nn_rsample_defrag *sample, struct nn_rd
newiv->min = rdata->min; newiv->min = rdata->min;
newiv->maxp1 = rdata->maxp1; newiv->maxp1 = rdata->maxp1;
nn_rdata_addbias (rdata); nn_rdata_addbias (rdata);
ut_avlInsertIPath (&rsample_defrag_fragtree_treedef, &sample->fragtree, newiv, path); ddsrt_avl_insert_ipath (&rsample_defrag_fragtree_treedef, &sample->fragtree, newiv, path);
if (sample->lastfrag == NULL || rdata->min > sample->lastfrag->min) if (sample->lastfrag == NULL || rdata->min > sample->lastfrag->min)
sample->lastfrag = newiv; sample->lastfrag = newiv;
} }
@ -1010,7 +1010,7 @@ static struct nn_rsample *defrag_rsample_new (struct nn_rdata *rdata, const stru
{ {
struct nn_rsample *rsample; struct nn_rsample *rsample;
struct nn_rsample_defrag *dfsample; struct nn_rsample_defrag *dfsample;
ut_avlIPath_t ivpath; ddsrt_avl_ipath_t ivpath;
if ((rsample = nn_rmsg_alloc (rdata->rmsg, sizeof (*rsample))) == NULL) if ((rsample = nn_rmsg_alloc (rdata->rmsg, sizeof (*rsample))) == NULL)
return NULL; return NULL;
@ -1022,7 +1022,7 @@ static struct nn_rsample *defrag_rsample_new (struct nn_rdata *rdata, const stru
return NULL; return NULL;
*dfsample->sampleinfo = *sampleinfo; *dfsample->sampleinfo = *sampleinfo;
ut_avlInit (&rsample_defrag_fragtree_treedef, &dfsample->fragtree); ddsrt_avl_init (&rsample_defrag_fragtree_treedef, &dfsample->fragtree);
/* add sentinel if rdata is not the first fragment of the message */ /* add sentinel if rdata is not the first fragment of the message */
if (rdata->min > 0) if (rdata->min > 0)
@ -1032,12 +1032,12 @@ static struct nn_rsample *defrag_rsample_new (struct nn_rdata *rdata, const stru
return NULL; return NULL;
sentinel->first = sentinel->last = NULL; sentinel->first = sentinel->last = NULL;
sentinel->min = sentinel->maxp1 = 0; sentinel->min = sentinel->maxp1 = 0;
ut_avlLookupIPath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &sentinel->min, &ivpath); ddsrt_avl_lookup_ipath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &sentinel->min, &ivpath);
ut_avlInsertIPath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, sentinel, &ivpath); ddsrt_avl_insert_ipath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, sentinel, &ivpath);
} }
/* add an interval for the first received fragment */ /* add an interval for the first received fragment */
ut_avlLookupIPath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &rdata->min, &ivpath); ddsrt_avl_lookup_ipath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &rdata->min, &ivpath);
defrag_rsample_addiv (dfsample, rdata, &ivpath); defrag_rsample_addiv (dfsample, rdata, &ivpath);
return rsample; return rsample;
} }
@ -1084,7 +1084,7 @@ static int is_complete (const struct nn_rsample_defrag *sample)
one interval covering all bytes. One interval because of the one interval covering all bytes. One interval because of the
greedy coalescing in add_fragment(). There is at least one greedy coalescing in add_fragment(). There is at least one
interval if we get here. */ interval if we get here. */
const struct nn_defrag_iv *iv = ut_avlRoot (&rsample_defrag_fragtree_treedef, &sample->fragtree); const struct nn_defrag_iv *iv = ddsrt_avl_root (&rsample_defrag_fragtree_treedef, &sample->fragtree);
assert (iv != NULL); assert (iv != NULL);
if (iv->min == 0 && iv->maxp1 >= sample->sampleinfo->size) if (iv->min == 0 && iv->maxp1 >= sample->sampleinfo->size)
{ {
@ -1094,7 +1094,7 @@ static int is_complete (const struct nn_rsample_defrag *sample)
samples that will never be completed; dropping them in the samples that will never be completed; dropping them in the
defragmenter would be feasible by discarding all fragments of defragmenter would be feasible by discarding all fragments of
that sample collected so far. */ that sample collected so far. */
assert (ut_avlIsSingleton (&sample->fragtree)); assert (ddsrt_avl_is_singleton (&sample->fragtree));
return 1; return 1;
} }
else else
@ -1111,14 +1111,14 @@ static void rsample_convert_defrag_to_reorder (struct nn_rsample *sample)
self-respecting compiler will optimise them away, and any self-respecting compiler will optimise them away, and any
self-respecting CPU would need to copy them via registers anyway self-respecting CPU would need to copy them via registers anyway
because it uses a load-store architecture. */ because it uses a load-store architecture. */
struct nn_defrag_iv *iv = ut_avlRootNonEmpty (&rsample_defrag_fragtree_treedef, &sample->u.defrag.fragtree); struct nn_defrag_iv *iv = ddsrt_avl_root_non_empty (&rsample_defrag_fragtree_treedef, &sample->u.defrag.fragtree);
struct nn_rdata *fragchain = iv->first; struct nn_rdata *fragchain = iv->first;
struct nn_rsample_info *sampleinfo = sample->u.defrag.sampleinfo; struct nn_rsample_info *sampleinfo = sample->u.defrag.sampleinfo;
struct nn_rsample_chain_elem *sce; struct nn_rsample_chain_elem *sce;
seqno_t seq = sample->u.defrag.seq; seqno_t seq = sample->u.defrag.seq;
/* re-use memory fragment interval node for sample chain */ /* re-use memory fragment interval node for sample chain */
sce = (struct nn_rsample_chain_elem *) ut_avlRootNonEmpty (&rsample_defrag_fragtree_treedef, &sample->u.defrag.fragtree); sce = (struct nn_rsample_chain_elem *) ddsrt_avl_root_non_empty (&rsample_defrag_fragtree_treedef, &sample->u.defrag.fragtree);
sce->fragchain = fragchain; sce->fragchain = fragchain;
sce->next = NULL; sce->next = NULL;
sce->sampleinfo = sampleinfo; sce->sampleinfo = sampleinfo;
@ -1145,7 +1145,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct
/* there must be a last fragment */ /* there must be a last fragment */
assert (dfsample->lastfrag); assert (dfsample->lastfrag);
/* relatively expensive test: lastfrag, tree must be consistent */ /* relatively expensive test: lastfrag, tree must be consistent */
assert (dfsample->lastfrag == ut_avlFindMax (&rsample_defrag_fragtree_treedef, &dfsample->fragtree)); assert (dfsample->lastfrag == ddsrt_avl_find_max (&rsample_defrag_fragtree_treedef, &dfsample->fragtree));
DDS_LOG(DDS_LC_RADMIN, " lastfrag %p [%u..%u)\n", DDS_LOG(DDS_LC_RADMIN, " lastfrag %p [%u..%u)\n",
(void *) dfsample->lastfrag, (void *) dfsample->lastfrag,
@ -1162,7 +1162,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct
else else
{ {
/* Slow path: find preceding fragment by tree search */ /* Slow path: find preceding fragment by tree search */
predeq = ut_avlLookupPredEq (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min); predeq = ddsrt_avl_lookup_pred_eq (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min);
assert (predeq); assert (predeq);
DDS_LOG(DDS_LC_RADMIN, " slow path: predeq = lookup %u => %p [%u..%u)\n", DDS_LOG(DDS_LC_RADMIN, " slow path: predeq = lookup %u => %p [%u..%u)\n",
min, (void *) predeq, predeq->min, predeq->maxp1); min, (void *) predeq, predeq->min, predeq->maxp1);
@ -1206,7 +1206,7 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct
return is_complete (dfsample) ? sample : NULL; return is_complete (dfsample) ? sample : NULL;
} }
else if (predeq != dfsample->lastfrag && /* if predeq is last frag, there is no succ */ else if (predeq != dfsample->lastfrag && /* if predeq is last frag, there is no succ */
(succ = ut_avlFindSucc (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, predeq)) != NULL && (succ = ddsrt_avl_find_succ (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, predeq)) != NULL &&
succ->min <= maxp1) succ->min <= maxp1)
{ {
/* extends succ (at the low end; no guarantee each individual /* extends succ (at the low end; no guarantee each individual
@ -1236,9 +1236,9 @@ static struct nn_rsample *defrag_add_fragment (struct nn_rsample *sample, struct
{ {
/* doesn't extend either predeq at the end or succ at the head => /* doesn't extend either predeq at the end or succ at the head =>
new interval; rdata did not cause completion of sample */ new interval; rdata did not cause completion of sample */
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
DDS_LOG(DDS_LC_RADMIN, " new interval\n"); DDS_LOG(DDS_LC_RADMIN, " new interval\n");
if (ut_avlLookupIPath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min, &path)) if (ddsrt_avl_lookup_ipath (&rsample_defrag_fragtree_treedef, &dfsample->fragtree, &min, &path))
assert (0); assert (0);
defrag_rsample_addiv (dfsample, rdata, &path); defrag_rsample_addiv (dfsample, rdata, &path);
return NULL; return NULL;
@ -1274,7 +1274,7 @@ static int defrag_limit_samples (struct nn_defrag *defrag, seqno_t seq, seqno_t
break; break;
case NN_DEFRAG_DROP_OLDEST: case NN_DEFRAG_DROP_OLDEST:
DDS_LOG(DDS_LC_RADMIN, " drop mode = DROP_OLDEST\n"); DDS_LOG(DDS_LC_RADMIN, " drop mode = DROP_OLDEST\n");
sample_to_drop = ut_avlFindMin (&defrag_sampletree_treedef, &defrag->sampletree); sample_to_drop = ddsrt_avl_find_min (&defrag_sampletree_treedef, &defrag->sampletree);
assert (sample_to_drop); assert (sample_to_drop);
if (seq < sample_to_drop->u.defrag.seq) if (seq < sample_to_drop->u.defrag.seq)
{ {
@ -1287,7 +1287,7 @@ static int defrag_limit_samples (struct nn_defrag *defrag, seqno_t seq, seqno_t
defrag_rsample_drop (defrag, sample_to_drop); defrag_rsample_drop (defrag, sample_to_drop);
if (sample_to_drop == defrag->max_sample) if (sample_to_drop == defrag->max_sample)
{ {
defrag->max_sample = ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree); defrag->max_sample = ddsrt_avl_find_max (&defrag_sampletree_treedef, &defrag->sampletree);
*max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0; *max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0;
DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n", DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n",
(void *) defrag->max_sample, (void *) defrag->max_sample,
@ -1322,7 +1322,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata
by adding BIAS to the refcount. */ by adding BIAS to the refcount. */
struct nn_rsample *sample, *result; struct nn_rsample *sample, *result;
seqno_t max_seq; seqno_t max_seq;
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
assert (defrag->n_samples <= defrag->max_samples); assert (defrag->n_samples <= defrag->max_samples);
@ -1334,7 +1334,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata
/* max_seq is used for the fast path, and is 0 when there is no /* max_seq is used for the fast path, and is 0 when there is no
last message in 'defrag'. max_seq and max_sample must be last message in 'defrag'. max_seq and max_sample must be
consistent. Max_sample must be consistent with tree */ consistent. Max_sample must be consistent with tree */
assert (defrag->max_sample == ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree)); assert (defrag->max_sample == ddsrt_avl_find_max (&defrag_sampletree_treedef, &defrag->sampletree));
max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0; max_seq = defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0;
DDS_LOG(DDS_LC_RADMIN, "defrag_rsample(%p, %p [%u..%u) msg %p, %p seq %"PRId64" size %u) max_seq %p %"PRId64":\n", DDS_LOG(DDS_LC_RADMIN, "defrag_rsample(%p, %p [%u..%u) msg %p, %p seq %"PRId64" size %u) max_seq %p %"PRId64":\n",
(void *) defrag, (void *) rdata, rdata->min, rdata->maxp1, (void *) rdata->rmsg, (void *) defrag, (void *) rdata, rdata->min, rdata->maxp1, (void *) rdata->rmsg,
@ -1358,22 +1358,22 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata
child of the old maximum node */ child of the old maximum node */
/* FIXME: MERGE THIS ONE WITH THE NEXT */ /* FIXME: MERGE THIS ONE WITH THE NEXT */
DDS_LOG(DDS_LC_RADMIN, " new max sample\n"); DDS_LOG(DDS_LC_RADMIN, " new max sample\n");
ut_avlLookupIPath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path); ddsrt_avl_lookup_ipath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path);
if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL) if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL)
return NULL; return NULL;
ut_avlInsertIPath (&defrag_sampletree_treedef, &defrag->sampletree, sample, &path); ddsrt_avl_insert_ipath (&defrag_sampletree_treedef, &defrag->sampletree, sample, &path);
defrag->max_sample = sample; defrag->max_sample = sample;
defrag->n_samples++; defrag->n_samples++;
result = NULL; result = NULL;
} }
else if ((sample = ut_avlLookupIPath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path)) == NULL) else if ((sample = ddsrt_avl_lookup_ipath (&defrag_sampletree_treedef, &defrag->sampletree, &sampleinfo->seq, &path)) == NULL)
{ {
/* a new sequence number, but smaller than the maximum */ /* a new sequence number, but smaller than the maximum */
DDS_LOG(DDS_LC_RADMIN, " new sample less than max\n"); DDS_LOG(DDS_LC_RADMIN, " new sample less than max\n");
assert (sampleinfo->seq < max_seq); assert (sampleinfo->seq < max_seq);
if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL) if ((sample = defrag_rsample_new (rdata, sampleinfo)) == NULL)
return NULL; return NULL;
ut_avlInsertIPath (&defrag_sampletree_treedef, &defrag->sampletree, sample, &path); ddsrt_avl_insert_ipath (&defrag_sampletree_treedef, &defrag->sampletree, sample, &path);
defrag->n_samples++; defrag->n_samples++;
result = NULL; result = NULL;
} }
@ -1390,12 +1390,12 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata
reorder format. If it is the sample with the maximum sequence in reorder format. If it is the sample with the maximum sequence in
the tree, an update of max_sample is required. */ the tree, an update of max_sample is required. */
DDS_LOG(DDS_LC_RADMIN, " complete\n"); DDS_LOG(DDS_LC_RADMIN, " complete\n");
ut_avlDelete (&defrag_sampletree_treedef, &defrag->sampletree, result); ddsrt_avl_delete (&defrag_sampletree_treedef, &defrag->sampletree, result);
assert (defrag->n_samples > 0); assert (defrag->n_samples > 0);
defrag->n_samples--; defrag->n_samples--;
if (result == defrag->max_sample) if (result == defrag->max_sample)
{ {
defrag->max_sample = ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree); defrag->max_sample = ddsrt_avl_find_max (&defrag_sampletree_treedef, &defrag->sampletree);
DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n", DDS_LOG(DDS_LC_RADMIN, " updating max_sample: now %p %"PRId64"\n",
(void *) defrag->max_sample, (void *) defrag->max_sample,
defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0); defrag->max_sample ? defrag->max_sample->u.defrag.seq : 0);
@ -1403,7 +1403,7 @@ struct nn_rsample *nn_defrag_rsample (struct nn_defrag *defrag, struct nn_rdata
rsample_convert_defrag_to_reorder (result); rsample_convert_defrag_to_reorder (result);
} }
assert (defrag->max_sample == ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree)); assert (defrag->max_sample == ddsrt_avl_find_max (&defrag_sampletree_treedef, &defrag->sampletree));
return result; return result;
} }
@ -1412,14 +1412,14 @@ void nn_defrag_notegap (struct nn_defrag *defrag, seqno_t min, seqno_t maxp1)
/* All sequence numbers in [min,maxp1) are unavailable so any /* All sequence numbers in [min,maxp1) are unavailable so any
fragments in that range must be discarded. Used both for fragments in that range must be discarded. Used both for
Hearbeats (by setting min=1) and for Gaps. */ Hearbeats (by setting min=1) and for Gaps. */
struct nn_rsample *s = ut_avlLookupSuccEq (&defrag_sampletree_treedef, &defrag->sampletree, &min); struct nn_rsample *s = ddsrt_avl_lookup_succ_eq (&defrag_sampletree_treedef, &defrag->sampletree, &min);
while (s && s->u.defrag.seq < maxp1) while (s && s->u.defrag.seq < maxp1)
{ {
struct nn_rsample *s1 = ut_avlFindSucc (&defrag_sampletree_treedef, &defrag->sampletree, s); struct nn_rsample *s1 = ddsrt_avl_find_succ (&defrag_sampletree_treedef, &defrag->sampletree, s);
defrag_rsample_drop (defrag, s); defrag_rsample_drop (defrag, s);
s = s1; s = s1;
} }
defrag->max_sample = ut_avlFindMax (&defrag_sampletree_treedef, &defrag->sampletree); defrag->max_sample = ddsrt_avl_find_max (&defrag_sampletree_treedef, &defrag->sampletree);
} }
int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnum, struct nn_fragment_number_set *map, uint32_t maxsz) int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnum, struct nn_fragment_number_set *map, uint32_t maxsz)
@ -1428,7 +1428,7 @@ int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnu
struct nn_defrag_iv *iv; struct nn_defrag_iv *iv;
uint32_t i, fragsz, nfrags; uint32_t i, fragsz, nfrags;
assert (maxsz <= 256); assert (maxsz <= 256);
s = ut_avlLookup (&defrag_sampletree_treedef, &defrag->sampletree, &seq); s = ddsrt_avl_lookup (&defrag_sampletree_treedef, &defrag->sampletree, &seq);
if (s == NULL) if (s == NULL)
{ {
if (maxfragnum == UINT32_MAX) if (maxfragnum == UINT32_MAX)
@ -1465,7 +1465,7 @@ int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnu
are missing the first fragment. */ are missing the first fragment. */
struct nn_defrag_iv *liv = s->u.defrag.lastfrag; struct nn_defrag_iv *liv = s->u.defrag.lastfrag;
nn_fragment_number_t map_end; nn_fragment_number_t map_end;
iv = ut_avlFindMin (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree); iv = ddsrt_avl_find_min (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree);
assert (iv != NULL); assert (iv != NULL);
/* iv is first interval, iv->maxp1 is first byte beyond that => /* iv is first interval, iv->maxp1 is first byte beyond that =>
divide by fragsz to get first missing fragment */ divide by fragsz to get first missing fragment */
@ -1485,7 +1485,7 @@ int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnu
map->bitmap_base, but there is nothing to request in that map->bitmap_base, but there is nothing to request in that
case. */ case. */
map->numbits = (map_end < map->bitmap_base) ? 0 : map_end - map->bitmap_base + 1; map->numbits = (map_end < map->bitmap_base) ? 0 : map_end - map->bitmap_base + 1;
iv = ut_avlFindSucc (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree, iv); iv = ddsrt_avl_find_succ (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree, iv);
} }
/* Clear bitmap, then set bits for gaps in available fragments */ /* Clear bitmap, then set bits for gaps in available fragments */
@ -1515,7 +1515,7 @@ int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnu
at fragment containing maxp1 (because we don't have that byte at fragment containing maxp1 (because we don't have that byte
yet), and runs until the next interval begins */ yet), and runs until the next interval begins */
i = iv->maxp1 / fragsz; i = iv->maxp1 / fragsz;
iv = ut_avlFindSucc (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree, iv); iv = ddsrt_avl_find_succ (&rsample_defrag_fragtree_treedef, &s->u.defrag.fragtree, iv);
} }
/* and set bits for missing fragments beyond the highest interval */ /* and set bits for missing fragments beyond the highest interval */
for (; i < map->bitmap_base + map->numbits; i++) for (; i < map->bitmap_base + map->numbits; i++)
@ -1603,7 +1603,7 @@ int nn_defrag_nackmap (struct nn_defrag *defrag, seqno_t seq, uint32_t maxfragnu
in the overview comment at the top of this file. */ in the overview comment at the top of this file. */
struct nn_reorder { struct nn_reorder {
ut_avlTree_t sampleivtree; ddsrt_avl_tree_t sampleivtree;
struct nn_rsample *max_sampleiv; /* = max(sampleivtree) */ struct nn_rsample *max_sampleiv; /* = max(sampleivtree) */
seqno_t next_seq; seqno_t next_seq;
enum nn_reorder_mode mode; enum nn_reorder_mode mode;
@ -1611,15 +1611,15 @@ struct nn_reorder {
uint32_t n_samples; uint32_t n_samples;
}; };
static const ut_avlTreedef_t reorder_sampleivtree_treedef = static const ddsrt_avl_treedef_t reorder_sampleivtree_treedef =
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_rsample, u.reorder.avlnode), offsetof (struct nn_rsample, u.reorder.min), compare_seqno, 0); DDSRT_AVL_TREEDEF_INITIALIZER (offsetof (struct nn_rsample, u.reorder.avlnode), offsetof (struct nn_rsample, u.reorder.min), compare_seqno, 0);
struct nn_reorder *nn_reorder_new (enum nn_reorder_mode mode, uint32_t max_samples) struct nn_reorder *nn_reorder_new (enum nn_reorder_mode mode, uint32_t max_samples)
{ {
struct nn_reorder *r; struct nn_reorder *r;
if ((r = ddsrt_malloc (sizeof (*r))) == NULL) if ((r = ddsrt_malloc (sizeof (*r))) == NULL)
return NULL; return NULL;
ut_avlInit (&reorder_sampleivtree_treedef, &r->sampleivtree); ddsrt_avl_init (&reorder_sampleivtree_treedef, &r->sampleivtree);
r->max_sampleiv = NULL; r->max_sampleiv = NULL;
r->next_seq = 1; r->next_seq = 1;
r->mode = mode; r->mode = mode;
@ -1644,10 +1644,10 @@ void nn_reorder_free (struct nn_reorder *r)
struct nn_rsample *iv; struct nn_rsample *iv;
struct nn_rsample_chain_elem *sce; struct nn_rsample_chain_elem *sce;
/* FXIME: instead of findmin/delete, a treewalk can be used. */ /* FXIME: instead of findmin/delete, a treewalk can be used. */
iv = ut_avlFindMin (&reorder_sampleivtree_treedef, &r->sampleivtree); iv = ddsrt_avl_find_min (&reorder_sampleivtree_treedef, &r->sampleivtree);
while (iv) while (iv)
{ {
ut_avlDelete (&reorder_sampleivtree_treedef, &r->sampleivtree, iv); ddsrt_avl_delete (&reorder_sampleivtree_treedef, &r->sampleivtree, iv);
sce = iv->u.reorder.sc.first; sce = iv->u.reorder.sc.first;
while (sce) while (sce)
{ {
@ -1655,17 +1655,17 @@ void nn_reorder_free (struct nn_reorder *r)
nn_fragchain_unref (sce->fragchain); nn_fragchain_unref (sce->fragchain);
sce = sce1; sce = sce1;
} }
iv = ut_avlFindMin (&reorder_sampleivtree_treedef, &r->sampleivtree); iv = ddsrt_avl_find_min (&reorder_sampleivtree_treedef, &r->sampleivtree);
} }
ddsrt_free (r); ddsrt_free (r);
} }
static void reorder_add_rsampleiv (struct nn_reorder *reorder, struct nn_rsample *rsample) static void reorder_add_rsampleiv (struct nn_reorder *reorder, struct nn_rsample *rsample)
{ {
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
if (ut_avlLookupIPath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &rsample->u.reorder.min, &path) != NULL) if (ddsrt_avl_lookup_ipath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &rsample->u.reorder.min, &path) != NULL)
assert (0); assert (0);
ut_avlInsertIPath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, rsample, &path); ddsrt_avl_insert_ipath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, rsample, &path);
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -1713,7 +1713,7 @@ static int reorder_try_append_and_discard (struct nn_reorder *reorder, struct nn
appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto, appendto->u.reorder.min, appendto->u.reorder.maxp1, (void *) appendto,
todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard); todiscard->u.reorder.min, todiscard->u.reorder.maxp1, (void *) todiscard);
assert (todiscard->u.reorder.min == appendto->u.reorder.maxp1); assert (todiscard->u.reorder.min == appendto->u.reorder.maxp1);
ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, todiscard); ddsrt_avl_delete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, todiscard);
append_rsample_interval (appendto, todiscard); append_rsample_interval (appendto, todiscard);
DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: max_sampleiv needs update? %s\n", DDS_LOG(DDS_LC_RADMIN, " try_append_and_discard: max_sampleiv needs update? %s\n",
(todiscard == reorder->max_sampleiv) ? "yes" : "no"); (todiscard == reorder->max_sampleiv) ? "yes" : "no");
@ -1793,8 +1793,8 @@ static void delete_last_sample (struct nn_reorder *reorder)
recalc max_sampleiv. */ recalc max_sampleiv. */
DDS_LOG(DDS_LC_RADMIN, " delete_last_sample: in singleton interval\n"); DDS_LOG(DDS_LC_RADMIN, " delete_last_sample: in singleton interval\n");
fragchain = last->sc.first->fragchain; fragchain = last->sc.first->fragchain;
ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, reorder->max_sampleiv); ddsrt_avl_delete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, reorder->max_sampleiv);
reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); reorder->max_sampleiv = ddsrt_avl_find_max (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
/* No harm done if it the sampleivtree is empty, except that we /* No harm done if it the sampleivtree is empty, except that we
chose not to allow it */ chose not to allow it */
assert (reorder->max_sampleiv != NULL); assert (reorder->max_sampleiv != NULL);
@ -1847,7 +1847,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
seq; max must be set iff the reorder is non-empty. */ seq; max must be set iff the reorder is non-empty. */
#ifndef NDEBUG #ifndef NDEBUG
{ {
struct nn_rsample *min = ut_avlFindMin (&reorder_sampleivtree_treedef, &reorder->sampleivtree); struct nn_rsample *min = ddsrt_avl_find_min (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
if (min) if (min)
DDS_LOG(DDS_LC_RADMIN, " min = %"PRId64" @ %p\n", min->u.reorder.min, (void *) min); DDS_LOG(DDS_LC_RADMIN, " min = %"PRId64" @ %p\n", min->u.reorder.min, (void *) min);
assert (min == NULL || reorder->next_seq < min->u.reorder.min); assert (min == NULL || reorder->next_seq < min->u.reorder.min);
@ -1855,8 +1855,8 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
(reorder->max_sampleiv != NULL && min != NULL)); (reorder->max_sampleiv != NULL && min != NULL));
} }
#endif #endif
assert ((!!ut_avlIsEmpty (&reorder->sampleivtree)) == (reorder->max_sampleiv == NULL)); assert ((!!ddsrt_avl_is_empty (&reorder->sampleivtree)) == (reorder->max_sampleiv == NULL));
assert (reorder->max_sampleiv == NULL || reorder->max_sampleiv == ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree)); assert (reorder->max_sampleiv == NULL || reorder->max_sampleiv == ddsrt_avl_find_max (&reorder_sampleivtree_treedef, &reorder->sampleivtree));
assert (reorder->n_samples <= reorder->max_samples); assert (reorder->n_samples <= reorder->max_samples);
if (reorder->max_sampleiv) if (reorder->max_sampleiv)
DDS_LOG(DDS_LC_RADMIN, " max = [%"PRId64",%"PRId64") @ %p\n", reorder->max_sampleiv->u.reorder.min, reorder->max_sampleiv->u.reorder.maxp1, (void *) reorder->max_sampleiv); DDS_LOG(DDS_LC_RADMIN, " max = [%"PRId64",%"PRId64") @ %p\n", reorder->max_sampleiv->u.reorder.min, reorder->max_sampleiv->u.reorder.maxp1, (void *) reorder->max_sampleiv);
@ -1883,7 +1883,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
out-of-order either ends up here or in discard.) */ out-of-order either ends up here or in discard.) */
if (reorder->max_sampleiv != NULL) if (reorder->max_sampleiv != NULL)
{ {
struct nn_rsample *min = ut_avlFindMin (&reorder_sampleivtree_treedef, &reorder->sampleivtree); struct nn_rsample *min = ddsrt_avl_find_min (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
DDS_LOG(DDS_LC_RADMIN, " try append_and_discard\n"); DDS_LOG(DDS_LC_RADMIN, " try append_and_discard\n");
if (reorder_try_append_and_discard (reorder, rsampleiv, min)) if (reorder_try_append_and_discard (reorder, rsampleiv, min))
reorder->max_sampleiv = NULL; reorder->max_sampleiv = NULL;
@ -1908,7 +1908,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
DDS_LOG(DDS_LC_RADMIN, " discard: too old\n"); DDS_LOG(DDS_LC_RADMIN, " discard: too old\n");
return NN_REORDER_TOO_OLD; /* don't want refcount increment */ return NN_REORDER_TOO_OLD; /* don't want refcount increment */
} }
else if (ut_avlIsEmpty (&reorder->sampleivtree)) else if (ddsrt_avl_is_empty (&reorder->sampleivtree))
{ {
/* else, if nothing's stored simply add this one, max_samples = 0 /* else, if nothing's stored simply add this one, max_samples = 0
is technically allowed, and potentially useful, so check for is technically allowed, and potentially useful, so check for
@ -1989,7 +1989,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
return NN_REORDER_REJECT; return NN_REORDER_REJECT;
} }
predeq = ut_avlLookupPredEq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->min); predeq = ddsrt_avl_lookup_pred_eq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->min);
if (predeq) if (predeq)
DDS_LOG(DDS_LC_RADMIN, " predeq = [%"PRId64",%"PRId64") @ %p\n", DDS_LOG(DDS_LC_RADMIN, " predeq = [%"PRId64",%"PRId64") @ %p\n",
predeq->u.reorder.min, predeq->u.reorder.maxp1, (void *) predeq); predeq->u.reorder.min, predeq->u.reorder.maxp1, (void *) predeq);
@ -2002,7 +2002,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
return NN_REORDER_REJECT; return NN_REORDER_REJECT;
} }
immsucc = ut_avlLookup (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->maxp1); immsucc = ddsrt_avl_lookup (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &s->maxp1);
if (immsucc) if (immsucc)
DDS_LOG(DDS_LC_RADMIN, " immsucc = [%"PRId64",%"PRId64") @ %p\n", DDS_LOG(DDS_LC_RADMIN, " immsucc = [%"PRId64",%"PRId64") @ %p\n",
immsucc->u.reorder.min, immsucc->u.reorder.maxp1, (void *) immsucc); immsucc->u.reorder.min, immsucc->u.reorder.maxp1, (void *) immsucc);
@ -2040,7 +2040,7 @@ nn_reorder_result_t nn_reorder_rsample (struct nn_rsample_chain *sc, struct nn_r
Therefore, we can swap rsampleiv in for immsucc and avoid the Therefore, we can swap rsampleiv in for immsucc and avoid the
case above. */ case above. */
rsampleiv->u.reorder = immsucc->u.reorder; rsampleiv->u.reorder = immsucc->u.reorder;
ut_avlSwapNode (&reorder_sampleivtree_treedef, &reorder->sampleivtree, immsucc, rsampleiv); ddsrt_avl_swap_node (&reorder_sampleivtree_treedef, &reorder->sampleivtree, immsucc, rsampleiv);
if (immsucc == reorder->max_sampleiv) if (immsucc == reorder->max_sampleiv)
reorder->max_sampleiv = rsampleiv; reorder->max_sampleiv = rsampleiv;
} }
@ -2072,12 +2072,12 @@ static struct nn_rsample *coalesce_intervals_touching_range (struct nn_reorder *
struct nn_rsample *s, *t; struct nn_rsample *s, *t;
*valuable = 0; *valuable = 0;
/* Find first (lowest m) interval [m,n) s.t. n >= min && m <= maxp1 */ /* Find first (lowest m) interval [m,n) s.t. n >= min && m <= maxp1 */
s = ut_avlLookupPredEq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &min); s = ddsrt_avl_lookup_pred_eq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &min);
if (s && s->u.reorder.maxp1 >= min) if (s && s->u.reorder.maxp1 >= min)
{ {
/* m <= min && n >= min (note: pred of s [m',n') necessarily has n' < m) */ /* m <= min && n >= min (note: pred of s [m',n') necessarily has n' < m) */
#ifndef NDEBUG #ifndef NDEBUG
struct nn_rsample *q = ut_avlFindPred (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s); struct nn_rsample *q = ddsrt_avl_find_pred (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s);
assert (q == NULL || q->u.reorder.maxp1 < min); assert (q == NULL || q->u.reorder.maxp1 < min);
#endif #endif
} }
@ -2086,15 +2086,15 @@ static struct nn_rsample *coalesce_intervals_touching_range (struct nn_reorder *
/* No good, but the first (if s = NULL) or the next one (if s != /* No good, but the first (if s = NULL) or the next one (if s !=
NULL) may still have m <= maxp1 (m > min is implied now). If NULL) may still have m <= maxp1 (m > min is implied now). If
not, no such interval. */ not, no such interval. */
s = ut_avlFindSucc (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s); s = ddsrt_avl_find_succ (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s);
if (!(s && s->u.reorder.min <= maxp1)) if (!(s && s->u.reorder.min <= maxp1))
return NULL; return NULL;
} }
/* Append successors [m',n') s.t. m' <= maxp1 to s */ /* Append successors [m',n') s.t. m' <= maxp1 to s */
assert (s->u.reorder.min + s->u.reorder.n_samples <= s->u.reorder.maxp1); assert (s->u.reorder.min + s->u.reorder.n_samples <= s->u.reorder.maxp1);
while ((t = ut_avlFindSucc (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s)) != NULL && t->u.reorder.min <= maxp1) while ((t = ddsrt_avl_find_succ (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s)) != NULL && t->u.reorder.min <= maxp1)
{ {
ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, t); ddsrt_avl_delete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, t);
assert (t->u.reorder.min + t->u.reorder.n_samples <= t->u.reorder.maxp1); assert (t->u.reorder.min + t->u.reorder.n_samples <= t->u.reorder.maxp1);
append_rsample_interval (s, t); append_rsample_interval (s, t);
*valuable = 1; *valuable = 1;
@ -2126,8 +2126,8 @@ static int reorder_insert_gap (struct nn_reorder *reorder, struct nn_rdata *rdat
{ {
struct nn_rsample_chain_elem *sce; struct nn_rsample_chain_elem *sce;
struct nn_rsample *s; struct nn_rsample *s;
ut_avlIPath_t path; ddsrt_avl_ipath_t path;
if (ut_avlLookupIPath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &min, &path) != NULL) if (ddsrt_avl_lookup_ipath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &min, &path) != NULL)
assert (0); assert (0);
if ((sce = nn_rmsg_alloc (rdata->rmsg, sizeof (*sce))) == NULL) if ((sce = nn_rmsg_alloc (rdata->rmsg, sizeof (*sce))) == NULL)
return 0; return 0;
@ -2140,7 +2140,7 @@ static int reorder_insert_gap (struct nn_reorder *reorder, struct nn_rdata *rdat
s->u.reorder.min = min; s->u.reorder.min = min;
s->u.reorder.maxp1 = maxp1; s->u.reorder.maxp1 = maxp1;
s->u.reorder.n_samples = 1; s->u.reorder.n_samples = 1;
ut_avlInsertIPath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s, &path); ddsrt_avl_insert_ipath (&reorder_sampleivtree_treedef, &reorder->sampleivtree, s, &path);
return 1; return 1;
} }
@ -2225,7 +2225,7 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord
delete_last_sample (reorder); delete_last_sample (reorder);
(*refcount_adjust)++; (*refcount_adjust)++;
} }
reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); reorder->max_sampleiv = ddsrt_avl_find_max (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
return res; return res;
} }
else if (coalesced->u.reorder.min <= reorder->next_seq) else if (coalesced->u.reorder.min <= reorder->next_seq)
@ -2233,11 +2233,11 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord
DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p containing %d samples\n", DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p containing %d samples\n",
coalesced->u.reorder.min, coalesced->u.reorder.maxp1, coalesced->u.reorder.min, coalesced->u.reorder.maxp1,
(void *) coalesced, coalesced->u.reorder.n_samples); (void *) coalesced, coalesced->u.reorder.n_samples);
ut_avlDelete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, coalesced); ddsrt_avl_delete (&reorder_sampleivtree_treedef, &reorder->sampleivtree, coalesced);
if (coalesced->u.reorder.min <= reorder->next_seq) if (coalesced->u.reorder.min <= reorder->next_seq)
assert (min <= reorder->next_seq); assert (min <= reorder->next_seq);
reorder->next_seq = coalesced->u.reorder.maxp1; reorder->next_seq = coalesced->u.reorder.maxp1;
reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); reorder->max_sampleiv = ddsrt_avl_find_max (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
DDS_LOG(DDS_LC_RADMIN, " next expected: %"PRId64"\n", reorder->next_seq); DDS_LOG(DDS_LC_RADMIN, " next expected: %"PRId64"\n", reorder->next_seq);
*sc = coalesced->u.reorder.sc; *sc = coalesced->u.reorder.sc;
@ -2251,7 +2251,7 @@ nn_reorder_result_t nn_reorder_gap (struct nn_rsample_chain *sc, struct nn_reord
{ {
DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p - that is all\n", DDS_LOG(DDS_LC_RADMIN, " coalesced = [%"PRId64",%"PRId64") @ %p - that is all\n",
coalesced->u.reorder.min, coalesced->u.reorder.maxp1, (void *) coalesced); coalesced->u.reorder.min, coalesced->u.reorder.maxp1, (void *) coalesced);
reorder->max_sampleiv = ut_avlFindMax (&reorder_sampleivtree_treedef, &reorder->sampleivtree); reorder->max_sampleiv = ddsrt_avl_find_max (&reorder_sampleivtree_treedef, &reorder->sampleivtree);
return valuable ? NN_REORDER_ACCEPT : NN_REORDER_REJECT; return valuable ? NN_REORDER_ACCEPT : NN_REORDER_REJECT;
} }
} }
@ -2264,7 +2264,7 @@ int nn_reorder_wantsample (struct nn_reorder *reorder, seqno_t seq)
return 0; return 0;
/* Find interval that contains seq, if we know seq. We are /* Find interval that contains seq, if we know seq. We are
interested if seq is outside this interval (if any). */ interested if seq is outside this interval (if any). */
s = ut_avlLookupPredEq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &seq); s = ddsrt_avl_lookup_pred_eq (&reorder_sampleivtree_treedef, &reorder->sampleivtree, &seq);
return (s == NULL || s->u.reorder.maxp1 <= seq); return (s == NULL || s->u.reorder.maxp1 <= seq);
} }
@ -2307,7 +2307,7 @@ unsigned nn_reorder_nackmap (struct nn_reorder *reorder, seqno_t base, seqno_t m
map->numbits = (uint32_t) (maxseq + 1 - base); map->numbits = (uint32_t) (maxseq + 1 - base);
nn_bitset_zero (map->numbits, map->bits); nn_bitset_zero (map->numbits, map->bits);
if ((iv = ut_avlFindMin (&reorder_sampleivtree_treedef, &reorder->sampleivtree)) != NULL) if ((iv = ddsrt_avl_find_min (&reorder_sampleivtree_treedef, &reorder->sampleivtree)) != NULL)
assert (iv->u.reorder.min > base); assert (iv->u.reorder.min > base);
i = base; i = base;
while (iv && i < base + map->numbits) while (iv && i < base + map->numbits)
@ -2318,7 +2318,7 @@ unsigned nn_reorder_nackmap (struct nn_reorder *reorder, seqno_t base, seqno_t m
nn_bitset_set (map->numbits, map->bits, x); nn_bitset_set (map->numbits, map->bits, x);
} }
i = iv->u.reorder.maxp1; i = iv->u.reorder.maxp1;
iv = ut_avlFindSucc (&reorder_sampleivtree_treedef, &reorder->sampleivtree, iv); iv = ddsrt_avl_find_succ (&reorder_sampleivtree_treedef, &reorder->sampleivtree, iv);
} }
if (notail && i < base + map->numbits) if (notail && i < base + map->numbits)
map->numbits = (unsigned) (i - base); map->numbits = (unsigned) (i - base);

View file

@ -20,7 +20,7 @@
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds__stream.h" #include "dds__stream.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"
@ -767,7 +767,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
} }
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL) if ((rn = ddsrt_avl_lookup (&wr_readers_treedef, &wr->readers, &src)) == NULL)
{ {
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst)); DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst));
goto out; goto out;
@ -823,7 +823,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
that rn->seq <= wr->seq) */ that rn->seq <= wr->seq) */
rn->seq = wr->seq; rn->seq = wr->seq;
} }
ut_avlAugmentUpdate (&wr_readers_treedef, rn); ddsrt_avl_augment_update (&wr_readers_treedef, rn);
n = remove_acked_messages (wr, &whcst, &deferred_free_list); n = remove_acked_messages (wr, &whcst, &deferred_free_list);
DDS_TRACE(" ACK%"PRId64" RM%u", n_ack, n); DDS_TRACE(" ACK%"PRId64" RM%u", n_ack, n);
} }
@ -850,7 +850,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
that rn->seq <= wr->seq) */ that rn->seq <= wr->seq) */
rn->seq = wr->seq; rn->seq = wr->seq;
} }
ut_avlAugmentUpdate (&wr_readers_treedef, rn); ddsrt_avl_augment_update (&wr_readers_treedef, rn);
DDS_LOG(DDS_LC_THROTTLE, "writer %x:%x:%x:%x considering reader %x:%x:%x:%x responsive again\n", PGUID (wr->e.guid), PGUID (rn->prd_guid)); DDS_LOG(DDS_LC_THROTTLE, "writer %x:%x:%x:%x considering reader %x:%x:%x:%x responsive again\n", PGUID (wr->e.guid), PGUID (rn->prd_guid));
} }
@ -867,7 +867,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
rn->has_replied_to_hb = 1; rn->has_replied_to_hb = 1;
/* walk the whole tree to ensure all proxy readers for this writer /* walk the whole tree to ensure all proxy readers for this writer
have their unack'ed info updated */ have their unack'ed info updated */
ut_avlAugmentUpdate (&wr_readers_treedef, rn); ddsrt_avl_augment_update (&wr_readers_treedef, rn);
} }
if (is_preemptive_ack) if (is_preemptive_ack)
{ {
@ -1075,7 +1075,7 @@ static int handle_AckNack (struct receiver_state *rst, nn_etime_t tnow, const Ac
return 1; return 1;
} }
static void handle_forall_destinations (const nn_guid_t *dst, struct proxy_writer *pwr, ut_avlWalk_t fun, void *arg) static void handle_forall_destinations (const nn_guid_t *dst, struct proxy_writer *pwr, ddsrt_avl_walk_t fun, void *arg)
{ {
/* prefix: id: to: /* prefix: id: to:
0 0 all matched readers 0 0 all matched readers
@ -1093,12 +1093,12 @@ static void handle_forall_destinations (const nn_guid_t *dst, struct proxy_write
switch ((haveprefix << 1) | haveid) switch ((haveprefix << 1) | haveid)
{ {
case (0 << 1) | 0: /* all: full treewalk */ case (0 << 1) | 0: /* all: full treewalk */
ut_avlWalk (&pwr_readers_treedef, &pwr->readers, fun, arg); ddsrt_avl_walk (&pwr_readers_treedef, &pwr->readers, fun, arg);
break; break;
case (0 << 1) | 1: /* all with correct entityid: special filtering treewalk */ case (0 << 1) | 1: /* all with correct entityid: special filtering treewalk */
{ {
struct pwr_rd_match *wn; struct pwr_rd_match *wn;
for (wn = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); wn; wn = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, wn)) for (wn = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers); wn; wn = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, wn))
{ {
if (wn->rd_guid.entityid.u == dst->entityid.u) if (wn->rd_guid.entityid.u == dst->entityid.u)
fun (wn, arg); fun (wn, arg);
@ -1110,13 +1110,13 @@ static void handle_forall_destinations (const nn_guid_t *dst, struct proxy_write
nn_guid_t a, b; nn_guid_t a, b;
a = *dst; a.entityid.u = 0; a = *dst; a.entityid.u = 0;
b = *dst; b.entityid.u = ~0u; b = *dst; b.entityid.u = ~0u;
ut_avlWalkRange (&pwr_readers_treedef, &pwr->readers, &a, &b, fun, arg); ddsrt_avl_walk_range (&pwr_readers_treedef, &pwr->readers, &a, &b, fun, arg);
} }
break; break;
case (1 << 1) | 1: /* fully addressed: dst should exist (but for removal) */ case (1 << 1) | 1: /* fully addressed: dst should exist (but for removal) */
{ {
struct pwr_rd_match *wn; struct pwr_rd_match *wn;
if ((wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, dst)) != NULL) if ((wn = ddsrt_avl_lookup (&pwr_readers_treedef, &pwr->readers, dst)) != NULL)
fun (wn, arg); fun (wn, arg);
} }
break; break;
@ -1289,7 +1289,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
else else
nn_dqueue_enqueue (pwr->dqueue, &sc, res); nn_dqueue_enqueue (pwr->dqueue, &sc, res);
} }
for (wn = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); wn; wn = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, wn)) for (wn = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers); wn; wn = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, wn))
if (wn->in_sync != PRMSS_SYNC) if (wn->in_sync != PRMSS_SYNC)
{ {
seqno_t last_deliv_seq = 0; seqno_t last_deliv_seq = 0;
@ -1324,7 +1324,7 @@ static int handle_Heartbeat (struct receiver_state *rst, nn_etime_t tnow, struct
arg.timestamp = timestamp; arg.timestamp = timestamp;
arg.tnow = tnow; arg.tnow = tnow;
arg.tnow_mt = now_mt (); arg.tnow_mt = now_mt ();
handle_forall_destinations (&dst, pwr, (ut_avlWalk_t) handle_Heartbeat_helper, &arg); handle_forall_destinations (&dst, pwr, (ddsrt_avl_walk_t) handle_Heartbeat_helper, &arg);
DDS_TRACE(")"); DDS_TRACE(")");
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
@ -1380,7 +1380,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
discover a missing fragment, which differs significantly from discover a missing fragment, which differs significantly from
handle_Heartbeat's scheduling of an AckNack event when it must handle_Heartbeat's scheduling of an AckNack event when it must
respond. Why? Just because. */ respond. Why? Just because. */
if (ut_avlIsEmpty (&pwr->readers) || pwr->local_matching_inprogress) if (ddsrt_avl_is_empty (&pwr->readers) || pwr->local_matching_inprogress)
DDS_TRACE(" no readers"); DDS_TRACE(" no readers");
else else
{ {
@ -1392,19 +1392,19 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
assuming a reliable writer -> unreliable reader is rare, and assuming a reliable writer -> unreliable reader is rare, and
so scanning the readers is acceptable if the first guess so scanning the readers is acceptable if the first guess
fails */ fails */
m = ut_avlRootNonEmpty (&pwr_readers_treedef, &pwr->readers); m = ddsrt_avl_root_non_empty (&pwr_readers_treedef, &pwr->readers);
if (m->acknack_xevent == NULL) if (m->acknack_xevent == NULL)
{ {
m = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); m = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers);
while (m && m->acknack_xevent == NULL) while (m && m->acknack_xevent == NULL)
m = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, m); m = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, m);
} }
} }
else if (seq < nn_reorder_next_seq (pwr->reorder)) else if (seq < nn_reorder_next_seq (pwr->reorder))
{ {
/* Check out-of-sync readers -- should add a bit to cheaply test /* Check out-of-sync readers -- should add a bit to cheaply test
whether there are any (usually there aren't) */ whether there are any (usually there aren't) */
m = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); m = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers);
while (m) while (m)
{ {
if ((m->in_sync == PRMSS_OUT_OF_SYNC) && m->acknack_xevent != NULL && nn_reorder_wantsample (m->u.not_in_sync.reorder, seq)) if ((m->in_sync == PRMSS_OUT_OF_SYNC) && m->acknack_xevent != NULL && nn_reorder_wantsample (m->u.not_in_sync.reorder, seq))
@ -1414,7 +1414,7 @@ static int handle_HeartbeatFrag (struct receiver_state *rst, UNUSED_ARG(nn_etime
reader to decide which fragments to nack */ reader to decide which fragments to nack */
break; break;
} }
m = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, m); m = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, m);
} }
} }
@ -1495,7 +1495,7 @@ static int handle_NackFrag (struct receiver_state *rst, nn_etime_t tnow, const N
} }
ddsrt_mutex_lock (&wr->e.lock); ddsrt_mutex_lock (&wr->e.lock);
if ((rn = ut_avlLookup (&wr_readers_treedef, &wr->readers, &src)) == NULL) if ((rn = ddsrt_avl_lookup (&wr_readers_treedef, &wr->readers, &src)) == NULL)
{ {
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection", PGUID (src), PGUID (dst)); DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x not a connection", PGUID (src), PGUID (dst));
goto out; goto out;
@ -1737,7 +1737,7 @@ static int handle_Gap (struct receiver_state *rst, nn_etime_t tnow, struct nn_rm
lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow); lease_renew (ddsrt_atomic_ldvoidp (&pwr->c.proxypp->lease), tnow);
ddsrt_mutex_lock (&pwr->e.lock); ddsrt_mutex_lock (&pwr->e.lock);
if ((wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &dst)) == NULL) if ((wn = ddsrt_avl_lookup (&pwr_readers_treedef, &pwr->readers, &dst)) == NULL)
{ {
DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst)); DDS_TRACE("%x:%x:%x:%x -> %x:%x:%x:%x not a connection)", PGUID (src), PGUID (dst));
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
@ -2069,11 +2069,11 @@ retry:
we fall back to using the GUIDs so that we can deliver all we fall back to using the GUIDs so that we can deliver all
samples we received from it. As writer being deleted any samples we received from it. As writer being deleted any
reliable samples that are rejected are simply discarded. */ reliable samples that are rejected are simply discarded. */
ut_avlIter_t it; ddsrt_avl_iter_t it;
struct pwr_rd_match *m; struct pwr_rd_match *m;
ddsrt_mutex_unlock (&pwr->rdary.rdary_lock); ddsrt_mutex_unlock (&pwr->rdary.rdary_lock);
if (!pwr_locked) ddsrt_mutex_lock (&pwr->e.lock); if (!pwr_locked) ddsrt_mutex_lock (&pwr->e.lock);
for (m = ut_avlIterFirst (&pwr_readers_treedef, &pwr->readers, &it); m != NULL; m = ut_avlIterNext (&it)) for (m = ddsrt_avl_iter_first (&pwr_readers_treedef, &pwr->readers, &it); m != NULL; m = ddsrt_avl_iter_next (&it))
{ {
struct reader *rd; struct reader *rd;
if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL) if ((rd = ephash_lookup_reader_guid (&m->rd_guid)) != NULL)
@ -2138,7 +2138,7 @@ static void clean_defrag (struct proxy_writer *pwr)
if (pwr->n_readers_out_of_sync > 0) if (pwr->n_readers_out_of_sync > 0)
{ {
struct pwr_rd_match *wn; struct pwr_rd_match *wn;
for (wn = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); wn != NULL; wn = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, wn)) for (wn = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers); wn != NULL; wn = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, wn))
{ {
if (wn->in_sync == PRMSS_OUT_OF_SYNC) if (wn->in_sync == PRMSS_OUT_OF_SYNC)
{ {
@ -2199,7 +2199,7 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct
return; return;
} }
if (ut_avlIsEmpty (&pwr->readers) || pwr->local_matching_inprogress) if (ddsrt_avl_is_empty (&pwr->readers) || pwr->local_matching_inprogress)
{ {
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x: no readers", PGUID (pwr->e.guid), PGUID (dst)); DDS_TRACE(" %x:%x:%x:%x -> %x:%x:%x:%x: no readers", PGUID (pwr->e.guid), PGUID (dst));
@ -2274,9 +2274,9 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct
writer may have become in sync with the proxy writer and the writer may have become in sync with the proxy writer and the
writer; those catching up with TL all by themselves go through writer; those catching up with TL all by themselves go through
the "TOO_OLD" path below. */ the "TOO_OLD" path below. */
ut_avlIter_t it; ddsrt_avl_iter_t it;
struct pwr_rd_match *wn; struct pwr_rd_match *wn;
for (wn = ut_avlIterFirst (&pwr_readers_treedef, &pwr->readers, &it); wn != NULL; wn = ut_avlIterNext (&it)) for (wn = ddsrt_avl_iter_first (&pwr_readers_treedef, &pwr->readers, &it); wn != NULL; wn = ddsrt_avl_iter_next (&it))
if (wn->in_sync == PRMSS_TLCATCHUP) if (wn->in_sync == PRMSS_TLCATCHUP)
maybe_set_reader_in_sync (pwr, wn, sampleinfo->seq); maybe_set_reader_in_sync (pwr, wn, sampleinfo->seq);
} }
@ -2286,7 +2286,7 @@ static void handle_regular (struct receiver_state *rst, nn_etime_t tnow, struct
struct pwr_rd_match *wn; struct pwr_rd_match *wn;
struct nn_rsample *rsample_dup = NULL; struct nn_rsample *rsample_dup = NULL;
int reuse_rsample_dup = 0; int reuse_rsample_dup = 0;
for (wn = ut_avlFindMin (&pwr_readers_treedef, &pwr->readers); wn != NULL; wn = ut_avlFindSucc (&pwr_readers_treedef, &pwr->readers, wn)) for (wn = ddsrt_avl_find_min (&pwr_readers_treedef, &pwr->readers); wn != NULL; wn = ddsrt_avl_find_succ (&pwr_readers_treedef, &pwr->readers, wn))
{ {
nn_reorder_result_t rres2; nn_reorder_result_t rres2;
if (wn->in_sync != PRMSS_OUT_OF_SYNC || sampleinfo->seq > wn->u.not_in_sync.end_of_out_of_sync_seq) if (wn->in_sync != PRMSS_OUT_OF_SYNC || sampleinfo->seq > wn->u.not_in_sync.end_of_out_of_sync_seq)
@ -2380,7 +2380,7 @@ static void drop_oversize (struct receiver_state *rst, struct nn_rmsg *rmsg, con
dst.entityid = msg->readerId; dst.entityid = msg->readerId;
ddsrt_mutex_lock (&pwr->e.lock); ddsrt_mutex_lock (&pwr->e.lock);
wn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &dst); wn = ddsrt_avl_lookup (&pwr_readers_treedef, &pwr->readers, &dst);
gap_was_valuable = handle_one_gap (pwr, wn, sampleinfo->seq, sampleinfo->seq+1, gap, &refc_adjust); gap_was_valuable = handle_one_gap (pwr, wn, sampleinfo->seq, sampleinfo->seq+1, gap, &refc_adjust);
nn_fragchain_adjust_refcount (gap, refc_adjust); nn_fragchain_adjust_refcount (gap, refc_adjust);
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/ddsi/q_entity.h" #include "dds/ddsi/q_entity.h"
#include "dds/ddsi/q_addrset.h" #include "dds/ddsi/q_addrset.h"
#include "dds/ddsi/q_xmsg.h" #include "dds/ddsi/q_xmsg.h"
@ -51,12 +51,12 @@
static const struct wr_prd_match *root_rdmatch (const struct writer *wr) static const struct wr_prd_match *root_rdmatch (const struct writer *wr)
{ {
return ut_avlRoot (&wr_readers_treedef, &wr->readers); return ddsrt_avl_root (&wr_readers_treedef, &wr->readers);
} }
static int have_reliable_subs (const struct writer *wr) static int have_reliable_subs (const struct writer *wr)
{ {
if (ut_avlIsEmpty (&wr->readers) || root_rdmatch (wr)->min_seq == MAX_SEQ_NUMBER) if (ddsrt_avl_is_empty (&wr->readers) || root_rdmatch (wr)->min_seq == MAX_SEQ_NUMBER)
return 0; return 0;
else else
return 1; return 1;
@ -152,7 +152,7 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru
/* out of memory at worst slows down traffic */ /* out of memory at worst slows down traffic */
return NULL; return NULL;
if (ut_avlIsEmpty (&wr->readers) || wr->num_reliable_readers == 0) if (ddsrt_avl_is_empty (&wr->readers) || wr->num_reliable_readers == 0)
{ {
/* Not really supposed to come here, at least not for the first /* Not really supposed to come here, at least not for the first
case. Secondly, there really seems to be little use for case. Secondly, there really seems to be little use for
@ -192,9 +192,9 @@ struct nn_xmsg *writer_hbcontrol_create_heartbeat (struct writer *wr, const stru
DDS_TRACE("unicasting to prd %x:%x:%x:%x ", PGUID (*prd_guid)); DDS_TRACE("unicasting to prd %x:%x:%x:%x ", PGUID (*prd_guid));
DDS_TRACE("(rel-prd %d seq-eq-max %d seq %"PRId64" maxseq %"PRId64")\n", DDS_TRACE("(rel-prd %d seq-eq-max %d seq %"PRId64" maxseq %"PRId64")\n",
wr->num_reliable_readers, wr->num_reliable_readers,
ut_avlIsEmpty (&wr->readers) ? -1 : root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max, ddsrt_avl_is_empty (&wr->readers) ? -1 : root_rdmatch (wr)->num_reliable_readers_where_seq_equals_max,
wr->seq, wr->seq,
ut_avlIsEmpty (&wr->readers) ? (seqno_t) -1 : root_rdmatch (wr)->max_seq); ddsrt_avl_is_empty (&wr->readers) ? (seqno_t) -1 : root_rdmatch (wr)->max_seq);
if (prd_guid == NULL) if (prd_guid == NULL)
{ {
@ -312,8 +312,8 @@ struct nn_xmsg *writer_hbcontrol_piggyback (struct writer *wr, const struct whc_
PGUID (wr->e.guid), PGUID (wr->e.guid),
*hbansreq ? "" : " final", *hbansreq ? "" : " final",
(hbc->tsched.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double) (hbc->tsched.v - tnow.v) / 1e9, (hbc->tsched.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double) (hbc->tsched.v - tnow.v) / 1e9,
ut_avlIsEmpty (&wr->readers) ? -1 : root_rdmatch (wr)->min_seq, ddsrt_avl_is_empty (&wr->readers) ? -1 : root_rdmatch (wr)->min_seq,
ut_avlIsEmpty (&wr->readers) || root_rdmatch (wr)->all_have_replied_to_hb ? "" : "!", ddsrt_avl_is_empty (&wr->readers) || root_rdmatch (wr)->all_have_replied_to_hb ? "" : "!",
whcst->max_seq, READ_SEQ_XMIT(wr)); whcst->max_seq, READ_SEQ_XMIT(wr));
} }

View file

@ -16,8 +16,8 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/util/ut_fibheap.h" #include "dds/ddsrt/fibheap.h"
#include "dds/ddsi/q_time.h" #include "dds/ddsi/q_time.h"
#include "dds/ddsi/q_log.h" #include "dds/ddsi/q_log.h"
@ -70,7 +70,7 @@ enum xeventkind
struct xevent struct xevent
{ {
ut_fibheapNode_t heapnode; ddsrt_fibheap_node_t heapnode;
struct xeventq *evq; struct xeventq *evq;
nn_mtime_t tsched; nn_mtime_t tsched;
enum xeventkind kind; enum xeventkind kind;
@ -133,7 +133,7 @@ struct xevent_nt
/* xmsg is self-contained / relies on reference counts */ /* xmsg is self-contained / relies on reference counts */
struct nn_xmsg *msg; struct nn_xmsg *msg;
size_t queued_rexmit_bytes; size_t queued_rexmit_bytes;
ut_avlNode_t msg_avlnode; ddsrt_avl_node_t msg_avlnode;
} msg_rexmit; } msg_rexmit;
struct { struct {
/* xmsg is self-contained / relies on reference counts */ /* xmsg is self-contained / relies on reference counts */
@ -143,8 +143,8 @@ struct xevent_nt
}; };
struct xeventq { struct xeventq {
ut_fibheap_t xevents; ddsrt_fibheap_t xevents;
ut_avlTree_t msg_xevents; ddsrt_avl_tree_t msg_xevents;
struct xevent_nt *non_timed_xmit_list_oldest; struct xevent_nt *non_timed_xmit_list_oldest;
struct xevent_nt *non_timed_xmit_list_newest; /* undefined if ..._oldest == NULL */ struct xevent_nt *non_timed_xmit_list_newest; /* undefined if ..._oldest == NULL */
size_t queued_rexmit_bytes; size_t queued_rexmit_bytes;
@ -164,9 +164,9 @@ static nn_mtime_t earliest_in_xeventq (struct xeventq *evq);
static int msg_xevents_cmp (const void *a, const void *b); static int msg_xevents_cmp (const void *a, const void *b);
static int compare_xevent_tsched (const void *va, const void *vb); static int compare_xevent_tsched (const void *va, const void *vb);
static const ut_avlTreedef_t msg_xevents_treedef = UT_AVL_TREEDEF_INITIALIZER_INDKEY (offsetof (struct xevent_nt, u.msg_rexmit.msg_avlnode), offsetof (struct xevent_nt, u.msg_rexmit.msg), msg_xevents_cmp, 0); static const ddsrt_avl_treedef_t msg_xevents_treedef = DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY (offsetof (struct xevent_nt, u.msg_rexmit.msg_avlnode), offsetof (struct xevent_nt, u.msg_rexmit.msg), msg_xevents_cmp, 0);
static const ut_fibheapDef_t evq_xevents_fhdef = UT_FIBHEAPDEF_INITIALIZER(offsetof (struct xevent, heapnode), compare_xevent_tsched); static const ddsrt_fibheap_def_t evq_xevents_fhdef = DDSRT_FIBHEAPDEF_INITIALIZER(offsetof (struct xevent, heapnode), compare_xevent_tsched);
static int compare_xevent_tsched (const void *va, const void *vb) static int compare_xevent_tsched (const void *va, const void *vb)
{ {
@ -209,21 +209,21 @@ static struct xevent_nt *lookup_msg (struct xeventq *evq, struct nn_xmsg *msg)
{ {
assert (nn_xmsg_kind (msg) == NN_XMSG_KIND_DATA_REXMIT); assert (nn_xmsg_kind (msg) == NN_XMSG_KIND_DATA_REXMIT);
trace_msg ("lookup-msg", msg); trace_msg ("lookup-msg", msg);
return ut_avlLookup (&msg_xevents_treedef, &evq->msg_xevents, msg); return ddsrt_avl_lookup (&msg_xevents_treedef, &evq->msg_xevents, msg);
} }
static void remember_msg (struct xeventq *evq, struct xevent_nt *ev) static void remember_msg (struct xeventq *evq, struct xevent_nt *ev)
{ {
assert (ev->kind == XEVK_MSG_REXMIT); assert (ev->kind == XEVK_MSG_REXMIT);
trace_msg ("remember-msg", ev->u.msg_rexmit.msg); trace_msg ("remember-msg", ev->u.msg_rexmit.msg);
ut_avlInsert (&msg_xevents_treedef, &evq->msg_xevents, ev); ddsrt_avl_insert (&msg_xevents_treedef, &evq->msg_xevents, ev);
} }
static void forget_msg (struct xeventq *evq, struct xevent_nt *ev) static void forget_msg (struct xeventq *evq, struct xevent_nt *ev)
{ {
assert (ev->kind == XEVK_MSG_REXMIT); assert (ev->kind == XEVK_MSG_REXMIT);
trace_msg ("forget-msg", ev->u.msg_rexmit.msg); trace_msg ("forget-msg", ev->u.msg_rexmit.msg);
ut_avlDelete (&msg_xevents_treedef, &evq->msg_xevents, ev); ddsrt_avl_delete (&msg_xevents_treedef, &evq->msg_xevents, ev);
} }
static void add_to_non_timed_xmit_list (struct xeventq *evq, struct xevent_nt *ev) static void add_to_non_timed_xmit_list (struct xeventq *evq, struct xevent_nt *ev)
@ -330,7 +330,7 @@ static void free_xevent_nt (struct xeventq *evq, struct xevent_nt *ev)
nn_xmsg_free (ev->u.msg.msg); nn_xmsg_free (ev->u.msg.msg);
break; break;
case XEVK_MSG_REXMIT: case XEVK_MSG_REXMIT:
assert (ut_avlLookup (&msg_xevents_treedef, &evq->msg_xevents, ev->u.msg_rexmit.msg) == NULL); assert (ddsrt_avl_lookup (&msg_xevents_treedef, &evq->msg_xevents, ev->u.msg_rexmit.msg) == NULL);
update_rexmit_counts (evq, ev); update_rexmit_counts (evq, ev);
nn_xmsg_free (ev->u.msg_rexmit.msg); nn_xmsg_free (ev->u.msg_rexmit.msg);
break; break;
@ -351,12 +351,12 @@ void delete_xevent (struct xevent *ev)
if (ev->tsched.v != T_NEVER) if (ev->tsched.v != T_NEVER)
{ {
ev->tsched.v = TSCHED_DELETE; ev->tsched.v = TSCHED_DELETE;
ut_fibheapDecreaseKey (&evq_xevents_fhdef, &evq->xevents, ev); ddsrt_fibheap_decrease_key (&evq_xevents_fhdef, &evq->xevents, ev);
} }
else else
{ {
ev->tsched.v = TSCHED_DELETE; ev->tsched.v = TSCHED_DELETE;
ut_fibheapInsert (&evq_xevents_fhdef, &evq->xevents, ev); ddsrt_fibheap_insert (&evq_xevents_fhdef, &evq->xevents, ev);
} }
/* TSCHED_DELETE is absolute minimum time, so chances are we need to /* TSCHED_DELETE is absolute minimum time, so chances are we need to
wake up the thread. The superfluous signal is harmless. */ wake up the thread. The superfluous signal is harmless. */
@ -384,12 +384,12 @@ int resched_xevent_if_earlier (struct xevent *ev, nn_mtime_t tsched)
if (ev->tsched.v != T_NEVER) if (ev->tsched.v != T_NEVER)
{ {
ev->tsched = tsched; ev->tsched = tsched;
ut_fibheapDecreaseKey (&evq_xevents_fhdef, &evq->xevents, ev); ddsrt_fibheap_decrease_key (&evq_xevents_fhdef, &evq->xevents, ev);
} }
else else
{ {
ev->tsched = tsched; ev->tsched = tsched;
ut_fibheapInsert (&evq_xevents_fhdef, &evq->xevents, ev); ddsrt_fibheap_insert (&evq_xevents_fhdef, &evq->xevents, ev);
} }
is_resched = 1; is_resched = 1;
if (tsched.v < tbefore.v) if (tsched.v < tbefore.v)
@ -435,7 +435,7 @@ static nn_mtime_t earliest_in_xeventq (struct xeventq *evq)
{ {
struct xevent *min; struct xevent *min;
ASSERT_MUTEX_HELD (&evq->lock); ASSERT_MUTEX_HELD (&evq->lock);
if ((min = ut_fibheapMin (&evq_xevents_fhdef, &evq->xevents)) != NULL) if ((min = ddsrt_fibheap_min (&evq_xevents_fhdef, &evq->xevents)) != NULL)
return min->tsched; return min->tsched;
else else
{ {
@ -453,7 +453,7 @@ static void qxev_insert (struct xevent *ev)
if (ev->tsched.v != T_NEVER) if (ev->tsched.v != T_NEVER)
{ {
nn_mtime_t tbefore = earliest_in_xeventq (evq); nn_mtime_t tbefore = earliest_in_xeventq (evq);
ut_fibheapInsert (&evq_xevents_fhdef, &evq->xevents, ev); ddsrt_fibheap_insert (&evq_xevents_fhdef, &evq->xevents, ev);
if (ev->tsched.v < tbefore.v) if (ev->tsched.v < tbefore.v)
ddsrt_cond_signal (&evq->cond); ddsrt_cond_signal (&evq->cond);
} }
@ -485,8 +485,8 @@ struct xeventq * xeventq_new
/* limit to 2GB to prevent overflow (4GB - 64kB should be ok, too) */ /* limit to 2GB to prevent overflow (4GB - 64kB should be ok, too) */
if (max_queued_rexmit_bytes > 2147483648u) if (max_queued_rexmit_bytes > 2147483648u)
max_queued_rexmit_bytes = 2147483648u; max_queued_rexmit_bytes = 2147483648u;
ut_fibheapInit (&evq_xevents_fhdef, &evq->xevents); ddsrt_fibheap_init (&evq_xevents_fhdef, &evq->xevents);
ut_avlInit (&msg_xevents_treedef, &evq->msg_xevents); ddsrt_avl_init (&msg_xevents_treedef, &evq->msg_xevents);
evq->non_timed_xmit_list_oldest = NULL; evq->non_timed_xmit_list_oldest = NULL;
evq->non_timed_xmit_list_newest = NULL; evq->non_timed_xmit_list_newest = NULL;
evq->terminate = 0; evq->terminate = 0;
@ -540,7 +540,7 @@ void xeventq_free (struct xeventq *evq)
{ {
struct xevent *ev; struct xevent *ev;
assert (evq->ts == NULL); assert (evq->ts == NULL);
while ((ev = ut_fibheapExtractMin (&evq_xevents_fhdef, &evq->xevents)) != NULL) while ((ev = ddsrt_fibheap_extract_min (&evq_xevents_fhdef, &evq->xevents)) != NULL)
{ {
if (ev->tsched.v == TSCHED_DELETE || ev->kind != XEVK_CALLBACK) if (ev->tsched.v == TSCHED_DELETE || ev->kind != XEVK_CALLBACK)
free_xevent (evq, ev); free_xevent (evq, ev);
@ -559,7 +559,7 @@ void xeventq_free (struct xeventq *evq)
} }
while (!non_timed_xmit_list_is_empty(evq)) while (!non_timed_xmit_list_is_empty(evq))
free_xevent_nt (evq, getnext_from_non_timed_xmit_list (evq)); free_xevent_nt (evq, getnext_from_non_timed_xmit_list (evq));
assert (ut_avlIsEmpty (&evq->msg_xevents)); assert (ddsrt_avl_is_empty (&evq->msg_xevents));
ddsrt_cond_destroy (&evq->cond); ddsrt_cond_destroy (&evq->cond);
ddsrt_mutex_destroy (&evq->lock); ddsrt_mutex_destroy (&evq->lock);
ddsrt_free (evq); ddsrt_free (evq);
@ -636,8 +636,8 @@ static void handle_xevk_heartbeat (struct nn_xpack *xp, struct xevent *ev, nn_mt
hbansreq ? "" : " final", hbansreq ? "" : " final",
msg ? "sent" : "suppressed", msg ? "sent" : "suppressed",
(t_next.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double)(t_next.v - tnow.v) / 1e9, (t_next.v == T_NEVER) ? POS_INFINITY_DOUBLE : (double)(t_next.v - tnow.v) / 1e9,
ut_avlIsEmpty (&wr->readers) ? (seqno_t) -1 : ((struct wr_prd_match *) ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers))->min_seq, ddsrt_avl_is_empty (&wr->readers) ? (seqno_t) -1 : ((struct wr_prd_match *) ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers))->min_seq,
ut_avlIsEmpty (&wr->readers) || ((struct wr_prd_match *) ut_avlRootNonEmpty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb ? "" : "!", ddsrt_avl_is_empty (&wr->readers) || ((struct wr_prd_match *) ddsrt_avl_root_non_empty (&wr_readers_treedef, &wr->readers))->all_have_replied_to_hb ? "" : "!",
whcst.max_seq, READ_SEQ_XMIT(wr)); whcst.max_seq, READ_SEQ_XMIT(wr));
resched_xevent_if_earlier (ev, t_next); resched_xevent_if_earlier (ev, t_next);
wr->hbcontrol.tsched = t_next; wr->hbcontrol.tsched = t_next;
@ -888,7 +888,7 @@ static void handle_xevk_acknack (UNUSED_ARG (struct nn_xpack *xp), struct xevent
} }
ddsrt_mutex_lock (&pwr->e.lock); ddsrt_mutex_lock (&pwr->e.lock);
if ((rwn = ut_avlLookup (&pwr_readers_treedef, &pwr->readers, &ev->u.acknack.rd_guid)) == NULL) if ((rwn = ddsrt_avl_lookup (&pwr_readers_treedef, &pwr->readers, &ev->u.acknack.rd_guid)) == NULL)
{ {
ddsrt_mutex_unlock (&pwr->e.lock); ddsrt_mutex_unlock (&pwr->e.lock);
return; return;
@ -1322,7 +1322,7 @@ static void handle_xevents (struct thread_state1 * const ts1, struct xeventq *xe
{ {
while (earliest_in_xeventq(xevq).v <= tnow.v) while (earliest_in_xeventq(xevq).v <= tnow.v)
{ {
struct xevent *xev = ut_fibheapExtractMin (&evq_xevents_fhdef, &xevq->xevents); struct xevent *xev = ddsrt_fibheap_extract_min (&evq_xevents_fhdef, &xevq->xevents);
if (xev->tsched.v == TSCHED_DELETE) if (xev->tsched.v == TSCHED_DELETE)
{ {
free_xevent (xevq, xev); free_xevent (xevq, xev);

View file

@ -23,8 +23,8 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/random.h" #include "dds/ddsrt/random.h"
#include "dds/util/ut_avl.h" #include "dds/ddsrt/avl.h"
#include "dds/util/ut_thread_pool.h" #include "dds/ddsrt/thread_pool.h"
#include "dds/ddsi/q_protocol.h" #include "dds/ddsi/q_protocol.h"
#include "dds/ddsi/q_xqos.h" #include "dds/ddsi/q_xqos.h"
@ -1340,7 +1340,7 @@ static void nn_xpack_send1_threaded (const nn_locator_t *loc, void * varg)
arg->xp = (struct nn_xpack *) varg; arg->xp = (struct nn_xpack *) varg;
arg->loc = loc; arg->loc = loc;
ddsrt_atomic_inc32 (&arg->xp->calls); ddsrt_atomic_inc32 (&arg->xp->calls);
ut_thread_pool_submit (gv.thread_pool, nn_xpack_send1_thread, arg); ddsrt_thread_pool_submit (gv.thread_pool, nn_xpack_send1_thread, arg);
} }
static void nn_xpack_send_real (struct nn_xpack * xp) static void nn_xpack_send_real (struct nn_xpack * xp)

View file

@ -18,7 +18,7 @@ target_include_directories(
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../ddsc/src>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../ddsc/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../ddsi/include>") "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../ddsi/include>")
target_link_libraries(rhc_torture RhcTypes ddsc util) target_link_libraries(rhc_torture RhcTypes ddsc)
add_test( add_test(
NAME rhc_torture NAME rhc_torture

View file

@ -78,6 +78,21 @@ list(APPEND sources
"${source_path}/strtod.c" "${source_path}/strtod.c"
"${source_path}/strtol.c") "${source_path}/strtol.c")
list(APPEND headers
"${source_path}/dds/ddsrt/avl.h"
"${source_path}/dds/ddsrt/expand_envvars.h"
"${source_path}/dds/ddsrt/fibheap.h"
"${source_path}/dds/ddsrt/hopscotch.h"
"${source_path}/dds/ddsrt/thread_pool.h")
list(APPEND sources
"${source_path}/avl.c"
"${source_path}/expand_envvars.c"
"${source_path}/fibheap.c"
"${source_path}/hopscotch.c"
"${source_path}/thread_pool.c"
"${source_path}/xmlparser.c")
# Not every target offers the same set of features. For embedded targets the # Not every target offers the same set of features. For embedded targets the
# set of features may even be different between builds. e.g. a FreeRTOS build # set of features may even be different between builds. e.g. a FreeRTOS build
# could use the lightweight IP stack, but later change to FreeRTOS+TCP. # could use the lightweight IP stack, but later change to FreeRTOS+TCP.

View file

@ -0,0 +1,359 @@
/*
* 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_AVL_H
#define DDSRT_AVL_H
/* The tree library never performs memory allocations or deallocations internally.
- Treedef_t: defines the properties of the tree, offsets,
comparison functions, augmented structures, flags -- these are
related to the code/data structure in which the tree is embedded,
and in nearly all cases known at compile time.
- avlTree_t: represents the tree, i.e., pointer to the root.
- avlNode_t: contains the administrative data for a single node in
the tree.
For a tree node:
struct T {
avlNode_t avlnode;
int key;
};
by definition, avlnodeoffset == offsetof(struct T, avlnode) and
keyoffset = offsetof(struct T, key). The user of the library only
ever deals in pointers to (in this case) struct T, never with
pointers to the avlNode_t, and the compare function operations on
pointers to keys, in this case pointers to "int"s. If you wish, you
can also do: keyoffset = 0, in which case the compare function
would be operating on struct T's.
The compare function is assumed to behave just like all compare
functions in the C library: < 0, =0, >0 for left argument less
than, equal to or greater than the right argument.
The "augment" function is automatically called whenever some of the
children of a node change, as well as when the "augment" function
has been called on some of the children. It allows you to maintain
a "summary" of the subtree -- currently only used in ddsi2e, in one
spot.
Trees come in various "variants", configured through "treedef"
flags:
- direct/indirect key: direct meaning the key value is embedded in
the structure containing the avlNode_t, indirect meaning a
pointer to the key value is. The compare function doesn't deal
with tree nodes, but with key values.
- re-entrant: in the style of the C library, meaning, the
comparison function gets a user-supplied 3rd argument (in
particular used by mmstat).
- unique keys/duplicate keys: when keys must be unique, some
optimizations apply; it is up to the caller to ensure one doesn't
violate the uniqueness of the keys (it'll happily crash in insert
if you don't); when duplicate keys are allowed, a forward scan of
the tree will visit them in the order of insertion.
For a tree node:
struct T {
avlnode_t avlnode;
char *key;
};
you could set the "indirect" flag, and then you simply use
strcmp(), avoiding the need for passing templates in looking up key
values. Much nicer.
There is also an orthogonal variant that is enforced through the
type system -- note that would be possible for all of the above as
well, but the number of cases simply explodes and none of the above
flags affects the dynamically changing data structures (just the
tree definition), unlike this one.
- the "C" variant keeps track of the number of nodes in the tree to
support a "count" operation in O(1) time, but is otherwise
identical.
The various initializer macros and TreedefInit functions should
make sense with this.
All functions for looking up nodes return NULL if there is no node
satisfying the requirements.
- Init: initializes a tree (really just: root = NULL, perhaps count = 0)
- Free: calls "freefun" on each node, which may free the node
- FreeArg: as "Free", but with an extra, user-supplied, argument
- Root: returns the root node
- Lookup: returns a node with key value "key" (ref allowdups flag)
- LookupIPath: like Lookup, but also filling an IPath_t structure
for efficient insertion in case of a failed lookup (or inserting
duplicates)
- LookupDPath: like Lookup, but also filling a DPath_t structure
that helps with deleting a node
- LookupPredEq: locates the node with the greatest key value <= "key"
- LookupSuccEq: similar, but smallest key value >= "key"
- LookupPred: similar, < "key"
- LookupSucc: similar, > "key"
- Insert: convenience function: LookupIPath ; InsertIPath
- Delete: convenience function: LookupDPath ; DeleteDPath
- InsertIPath: insert node based on the "path" obtained from LookupIPath
- DeleteDPath: delete node, using information in "path" to do so efficiently
- SwapNode: replace "oldn" by "newn" without modifying the tree
structure (the key need not be equal, but must be
FindPred(oldn).key < newn.key < FindSucc(oldn).key, where a
non-existing predecessor has key -inf and a non-existing
successor has key +inf, and where it is understood that the <
operator becomes <= if allowdups is set
- AugmentUpdate: to be called when something in "node" changes that
affects the subtree "summary" computed by the configured
"augment" function
- IsEmpty: returns 1 if tree is empty, 0 if not
- IsSingleton: returns 1 if tree contains exactly one node, 0 if not
- FindMin: returns the node with the smallest key value in the tree
- FindMax: similar, largest key value
- FindPred: preceding node in in-order treewalk
- FindSucc: similar, following node
- Walk: calls "f" with user-supplied argument "a" once for each
node, starting at FindMin and ending at FindMax
- ConstWalk: same, but with a const tree
- WalkRange: like Walk, but only visiting nodes with key values in
range [min,max] (that's inclusive)
- ConstWalkRange: same, but with a const tree
- WalkRangeReverse: like WalkRange, but in the reverse direction
- ConstWalkRangeReverse: same, but with a const tree
- IterFirst: starts forward iteration, starting at (and returning) FindMin
- IterSuccEq: similar, starting at LookupSuccEq
- IterSucc: similar, starting at LookupSucc
- IterNext: returns FindSucc(last returned node); may not be called
if preceding IterXXX call on same "iter" returned NULL
That's all there is to it.
Note that all calls to Walk(f,a) can be rewritten as:
for(n=IterFirst(&it); n; n=IterNext(&it)) { f(n,a) }
or as
for(n=FindMin(); n; n=FindSucc(n)) { f(n,a) }
The walk functions and iterators may not alter the tree
structure. If that is desired, the latter can easily be rewritten
as:
n=FindMin() ; while(n) { nn=FindSucc(n); f(n,a); n=nn }
because FindMin/FindSucc doesn't store any information to allow
fast processing. That'll allow every operation, with the obvious
exception of f(n) calling Delete(FindSucc(n)).
Currently, all trees maintain parent pointers, but it may be worth
doing a separate set without it, as it reduces the size of
avlNode_t. But in that case, the FindMin/FindSucc option would no
longer be a reasonable option because it would be prohibitively
expensive, whereas the IterFirst/IterNext option are alway
efficiently. If one were to do a threaded tree variant, the
implemetantion of IterFirst/IterNext would become absolute trivial
and faster still, but at the cost of significantly more overhead in
memory and updates. */
#include <stdint.h>
#include <stdlib.h>
#include "dds/export.h"
#include "dds/ddsrt/attributes.h"
#if defined (__cplusplus)
extern "C" {
#endif
#define DDSRT_AVL_MAX_TREEHEIGHT (12 * sizeof (void *))
typedef int (*ddsrt_avl_compare_t) (const void *a, const void *b);
typedef int (*ddsrt_avl_compare_r_t) (const void *a, const void *b, void *arg);
typedef void (*ddsrt_avl_augment_t) (void *node, const void *left, const void *right);
typedef void (*ddsrt_avl_walk_t) (void *node, void *arg);
typedef void (*ddsrt_avl_const_walk_t) (const void *node, void *arg);
typedef struct ddsrt_avl_node {
struct ddsrt_avl_node *cs[2]; /* 0 = left, 1 = right */
struct ddsrt_avl_node *parent;
int height;
} ddsrt_avl_node_t;
#define DDSRT_AVL_TREEDEF_FLAG_INDKEY 1
#define DDSRT_AVL_TREEDEF_FLAG_R 2
#define DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS 4
typedef struct ddsrt_avl_treedef {
#if defined (__cplusplus)
ddsrt_avl_treedef() {}
#endif
size_t avlnodeoffset;
size_t keyoffset;
union {
ddsrt_avl_compare_t comparekk;
ddsrt_avl_compare_r_t comparekk_r;
} u;
ddsrt_avl_augment_t augment;
uint32_t flags;
void *cmp_arg; /* for _r variant */
} ddsrt_avl_treedef_t;
typedef struct ddsrt_avl_ctreedef {
ddsrt_avl_treedef_t t;
} ddsrt_avl_ctreedef_t;
typedef struct ddsrt_avl_tree {
ddsrt_avl_node_t *root;
} ddsrt_avl_tree_t;
typedef struct ddsrt_avl_ctree {
ddsrt_avl_tree_t t;
size_t count;
} ddsrt_avl_ctree_t;
typedef struct ddsrt_avl_path {
int depth; /* total depth of path */
int pnodeidx;
ddsrt_avl_node_t *parent; /* (nodeidx == 0 ? NULL : *(path[nodeidx-1])) */
ddsrt_avl_node_t **pnode[DDSRT_AVL_MAX_TREEHEIGHT];
} ddsrt_avl_path_t;
typedef struct ddsrt_avl_ipath {
ddsrt_avl_path_t p;
} ddsrt_avl_ipath_t;
typedef struct ddsrt_avl_dpath {
ddsrt_avl_path_t p;
} ddsrt_avl_dpath_t;
typedef struct ddsrt_avl_iter {
const ddsrt_avl_treedef_t *td;
ddsrt_avl_node_t *right;
ddsrt_avl_node_t **todop;
ddsrt_avl_node_t *todo[1+DDSRT_AVL_MAX_TREEHEIGHT];
} ddsrt_avl_iter_t;
typedef struct ddsrt_avl_citer {
ddsrt_avl_iter_t t;
} ddsrt_avl_citer_t;
/* avlnodeoffset and keyoffset must both be in [0,2**31-1] */
#define DDSRT_AVL_TREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), 0, 0 }
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY, 0 }
#define DDSRT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
#define DDSRT_AVL_TREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_R, (cmparg) }
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_R, (cmparg) }
#define DDSRT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_R|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
#define DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), DDSRT_AVL_TREEDEF_FLAG_INDKEY|DDSRT_AVL_TREEDEF_FLAG_R|DDSRT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
/* Not maintaining # nodes */
DDS_EXPORT void ddsrt_avl_treedef_init (ddsrt_avl_treedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_t comparekk, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ddsrt_avl_treedef_init_r (ddsrt_avl_treedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_r_t comparekk_r, void *cmp_arg, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ddsrt_avl_init (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_free (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void (*freefun) (void *node)) ddsrt_nonnull((1,2));
DDS_EXPORT void ddsrt_avl_free_arg (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void (*freefun) (void *node, void *arg), void *arg) ddsrt_nonnull((1,2));
DDS_EXPORT void *ddsrt_avl_root (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_root_non_empty (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_ipath (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_dpath (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_pred_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_succ_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_pred (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_lookup_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_insert (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_delete (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_insert_ipath (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *node, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_delete_dpath (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *node, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_swap_node (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, void *oldn, void *newn) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_augment_update (const ddsrt_avl_treedef_t *td, void *node) ddsrt_nonnull_all;
DDS_EXPORT int ddsrt_avl_is_empty (const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT int ddsrt_avl_is_singleton (const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_find_min (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_find_max (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_find_pred (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void *ddsrt_avl_find_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void ddsrt_avl_walk (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ddsrt_avl_const_walk (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ddsrt_avl_walk_range (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ddsrt_avl_const_walk_range (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ddsrt_avl_walk_range_reverse (const ddsrt_avl_treedef_t *td, ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ddsrt_avl_const_walk_range_reverse (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void *ddsrt_avl_iter_first (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_iter_succ_eq (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_iter_succ (const ddsrt_avl_treedef_t *td, const ddsrt_avl_tree_t *tree, ddsrt_avl_iter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_iter_next (ddsrt_avl_iter_t *iter) ddsrt_nonnull_all;
/* Maintaining # nodes */
#define DDSRT_AVL_CTREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER (avlnodeoffset, keyoffset, comparekk, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY (avlnodeoffset, keyoffset, comparekk, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define DDSRT_AVL_CTREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { DDSRT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
DDS_EXPORT void ddsrt_avl_ctreedef_init (ddsrt_avl_ctreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_t comparekk, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ddsrt_avl_ctreedef_init_r (ddsrt_avl_ctreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ddsrt_avl_compare_r_t comparekk_r, void *cmp_arg, ddsrt_avl_augment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ddsrt_avl_cinit (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cfree (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void (*freefun) (void *node)) ddsrt_nonnull((1,2));
DDS_EXPORT void ddsrt_avl_cfree_arg (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void (*freefun) (void *node, void *arg), void *arg) ddsrt_nonnull((1,2));
DDS_EXPORT void *ddsrt_avl_croot (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_croot_non_empty (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_ipath (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_dpath (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_pred_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_succ_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_pred (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_clookup_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cinsert (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cdelete (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cinsert_ipath (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *node, ddsrt_avl_ipath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cdelete_dpath (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *node, ddsrt_avl_dpath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_cswap_node (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, void *oldn, void *newn) ddsrt_nonnull_all;
DDS_EXPORT void ddsrt_avl_caugment_update (const ddsrt_avl_ctreedef_t *td, void *node) ddsrt_nonnull_all;
DDS_EXPORT int ddsrt_avl_cis_empty (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT int ddsrt_avl_cis_singleton (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT size_t ddsrt_avl_ccount (const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_cfind_min (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_cfind_max (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_cfind_pred (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void *ddsrt_avl_cfind_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void ddsrt_avl_cwalk (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ddsrt_avl_cconst_walk (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ddsrt_avl_cwalk_range (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ddsrt_avl_cconst_walk_range (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ddsrt_avl_cwalk_range_reverse (const ddsrt_avl_ctreedef_t *td, ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ddsrt_avl_cconst_walk_range_reverse (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, const void *min, const void *max, ddsrt_avl_const_walk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void *ddsrt_avl_citer_first (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_citer_succ_eq (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_citer_succ (const ddsrt_avl_ctreedef_t *td, const ddsrt_avl_ctree_t *tree, ddsrt_avl_citer_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ddsrt_avl_citer_next (ddsrt_avl_citer_t *iter) ddsrt_nonnull_all;
#if defined (__cplusplus)
}
#endif
#endif /* DDSRT_AVL_H */

View file

@ -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 UT_EXPAND_ENVVARS_H #ifndef DDSRT_EXPAND_ENVVARS_H
#define UT_EXPAND_ENVVARS_H #define DDSRT_EXPAND_ENVVARS_H
#include "dds/export.h" #include "dds/export.h"
@ -19,10 +19,10 @@ extern "C" {
#endif #endif
/* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X */ /* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X */
DDS_EXPORT char *ut_expand_envvars(const char *string); DDS_EXPORT char *ddsrt_expand_envvars(const char *string);
/* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, $ and \ can be escaped with \ */ /* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, $ and \ can be escaped with \ */
DDS_EXPORT char *ut_expand_envvars_sh(const char *string); DDS_EXPORT char *ddsrt_expand_envvars_sh(const char *string);
#if defined (__cplusplus) #if defined (__cplusplus)
} }

View file

@ -0,0 +1,54 @@
/*
* 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_FIBHEAP_H
#define DDSRT_FIBHEAP_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
typedef struct ddsrt_fibheap_node {
struct ddsrt_fibheap_node *parent, *children;
struct ddsrt_fibheap_node *prev, *next;
unsigned mark: 1;
unsigned degree: 31;
} ddsrt_fibheap_node_t;
typedef struct ddsrt_fibheap_def {
uintptr_t offset;
int (*cmp) (const void *va, const void *vb);
} ddsrt_fibheap_def_t;
typedef struct ddsrt_fibheap {
ddsrt_fibheap_node_t *roots; /* points to root with min key value */
} ddsrt_fibheap_t;
#define DDSRT_FIBHEAPDEF_INITIALIZER(offset, cmp) { (offset), (cmp) }
DDS_EXPORT void ddsrt_fibheap_def_init (ddsrt_fibheap_def_t *fhdef, uintptr_t offset, int (*cmp) (const void *va, const void *vb));
DDS_EXPORT void ddsrt_fibheap_init (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh);
DDS_EXPORT void *ddsrt_fibheap_min (const ddsrt_fibheap_def_t *fhdef, const ddsrt_fibheap_t *fh);
DDS_EXPORT void ddsrt_fibheap_merge (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *a, ddsrt_fibheap_t *b);
DDS_EXPORT void ddsrt_fibheap_insert (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode);
DDS_EXPORT void ddsrt_fibheap_delete (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode);
DDS_EXPORT void *ddsrt_fibheap_extract_min (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh);
DDS_EXPORT void ddsrt_fibheap_decrease_key (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode); /* to be called AFTER decreasing the key */
#if defined (__cplusplus)
}
#endif
#endif /* DDSRT_FIBHEAP_H */

View file

@ -0,0 +1,104 @@
/*
* 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_HOPSCOTCH_H
#define DDSRT_HOPSCOTCH_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
/* Concurrent version */
struct ddsrt_chh;
struct ddsrt_chh_bucket;
struct ddsrt_chh_iter {
struct ddsrt_chh_bucket *bs;
uint32_t size;
uint32_t cursor;
};
/*
* The hopscotch hash table is dependent on a proper functioning hash.
* If the hash function generates a lot of hash collisions, then it will
* not be able to handle that by design.
* It is capable of handling some collisions, but not more than 32 per
* bucket (less, when other hash values are clustered around the
* collision value).
* When proper distributed hash values are generated, then hopscotch
* works nice and quickly.
*/
typedef uint32_t (*ddsrt_hh_hash_fn) (const void *);
/*
* Hopscotch needs to be able to compare two elements.
* Returns 0 when not equal.
*/
typedef int (*ddsrt_hh_equals_fn) (const void *, const void *);
/*
* Hopscotch is will resize its internal buckets list when needed. It will
* call this garbage collection function with the old buckets list. The
* caller has to delete the list when it deems it safe to do so.
*/
typedef void (*ddsrt_hh_buckets_gc_fn) (void *);
DDS_EXPORT struct ddsrt_chh *ddsrt_chh_new (uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals, ddsrt_hh_buckets_gc_fn gc_buckets);
DDS_EXPORT void ddsrt_chh_free (struct ddsrt_chh * __restrict hh);
DDS_EXPORT void *ddsrt_chh_lookup (struct ddsrt_chh * __restrict rt, const void * __restrict template);
DDS_EXPORT int ddsrt_chh_add (struct ddsrt_chh * __restrict rt, const void * __restrict data);
DDS_EXPORT int ddsrt_chh_remove (struct ddsrt_chh * __restrict rt, const void * __restrict template);
DDS_EXPORT void ddsrt_chh_enum_unsafe (struct ddsrt_chh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
void *ddsrt_chh_iter_first (struct ddsrt_chh * __restrict rt, struct ddsrt_chh_iter *it);
void *ddsrt_chh_iter_next (struct ddsrt_chh_iter *it);
/* Sequential version */
struct ddsrt_hh;
struct ddsrt_hh_iter {
struct ddsrt_hh *hh;
uint32_t cursor;
};
DDS_EXPORT struct ddsrt_hh *ddsrt_hh_new (uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals);
DDS_EXPORT void ddsrt_hh_free (struct ddsrt_hh * __restrict hh);
DDS_EXPORT void *ddsrt_hh_lookup (const struct ddsrt_hh * __restrict rt, const void * __restrict template);
DDS_EXPORT int ddsrt_hh_add (struct ddsrt_hh * __restrict rt, const void * __restrict data);
DDS_EXPORT int ddsrt_hh_remove (struct ddsrt_hh * __restrict rt, const void * __restrict template);
DDS_EXPORT void ddsrt_hh_enum (struct ddsrt_hh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
DDS_EXPORT void *ddsrt_hh_iter_first (struct ddsrt_hh * __restrict rt, struct ddsrt_hh_iter * __restrict iter); /* may delete nodes */
DDS_EXPORT void *ddsrt_hh_iter_next (struct ddsrt_hh_iter * __restrict iter);
/* Sequential version, embedded data */
struct ddsrt_ehh;
struct ddsrt_ehh_iter {
struct ddsrt_ehh *hh;
uint32_t cursor;
};
DDS_EXPORT struct ddsrt_ehh *ddsrt_ehh_new (size_t elemsz, uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals);
DDS_EXPORT void ddsrt_ehh_free (struct ddsrt_ehh * __restrict hh);
DDS_EXPORT void *ddsrt_ehh_lookup (const struct ddsrt_ehh * __restrict rt, const void * __restrict template);
DDS_EXPORT int ddsrt_ehh_add (struct ddsrt_ehh * __restrict rt, const void * __restrict data);
DDS_EXPORT int ddsrt_ehh_remove (struct ddsrt_ehh * __restrict rt, const void * __restrict template);
DDS_EXPORT void ddsrt_ehh_enum (struct ddsrt_ehh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
DDS_EXPORT void *ddsrt_ehh_iter_first (struct ddsrt_ehh * __restrict rt, struct ddsrt_ehh_iter * __restrict iter); /* may delete nodes */
DDS_EXPORT void *ddsrt_ehh_iter_next (struct ddsrt_ehh_iter * __restrict iter);
#if defined (__cplusplus)
}
#endif
#endif

View file

@ -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 UT_THREAD_POOL_H #ifndef DDSRT_THREAD_POOL_H
#define UT_THREAD_POOL_H #define DDSRT_THREAD_POOL_H
#include <stdint.h> #include <stdint.h>
@ -22,16 +22,16 @@
extern "C" { extern "C" {
#endif #endif
typedef struct ut_thread_pool_s *ut_thread_pool; typedef struct ddsrt_thread_pool_s *ddsrt_thread_pool;
/* /*
ut_thread_pool_new: Creates a new thread pool. Returns NULL if ddsrt_thread_pool_new: Creates a new thread pool. Returns NULL if
cannot create initial set of threads. Threads are created with cannot create initial set of threads. Threads are created with
the optional atribute argument. Additional threads may be created the optional atribute argument. Additional threads may be created
on demand up to max_threads. on demand up to max_threads.
*/ */
DDS_EXPORT ut_thread_pool ut_thread_pool_new DDS_EXPORT ddsrt_thread_pool ddsrt_thread_pool_new
( (
uint32_t threads, /* Initial number of threads in pool (can be 0) */ uint32_t threads, /* Initial number of threads in pool (can be 0) */
uint32_t max_threads, /* Maximum number of threads in pool (0 == infinite) */ uint32_t max_threads, /* Maximum number of threads in pool (0 == infinite) */
@ -39,25 +39,25 @@ DDS_EXPORT ut_thread_pool ut_thread_pool_new
ddsrt_threadattr_t * attr /* Attributes used to create pool threads (can be NULL) */ ddsrt_threadattr_t * attr /* Attributes used to create pool threads (can be NULL) */
); );
/* ut_thread_pool_free: Frees pool, destroying threads. */ /* ddsrt_thread_pool_free: Frees pool, destroying threads. */
DDS_EXPORT void ut_thread_pool_free (ut_thread_pool pool); DDS_EXPORT void ddsrt_thread_pool_free (ddsrt_thread_pool pool);
/* ut_thread_pool_purge: Purge threads from pool back to initial set. */ /* ddsrt_thread_pool_purge: Purge threads from pool back to initial set. */
DDS_EXPORT void ut_thread_pool_purge (ut_thread_pool pool); DDS_EXPORT void ddsrt_thread_pool_purge (ddsrt_thread_pool pool);
/* /*
ut_thread_pool_submit: Submit a thread function and associated argument ddsrt_thread_pool_submit: Submit a thread function and associated argument
to be invoked by a thread from the pool. If no threads are available a to be invoked by a thread from the pool. If no threads are available a
new thread will be created on demand to handle the function unless the new thread will be created on demand to handle the function unless the
pool thread maximum has been reached, in which case the function is queued. pool thread maximum has been reached, in which case the function is queued.
Note that if the pool queue has reached it's maximum DDS_RETCODE_TRY_AGAIN is returned. Note that if the pool queue has reached it's maximum DDS_RETCODE_TRY_AGAIN is returned.
*/ */
DDS_EXPORT dds_retcode_t ut_thread_pool_submit DDS_EXPORT dds_retcode_t ddsrt_thread_pool_submit
( (
ut_thread_pool pool, /* Thread pool instance */ ddsrt_thread_pool pool, /* Thread pool instance */
void (*fn) (void *arg), /* Function to be invoked by thread from pool */ void (*fn) (void *arg), /* Function to be invoked by thread from pool */
void * arg /* Argument passed to invoked function */ void * arg /* Argument passed to invoked function */
); );
@ -66,4 +66,4 @@ DDS_EXPORT dds_retcode_t ut_thread_pool_submit
} }
#endif #endif
#endif /* UT_THREAD_POOL_H */ #endif /* DDSRT_THREAD_POOL_H */

View file

@ -0,0 +1,52 @@
/*
* 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_XMLPARSER_H
#define DDSRT_XMLPARSER_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
typedef int (*ddsrt_xmlp_proc_elem_open_t) (void *varg, uintptr_t parentinfo, uintptr_t *eleminfo, const char *name);
typedef int (*ddsrt_xmlp_proc_attr_t) (void *varg, uintptr_t eleminfo, const char *name, const char *value);
typedef int (*ddsrt_xmlp_proc_elem_data_t) (void *varg, uintptr_t eleminfo, const char *data);
typedef int (*ddsrt_xmlp_proc_elem_close_t) (void *varg, uintptr_t eleminfo);
typedef void (*ddsrt_xmlp_error) (void *varg, const char *msg, int line);
struct ddsrt_xmlp_callbacks {
ddsrt_xmlp_proc_elem_open_t elem_open;
ddsrt_xmlp_proc_attr_t attr;
ddsrt_xmlp_proc_elem_data_t elem_data;
ddsrt_xmlp_proc_elem_close_t elem_close;
ddsrt_xmlp_error error;
};
struct ddsrt_xmlp_state;
DDS_EXPORT struct ddsrt_xmlp_state *ddsrt_xmlp_new_file (FILE *fp, void *varg, const struct ddsrt_xmlp_callbacks *cb);
DDS_EXPORT struct ddsrt_xmlp_state *ddsrt_xmlp_new_string (const char *string, void *varg, const struct ddsrt_xmlp_callbacks *cb);
DDS_EXPORT void ddsrt_xmlp_set_requireEOF (struct ddsrt_xmlp_state *st, int require_eof);
DDS_EXPORT size_t ddsrt_xmlp_get_bufpos (const struct ddsrt_xmlp_state *st);
DDS_EXPORT void ddsrt_xmlp_free (struct ddsrt_xmlp_state *st);
DDS_EXPORT int ddsrt_xmlp_parse (struct ddsrt_xmlp_state *st);
DDS_EXPORT int ddsrt_xmlUnescapeInsitu (char *buffer, size_t *n);
#if defined (__cplusplus)
}
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/log.h" #include "dds/ddsrt/log.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/util/ut_expand_envvars.h" #include "dds/ddsrt/expand_envvars.h"
typedef char * (*expand_fn)(const char *src0); typedef char * (*expand_fn)(const char *src0);
@ -157,7 +157,7 @@ static char *expand_envchar (const char **src, expand_fn expand)
return expand_env (name, 0, NULL, expand); return expand_env (name, 0, NULL, expand);
} }
char *ut_expand_envvars_sh (const char *src0) char *ddsrt_expand_envvars_sh (const char *src0)
{ {
/* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms; $ and \ can be escaped with \ */ /* Expands $X, ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms; $ and \ can be escaped with \ */
const char *src = src0; const char *src = src0;
@ -180,11 +180,11 @@ char *ut_expand_envvars_sh (const char *src0)
ddsrt_free(dst); ddsrt_free(dst);
return NULL; return NULL;
} else if (*src == '{') { } else if (*src == '{') {
x = expand_envbrace (&src, &ut_expand_envvars_sh); x = expand_envbrace (&src, &ddsrt_expand_envvars_sh);
} else if (isalnum ((unsigned char) *src) || *src == '_') { } else if (isalnum ((unsigned char) *src) || *src == '_') {
x = expand_envsimple (&src, &ut_expand_envvars_sh); x = expand_envsimple (&src, &ddsrt_expand_envvars_sh);
} else { } else {
x = expand_envchar (&src, &ut_expand_envvars_sh); x = expand_envchar (&src, &ddsrt_expand_envvars_sh);
} }
if (x == NULL) { if (x == NULL) {
ddsrt_free(dst); ddsrt_free(dst);
@ -203,7 +203,7 @@ char *ut_expand_envvars_sh (const char *src0)
return dst; return dst;
} }
char *ut_expand_envvars (const char *src0) char *ddsrt_expand_envvars (const char *src0)
{ {
/* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X */ /* Expands ${X}, ${X:-Y}, ${X:+Y}, ${X:?Y} forms, but not $X */
const char *src = src0; const char *src = src0;
@ -213,7 +213,7 @@ char *ut_expand_envvars (const char *src0)
if (*src == '$' && *(src + 1) == '{') { if (*src == '$' && *(src + 1) == '{') {
char *x, *xp; char *x, *xp;
src++; src++;
x = expand_envbrace (&src, &ut_expand_envvars); x = expand_envbrace (&src, &ddsrt_expand_envvars);
if (x == NULL) { if (x == NULL) {
ddsrt_free(dst); ddsrt_free(dst);
return NULL; return NULL;

View file

@ -14,7 +14,7 @@
#include <assert.h> #include <assert.h>
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/util/ut_fibheap.h" #include "dds/ddsrt/fibheap.h"
/* max degree: n >= F_{d+2} >= \phi^d ==> d <= log_\phi n, where \phi /* max degree: n >= F_{d+2} >= \phi^d ==> d <= log_\phi n, where \phi
(as usual) is the golden ratio ~= 1.618. We know n <= (size of (as usual) is the golden ratio ~= 1.618. We know n <= (size of
@ -23,24 +23,24 @@
space). */ space). */
#define MAX_DEGREE ((unsigned) (sizeof (void *) * CHAR_BIT - 1)) #define MAX_DEGREE ((unsigned) (sizeof (void *) * CHAR_BIT - 1))
static int cmp (const ut_fibheapDef_t *fhdef, const ut_fibheapNode_t *a, const ut_fibheapNode_t *b) static int cmp (const ddsrt_fibheap_def_t *fhdef, const ddsrt_fibheap_node_t *a, const ddsrt_fibheap_node_t *b)
{ {
return fhdef->cmp ((const char *) a - fhdef->offset, (const char *) b - fhdef->offset); return fhdef->cmp ((const char *) a - fhdef->offset, (const char *) b - fhdef->offset);
} }
void ut_fibheapDefInit (ut_fibheapDef_t *fhdef, uintptr_t offset, int (*cmp) (const void *va, const void *vb)) void ddsrt_fibheap_def_init (ddsrt_fibheap_def_t *fhdef, uintptr_t offset, int (*cmp) (const void *va, const void *vb))
{ {
fhdef->offset = offset; fhdef->offset = offset;
fhdef->cmp = cmp; fhdef->cmp = cmp;
} }
void ut_fibheapInit (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh) void ddsrt_fibheap_init (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh)
{ {
DDSRT_UNUSED_ARG(fhdef); DDSRT_UNUSED_ARG(fhdef);
fh->roots = NULL; fh->roots = NULL;
} }
void *ut_fibheapMin (const ut_fibheapDef_t *fhdef, const ut_fibheap_t *fh) void *ddsrt_fibheap_min (const ddsrt_fibheap_def_t *fhdef, const ddsrt_fibheap_t *fh)
{ {
if (fh->roots) { if (fh->roots) {
return (void *) ((char *) fh->roots - fhdef->offset); return (void *) ((char *) fh->roots - fhdef->offset);
@ -49,16 +49,16 @@ void *ut_fibheapMin (const ut_fibheapDef_t *fhdef, const ut_fibheap_t *fh)
} }
} }
static void ut_fibheap_merge_nonempty_list (ut_fibheapNode_t **markptr, ut_fibheapNode_t *list) static void ddsrt_fibheap_merge_nonempty_list (ddsrt_fibheap_node_t **markptr, ddsrt_fibheap_node_t *list)
{ {
assert (list != NULL); assert (list != NULL);
if (*markptr == NULL) { if (*markptr == NULL) {
*markptr = list; *markptr = list;
} else { } else {
ut_fibheapNode_t * const mark = *markptr; ddsrt_fibheap_node_t * const mark = *markptr;
ut_fibheapNode_t * const old_mark_next = mark->next; ddsrt_fibheap_node_t * const old_mark_next = mark->next;
ut_fibheapNode_t * const old_list_prev = list->prev; ddsrt_fibheap_node_t * const old_list_prev = list->prev;
mark->next = list; mark->next = list;
old_mark_next->prev = old_list_prev; old_mark_next->prev = old_list_prev;
list->prev = mark; list->prev = mark;
@ -66,7 +66,7 @@ static void ut_fibheap_merge_nonempty_list (ut_fibheapNode_t **markptr, ut_fibhe
} }
} }
static void ut_fibheap_merge_into (const ut_fibheapDef_t *fhdef, ut_fibheap_t *a, ut_fibheapNode_t * const br) static void ddsrt_fibheap_merge_into (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *a, ddsrt_fibheap_node_t * const br)
{ {
if (br == NULL) { if (br == NULL) {
return; return;
@ -74,25 +74,25 @@ static void ut_fibheap_merge_into (const ut_fibheapDef_t *fhdef, ut_fibheap_t *a
a->roots = br; a->roots = br;
} else { } else {
const int c = cmp (fhdef, br, a->roots); const int c = cmp (fhdef, br, a->roots);
ut_fibheap_merge_nonempty_list (&a->roots, br); ddsrt_fibheap_merge_nonempty_list (&a->roots, br);
if (c < 0) if (c < 0)
a->roots = br; a->roots = br;
} }
} }
void ut_fibheapMerge (const ut_fibheapDef_t *fhdef, ut_fibheap_t *a, ut_fibheap_t *b) void ddsrt_fibheap_merge (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *a, ddsrt_fibheap_t *b)
{ {
/* merges nodes from b into a, thereafter, b is empty */ /* merges nodes from b into a, thereafter, b is empty */
ut_fibheap_merge_into (fhdef, a, b->roots); ddsrt_fibheap_merge_into (fhdef, a, b->roots);
b->roots = NULL; b->roots = NULL;
} }
void ut_fibheapInsert (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode) void ddsrt_fibheap_insert (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode)
{ {
/* fibheap node is opaque => nothing in node changes as far as /* fibheap node is opaque => nothing in node changes as far as
caller is concerned => declare as const argument, then drop the caller is concerned => declare as const argument, then drop the
const qualifier */ const qualifier */
ut_fibheapNode_t *node = (ut_fibheapNode_t *) ((char *) vnode + fhdef->offset); ddsrt_fibheap_node_t *node = (ddsrt_fibheap_node_t *) ((char *) vnode + fhdef->offset);
/* new heap of degree 0 (i.e., only containing NODE) */ /* new heap of degree 0 (i.e., only containing NODE) */
node->parent = node->children = NULL; node->parent = node->children = NULL;
@ -101,24 +101,24 @@ void ut_fibheapInsert (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const voi
node->degree = 0; node->degree = 0;
/* then merge it in */ /* then merge it in */
ut_fibheap_merge_into (fhdef, fh, node); ddsrt_fibheap_merge_into (fhdef, fh, node);
} }
static void ut_fibheap_add_as_child (ut_fibheapNode_t *parent, ut_fibheapNode_t *child) static void ddsrt_fibheap_add_as_child (ddsrt_fibheap_node_t *parent, ddsrt_fibheap_node_t *child)
{ {
parent->degree++; parent->degree++;
child->parent = parent; child->parent = parent;
child->prev = child->next = child; child->prev = child->next = child;
ut_fibheap_merge_nonempty_list (&parent->children, child); ddsrt_fibheap_merge_nonempty_list (&parent->children, child);
} }
static void ut_fibheap_delete_one_from_list (ut_fibheapNode_t **markptr, ut_fibheapNode_t *node) static void ddsrt_fibheap_delete_one_from_list (ddsrt_fibheap_node_t **markptr, ddsrt_fibheap_node_t *node)
{ {
if (node->next == node) { if (node->next == node) {
*markptr = NULL; *markptr = NULL;
} else { } else {
ut_fibheapNode_t * const node_prev = node->prev; ddsrt_fibheap_node_t * const node_prev = node->prev;
ut_fibheapNode_t * const node_next = node->next; ddsrt_fibheap_node_t * const node_next = node->next;
node_prev->next = node_next; node_prev->next = node_next;
node_next->prev = node_prev; node_next->prev = node_prev;
if (*markptr == node) { if (*markptr == node) {
@ -127,10 +127,10 @@ static void ut_fibheap_delete_one_from_list (ut_fibheapNode_t **markptr, ut_fibh
} }
} }
void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh) void *ddsrt_fibheap_extract_min (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh)
{ {
ut_fibheapNode_t *roots[MAX_DEGREE + 1]; ddsrt_fibheap_node_t *roots[MAX_DEGREE + 1];
ut_fibheapNode_t * const min = fh->roots; ddsrt_fibheap_node_t * const min = fh->roots;
unsigned min_degree_noninit = 0; unsigned min_degree_noninit = 0;
/* empty heap => return that, alternative would be to require the /* empty heap => return that, alternative would be to require the
@ -147,7 +147,7 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
} }
/* remove min from fh->roots */ /* remove min from fh->roots */
ut_fibheap_delete_one_from_list (&fh->roots, min); ddsrt_fibheap_delete_one_from_list (&fh->roots, min);
/* FIXME: can speed up by combining a few things & improving /* FIXME: can speed up by combining a few things & improving
locality of reference by scanning lists only once */ locality of reference by scanning lists only once */
@ -155,30 +155,30 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
/* insert min'schildren as new roots -- must fix parent pointers, /* insert min'schildren as new roots -- must fix parent pointers,
and reset marks because roots are always unmarked */ and reset marks because roots are always unmarked */
if (min->children) { if (min->children) {
ut_fibheapNode_t * const mark = min->children; ddsrt_fibheap_node_t * const mark = min->children;
ut_fibheapNode_t *n = mark; ddsrt_fibheap_node_t *n = mark;
do { do {
n->parent = NULL; n->parent = NULL;
n->mark = 0; n->mark = 0;
n = n->next; n = n->next;
} while (n != mark); } while (n != mark);
ut_fibheap_merge_nonempty_list (&fh->roots, min->children); ddsrt_fibheap_merge_nonempty_list (&fh->roots, min->children);
} }
/* iteratively merge roots of equal degree, completely messing up /* iteratively merge roots of equal degree, completely messing up
fh->roots, ... */ fh->roots, ... */
{ {
ut_fibheapNode_t *const mark = fh->roots; ddsrt_fibheap_node_t *const mark = fh->roots;
ut_fibheapNode_t *n = mark; ddsrt_fibheap_node_t *n = mark;
do { do {
ut_fibheapNode_t * const n1 = n->next; ddsrt_fibheap_node_t * const n1 = n->next;
/* if n is first root with this high a degree, there's certainly /* if n is first root with this high a degree, there's certainly
not going to be another root to merge with yet */ not going to be another root to merge with yet */
while (n->degree < min_degree_noninit && roots[n->degree]) { while (n->degree < min_degree_noninit && roots[n->degree]) {
unsigned const degree = n->degree; unsigned const degree = n->degree;
ut_fibheapNode_t *u, *v; ddsrt_fibheap_node_t *u, *v;
if (cmp (fhdef, roots[degree], n) < 0) { if (cmp (fhdef, roots[degree], n) < 0) {
u = roots[degree]; v = n; u = roots[degree]; v = n;
@ -186,7 +186,7 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
u = n; v = roots[degree]; u = n; v = roots[degree];
} }
roots[degree] = NULL; roots[degree] = NULL;
ut_fibheap_add_as_child (u, v); ddsrt_fibheap_add_as_child (u, v);
n = u; n = u;
} }
@ -206,7 +206,7 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
memory at an astonishing rate, and we need to compare the root memory at an astonishing rate, and we need to compare the root
keys anyway to find the minimum */ keys anyway to find the minimum */
{ {
ut_fibheapNode_t *mark, *cursor, *newmin; ddsrt_fibheap_node_t *mark, *cursor, *newmin;
unsigned i; unsigned i;
for (i = 0; roots[i] == NULL; i++) { for (i = 0; roots[i] == NULL; i++) {
assert (i+1 < min_degree_noninit); assert (i+1 < min_degree_noninit);
@ -216,7 +216,7 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
mark = cursor = roots[i]; mark = cursor = roots[i];
for (++i; i < min_degree_noninit; i++) { for (++i; i < min_degree_noninit; i++) {
if (roots[i]) { if (roots[i]) {
ut_fibheapNode_t * const r = roots[i]; ddsrt_fibheap_node_t * const r = roots[i];
if (cmp (fhdef, r, newmin) < 0) if (cmp (fhdef, r, newmin) < 0)
newmin = r; newmin = r;
r->prev = cursor; r->prev = cursor;
@ -233,17 +233,17 @@ void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh)
return (void *) ((char *) min - fhdef->offset); return (void *) ((char *) min - fhdef->offset);
} }
static void ut_fibheap_cutnode (ut_fibheap_t *fh, ut_fibheapNode_t *node) static void ddsrt_fibheap_cutnode (ddsrt_fibheap_t *fh, ddsrt_fibheap_node_t *node)
{ {
/* by marking the node, we ensure it gets cut */ /* by marking the node, we ensure it gets cut */
node->mark = 1; node->mark = 1;
/* traverse towards the root, cutting marked nodes on the way */ /* traverse towards the root, cutting marked nodes on the way */
while (node->parent && node->mark) { while (node->parent && node->mark) {
ut_fibheapNode_t *parent = node->parent; ddsrt_fibheap_node_t *parent = node->parent;
assert (parent->degree > 0); assert (parent->degree > 0);
ut_fibheap_delete_one_from_list (&parent->children, node); ddsrt_fibheap_delete_one_from_list (&parent->children, node);
parent->degree--; parent->degree--;
node->mark = 0; node->mark = 0;
@ -252,7 +252,7 @@ static void ut_fibheap_cutnode (ut_fibheap_t *fh, ut_fibheapNode_t *node)
/* we assume heap properties haven't been violated, and therefore /* we assume heap properties haven't been violated, and therefore
none of the nodes we cut can become the new minimum */ none of the nodes we cut can become the new minimum */
ut_fibheap_merge_nonempty_list (&fh->roots, node); ddsrt_fibheap_merge_nonempty_list (&fh->roots, node);
node = parent; node = parent;
} }
@ -264,12 +264,12 @@ static void ut_fibheap_cutnode (ut_fibheap_t *fh, ut_fibheapNode_t *node)
} }
} }
void ut_fibheapDecreaseKey (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode) void ddsrt_fibheap_decrease_key (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode)
{ {
/* fibheap node is opaque => nothing in node changes as far as /* fibheap node is opaque => nothing in node changes as far as
caller is concerned => declare as const argument, then drop the caller is concerned => declare as const argument, then drop the
const qualifier */ const qualifier */
ut_fibheapNode_t *node = (ut_fibheapNode_t *) ((char *) vnode + fhdef->offset); ddsrt_fibheap_node_t *node = (ddsrt_fibheap_node_t *) ((char *) vnode + fhdef->offset);
if (node->parent && cmp (fhdef, node->parent, node) <= 0) { if (node->parent && cmp (fhdef, node->parent, node) <= 0) {
/* heap property not violated, do nothing */ /* heap property not violated, do nothing */
@ -278,7 +278,7 @@ void ut_fibheapDecreaseKey (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, cons
/* heap property violated by decreasing the key, but we cut it /* heap property violated by decreasing the key, but we cut it
pretending nothing has happened yet, then fix up the minimum if pretending nothing has happened yet, then fix up the minimum if
this node is the new minimum */ this node is the new minimum */
ut_fibheap_cutnode (fh, node); ddsrt_fibheap_cutnode (fh, node);
} }
if (cmp (fhdef, node, fh->roots) < 0) { if (cmp (fhdef, node, fh->roots) < 0) {
fh->roots = node; fh->roots = node;
@ -286,19 +286,19 @@ void ut_fibheapDecreaseKey (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, cons
} }
} }
void ut_fibheapDelete (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode) void ddsrt_fibheap_delete (const ddsrt_fibheap_def_t *fhdef, ddsrt_fibheap_t *fh, const void *vnode)
{ {
/* fibheap node is opaque => nothing in node changes as far as /* fibheap node is opaque => nothing in node changes as far as
caller is concerned => declare as const argument, then drop the caller is concerned => declare as const argument, then drop the
const qualifier */ const qualifier */
ut_fibheapNode_t *node = (ut_fibheapNode_t *) ((char *) vnode + fhdef->offset); ddsrt_fibheap_node_t *node = (ddsrt_fibheap_node_t *) ((char *) vnode + fhdef->offset);
/* essentially decreasekey(node);extractmin while pretending the /* essentially decreasekey(node);extractmin while pretending the
node key is -infinity. That means we can't directly call node key is -infinity. That means we can't directly call
decreasekey, because it considers the actual value of the key. */ decreasekey, because it considers the actual value of the key. */
if (node->parent != NULL) { if (node->parent != NULL) {
ut_fibheap_cutnode (fh, node); ddsrt_fibheap_cutnode (fh, node);
} }
fh->roots = node; fh->roots = node;
(void) ut_fibheapExtractMin (fhdef, fh); (void) ddsrt_fibheap_extract_min (fhdef, fh);
} }

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/atomics.h" #include "dds/ddsrt/atomics.h"
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/util/ut_hopscotch.h" #include "dds/ddsrt/hopscotch.h"
#define HH_HOP_RANGE 32 #define HH_HOP_RANGE 32
#define HH_ADD_RANGE 64 #define HH_ADD_RANGE 64
@ -27,45 +27,45 @@
#define N_BACKING_LOCKS 32 #define N_BACKING_LOCKS 32
#define N_RESIZE_LOCKS 8 #define N_RESIZE_LOCKS 8
struct ut_chhBucket { struct ddsrt_chh_bucket {
ddsrt_atomic_uint32_t hopinfo; ddsrt_atomic_uint32_t hopinfo;
ddsrt_atomic_uint32_t timestamp; ddsrt_atomic_uint32_t timestamp;
ddsrt_atomic_uint32_t lock; ddsrt_atomic_uint32_t lock;
ddsrt_atomic_voidp_t data; ddsrt_atomic_voidp_t data;
}; };
struct ut_chhBucketArray { struct ddsrt_chh_bucket_array {
uint32_t size; /* power of 2 */ uint32_t size; /* power of 2 */
struct ut_chhBucket bs[]; struct ddsrt_chh_bucket bs[];
}; };
struct ut_chhBackingLock { struct ddsrt_chh_backing_lock {
ddsrt_mutex_t lock; ddsrt_mutex_t lock;
ddsrt_cond_t cv; ddsrt_cond_t cv;
}; };
struct ut_chh { struct ddsrt_chh {
ddsrt_atomic_voidp_t buckets; /* struct ut_chhBucketArray * */ ddsrt_atomic_voidp_t buckets; /* struct ddsrt_chh_bucket_array * */
struct ut_chhBackingLock backingLocks[N_BACKING_LOCKS]; struct ddsrt_chh_backing_lock backingLocks[N_BACKING_LOCKS];
ut_hhHash_fn hash; ddsrt_hh_hash_fn hash;
ut_hhEquals_fn equals; ddsrt_hh_equals_fn equals;
ddsrt_rwlock_t resize_locks[N_RESIZE_LOCKS]; ddsrt_rwlock_t resize_locks[N_RESIZE_LOCKS];
ut_hhBucketsGc_fn gc_buckets; ddsrt_hh_buckets_gc_fn gc_buckets;
}; };
#define CHH_MAX_TRIES 4 #define CHH_MAX_TRIES 4
#define CHH_BUSY ((void *) 1) #define CHH_BUSY ((void *) 1)
static int ut_chhDataValid_p (void *data) static int ddsrt_chh_data_valid_p (void *data)
{ {
return data != NULL && data != CHH_BUSY; return data != NULL && data != CHH_BUSY;
} }
static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals, ut_hhBucketsGc_fn gc_buckets) static int ddsrt_chh_init (struct ddsrt_chh *rt, uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals, ddsrt_hh_buckets_gc_fn gc_buckets)
{ {
uint32_t size; uint32_t size;
uint32_t i; uint32_t i;
struct ut_chhBucketArray *buckets; struct ddsrt_chh_bucket_array *buckets;
size = HH_HOP_RANGE; size = HH_HOP_RANGE;
while (size < init_size) { while (size < init_size) {
@ -75,11 +75,11 @@ static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash,
rt->equals = equals; rt->equals = equals;
rt->gc_buckets = gc_buckets; rt->gc_buckets = gc_buckets;
buckets = ddsrt_malloc (offsetof (struct ut_chhBucketArray, bs) + size * sizeof (*buckets->bs)); buckets = ddsrt_malloc (offsetof (struct ddsrt_chh_bucket_array, bs) + size * sizeof (*buckets->bs));
ddsrt_atomic_stvoidp (&rt->buckets, buckets); ddsrt_atomic_stvoidp (&rt->buckets, buckets);
buckets->size = size; buckets->size = size;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
struct ut_chhBucket *b = &buckets->bs[i]; struct ddsrt_chh_bucket *b = &buckets->bs[i];
ddsrt_atomic_st32 (&b->hopinfo, 0); ddsrt_atomic_st32 (&b->hopinfo, 0);
ddsrt_atomic_st32 (&b->timestamp, 0); ddsrt_atomic_st32 (&b->timestamp, 0);
ddsrt_atomic_st32 (&b->lock, 0); ddsrt_atomic_st32 (&b->lock, 0);
@ -87,7 +87,7 @@ static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash,
} }
for (i = 0; i < N_BACKING_LOCKS; i++) { for (i = 0; i < N_BACKING_LOCKS; i++) {
struct ut_chhBackingLock *s = &rt->backingLocks[i]; struct ddsrt_chh_backing_lock *s = &rt->backingLocks[i];
ddsrt_mutex_init (&s->lock); ddsrt_mutex_init (&s->lock);
ddsrt_cond_init (&s->cv); ddsrt_cond_init (&s->cv);
} }
@ -97,12 +97,12 @@ static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash,
return 0; return 0;
} }
static void ut_chhFini (struct ut_chh *rt) static void ddsrt_chh_fini (struct ddsrt_chh *rt)
{ {
int i; int i;
ddsrt_free (ddsrt_atomic_ldvoidp (&rt->buckets)); ddsrt_free (ddsrt_atomic_ldvoidp (&rt->buckets));
for (i = 0; i < N_BACKING_LOCKS; i++) { for (i = 0; i < N_BACKING_LOCKS; i++) {
struct ut_chhBackingLock *s = &rt->backingLocks[i]; struct ddsrt_chh_backing_lock *s = &rt->backingLocks[i];
ddsrt_cond_destroy (&s->cv); ddsrt_cond_destroy (&s->cv);
ddsrt_mutex_destroy (&s->lock); ddsrt_mutex_destroy (&s->lock);
} }
@ -111,10 +111,10 @@ static void ut_chhFini (struct ut_chh *rt)
} }
} }
struct ut_chh *ut_chhNew (uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals, ut_hhBucketsGc_fn gc_buckets) struct ddsrt_chh *ddsrt_chh_new (uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals, ddsrt_hh_buckets_gc_fn gc_buckets)
{ {
struct ut_chh *hh = ddsrt_malloc (sizeof (*hh)); struct ddsrt_chh *hh = ddsrt_malloc (sizeof (*hh));
if (ut_chhInit (hh, init_size, hash, equals, gc_buckets) < 0) { if (ddsrt_chh_init (hh, init_size, hash, equals, gc_buckets) < 0) {
ddsrt_free (hh); ddsrt_free (hh);
return NULL; return NULL;
} else { } else {
@ -122,22 +122,22 @@ struct ut_chh *ut_chhNew (uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn
} }
} }
void ut_chhFree (struct ut_chh * UT_HH_RESTRICT hh) void ddsrt_chh_free (struct ddsrt_chh * __restrict hh)
{ {
ut_chhFini (hh); ddsrt_chh_fini (hh);
ddsrt_free (hh); ddsrt_free (hh);
} }
#define LOCKBIT ((uint32_t)1 << 31) #define LOCKBIT ((uint32_t)1 << 31)
static void ut_chhLockBucket (struct ut_chh *rt, uint32_t bidx) static void ddsrt_chh_lock_bucket (struct ddsrt_chh *rt, uint32_t bidx)
{ {
/* Lock: MSB <=> LOCKBIT, LSBs <=> wait count; note that /* Lock: MSB <=> LOCKBIT, LSBs <=> wait count; note that
(o&LOCKBIT)==0 means a thread can sneak in when there are (o&LOCKBIT)==0 means a thread can sneak in when there are
already waiters, changing it to o==0 would avoid that. */ already waiters, changing it to o==0 would avoid that. */
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const b = &bsary->bs[bidx]; struct ddsrt_chh_bucket * const b = &bsary->bs[bidx];
struct ut_chhBackingLock * const s = &rt->backingLocks[bidx % N_BACKING_LOCKS]; struct ddsrt_chh_backing_lock * const s = &rt->backingLocks[bidx % N_BACKING_LOCKS];
uint32_t o, n; uint32_t o, n;
fastpath_retry: fastpath_retry:
o = ddsrt_atomic_ld32 (&b->lock); o = ddsrt_atomic_ld32 (&b->lock);
@ -162,11 +162,11 @@ static void ut_chhLockBucket (struct ut_chh *rt, uint32_t bidx)
} }
} }
static void ut_chhUnlockBucket (struct ut_chh *rt, uint32_t bidx) static void ddsrt_chh_unlock_bucket (struct ddsrt_chh *rt, uint32_t bidx)
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const b = &bsary->bs[bidx]; struct ddsrt_chh_bucket * const b = &bsary->bs[bidx];
struct ut_chhBackingLock * const s = &rt->backingLocks[bidx % N_BACKING_LOCKS]; struct ddsrt_chh_backing_lock * const s = &rt->backingLocks[bidx % N_BACKING_LOCKS];
uint32_t o, n; uint32_t o, n;
retry: retry:
o = ddsrt_atomic_ld32 (&b->lock); o = ddsrt_atomic_ld32 (&b->lock);
@ -190,9 +190,9 @@ static void ut_chhUnlockBucket (struct ut_chh *rt, uint32_t bidx)
} }
} }
static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary, ut_hhEquals_fn equals, const uint32_t bucket, const void *template) static void *ddsrt_chh_lookup_internal (struct ddsrt_chh_bucket_array const * const bsary, ddsrt_hh_equals_fn equals, const uint32_t bucket, const void *template)
{ {
struct ut_chhBucket const * const bs = bsary->bs; struct ddsrt_chh_bucket const * const bs = bsary->bs;
const uint32_t idxmask = bsary->size - 1; const uint32_t idxmask = bsary->size - 1;
uint32_t timestamp; uint32_t timestamp;
int try_counter = 0; int try_counter = 0;
@ -205,7 +205,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary,
for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) { for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) {
const uint32_t bidx = (bucket + idx) & idxmask; const uint32_t bidx = (bucket + idx) & idxmask;
void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data); void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data);
if (ut_chhDataValid_p (data) && equals (data, template)) { if (ddsrt_chh_data_valid_p (data) && equals (data, template)) {
return data; return data;
} }
} }
@ -218,7 +218,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary,
for (idx = 0; idx < HH_HOP_RANGE; idx++) { for (idx = 0; idx < HH_HOP_RANGE; idx++) {
const uint32_t bidx = (bucket + idx) & idxmask; const uint32_t bidx = (bucket + idx) & idxmask;
void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data); void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data);
if (ut_chhDataValid_p (data) && equals (data, template)) { if (ddsrt_chh_data_valid_p (data) && equals (data, template)) {
return data; return data;
} }
} }
@ -232,19 +232,19 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary,
ddsrt_atomic_st32 (var__, (expr_)); \ ddsrt_atomic_st32 (var__, (expr_)); \
} while (0) } while (0)
void *ut_chhLookup (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) void *ddsrt_chh_lookup (struct ddsrt_chh * __restrict rt, const void * __restrict template)
{ {
struct ut_chhBucketArray const * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array const * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
const uint32_t idxmask = bsary->size - 1; const uint32_t idxmask = bsary->size - 1;
const uint32_t bucket = hash & idxmask; const uint32_t bucket = hash & idxmask;
return ut_chhLookupInternal (bsary, rt->equals, bucket, template); return ddsrt_chh_lookup_internal (bsary, rt->equals, bucket, template);
} }
static uint32_t ut_chhFindCloserFreeBucket (struct ut_chh *rt, uint32_t free_bucket, uint32_t *free_distance) static uint32_t ddsrt_chh_find_closer_free_bucket (struct ddsrt_chh *rt, uint32_t free_bucket, uint32_t *free_distance)
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const bs = bsary->bs; struct ddsrt_chh_bucket * const bs = bsary->bs;
const uint32_t idxmask = bsary->size - 1; const uint32_t idxmask = bsary->size - 1;
uint32_t move_bucket, free_dist; uint32_t move_bucket, free_dist;
move_bucket = (free_bucket - (HH_HOP_RANGE - 1)) & idxmask; move_bucket = (free_bucket - (HH_HOP_RANGE - 1)) & idxmask;
@ -260,7 +260,7 @@ static uint32_t ut_chhFindCloserFreeBucket (struct ut_chh *rt, uint32_t free_buc
} }
} }
if (move_free_distance != NOT_A_BUCKET) { if (move_free_distance != NOT_A_BUCKET) {
ut_chhLockBucket (rt, move_bucket); ddsrt_chh_lock_bucket (rt, move_bucket);
if (start_hop_info == ddsrt_atomic_ld32 (&bs[move_bucket].hopinfo)) if (start_hop_info == ddsrt_atomic_ld32 (&bs[move_bucket].hopinfo))
{ {
uint32_t new_free_bucket = (move_bucket + move_free_distance) & idxmask; uint32_t new_free_bucket = (move_bucket + move_free_distance) & idxmask;
@ -272,31 +272,31 @@ static uint32_t ut_chhFindCloserFreeBucket (struct ut_chh *rt, uint32_t free_buc
ddsrt_atomic_rmw32_nonatomic (&bs[move_bucket].hopinfo, x, x & ~(1u << move_free_distance)); ddsrt_atomic_rmw32_nonatomic (&bs[move_bucket].hopinfo, x, x & ~(1u << move_free_distance));
*free_distance -= free_dist - move_free_distance; *free_distance -= free_dist - move_free_distance;
ut_chhUnlockBucket (rt, move_bucket); ddsrt_chh_unlock_bucket (rt, move_bucket);
return new_free_bucket; return new_free_bucket;
} }
ut_chhUnlockBucket (rt, move_bucket); ddsrt_chh_unlock_bucket (rt, move_bucket);
} }
move_bucket = (move_bucket + 1) & idxmask; move_bucket = (move_bucket + 1) & idxmask;
} }
return NOT_A_BUCKET; return NOT_A_BUCKET;
} }
static void ut_chhResize (struct ut_chh *rt) static void ddsrt_chh_resize (struct ddsrt_chh *rt)
{ {
/* doubles the size => bucket index gains one bit at the msb => /* doubles the size => bucket index gains one bit at the msb =>
start bucket is unchanged or moved into the added half of the set start bucket is unchanged or moved into the added half of the set
=> those for which the (new) msb is 0 are guaranteed to fit, and => those for which the (new) msb is 0 are guaranteed to fit, and
so are those for which the (new) msb is 1 => never have to resize so are those for which the (new) msb is 1 => never have to resize
recursively */ recursively */
struct ut_chhBucketArray * const bsary0 = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary0 = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const bs0 = bsary0->bs; struct ddsrt_chh_bucket * const bs0 = bsary0->bs;
struct ut_chhBucketArray *bsary1; struct ddsrt_chh_bucket_array *bsary1;
struct ut_chhBucket *bs1; struct ddsrt_chh_bucket *bs1;
uint32_t i, idxmask0, idxmask1; uint32_t i, idxmask0, idxmask1;
assert (bsary0->size > 0); assert (bsary0->size > 0);
bsary1 = ddsrt_malloc (offsetof (struct ut_chhBucketArray, bs) + 2 * bsary0->size * sizeof (*bsary1->bs)); bsary1 = ddsrt_malloc (offsetof (struct ddsrt_chh_bucket_array, bs) + 2 * bsary0->size * sizeof (*bsary1->bs));
bsary1->size = 2 * bsary0->size; bsary1->size = 2 * bsary0->size;
bs1 = bsary1->bs; bs1 = bsary1->bs;
@ -327,15 +327,15 @@ static void ut_chhResize (struct ut_chh *rt)
rt->gc_buckets (bsary0); rt->gc_buckets (bsary0);
} }
int ut_chhAdd (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data) int ddsrt_chh_add (struct ddsrt_chh * __restrict rt, const void * __restrict data)
{ {
const uint32_t hash = rt->hash (data); const uint32_t hash = rt->hash (data);
uint32_t size; uint32_t size;
ddsrt_rwlock_read (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_read (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const bs = bsary->bs; struct ddsrt_chh_bucket * const bs = bsary->bs;
uint32_t idxmask; uint32_t idxmask;
uint32_t start_bucket, free_distance, free_bucket; uint32_t start_bucket, free_distance, free_bucket;
@ -343,9 +343,9 @@ int ut_chhAdd (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT da
idxmask = size - 1; idxmask = size - 1;
start_bucket = hash & idxmask; start_bucket = hash & idxmask;
ut_chhLockBucket (rt, start_bucket); ddsrt_chh_lock_bucket (rt, start_bucket);
if (ut_chhLookupInternal (bsary, rt->equals, start_bucket, data)) { if (ddsrt_chh_lookup_internal (bsary, rt->equals, start_bucket, data)) {
ut_chhUnlockBucket (rt, start_bucket); ddsrt_chh_unlock_bucket (rt, start_bucket);
ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
return 0; return 0;
} }
@ -365,77 +365,77 @@ int ut_chhAdd (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT da
ddsrt_atomic_rmw32_nonatomic (&bs[start_bucket].hopinfo, x, x | (1u << free_distance)); ddsrt_atomic_rmw32_nonatomic (&bs[start_bucket].hopinfo, x, x | (1u << free_distance));
ddsrt_atomic_fence (); ddsrt_atomic_fence ();
ddsrt_atomic_stvoidp (&bs[free_bucket].data, (void *) data); ddsrt_atomic_stvoidp (&bs[free_bucket].data, (void *) data);
ut_chhUnlockBucket (rt, start_bucket); ddsrt_chh_unlock_bucket (rt, start_bucket);
ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
return 1; return 1;
} }
free_bucket = ut_chhFindCloserFreeBucket (rt, free_bucket, &free_distance); free_bucket = ddsrt_chh_find_closer_free_bucket (rt, free_bucket, &free_distance);
assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask); assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask);
} while (free_bucket != NOT_A_BUCKET); } while (free_bucket != NOT_A_BUCKET);
} }
ut_chhUnlockBucket (rt, start_bucket); ddsrt_chh_unlock_bucket (rt, start_bucket);
} }
ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
{ {
int i; int i;
struct ut_chhBucketArray *bsary1; struct ddsrt_chh_bucket_array *bsary1;
for (i = 0; i < N_RESIZE_LOCKS; i++) { for (i = 0; i < N_RESIZE_LOCKS; i++) {
ddsrt_rwlock_write (&rt->resize_locks[i]); ddsrt_rwlock_write (&rt->resize_locks[i]);
} }
/* another thread may have sneaked past and grown the hash table */ /* another thread may have sneaked past and grown the hash table */
bsary1 = ddsrt_atomic_ldvoidp (&rt->buckets); bsary1 = ddsrt_atomic_ldvoidp (&rt->buckets);
if (bsary1->size == size) { if (bsary1->size == size) {
ut_chhResize (rt); ddsrt_chh_resize (rt);
} }
for (i = 0; i < N_RESIZE_LOCKS; i++) { for (i = 0; i < N_RESIZE_LOCKS; i++) {
ddsrt_rwlock_unlock (&rt->resize_locks[i]); ddsrt_rwlock_unlock (&rt->resize_locks[i]);
} }
} }
return ut_chhAdd (rt, data); return ddsrt_chh_add (rt, data);
} }
int ut_chhRemove (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) int ddsrt_chh_remove (struct ddsrt_chh * __restrict rt, const void * __restrict template)
{ {
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
ddsrt_rwlock_read (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_read (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const bs = bsary->bs; struct ddsrt_chh_bucket * const bs = bsary->bs;
const uint32_t size = bsary->size; const uint32_t size = bsary->size;
const uint32_t idxmask = size - 1; const uint32_t idxmask = size - 1;
const uint32_t bucket = hash & idxmask; const uint32_t bucket = hash & idxmask;
uint32_t hopinfo; uint32_t hopinfo;
uint32_t idx; uint32_t idx;
ut_chhLockBucket (rt, bucket); ddsrt_chh_lock_bucket (rt, bucket);
hopinfo = ddsrt_atomic_ld32 (&bs[bucket].hopinfo); hopinfo = ddsrt_atomic_ld32 (&bs[bucket].hopinfo);
for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) { for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) {
if (hopinfo & 1) { if (hopinfo & 1) {
const uint32_t bidx = (bucket + idx) & idxmask; const uint32_t bidx = (bucket + idx) & idxmask;
void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data); void *data = ddsrt_atomic_ldvoidp (&bs[bidx].data);
if (ut_chhDataValid_p (data) && rt->equals (data, template)) { if (ddsrt_chh_data_valid_p (data) && rt->equals (data, template)) {
ddsrt_atomic_stvoidp (&bs[bidx].data, NULL); ddsrt_atomic_stvoidp (&bs[bidx].data, NULL);
ddsrt_atomic_rmw32_nonatomic (&bs[bucket].hopinfo, x, x & ~(1u << idx)); ddsrt_atomic_rmw32_nonatomic (&bs[bucket].hopinfo, x, x & ~(1u << idx));
ut_chhUnlockBucket (rt, bucket); ddsrt_chh_unlock_bucket (rt, bucket);
ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
return 1; return 1;
} }
} }
} }
ut_chhUnlockBucket (rt, bucket); ddsrt_chh_unlock_bucket (rt, bucket);
} }
ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]); ddsrt_rwlock_unlock (&rt->resize_locks[hash % N_RESIZE_LOCKS]);
return 0; return 0;
} }
void ut_chhEnumUnsafe (struct ut_chh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg) void ddsrt_chh_enum_unsafe (struct ddsrt_chh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg)
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
struct ut_chhBucket * const bs = bsary->bs; struct ddsrt_chh_bucket * const bs = bsary->bs;
uint32_t i; uint32_t i;
for (i = 0; i < bsary->size; i++) { for (i = 0; i < bsary->size; i++) {
void *data = ddsrt_atomic_ldvoidp (&bs[i].data); void *data = ddsrt_atomic_ldvoidp (&bs[i].data);
@ -445,7 +445,7 @@ void ut_chhEnumUnsafe (struct ut_chh * UT_HH_RESTRICT rt, void (*f) (void *a, vo
} }
} }
void *ut_chhIterNext (struct ut_chhIter *it) void *ddsrt_chh_iter_next (struct ddsrt_chh_iter *it)
{ {
uint32_t i; uint32_t i;
for (i = it->cursor; i < it->size; i++) { for (i = it->cursor; i < it->size; i++) {
@ -458,30 +458,30 @@ void *ut_chhIterNext (struct ut_chhIter *it)
return NULL; return NULL;
} }
void *ut_chhIterFirst (struct ut_chh * UT_HH_RESTRICT rt, struct ut_chhIter *it) void *ddsrt_chh_iter_first (struct ddsrt_chh * __restrict rt, struct ddsrt_chh_iter *it)
{ {
struct ut_chhBucketArray * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets); struct ddsrt_chh_bucket_array * const bsary = ddsrt_atomic_ldvoidp (&rt->buckets);
it->bs = bsary->bs; it->bs = bsary->bs;
it->size = bsary->size; it->size = bsary->size;
it->cursor = 0; it->cursor = 0;
return ut_chhIterNext (it); return ddsrt_chh_iter_next (it);
} }
/************* SEQUENTIAL VERSION ***************/ /************* SEQUENTIAL VERSION ***************/
struct ut_hhBucket { struct ddsrt_hh_bucket {
uint32_t hopinfo; uint32_t hopinfo;
void *data; void *data;
}; };
struct ut_hh { struct ddsrt_hh {
uint32_t size; /* power of 2 */ uint32_t size; /* power of 2 */
struct ut_hhBucket *buckets; struct ddsrt_hh_bucket *buckets;
ut_hhHash_fn hash; ddsrt_hh_hash_fn hash;
ut_hhEquals_fn equals; ddsrt_hh_equals_fn equals;
}; };
static void ut_hhInit (struct ut_hh *rt, uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals) static void ddsrt_hh_init (struct ddsrt_hh *rt, uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals)
{ {
uint32_t size = HH_HOP_RANGE; uint32_t size = HH_HOP_RANGE;
uint32_t i; uint32_t i;
@ -498,25 +498,25 @@ static void ut_hhInit (struct ut_hh *rt, uint32_t init_size, ut_hhHash_fn hash,
} }
} }
static void ut_hhFini (struct ut_hh *rt) static void ddsrt_hh_fini (struct ddsrt_hh *rt)
{ {
ddsrt_free (rt->buckets); ddsrt_free (rt->buckets);
} }
struct ut_hh *ut_hhNew (uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals) struct ddsrt_hh *ddsrt_hh_new (uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals)
{ {
struct ut_hh *hh = ddsrt_malloc (sizeof (*hh)); struct ddsrt_hh *hh = ddsrt_malloc (sizeof (*hh));
ut_hhInit (hh, init_size, hash, equals); ddsrt_hh_init (hh, init_size, hash, equals);
return hh; return hh;
} }
void ut_hhFree (struct ut_hh * UT_HH_RESTRICT hh) void ddsrt_hh_free (struct ddsrt_hh * __restrict hh)
{ {
ut_hhFini (hh); ddsrt_hh_fini (hh);
ddsrt_free (hh); ddsrt_free (hh);
} }
static void *ut_hhLookupInternal (const struct ut_hh *rt, const uint32_t bucket, const void *template) static void *ddsrt_hh_lookup_internal (const struct ddsrt_hh *rt, const uint32_t bucket, const void *template)
{ {
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
uint32_t hopinfo = rt->buckets[bucket].hopinfo; uint32_t hopinfo = rt->buckets[bucket].hopinfo;
@ -530,15 +530,15 @@ static void *ut_hhLookupInternal (const struct ut_hh *rt, const uint32_t bucket,
return NULL; return NULL;
} }
void *ut_hhLookup (const struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) void *ddsrt_hh_lookup (const struct ddsrt_hh * __restrict rt, const void * __restrict template)
{ {
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
const uint32_t bucket = hash & idxmask; const uint32_t bucket = hash & idxmask;
return ut_hhLookupInternal (rt, bucket, template); return ddsrt_hh_lookup_internal (rt, bucket, template);
} }
static uint32_t ut_hhFindCloserFreeBucket (struct ut_hh *rt, uint32_t free_bucket, uint32_t *free_distance) static uint32_t ddsrt_hh_find_closer_free_bucket (struct ddsrt_hh *rt, uint32_t free_bucket, uint32_t *free_distance)
{ {
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
uint32_t move_bucket, free_dist; uint32_t move_bucket, free_dist;
@ -567,9 +567,9 @@ static uint32_t ut_hhFindCloserFreeBucket (struct ut_hh *rt, uint32_t free_bucke
return NOT_A_BUCKET; return NOT_A_BUCKET;
} }
static void ut_hhResize (struct ut_hh *rt) static void ddsrt_hh_resize (struct ddsrt_hh *rt)
{ {
struct ut_hhBucket *bs1; struct ddsrt_hh_bucket *bs1;
uint32_t i, idxmask0, idxmask1; uint32_t i, idxmask0, idxmask1;
bs1 = ddsrt_malloc (2 * rt->size * sizeof (*rt->buckets)); bs1 = ddsrt_malloc (2 * rt->size * sizeof (*rt->buckets));
@ -599,14 +599,14 @@ static void ut_hhResize (struct ut_hh *rt)
rt->buckets = bs1; rt->buckets = bs1;
} }
int ut_hhAdd (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data) int ddsrt_hh_add (struct ddsrt_hh * __restrict rt, const void * __restrict data)
{ {
const uint32_t hash = rt->hash (data); const uint32_t hash = rt->hash (data);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
const uint32_t start_bucket = hash & idxmask; const uint32_t start_bucket = hash & idxmask;
uint32_t free_distance, free_bucket; uint32_t free_distance, free_bucket;
if (ut_hhLookupInternal (rt, start_bucket, data)) { if (ddsrt_hh_lookup_internal (rt, start_bucket, data)) {
return 0; return 0;
} }
@ -624,16 +624,16 @@ int ut_hhAdd (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data
rt->buckets[free_bucket].data = (void *) data; rt->buckets[free_bucket].data = (void *) data;
return 1; return 1;
} }
free_bucket = ut_hhFindCloserFreeBucket (rt, free_bucket, &free_distance); free_bucket = ddsrt_hh_find_closer_free_bucket (rt, free_bucket, &free_distance);
assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask); assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask);
} while (free_bucket != NOT_A_BUCKET); } while (free_bucket != NOT_A_BUCKET);
} }
ut_hhResize (rt); ddsrt_hh_resize (rt);
return ut_hhAdd (rt, data); return ddsrt_hh_add (rt, data);
} }
int ut_hhRemove (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) int ddsrt_hh_remove (struct ddsrt_hh * __restrict rt, const void * __restrict template)
{ {
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
@ -655,7 +655,7 @@ int ut_hhRemove (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT t
return 0; return 0;
} }
void ut_hhEnum (struct ut_hh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg) void ddsrt_hh_enum (struct ddsrt_hh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < rt->size; i++) { for (i = 0; i < rt->size; i++) {
@ -666,16 +666,16 @@ void ut_hhEnum (struct ut_hh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_ar
} }
} }
void *ut_hhIterFirst (struct ut_hh * UT_HH_RESTRICT rt, struct ut_hhIter * UT_HH_RESTRICT iter) void *ddsrt_hh_iter_first (struct ddsrt_hh * __restrict rt, struct ddsrt_hh_iter * __restrict iter)
{ {
iter->hh = rt; iter->hh = rt;
iter->cursor = 0; iter->cursor = 0;
return ut_hhIterNext (iter); return ddsrt_hh_iter_next (iter);
} }
void *ut_hhIterNext (struct ut_hhIter * UT_HH_RESTRICT iter) void *ddsrt_hh_iter_next (struct ddsrt_hh_iter * __restrict iter)
{ {
struct ut_hh *rt = iter->hh; struct ddsrt_hh *rt = iter->hh;
while (iter->cursor < rt->size) { while (iter->cursor < rt->size) {
void *data = rt->buckets[iter->cursor].data; void *data = rt->buckets[iter->cursor].data;
iter->cursor++; iter->cursor++;
@ -688,22 +688,22 @@ void *ut_hhIterNext (struct ut_hhIter * UT_HH_RESTRICT iter)
/************* SEQUENTIAL VERSION WITH EMBEDDED DATA ***************/ /************* SEQUENTIAL VERSION WITH EMBEDDED DATA ***************/
struct ut_ehhBucket { struct ddsrt_ehh_bucket {
uint32_t hopinfo; uint32_t hopinfo;
uint32_t inuse; uint32_t inuse;
char data[]; char data[];
}; };
struct ut_ehh { struct ddsrt_ehh {
uint32_t size; /* power of 2 */ uint32_t size; /* power of 2 */
size_t elemsz; size_t elemsz;
size_t bucketsz; size_t bucketsz;
char *buckets; /* ehhBucket, but embedded data messes up the layout */ char *buckets; /* ehhBucket, but embedded data messes up the layout */
ut_hhHash_fn hash; ddsrt_hh_hash_fn hash;
ut_hhEquals_fn equals; ddsrt_hh_equals_fn equals;
}; };
static void ut_ehhInit (struct ut_ehh *rt, size_t elemsz, uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals) static void ddsrt_ehh_init (struct ddsrt_ehh *rt, size_t elemsz, uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals)
{ {
uint32_t size = HH_HOP_RANGE; uint32_t size = HH_HOP_RANGE;
uint32_t i; uint32_t i;
@ -714,36 +714,36 @@ static void ut_ehhInit (struct ut_ehh *rt, size_t elemsz, uint32_t init_size, ut
rt->equals = equals; rt->equals = equals;
rt->size = size; rt->size = size;
rt->elemsz = elemsz; rt->elemsz = elemsz;
rt->bucketsz = sizeof (struct ut_ehhBucket) + ((elemsz+7) & ~(size_t)7); rt->bucketsz = sizeof (struct ddsrt_ehh_bucket) + ((elemsz+7) & ~(size_t)7);
rt->buckets = ddsrt_malloc (size * rt->bucketsz); rt->buckets = ddsrt_malloc (size * rt->bucketsz);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
struct ut_ehhBucket *b = (struct ut_ehhBucket *) (rt->buckets + i * rt->bucketsz); struct ddsrt_ehh_bucket *b = (struct ddsrt_ehh_bucket *) (rt->buckets + i * rt->bucketsz);
b->hopinfo = 0; b->hopinfo = 0;
b->inuse = 0; b->inuse = 0;
} }
} }
static void ut_ehhFini (struct ut_ehh *rt) static void ddsrt_ehh_fini (struct ddsrt_ehh *rt)
{ {
ddsrt_free (rt->buckets); ddsrt_free (rt->buckets);
} }
struct ut_ehh *ut_ehhNew (size_t elemsz, uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals) struct ddsrt_ehh *ddsrt_ehh_new (size_t elemsz, uint32_t init_size, ddsrt_hh_hash_fn hash, ddsrt_hh_equals_fn equals)
{ {
struct ut_ehh *hh = ddsrt_malloc (sizeof (*hh)); struct ddsrt_ehh *hh = ddsrt_malloc (sizeof (*hh));
ut_ehhInit (hh, elemsz, init_size, hash, equals); ddsrt_ehh_init (hh, elemsz, init_size, hash, equals);
return hh; return hh;
} }
void ut_ehhFree (struct ut_ehh * UT_HH_RESTRICT hh) void ddsrt_ehh_free (struct ddsrt_ehh * __restrict hh)
{ {
ut_ehhFini (hh); ddsrt_ehh_fini (hh);
ddsrt_free (hh); ddsrt_free (hh);
} }
static void *ut_ehhLookupInternal (const struct ut_ehh *rt, uint32_t bucket, const void *template) static void *ddsrt_ehh_lookup_internal (const struct ddsrt_ehh *rt, uint32_t bucket, const void *template)
{ {
const struct ut_ehhBucket *b = (const struct ut_ehhBucket *) (rt->buckets + bucket * rt->bucketsz); const struct ddsrt_ehh_bucket *b = (const struct ddsrt_ehh_bucket *) (rt->buckets + bucket * rt->bucketsz);
uint32_t hopinfo = b->hopinfo; uint32_t hopinfo = b->hopinfo;
if (hopinfo & 1) { if (hopinfo & 1) {
@ -758,7 +758,7 @@ static void *ut_ehhLookupInternal (const struct ut_ehh *rt, uint32_t bucket, con
bucket = 0; bucket = 0;
} }
if (hopinfo & 1) { if (hopinfo & 1) {
b = (const struct ut_ehhBucket *) (rt->buckets + bucket * rt->bucketsz); b = (const struct ddsrt_ehh_bucket *) (rt->buckets + bucket * rt->bucketsz);
if (b->inuse && rt->equals (b->data, template)) { if (b->inuse && rt->equals (b->data, template)) {
return (void *) b->data; return (void *) b->data;
} }
@ -767,21 +767,21 @@ static void *ut_ehhLookupInternal (const struct ut_ehh *rt, uint32_t bucket, con
return NULL; return NULL;
} }
void *ut_ehhLookup (const struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) void *ddsrt_ehh_lookup (const struct ddsrt_ehh * __restrict rt, const void * __restrict template)
{ {
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
const uint32_t bucket = hash & idxmask; const uint32_t bucket = hash & idxmask;
return ut_ehhLookupInternal (rt, bucket, template); return ddsrt_ehh_lookup_internal (rt, bucket, template);
} }
static uint32_t ut_ehhFindCloserFreeBucket (struct ut_ehh *rt, uint32_t free_bucket, uint32_t *free_distance) static uint32_t ddsrt_ehh_find_closer_free_bucket (struct ddsrt_ehh *rt, uint32_t free_bucket, uint32_t *free_distance)
{ {
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
uint32_t move_bucket, free_dist; uint32_t move_bucket, free_dist;
move_bucket = (free_bucket - (HH_HOP_RANGE - 1)) & idxmask; move_bucket = (free_bucket - (HH_HOP_RANGE - 1)) & idxmask;
for (free_dist = HH_HOP_RANGE - 1; free_dist > 0; free_dist--) { for (free_dist = HH_HOP_RANGE - 1; free_dist > 0; free_dist--) {
struct ut_ehhBucket * const mb = (struct ut_ehhBucket *) (rt->buckets + move_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const mb = (struct ddsrt_ehh_bucket *) (rt->buckets + move_bucket * rt->bucketsz);
uint32_t move_free_distance = NOT_A_BUCKET; uint32_t move_free_distance = NOT_A_BUCKET;
uint32_t mask = 1; uint32_t mask = 1;
uint32_t i; uint32_t i;
@ -793,8 +793,8 @@ static uint32_t ut_ehhFindCloserFreeBucket (struct ut_ehh *rt, uint32_t free_buc
} }
if (move_free_distance != NOT_A_BUCKET) { if (move_free_distance != NOT_A_BUCKET) {
uint32_t new_free_bucket = (move_bucket + move_free_distance) & idxmask; uint32_t new_free_bucket = (move_bucket + move_free_distance) & idxmask;
struct ut_ehhBucket * const fb = (struct ut_ehhBucket *) (rt->buckets + free_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const fb = (struct ddsrt_ehh_bucket *) (rt->buckets + free_bucket * rt->bucketsz);
struct ut_ehhBucket * const nfb = (struct ut_ehhBucket *) (rt->buckets + new_free_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const nfb = (struct ddsrt_ehh_bucket *) (rt->buckets + new_free_bucket * rt->bucketsz);
mb->hopinfo |= 1u << free_dist; mb->hopinfo |= 1u << free_dist;
fb->inuse = 1; fb->inuse = 1;
memcpy (fb->data, nfb->data, rt->elemsz); memcpy (fb->data, nfb->data, rt->elemsz);
@ -808,7 +808,7 @@ static uint32_t ut_ehhFindCloserFreeBucket (struct ut_ehh *rt, uint32_t free_buc
return NOT_A_BUCKET; return NOT_A_BUCKET;
} }
static void ut_ehhResize (struct ut_ehh *rt) static void ddsrt_ehh_resize (struct ddsrt_ehh *rt)
{ {
char *bs1; char *bs1;
uint32_t i, idxmask0, idxmask1; uint32_t i, idxmask0, idxmask1;
@ -816,22 +816,22 @@ static void ut_ehhResize (struct ut_ehh *rt)
bs1 = ddsrt_malloc (2 * rt->size * rt->bucketsz); bs1 = ddsrt_malloc (2 * rt->size * rt->bucketsz);
for (i = 0; i < 2 * rt->size; i++) { for (i = 0; i < 2 * rt->size; i++) {
struct ut_ehhBucket *b = (struct ut_ehhBucket *) (bs1 + i * rt->bucketsz); struct ddsrt_ehh_bucket *b = (struct ddsrt_ehh_bucket *) (bs1 + i * rt->bucketsz);
b->hopinfo = 0; b->hopinfo = 0;
b->inuse = 0; b->inuse = 0;
} }
idxmask0 = rt->size - 1; idxmask0 = rt->size - 1;
idxmask1 = 2 * rt->size - 1; idxmask1 = 2 * rt->size - 1;
for (i = 0; i < rt->size; i++) { for (i = 0; i < rt->size; i++) {
struct ut_ehhBucket const * const b = (struct ut_ehhBucket *) (rt->buckets + i * rt->bucketsz); struct ddsrt_ehh_bucket const * const b = (struct ddsrt_ehh_bucket *) (rt->buckets + i * rt->bucketsz);
if (b->inuse) { if (b->inuse) {
const uint32_t hash = rt->hash (b->data); const uint32_t hash = rt->hash (b->data);
const uint32_t old_start_bucket = hash & idxmask0; const uint32_t old_start_bucket = hash & idxmask0;
const uint32_t new_start_bucket = hash & idxmask1; const uint32_t new_start_bucket = hash & idxmask1;
const uint32_t dist = (i >= old_start_bucket) ? (i - old_start_bucket) : (rt->size + i - old_start_bucket); const uint32_t dist = (i >= old_start_bucket) ? (i - old_start_bucket) : (rt->size + i - old_start_bucket);
const uint32_t newb = (new_start_bucket + dist) & idxmask1; const uint32_t newb = (new_start_bucket + dist) & idxmask1;
struct ut_ehhBucket * const nsb = (struct ut_ehhBucket *) (bs1 + new_start_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const nsb = (struct ddsrt_ehh_bucket *) (bs1 + new_start_bucket * rt->bucketsz);
struct ut_ehhBucket * const nb = (struct ut_ehhBucket *) (bs1 + newb * rt->bucketsz); struct ddsrt_ehh_bucket * const nb = (struct ddsrt_ehh_bucket *) (bs1 + newb * rt->bucketsz);
assert (dist < HH_HOP_RANGE); assert (dist < HH_HOP_RANGE);
assert (!nb->inuse); assert (!nb->inuse);
nsb->hopinfo |= 1u << dist; nsb->hopinfo |= 1u << dist;
@ -845,20 +845,20 @@ static void ut_ehhResize (struct ut_ehh *rt)
rt->buckets = bs1; rt->buckets = bs1;
} }
int ut_ehhAdd (struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data) int ddsrt_ehh_add (struct ddsrt_ehh * __restrict rt, const void * __restrict data)
{ {
const uint32_t hash = rt->hash (data); const uint32_t hash = rt->hash (data);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
const uint32_t start_bucket = hash & idxmask; const uint32_t start_bucket = hash & idxmask;
uint32_t free_distance, free_bucket; uint32_t free_distance, free_bucket;
if (ut_ehhLookupInternal (rt, start_bucket, data)) { if (ddsrt_ehh_lookup_internal (rt, start_bucket, data)) {
return 0; return 0;
} }
free_bucket = start_bucket; free_bucket = start_bucket;
for (free_distance = 0; free_distance < HH_ADD_RANGE; free_distance++) { for (free_distance = 0; free_distance < HH_ADD_RANGE; free_distance++) {
struct ut_ehhBucket const * const fb = (struct ut_ehhBucket *) (rt->buckets + free_bucket * rt->bucketsz); struct ddsrt_ehh_bucket const * const fb = (struct ddsrt_ehh_bucket *) (rt->buckets + free_bucket * rt->bucketsz);
if (!fb->inuse) { if (!fb->inuse) {
break; break;
} }
@ -867,73 +867,73 @@ int ut_ehhAdd (struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT da
if (free_distance < HH_ADD_RANGE) { if (free_distance < HH_ADD_RANGE) {
do { do {
if (free_distance < HH_HOP_RANGE) { if (free_distance < HH_HOP_RANGE) {
struct ut_ehhBucket * const sb = (struct ut_ehhBucket *) (rt->buckets + start_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const sb = (struct ddsrt_ehh_bucket *) (rt->buckets + start_bucket * rt->bucketsz);
struct ut_ehhBucket * const fb = (struct ut_ehhBucket *) (rt->buckets + free_bucket * rt->bucketsz); struct ddsrt_ehh_bucket * const fb = (struct ddsrt_ehh_bucket *) (rt->buckets + free_bucket * rt->bucketsz);
assert ((uint32_t) free_bucket == ((start_bucket + free_distance) & idxmask)); assert ((uint32_t) free_bucket == ((start_bucket + free_distance) & idxmask));
sb->hopinfo |= 1u << free_distance; sb->hopinfo |= 1u << free_distance;
fb->inuse = 1; fb->inuse = 1;
memcpy (fb->data, data, rt->elemsz); memcpy (fb->data, data, rt->elemsz);
assert (ut_ehhLookupInternal (rt, start_bucket, data)); assert (ddsrt_ehh_lookup_internal (rt, start_bucket, data));
return 1; return 1;
} }
free_bucket = ut_ehhFindCloserFreeBucket (rt, free_bucket, &free_distance); free_bucket = ddsrt_ehh_find_closer_free_bucket (rt, free_bucket, &free_distance);
assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask); assert (free_bucket == NOT_A_BUCKET || free_bucket <= idxmask);
} while (free_bucket != NOT_A_BUCKET); } while (free_bucket != NOT_A_BUCKET);
} }
ut_ehhResize (rt); ddsrt_ehh_resize (rt);
return ut_ehhAdd (rt, data); return ddsrt_ehh_add (rt, data);
} }
int ut_ehhRemove (struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template) int ddsrt_ehh_remove (struct ddsrt_ehh * __restrict rt, const void * __restrict template)
{ {
const uint32_t hash = rt->hash (template); const uint32_t hash = rt->hash (template);
const uint32_t idxmask = rt->size - 1; const uint32_t idxmask = rt->size - 1;
const uint32_t bucket = hash & idxmask; const uint32_t bucket = hash & idxmask;
uint32_t hopinfo; uint32_t hopinfo;
struct ut_ehhBucket *sb; struct ddsrt_ehh_bucket *sb;
uint32_t idx; uint32_t idx;
sb = (struct ut_ehhBucket *) (rt->buckets + bucket * rt->bucketsz); sb = (struct ddsrt_ehh_bucket *) (rt->buckets + bucket * rt->bucketsz);
hopinfo = sb->hopinfo; hopinfo = sb->hopinfo;
for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) { for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) {
if (hopinfo & 1) { if (hopinfo & 1) {
const uint32_t bidx = (bucket + idx) & idxmask; const uint32_t bidx = (bucket + idx) & idxmask;
struct ut_ehhBucket *b = (struct ut_ehhBucket *) (rt->buckets + bidx * rt->bucketsz); struct ddsrt_ehh_bucket *b = (struct ddsrt_ehh_bucket *) (rt->buckets + bidx * rt->bucketsz);
if (b->inuse && rt->equals (b->data, template)) { if (b->inuse && rt->equals (b->data, template)) {
assert (ut_ehhLookupInternal(rt, bucket, template)); assert (ddsrt_ehh_lookup_internal(rt, bucket, template));
b->inuse = 0; b->inuse = 0;
sb->hopinfo &= ~(1u << idx); sb->hopinfo &= ~(1u << idx);
return 1; return 1;
} }
} }
} }
assert (!ut_ehhLookupInternal(rt, bucket, template)); assert (!ddsrt_ehh_lookup_internal(rt, bucket, template));
return 0; return 0;
} }
void ut_ehhEnum (struct ut_ehh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg) void ddsrt_ehh_enum (struct ddsrt_ehh * __restrict rt, void (*f) (void *a, void *f_arg), void *f_arg)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < rt->size; i++) { for (i = 0; i < rt->size; i++) {
struct ut_ehhBucket *b = (struct ut_ehhBucket *) (rt->buckets + i * rt->bucketsz); struct ddsrt_ehh_bucket *b = (struct ddsrt_ehh_bucket *) (rt->buckets + i * rt->bucketsz);
if (b->inuse) { if (b->inuse) {
f (b->data, f_arg); f (b->data, f_arg);
} }
} }
} }
void *ut_ehhIterFirst (struct ut_ehh * UT_HH_RESTRICT rt, struct ut_ehhIter * UT_HH_RESTRICT iter) void *ddsrt_ehh_iter_first (struct ddsrt_ehh * __restrict rt, struct ddsrt_ehh_iter * __restrict iter)
{ {
iter->hh = rt; iter->hh = rt;
iter->cursor = 0; iter->cursor = 0;
return ut_ehhIterNext (iter); return ddsrt_ehh_iter_next (iter);
} }
void *ut_ehhIterNext (struct ut_ehhIter * UT_HH_RESTRICT iter) void *ddsrt_ehh_iter_next (struct ddsrt_ehh_iter * __restrict iter)
{ {
struct ut_ehh *rt = iter->hh; struct ddsrt_ehh *rt = iter->hh;
while (iter->cursor < rt->size) { while (iter->cursor < rt->size) {
struct ut_ehhBucket *b = (struct ut_ehhBucket *) (rt->buckets + iter->cursor * rt->bucketsz); struct ddsrt_ehh_bucket *b = (struct ddsrt_ehh_bucket *) (rt->buckets + iter->cursor * rt->bucketsz);
iter->cursor++; iter->cursor++;
if (b->inuse) { if (b->inuse) {
return b->data; return b->data;

View file

@ -15,7 +15,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/sync.h" #include "dds/ddsrt/sync.h"
#include "dds/ddsrt/threads.h" #include "dds/ddsrt/threads.h"
#include "dds/util/ut_thread_pool.h" #include "dds/ddsrt/thread_pool.h"
typedef struct ddsi_work_queue_job typedef struct ddsi_work_queue_job
{ {
@ -25,7 +25,7 @@ typedef struct ddsi_work_queue_job
} }
* ddsi_work_queue_job_t; * ddsi_work_queue_job_t;
struct ut_thread_pool_s struct ddsrt_thread_pool_s
{ {
ddsi_work_queue_job_t m_jobs; /* Job queue */ ddsi_work_queue_job_t m_jobs; /* Job queue */
ddsi_work_queue_job_t m_jobs_tail; /* Tail of job queue */ ddsi_work_queue_job_t m_jobs_tail; /* Tail of job queue */
@ -42,10 +42,10 @@ struct ut_thread_pool_s
ddsrt_mutex_t m_mutex; /* Pool guard mutex */ ddsrt_mutex_t m_mutex; /* Pool guard mutex */
}; };
static uint32_t ut_thread_start_fn (void * arg) static uint32_t ddsrt_thread_start_fn (void * arg)
{ {
ddsi_work_queue_job_t job; ddsi_work_queue_job_t job;
ut_thread_pool pool = (ut_thread_pool) arg; ddsrt_thread_pool pool = (ddsrt_thread_pool) arg;
/* Thread loops, pulling jobs from queue */ /* Thread loops, pulling jobs from queue */
@ -88,7 +88,7 @@ static uint32_t ut_thread_start_fn (void * arg)
return 0; return 0;
} }
static dds_retcode_t ut_thread_pool_new_thread (ut_thread_pool pool) static dds_retcode_t ddsrt_thread_pool_new_thread (ddsrt_thread_pool pool)
{ {
static unsigned char pools = 0; /* Pool counter - TODO make atomic */ static unsigned char pools = 0; /* Pool counter - TODO make atomic */
@ -97,7 +97,7 @@ static dds_retcode_t ut_thread_pool_new_thread (ut_thread_pool pool)
dds_retcode_t res; dds_retcode_t res;
(void) snprintf (name, sizeof (name), "OSPL-%u-%u", pools++, pool->m_count++); (void) snprintf (name, sizeof (name), "OSPL-%u-%u", pools++, pool->m_count++);
res = ddsrt_thread_create (&id, name, &pool->m_attr, &ut_thread_start_fn, pool); res = ddsrt_thread_create (&id, name, &pool->m_attr, &ddsrt_thread_start_fn, pool);
if (res == DDS_RETCODE_OK) if (res == DDS_RETCODE_OK)
{ {
@ -110,9 +110,9 @@ static dds_retcode_t ut_thread_pool_new_thread (ut_thread_pool pool)
return res; return res;
} }
ut_thread_pool ut_thread_pool_new (uint32_t threads, uint32_t max_threads, uint32_t max_queue, ddsrt_threadattr_t * attr) ddsrt_thread_pool ddsrt_thread_pool_new (uint32_t threads, uint32_t max_threads, uint32_t max_queue, ddsrt_threadattr_t * attr)
{ {
ut_thread_pool pool; ddsrt_thread_pool pool;
ddsi_work_queue_job_t job; ddsi_work_queue_job_t job;
/* Sanity check QoS */ /* Sanity check QoS */
@ -144,9 +144,9 @@ ut_thread_pool ut_thread_pool_new (uint32_t threads, uint32_t max_threads, uint3
while (threads--) while (threads--)
{ {
if (ut_thread_pool_new_thread (pool) != DDS_RETCODE_OK) if (ddsrt_thread_pool_new_thread (pool) != DDS_RETCODE_OK)
{ {
ut_thread_pool_free (pool); ddsrt_thread_pool_free (pool);
pool = NULL; pool = NULL;
break; break;
} }
@ -158,7 +158,7 @@ ut_thread_pool ut_thread_pool_new (uint32_t threads, uint32_t max_threads, uint3
return pool; return pool;
} }
void ut_thread_pool_free (ut_thread_pool pool) void ddsrt_thread_pool_free (ddsrt_thread_pool pool)
{ {
ddsi_work_queue_job_t job; ddsi_work_queue_job_t job;
@ -205,7 +205,7 @@ void ut_thread_pool_free (ut_thread_pool pool)
ddsrt_free (pool); ddsrt_free (pool);
} }
dds_retcode_t ut_thread_pool_submit (ut_thread_pool pool, void (*fn) (void *arg), void * arg) dds_retcode_t ddsrt_thread_pool_submit (ddsrt_thread_pool pool, void (*fn) (void *arg), void * arg)
{ {
dds_retcode_t res = DDS_RETCODE_OK; dds_retcode_t res = DDS_RETCODE_OK;
ddsi_work_queue_job_t job; ddsi_work_queue_job_t job;
@ -255,7 +255,7 @@ dds_retcode_t ut_thread_pool_submit (ut_thread_pool pool, void (*fn) (void *arg)
if ((pool->m_thread_max == 0) || (pool->m_threads < pool->m_thread_max)) if ((pool->m_thread_max == 0) || (pool->m_threads < pool->m_thread_max))
{ {
/* OK if fails as have queued job */ /* OK if fails as have queued job */
(void) ut_thread_pool_new_thread (pool); (void) ddsrt_thread_pool_new_thread (pool);
} }
} }
@ -269,7 +269,7 @@ dds_retcode_t ut_thread_pool_submit (ut_thread_pool pool, void (*fn) (void *arg)
return res; return res;
} }
void ut_thread_pool_purge (ut_thread_pool pool) void ddsrt_thread_pool_purge (ddsrt_thread_pool pool)
{ {
uint32_t total; uint32_t total;

View file

@ -18,7 +18,7 @@
#include "dds/ddsrt/heap.h" #include "dds/ddsrt/heap.h"
#include "dds/ddsrt/misc.h" #include "dds/ddsrt/misc.h"
#include "dds/ddsrt/string.h" #include "dds/ddsrt/string.h"
#include "dds/util/ut_xmlparser.h" #include "dds/ddsrt/xmlparser.h"
#define TOK_EOF -1 #define TOK_EOF -1
#define TOK_OPEN_TAG -2 #define TOK_OPEN_TAG -2
@ -30,7 +30,7 @@
#define NOMARKER (~(size_t)0) #define NOMARKER (~(size_t)0)
struct ut_xmlpState { struct ddsrt_xmlp_state {
size_t cbufp; /* current position in cbuf */ size_t cbufp; /* current position in cbuf */
size_t cbufn; /* number of bytes in cbuf (cbufp <= cbufn) */ size_t cbufn; /* number of bytes in cbuf (cbufp <= cbufn) */
size_t cbufmax; /* allocated size of cbuf (cbufn <= cbufmax) */ size_t cbufmax; /* allocated size of cbuf (cbufn <= cbufmax) */
@ -50,7 +50,7 @@ struct ut_xmlpState {
int nest; /* current nesting level */ int nest; /* current nesting level */
void *varg; /* user argument to callback functions */ void *varg; /* user argument to callback functions */
int require_eof; /* if false, junk may follow top-level closing tag */ int require_eof; /* if false, junk may follow top-level closing tag */
struct ut_xmlpCallbacks cb; /* user-supplied callbacks (or stubs) */ struct ddsrt_xmlp_callbacks cb; /* user-supplied callbacks (or stubs) */
}; };
static int cb_null_elem_open (void *varg, uintptr_t parentinfo, uintptr_t *eleminfo, const char *name) static int cb_null_elem_open (void *varg, uintptr_t parentinfo, uintptr_t *eleminfo, const char *name)
@ -93,7 +93,7 @@ static void cb_null_error (void *varg, const char *msg, int line)
DDSRT_UNUSED_ARG (line); DDSRT_UNUSED_ARG (line);
} }
static void ut_xmlpNewCommon (struct ut_xmlpState *st) static void ddsrt_xmlp_new_common (struct ddsrt_xmlp_state *st)
{ {
st->cbufp = 0; st->cbufp = 0;
st->cbufmark = NOMARKER; st->cbufmark = NOMARKER;
@ -111,7 +111,7 @@ static void ut_xmlpNewCommon (struct ut_xmlpState *st)
st->require_eof = 1; st->require_eof = 1;
} }
static void ut_xmlpNewSetCB (struct ut_xmlpState *st, void *varg, const struct ut_xmlpCallbacks *cb) static void ddsrt_xmlp_new_setCB (struct ddsrt_xmlp_state *st, void *varg, const struct ddsrt_xmlp_callbacks *cb)
{ {
st->varg = varg; st->varg = varg;
st->cb = *cb; st->cb = *cb;
@ -122,43 +122,43 @@ static void ut_xmlpNewSetCB (struct ut_xmlpState *st, void *varg, const struct u
if (st->cb.error == 0) st->cb.error = cb_null_error; if (st->cb.error == 0) st->cb.error = cb_null_error;
} }
struct ut_xmlpState *ut_xmlpNewFile (FILE *fp, void *varg, const struct ut_xmlpCallbacks *cb) struct ddsrt_xmlp_state *ddsrt_xmlp_new_file (FILE *fp, void *varg, const struct ddsrt_xmlp_callbacks *cb)
{ {
struct ut_xmlpState *st; struct ddsrt_xmlp_state *st;
st = ddsrt_malloc (sizeof (*st)); st = ddsrt_malloc (sizeof (*st));
st->cbufn = 0; st->cbufn = 0;
st->cbufmax = 8192; st->cbufmax = 8192;
st->cbuf = ddsrt_malloc (st->cbufmax); st->cbuf = ddsrt_malloc (st->cbufmax);
st->fp = fp; st->fp = fp;
ut_xmlpNewCommon (st); ddsrt_xmlp_new_common (st);
ut_xmlpNewSetCB (st, varg, cb); ddsrt_xmlp_new_setCB (st, varg, cb);
return st; return st;
} }
struct ut_xmlpState *ut_xmlpNewString (const char *string, void *varg, const struct ut_xmlpCallbacks *cb) struct ddsrt_xmlp_state *ddsrt_xmlp_new_string (const char *string, void *varg, const struct ddsrt_xmlp_callbacks *cb)
{ {
struct ut_xmlpState *st; struct ddsrt_xmlp_state *st;
st = ddsrt_malloc (sizeof (*st)); st = ddsrt_malloc (sizeof (*st));
st->cbufn = strlen (string); st->cbufn = strlen (string);
st->cbufmax = st->cbufn; st->cbufmax = st->cbufn;
st->cbuf = (char *) string; st->cbuf = (char *) string;
st->fp = NULL; st->fp = NULL;
ut_xmlpNewCommon (st); ddsrt_xmlp_new_common (st);
ut_xmlpNewSetCB (st, varg, cb); ddsrt_xmlp_new_setCB (st, varg, cb);
return st; return st;
} }
void ut_xmlpSetRequireEOF (struct ut_xmlpState *st, int require_eof) void ddsrt_xmlp_set_requireEOF (struct ddsrt_xmlp_state *st, int require_eof)
{ {
st->require_eof = require_eof; st->require_eof = require_eof;
} }
size_t ut_xmlpGetBufpos (const struct ut_xmlpState *st) size_t ddsrt_xmlp_get_bufpos (const struct ddsrt_xmlp_state *st)
{ {
return st->cbufp; return st->cbufp;
} }
void ut_xmlpFree (struct ut_xmlpState *st) void ddsrt_xmlp_free (struct ddsrt_xmlp_state *st)
{ {
if (st->fp != NULL) { if (st->fp != NULL) {
ddsrt_free (st->cbuf); ddsrt_free (st->cbuf);
@ -167,7 +167,7 @@ void ut_xmlpFree (struct ut_xmlpState *st)
ddsrt_free (st); ddsrt_free (st);
} }
static int make_chars_available (struct ut_xmlpState *st, size_t nmin) static int make_chars_available (struct ddsrt_xmlp_state *st, size_t nmin)
{ {
size_t n, pos; size_t n, pos;
pos = (st->cbufmark != NOMARKER) ? st->cbufmark : st->cbufp; pos = (st->cbufmark != NOMARKER) ? st->cbufmark : st->cbufp;
@ -201,21 +201,21 @@ static int make_chars_available (struct ut_xmlpState *st, size_t nmin)
return (st->cbufn - st->cbufp >= nmin); return (st->cbufn - st->cbufp >= nmin);
} }
static void set_input_marker (struct ut_xmlpState *st) static void set_input_marker (struct ddsrt_xmlp_state *st)
{ {
assert (st->cbufmark == NOMARKER); assert (st->cbufmark == NOMARKER);
st->cbufmark = st->cbufp; st->cbufmark = st->cbufp;
st->linemark = st->line; st->linemark = st->line;
} }
static void discard_input_marker (struct ut_xmlpState *st) static void discard_input_marker (struct ddsrt_xmlp_state *st)
{ {
assert (st->cbufmark != NOMARKER); assert (st->cbufmark != NOMARKER);
st->cbufmark = NOMARKER; st->cbufmark = NOMARKER;
st->linemark = 0; st->linemark = 0;
} }
static void rewind_to_input_marker (struct ut_xmlpState *st) static void rewind_to_input_marker (struct ddsrt_xmlp_state *st)
{ {
assert (st->cbufmark != NOMARKER); assert (st->cbufmark != NOMARKER);
st->cbufp = st->cbufmark; st->cbufp = st->cbufmark;
@ -223,7 +223,7 @@ static void rewind_to_input_marker (struct ut_xmlpState *st)
discard_input_marker (st); discard_input_marker (st);
} }
static int next_char (struct ut_xmlpState *st) static int next_char (struct ddsrt_xmlp_state *st)
{ {
char c; char c;
if (!make_chars_available (st, 1)) { if (!make_chars_available (st, 1)) {
@ -236,7 +236,7 @@ static int next_char (struct ut_xmlpState *st)
return c; return c;
} }
static int peek_char (struct ut_xmlpState *st) static int peek_char (struct ddsrt_xmlp_state *st)
{ {
if (!make_chars_available (st, 1)) { if (!make_chars_available (st, 1)) {
return TOK_EOF; return TOK_EOF;
@ -244,7 +244,7 @@ static int peek_char (struct ut_xmlpState *st)
return st->cbuf[st->cbufp]; return st->cbuf[st->cbufp];
} }
static int peek_chars (struct ut_xmlpState *st, const char *seq, int consume) static int peek_chars (struct ddsrt_xmlp_state *st, const char *seq, int consume)
{ {
size_t n = strlen (seq); size_t n = strlen (seq);
if (!make_chars_available (st, n)) { if (!make_chars_available (st, n)) {
@ -354,13 +354,13 @@ static int unescape_insitu (char *buffer, size_t *n)
} }
DDSRT_WARNING_MSVC_ON(4996); DDSRT_WARNING_MSVC_ON(4996);
static void discard_payload (struct ut_xmlpState *st) static void discard_payload (struct ddsrt_xmlp_state *st)
{ {
st->tpp = 0; st->tpp = 0;
st->tpescp = 0; st->tpescp = 0;
} }
static int append_to_payload (struct ut_xmlpState *st, int c, int islit) static int append_to_payload (struct ddsrt_xmlp_state *st, int c, int islit)
{ {
if (!islit) { if (!islit) {
st->tp[st->tpp++] = (char) c; st->tp[st->tpp++] = (char) c;
@ -383,7 +383,7 @@ static int append_to_payload (struct ut_xmlpState *st, int c, int islit)
return 0; return 0;
} }
static int save_payload (char **payload, struct ut_xmlpState *st, int trim) static int save_payload (char **payload, struct ddsrt_xmlp_state *st, int trim)
{ {
char *p; char *p;
if (st->tpescp < st->tpp) { if (st->tpescp < st->tpp) {
@ -424,7 +424,7 @@ static int save_payload (char **payload, struct ut_xmlpState *st, int trim)
return 0; return 0;
} }
static int next_token_ident (struct ut_xmlpState *st, char **payload) static int next_token_ident (struct ddsrt_xmlp_state *st, char **payload)
{ {
while (qq_isidentcont (peek_char (st))) { while (qq_isidentcont (peek_char (st))) {
if (append_to_payload (st, next_char (st), 0) < 0) { if (append_to_payload (st, next_char (st), 0) < 0) {
@ -438,7 +438,7 @@ static int next_token_ident (struct ut_xmlpState *st, char **payload)
} }
} }
static int next_token_tag_withoutclose (struct ut_xmlpState *st, char **payload) static int next_token_tag_withoutclose (struct ddsrt_xmlp_state *st, char **payload)
{ {
if (peek_chars (st, "<![CDATA[", 0)) { if (peek_chars (st, "<![CDATA[", 0)) {
return next_char (st); return next_char (st);
@ -459,7 +459,7 @@ static int next_token_tag_withoutclose (struct ut_xmlpState *st, char **payload)
} }
} }
static int next_token_string (struct ut_xmlpState *st, char **payload) static int next_token_string (struct ddsrt_xmlp_state *st, char **payload)
{ {
/* pre: peek_char(st) == ('"' or '\'') */ /* pre: peek_char(st) == ('"' or '\'') */
int endm = next_char (st); int endm = next_char (st);
@ -478,7 +478,7 @@ static int next_token_string (struct ut_xmlpState *st, char **payload)
} }
} }
static int skip_comment (struct ut_xmlpState *st) static int skip_comment (struct ddsrt_xmlp_state *st)
{ {
if (!peek_chars (st, "<!--", 1)) { if (!peek_chars (st, "<!--", 1)) {
return 0; return 0;
@ -493,7 +493,7 @@ static int skip_comment (struct ut_xmlpState *st)
} }
} }
static void processing_instruction (struct ut_xmlpState *st, const char *end) static void processing_instruction (struct ddsrt_xmlp_state *st, const char *end)
{ {
/* just after <?; skip everything up to and include ?> */ /* just after <?; skip everything up to and include ?> */
while (peek_char (st) != TOK_EOF && !peek_chars (st, end, 1)) { while (peek_char (st) != TOK_EOF && !peek_chars (st, end, 1)) {
@ -501,7 +501,7 @@ static void processing_instruction (struct ut_xmlpState *st, const char *end)
} }
} }
static void drop_peek_token (struct ut_xmlpState *st) static void drop_peek_token (struct ddsrt_xmlp_state *st)
{ {
st->peektok = 0; st->peektok = 0;
if (st->peekpayload) { if (st->peekpayload) {
@ -510,7 +510,7 @@ static void drop_peek_token (struct ut_xmlpState *st)
} }
} }
static int next_token (struct ut_xmlpState *st, char **payload) static int next_token (struct ddsrt_xmlp_state *st, char **payload)
{ {
/* Always return a valid pointer to allocated memory or a null /* Always return a valid pointer to allocated memory or a null
pointer, regardless of token type */ pointer, regardless of token type */
@ -566,7 +566,7 @@ static int next_token (struct ut_xmlpState *st, char **payload)
} }
} }
static int peek_token (struct ut_xmlpState *st) static int peek_token (struct ddsrt_xmlp_state *st)
{ {
int tok; int tok;
char *payload; char *payload;
@ -576,7 +576,7 @@ static int peek_token (struct ut_xmlpState *st)
return tok; return tok;
} }
static int parse_element (struct ut_xmlpState *st, uintptr_t parentinfo) static int parse_element (struct ddsrt_xmlp_state *st, uintptr_t parentinfo)
{ {
#define PE_ERROR2(c,c1,c2) do { errc = (c); errc1 = (c1); errc2 = (c2); goto err; } while (0) #define PE_ERROR2(c,c1,c2) do { errc = (c); errc1 = (c1); errc2 = (c2); goto err; } while (0)
#define PE_ERROR(c,c1) PE_ERROR2(c,c1,0) #define PE_ERROR(c,c1) PE_ERROR2(c,c1,0)
@ -703,7 +703,7 @@ ok:
#undef PE_ERROR2 #undef PE_ERROR2
} }
int ut_xmlpParse (struct ut_xmlpState *st) int ddsrt_xmlp_parse (struct ddsrt_xmlp_state *st)
{ {
if (peek_token (st) == TOK_EOF) { if (peek_token (st) == TOK_EOF) {
return 0; return 0;
@ -717,6 +717,6 @@ int ut_xmlpParse (struct ut_xmlpState *st)
} }
} }
int ut_xmlUnescapeInsitu (char *buffer, size_t *n) { int ddsrt_xmlUnescapeInsitu (char *buffer, size_t *n) {
return unescape_insitu (buffer, n); return unescape_insitu (buffer, n);
} }

View file

@ -1,48 +0,0 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
include (GenerateExportHeader)
PREPEND(srcs_util "${CMAKE_CURRENT_SOURCE_DIR}/src" ut_avl.c ut_crc.c ut_expand_envvars.c ut_fibheap.c ut_hopscotch.c ut_thread_pool.c ut_xmlparser.c)
add_library(util ${srcs_util})
set_property(TARGET util PROPERTY POSITION_INDEPENDENT_CODE TRUE)
generate_export_header(
util
BASE_NAME
dds
EXPORT_FILE_NAME
"${CMAKE_CURRENT_BINARY_DIR}/include/dds/export.h")
# util must NOT link with ddsrt to avoid duplicate symbols in ddsc!
# ddsrt include directories are required though.
target_compile_definitions(
util
PUBLIC
$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_COMPILE_DEFINITIONS>>)
target_include_directories(
util
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:$<TARGET_PROPERTY:ddsrt,INTERFACE_INCLUDE_DIRECTORIES>>")
install(
DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include/dds"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT dev)
# TODO: improve test inclusion.
if((BUILD_TESTING) AND ((NOT DEFINED MSVC_VERSION) OR (MSVC_VERSION GREATER "1800")))
add_subdirectory(tests)
endif()

View file

@ -1,359 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef UT_AVL_H
#define UT_AVL_H
/* The tree library never performs memory allocations or deallocations internally.
- Treedef_t: defines the properties of the tree, offsets,
comparison functions, augmented structures, flags -- these are
related to the code/data structure in which the tree is embedded,
and in nearly all cases known at compile time.
- avlTree_t: represents the tree, i.e., pointer to the root.
- avlNode_t: contains the administrative data for a single node in
the tree.
For a tree node:
struct T {
avlNode_t avlnode;
int key;
};
by definition, avlnodeoffset == offsetof(struct T, avlnode) and
keyoffset = offsetof(struct T, key). The user of the library only
ever deals in pointers to (in this case) struct T, never with
pointers to the avlNode_t, and the compare function operations on
pointers to keys, in this case pointers to "int"s. If you wish, you
can also do: keyoffset = 0, in which case the compare function
would be operating on struct T's.
The compare function is assumed to behave just like all compare
functions in the C library: < 0, =0, >0 for left argument less
than, equal to or greater than the right argument.
The "augment" function is automatically called whenever some of the
children of a node change, as well as when the "augment" function
has been called on some of the children. It allows you to maintain
a "summary" of the subtree -- currently only used in ddsi2e, in one
spot.
Trees come in various "variants", configured through "treedef"
flags:
- direct/indirect key: direct meaning the key value is embedded in
the structure containing the avlNode_t, indirect meaning a
pointer to the key value is. The compare function doesn't deal
with tree nodes, but with key values.
- re-entrant: in the style of the C library, meaning, the
comparison function gets a user-supplied 3rd argument (in
particular used by mmstat).
- unique keys/duplicate keys: when keys must be unique, some
optimizations apply; it is up to the caller to ensure one doesn't
violate the uniqueness of the keys (it'll happily crash in insert
if you don't); when duplicate keys are allowed, a forward scan of
the tree will visit them in the order of insertion.
For a tree node:
struct T {
avlnode_t avlnode;
char *key;
};
you could set the "indirect" flag, and then you simply use
strcmp(), avoiding the need for passing templates in looking up key
values. Much nicer.
There is also an orthogonal variant that is enforced through the
type system -- note that would be possible for all of the above as
well, but the number of cases simply explodes and none of the above
flags affects the dynamically changing data structures (just the
tree definition), unlike this one.
- the "C" variant keeps track of the number of nodes in the tree to
support a "count" operation in O(1) time, but is otherwise
identical.
The various initializer macros and TreedefInit functions should
make sense with this.
All functions for looking up nodes return NULL if there is no node
satisfying the requirements.
- Init: initializes a tree (really just: root = NULL, perhaps count = 0)
- Free: calls "freefun" on each node, which may free the node
- FreeArg: as "Free", but with an extra, user-supplied, argument
- Root: returns the root node
- Lookup: returns a node with key value "key" (ref allowdups flag)
- LookupIPath: like Lookup, but also filling an IPath_t structure
for efficient insertion in case of a failed lookup (or inserting
duplicates)
- LookupDPath: like Lookup, but also filling a DPath_t structure
that helps with deleting a node
- LookupPredEq: locates the node with the greatest key value <= "key"
- LookupSuccEq: similar, but smallest key value >= "key"
- LookupPred: similar, < "key"
- LookupSucc: similar, > "key"
- Insert: convenience function: LookupIPath ; InsertIPath
- Delete: convenience function: LookupDPath ; DeleteDPath
- InsertIPath: insert node based on the "path" obtained from LookupIPath
- DeleteDPath: delete node, using information in "path" to do so efficiently
- SwapNode: replace "oldn" by "newn" without modifying the tree
structure (the key need not be equal, but must be
FindPred(oldn).key < newn.key < FindSucc(oldn).key, where a
non-existing predecessor has key -inf and a non-existing
successor has key +inf, and where it is understood that the <
operator becomes <= if allowdups is set
- AugmentUpdate: to be called when something in "node" changes that
affects the subtree "summary" computed by the configured
"augment" function
- IsEmpty: returns 1 if tree is empty, 0 if not
- IsSingleton: returns 1 if tree contains exactly one node, 0 if not
- FindMin: returns the node with the smallest key value in the tree
- FindMax: similar, largest key value
- FindPred: preceding node in in-order treewalk
- FindSucc: similar, following node
- Walk: calls "f" with user-supplied argument "a" once for each
node, starting at FindMin and ending at FindMax
- ConstWalk: same, but with a const tree
- WalkRange: like Walk, but only visiting nodes with key values in
range [min,max] (that's inclusive)
- ConstWalkRange: same, but with a const tree
- WalkRangeReverse: like WalkRange, but in the reverse direction
- ConstWalkRangeReverse: same, but with a const tree
- IterFirst: starts forward iteration, starting at (and returning) FindMin
- IterSuccEq: similar, starting at LookupSuccEq
- IterSucc: similar, starting at LookupSucc
- IterNext: returns FindSucc(last returned node); may not be called
if preceding IterXXX call on same "iter" returned NULL
That's all there is to it.
Note that all calls to Walk(f,a) can be rewritten as:
for(n=IterFirst(&it); n; n=IterNext(&it)) { f(n,a) }
or as
for(n=FindMin(); n; n=FindSucc(n)) { f(n,a) }
The walk functions and iterators may not alter the tree
structure. If that is desired, the latter can easily be rewritten
as:
n=FindMin() ; while(n) { nn=FindSucc(n); f(n,a); n=nn }
because FindMin/FindSucc doesn't store any information to allow
fast processing. That'll allow every operation, with the obvious
exception of f(n) calling Delete(FindSucc(n)).
Currently, all trees maintain parent pointers, but it may be worth
doing a separate set without it, as it reduces the size of
avlNode_t. But in that case, the FindMin/FindSucc option would no
longer be a reasonable option because it would be prohibitively
expensive, whereas the IterFirst/IterNext option are alway
efficiently. If one were to do a threaded tree variant, the
implemetantion of IterFirst/IterNext would become absolute trivial
and faster still, but at the cost of significantly more overhead in
memory and updates. */
#include <stdint.h>
#include <stdlib.h>
#include "dds/export.h"
#include "dds/ddsrt/attributes.h"
#if defined (__cplusplus)
extern "C" {
#endif
#define UT_AVL_MAX_TREEHEIGHT (12 * sizeof (void *))
typedef int (*ut_avlCompare_t) (const void *a, const void *b);
typedef int (*ut_avlCompare_r_t) (const void *a, const void *b, void *arg);
typedef void (*ut_avlAugment_t) (void *node, const void *left, const void *right);
typedef void (*ut_avlWalk_t) (void *node, void *arg);
typedef void (*ut_avlConstWalk_t) (const void *node, void *arg);
typedef struct ut_avlNode {
struct ut_avlNode *cs[2]; /* 0 = left, 1 = right */
struct ut_avlNode *parent;
int height;
} ut_avlNode_t;
#define UT_AVL_TREEDEF_FLAG_INDKEY 1
#define UT_AVL_TREEDEF_FLAG_R 2
#define UT_AVL_TREEDEF_FLAG_ALLOWDUPS 4
typedef struct ut_avlTreedef {
#if defined (__cplusplus)
ut_avlTreedef() {}
#endif
size_t avlnodeoffset;
size_t keyoffset;
union {
ut_avlCompare_t comparekk;
ut_avlCompare_r_t comparekk_r;
} u;
ut_avlAugment_t augment;
uint32_t flags;
void *cmp_arg; /* for _r variant */
} ut_avlTreedef_t;
typedef struct ut_avlCTreedef {
ut_avlTreedef_t t;
} ut_avlCTreedef_t;
typedef struct ut_avlTree {
ut_avlNode_t *root;
} ut_avlTree_t;
typedef struct ut_avlCTree {
ut_avlTree_t t;
size_t count;
} ut_avlCTree_t;
typedef struct ut_avlPath {
int depth; /* total depth of path */
int pnodeidx;
ut_avlNode_t *parent; /* (nodeidx == 0 ? NULL : *(path[nodeidx-1])) */
ut_avlNode_t **pnode[UT_AVL_MAX_TREEHEIGHT];
} ut_avlPath_t;
typedef struct ut_avlIPath {
ut_avlPath_t p;
} ut_avlIPath_t;
typedef struct ut_avlDPath {
ut_avlPath_t p;
} ut_avlDPath_t;
typedef struct ut_avlIter {
const ut_avlTreedef_t *td;
ut_avlNode_t *right;
ut_avlNode_t **todop;
ut_avlNode_t *todo[1+UT_AVL_MAX_TREEHEIGHT];
} ut_avlIter_t;
typedef struct ut_avlCIter {
ut_avlIter_t t;
} ut_avlCIter_t;
/* avlnodeoffset and keyoffset must both be in [0,2**31-1] */
#define UT_AVL_TREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), 0, 0 }
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY, 0 }
#define UT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, augment) { (avlnodeoffset), (keyoffset), { .comparekk = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, 0 }
#define UT_AVL_TREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_R, (cmparg) }
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R, (cmparg) }
#define UT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
#define UT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk_, cmparg, augment) { (avlnodeoffset), (keyoffset), { .comparekk_r = (comparekk_) }, (augment), UT_AVL_TREEDEF_FLAG_INDKEY|UT_AVL_TREEDEF_FLAG_R|UT_AVL_TREEDEF_FLAG_ALLOWDUPS, (cmparg) }
/* Not maintaining # nodes */
DDS_EXPORT void ut_avlTreedefInit (ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ut_avlCompare_t comparekk, ut_avlAugment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ut_avlTreedefInit_r (ut_avlTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ut_avlCompare_r_t comparekk_r, void *cmp_arg, ut_avlAugment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ut_avlInit (const ut_avlTreedef_t *td, ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlFree (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void (*freefun) (void *node)) ddsrt_nonnull((1,2));
DDS_EXPORT void ut_avlFreeArg (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void (*freefun) (void *node, void *arg), void *arg) ddsrt_nonnull((1,2));
DDS_EXPORT void *ut_avlRoot (const ut_avlTreedef_t *td, const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlRootNonEmpty (const ut_avlTreedef_t *td, const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookup (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupIPath (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key, ut_avlIPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupDPath (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key, ut_avlDPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupPredEq (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupSuccEq (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupPred (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlLookupSucc (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlInsert (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlDelete (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlInsertIPath (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void *node, ut_avlIPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlDeleteDPath (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void *node, ut_avlDPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlSwapNode (const ut_avlTreedef_t *td, ut_avlTree_t *tree, void *oldn, void *newn) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlAugmentUpdate (const ut_avlTreedef_t *td, void *node) ddsrt_nonnull_all;
DDS_EXPORT int ut_avlIsEmpty (const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT int ut_avlIsSingleton (const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlFindMin (const ut_avlTreedef_t *td, const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlFindMax (const ut_avlTreedef_t *td, const ut_avlTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlFindPred (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void *ut_avlFindSucc (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void ut_avlWalk (const ut_avlTreedef_t *td, ut_avlTree_t *tree, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ut_avlConstWalk (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ut_avlWalkRange (const ut_avlTreedef_t *td, ut_avlTree_t *tree, const void *min, const void *max, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ut_avlConstWalkRange (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *min, const void *max, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ut_avlWalkRangeReverse (const ut_avlTreedef_t *td, ut_avlTree_t *tree, const void *min, const void *max, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ut_avlConstWalkRangeReverse (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, const void *min, const void *max, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void *ut_avlIterFirst (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, ut_avlIter_t *iter) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlIterSuccEq (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, ut_avlIter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlIterSucc (const ut_avlTreedef_t *td, const ut_avlTree_t *tree, ut_avlIter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlIterNext (ut_avlIter_t *iter) ddsrt_nonnull_all;
/* Maintaining # nodes */
#define UT_AVL_CTREEDEF_INITIALIZER(avlnodeoffset, keyoffset, comparekk, augment) { UT_AVL_TREEDEF_INITIALIZER (avlnodeoffset, keyoffset, comparekk, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_INDKEY(avlnodeoffset, keyoffset, comparekk, augment) { UT_AVL_TREEDEF_INITIALIZER_INDKEY (avlnodeoffset, keyoffset, comparekk, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { UT_AVL_TREEDEF_INITIALIZER_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_INDKEY_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, augment) { UT_AVL_TREEDEF_INITIALIZER_INDKEY_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { UT_AVL_TREEDEF_INITIALIZER_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_INDKEY_R(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { UT_AVL_TREEDEF_INITIALIZER_INDKEY_R (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { UT_AVL_TREEDEF_INITIALIZER_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
#define UT_AVL_CTREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS(avlnodeoffset, keyoffset, comparekk, cmparg, augment) { UT_AVL_TREEDEF_INITIALIZER_INDKEY_R_ALLOWDUPS (avlnodeoffset, keyoffset, comparekk, cmparg, augment) }
DDS_EXPORT void ut_avlCTreedefInit (ut_avlCTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ut_avlCompare_t comparekk, ut_avlAugment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ut_avlCTreedefInit_r (ut_avlCTreedef_t *td, size_t avlnodeoffset, size_t keyoffset, ut_avlCompare_r_t comparekk_r, void *cmp_arg, ut_avlAugment_t augment, uint32_t flags) ddsrt_nonnull((1,4));
DDS_EXPORT void ut_avlCInit (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCFree (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void (*freefun) (void *node)) ddsrt_nonnull((1,2));
DDS_EXPORT void ut_avlCFreeArg (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void (*freefun) (void *node, void *arg), void *arg) ddsrt_nonnull((1,2));
DDS_EXPORT void *ut_avlCRoot (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCRootNonEmpty (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookup (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupIPath (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key, ut_avlIPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupDPath (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key, ut_avlDPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupPredEq (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupSuccEq (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupPred (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCLookupSucc (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCInsert (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCDelete (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void *node) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCInsertIPath (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void *node, ut_avlIPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCDeleteDPath (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void *node, ut_avlDPath_t *path) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCSwapNode (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, void *oldn, void *newn) ddsrt_nonnull_all;
DDS_EXPORT void ut_avlCAugmentUpdate (const ut_avlCTreedef_t *td, void *node) ddsrt_nonnull_all;
DDS_EXPORT int ut_avlCIsEmpty (const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT int ut_avlCIsSingleton (const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT size_t ut_avlCCount (const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCFindMin (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCFindMax (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCFindPred (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void *ut_avlCFindSucc (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *vnode) ddsrt_nonnull((1,2));
DDS_EXPORT void ut_avlCWalk (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ut_avlCConstWalk (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3));
DDS_EXPORT void ut_avlCWalkRange (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, const void *min, const void *max, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ut_avlCConstWalkRange (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *min, const void *max, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ut_avlCWalkRangeReverse (const ut_avlCTreedef_t *td, ut_avlCTree_t *tree, const void *min, const void *max, ut_avlWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void ut_avlCConstWalkRangeReverse (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, const void *min, const void *max, ut_avlConstWalk_t f, void *a) ddsrt_nonnull((1,2,3,4,5));
DDS_EXPORT void *ut_avlCIterFirst (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, ut_avlCIter_t *iter) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCIterSuccEq (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, ut_avlCIter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCIterSucc (const ut_avlCTreedef_t *td, const ut_avlCTree_t *tree, ut_avlCIter_t *iter, const void *key) ddsrt_nonnull_all;
DDS_EXPORT void *ut_avlCIterNext (ut_avlCIter_t *iter) ddsrt_nonnull_all;
#if defined (__cplusplus)
}
#endif
#endif /* UT_AVL_H */

View file

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

View file

@ -1,54 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef UT_FIBHEAP_H
#define UT_FIBHEAP_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
typedef struct ut_fibheapNode {
struct ut_fibheapNode *parent, *children;
struct ut_fibheapNode *prev, *next;
unsigned mark: 1;
unsigned degree: 31;
} ut_fibheapNode_t;
typedef struct ut_fibheapDef {
uintptr_t offset;
int (*cmp) (const void *va, const void *vb);
} ut_fibheapDef_t;
typedef struct ut_fibheap {
ut_fibheapNode_t *roots; /* points to root with min key value */
} ut_fibheap_t;
#define UT_FIBHEAPDEF_INITIALIZER(offset, cmp) { (offset), (cmp) }
DDS_EXPORT void ut_fibheapDefInit (ut_fibheapDef_t *fhdef, uintptr_t offset, int (*cmp) (const void *va, const void *vb));
DDS_EXPORT void ut_fibheapInit (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh);
DDS_EXPORT void *ut_fibheapMin (const ut_fibheapDef_t *fhdef, const ut_fibheap_t *fh);
DDS_EXPORT void ut_fibheapMerge (const ut_fibheapDef_t *fhdef, ut_fibheap_t *a, ut_fibheap_t *b);
DDS_EXPORT void ut_fibheapInsert (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode);
DDS_EXPORT void ut_fibheapDelete (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode);
DDS_EXPORT void *ut_fibheapExtractMin (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh);
DDS_EXPORT void ut_fibheapDecreaseKey (const ut_fibheapDef_t *fhdef, ut_fibheap_t *fh, const void *vnode); /* to be called AFTER decreasing the key */
#if defined (__cplusplus)
}
#endif
#endif /* UT_FIBHEAP_H */

View file

@ -1,110 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef UT_HOPSCOTCH_H
#define UT_HOPSCOTCH_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
#if __STDC_VERSION__ >= 199901L
#define UT_HH_RESTRICT restrict
#else
#define UT_HH_RESTRICT
#endif
/* Concurrent version */
struct ut_chh;
struct ut_chhBucket;
struct ut_chhIter {
struct ut_chhBucket *bs;
uint32_t size;
uint32_t cursor;
};
/*
* The hopscotch hash table is dependent on a proper functioning hash.
* If the hash function generates a lot of hash collisions, then it will
* not be able to handle that by design.
* It is capable of handling some collisions, but not more than 32 per
* bucket (less, when other hash values are clustered around the
* collision value).
* When proper distributed hash values are generated, then hopscotch
* works nice and quickly.
*/
typedef uint32_t (*ut_hhHash_fn) (const void *);
/*
* Hopscotch needs to be able to compare two elements.
* Returns 0 when not equal.
*/
typedef int (*ut_hhEquals_fn) (const void *, const void *);
/*
* Hopscotch is will resize its internal buckets list when needed. It will
* call this garbage collection function with the old buckets list. The
* caller has to delete the list when it deems it safe to do so.
*/
typedef void (*ut_hhBucketsGc_fn) (void *);
DDS_EXPORT struct ut_chh *ut_chhNew (uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals, ut_hhBucketsGc_fn gc_buckets);
DDS_EXPORT void ut_chhFree (struct ut_chh * UT_HH_RESTRICT hh);
DDS_EXPORT void *ut_chhLookup (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT int ut_chhAdd (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data);
DDS_EXPORT int ut_chhRemove (struct ut_chh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT void ut_chhEnumUnsafe (struct ut_chh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
void *ut_chhIterFirst (struct ut_chh * UT_HH_RESTRICT rt, struct ut_chhIter *it);
void *ut_chhIterNext (struct ut_chhIter *it);
/* Sequential version */
struct ut_hh;
struct ut_hhIter {
struct ut_hh *hh;
uint32_t cursor;
};
DDS_EXPORT struct ut_hh *ut_hhNew (uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals);
DDS_EXPORT void ut_hhFree (struct ut_hh * UT_HH_RESTRICT hh);
DDS_EXPORT void *ut_hhLookup (const struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT int ut_hhAdd (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data);
DDS_EXPORT int ut_hhRemove (struct ut_hh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT void ut_hhEnum (struct ut_hh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
DDS_EXPORT void *ut_hhIterFirst (struct ut_hh * UT_HH_RESTRICT rt, struct ut_hhIter * UT_HH_RESTRICT iter); /* may delete nodes */
DDS_EXPORT void *ut_hhIterNext (struct ut_hhIter * UT_HH_RESTRICT iter);
/* Sequential version, embedded data */
struct ut_ehh;
struct ut_ehhIter {
struct ut_ehh *hh;
uint32_t cursor;
};
DDS_EXPORT struct ut_ehh *ut_ehhNew (size_t elemsz, uint32_t init_size, ut_hhHash_fn hash, ut_hhEquals_fn equals);
DDS_EXPORT void ut_ehhFree (struct ut_ehh * UT_HH_RESTRICT hh);
DDS_EXPORT void *ut_ehhLookup (const struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT int ut_ehhAdd (struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT data);
DDS_EXPORT int ut_ehhRemove (struct ut_ehh * UT_HH_RESTRICT rt, const void * UT_HH_RESTRICT template);
DDS_EXPORT void ut_ehhEnum (struct ut_ehh * UT_HH_RESTRICT rt, void (*f) (void *a, void *f_arg), void *f_arg); /* may delete a */
DDS_EXPORT void *ut_ehhIterFirst (struct ut_ehh * UT_HH_RESTRICT rt, struct ut_ehhIter * UT_HH_RESTRICT iter); /* may delete nodes */
DDS_EXPORT void *ut_ehhIterNext (struct ut_ehhIter * UT_HH_RESTRICT iter);
#if defined (__cplusplus)
}
#endif
#endif

View file

@ -1,52 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef UT_XMLPARSER_H
#define UT_XMLPARSER_H
#include <stdint.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
typedef int (*ut_xmlpProcElemOpen_t) (void *varg, uintptr_t parentinfo, uintptr_t *eleminfo, const char *name);
typedef int (*ut_xmlpProcAttr_t) (void *varg, uintptr_t eleminfo, const char *name, const char *value);
typedef int (*ut_xmlpProcElemData_t) (void *varg, uintptr_t eleminfo, const char *data);
typedef int (*ut_xmlpProcElemClose_t) (void *varg, uintptr_t eleminfo);
typedef void (*ut_xmlpError) (void *varg, const char *msg, int line);
struct ut_xmlpCallbacks {
ut_xmlpProcElemOpen_t elem_open;
ut_xmlpProcAttr_t attr;
ut_xmlpProcElemData_t elem_data;
ut_xmlpProcElemClose_t elem_close;
ut_xmlpError error;
};
struct ut_xmlpState;
DDS_EXPORT struct ut_xmlpState *ut_xmlpNewFile (FILE *fp, void *varg, const struct ut_xmlpCallbacks *cb);
DDS_EXPORT struct ut_xmlpState *ut_xmlpNewString (const char *string, void *varg, const struct ut_xmlpCallbacks *cb);
DDS_EXPORT void ut_xmlpSetRequireEOF (struct ut_xmlpState *st, int require_eof);
DDS_EXPORT size_t ut_xmlpGetBufpos (const struct ut_xmlpState *st);
DDS_EXPORT void ut_xmlpFree (struct ut_xmlpState *st);
DDS_EXPORT int ut_xmlpParse (struct ut_xmlpState *st);
DDS_EXPORT int ut_xmlUnescapeInsitu (char *buffer, size_t *n);
#if defined (__cplusplus)
}
#endif
#endif

View file

@ -1,74 +0,0 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include "dds/util/ut_crc.h"
static const uint32_t crc32_table[] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4,
0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
uint32_t ut_crcCalculate (const void *buf, size_t length)
{
const unsigned char *vptr = buf;
size_t i;
uint32_t reg = 0;
unsigned char top;
for (i = 0; i < length; i++)
{
top = (unsigned char) (reg >> 24);
top ^= *vptr;
reg = (reg << 8) ^ crc32_table[top];
vptr++;
}
return reg;
}

View file

@ -1,15 +0,0 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
include(CUnit)
#add_cunit_executable(CUnit_util "handleserver.c")
#target_link_libraries(CUnit_util util)