Eliminate domain-specific global variables
This commit moves all but a handful of the global variables into the domain object, in particular including the DDSI configuration, globals and all transport internal state. The goal of this commit is not to produce the nicest code possible, but to get a working version that can support multiple simultaneous domains. Various choices are driven by this desire and it is expected that some of the changes will have to be undone. (E.g., passing the DDSI globals into address set operations and locator printing because there is no other way to figure out what transport to use for a given locator; storing the transport pointer inside the locator would solve that.) Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
8a591fdc9b
commit
c1f3ad8a22
93 changed files with 2802 additions and 2915 deletions
|
@ -215,6 +215,12 @@ inline void ddsrt_atomic_orptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v)
|
|||
inline void ddsrt_atomic_fence (void) {
|
||||
__asm volatile ("dmb" : : : "memory");
|
||||
}
|
||||
inline void ddsrt_atomic_fence_ldld (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
|
|
@ -326,6 +326,11 @@ inline void ddsrt_atomic_fence_ldld (void) {
|
|||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
__sync_synchronize ();
|
||||
#endif
|
||||
}
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
|
|
|
@ -302,6 +302,11 @@ inline void ddsrt_atomic_fence_ldld (void) {
|
|||
ddsrt_atomic_fence ();
|
||||
#endif
|
||||
}
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
#if !(defined _M_IX86 || defined _M_X64)
|
||||
ddsrt_atomic_fence ();
|
||||
#endif
|
||||
}
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
ddsrt_atomic_fence ();
|
||||
}
|
||||
|
|
|
@ -245,7 +245,10 @@ inline void ddsrt_atomic_fence (void) {
|
|||
membar_enter ();
|
||||
}
|
||||
inline void ddsrt_atomic_fence_ldld (void) {
|
||||
membar_enter ();
|
||||
membar_consumer ();
|
||||
}
|
||||
inline void ddsrt_atomic_fence_stst (void) {
|
||||
membar_producer ();
|
||||
}
|
||||
inline void ddsrt_atomic_fence_acq (void) {
|
||||
membar_enter ();
|
||||
|
|
|
@ -30,20 +30,20 @@ extern "C" {
|
|||
* When proper distributed hash values are generated, then hopscotch
|
||||
* works nice and quickly.
|
||||
*/
|
||||
typedef uint32_t (*ddsrt_hh_hash_fn) (const void *);
|
||||
typedef uint32_t (*ddsrt_hh_hash_fn) (const void *a);
|
||||
|
||||
/*
|
||||
* Hopscotch needs to be able to compare two elements.
|
||||
* Returns 0 when not equal.
|
||||
*/
|
||||
typedef int (*ddsrt_hh_equals_fn) (const void *, const void *);
|
||||
typedef int (*ddsrt_hh_equals_fn) (const void *a, const void *b);
|
||||
|
||||
/*
|
||||
* 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 *);
|
||||
typedef void (*ddsrt_hh_buckets_gc_fn) (void *bs, void *arg);
|
||||
|
||||
/* Sequential version */
|
||||
struct ddsrt_hh;
|
||||
|
@ -79,7 +79,7 @@ struct ddsrt_chh_iter {
|
|||
};
|
||||
#endif
|
||||
|
||||
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 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, void *gc_buckets_arg);
|
||||
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);
|
||||
|
|
|
@ -125,6 +125,7 @@ extern inline int ddsrt_atomic_casvoidp2 (volatile ddsrt_atomic_uintptr2_t *x, u
|
|||
/* FENCES */
|
||||
extern inline void ddsrt_atomic_fence (void);
|
||||
extern inline void ddsrt_atomic_fence_ldld (void);
|
||||
extern inline void ddsrt_atomic_fence_stst (void);
|
||||
extern inline void ddsrt_atomic_fence_acq (void);
|
||||
extern inline void ddsrt_atomic_fence_rel (void);
|
||||
|
||||
|
|
|
@ -299,6 +299,7 @@ struct ddsrt_chh {
|
|||
ddsrt_hh_equals_fn equals;
|
||||
ddsrt_rwlock_t resize_locks[N_RESIZE_LOCKS];
|
||||
ddsrt_hh_buckets_gc_fn gc_buckets;
|
||||
void *gc_buckets_arg;
|
||||
};
|
||||
|
||||
#define CHH_MAX_TRIES 4
|
||||
|
@ -309,7 +310,7 @@ static int ddsrt_chh_data_valid_p (void *data)
|
|||
return data != NULL && data != CHH_BUSY;
|
||||
}
|
||||
|
||||
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)
|
||||
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, void *gc_buckets_arg)
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t i;
|
||||
|
@ -322,6 +323,7 @@ static int ddsrt_chh_init (struct ddsrt_chh *rt, uint32_t init_size, ddsrt_hh_ha
|
|||
rt->hash = hash;
|
||||
rt->equals = equals;
|
||||
rt->gc_buckets = gc_buckets;
|
||||
rt->gc_buckets_arg = gc_buckets_arg;
|
||||
|
||||
buckets = ddsrt_malloc (offsetof (struct ddsrt_chh_bucket_array, bs) + size * sizeof (*buckets->bs));
|
||||
ddsrt_atomic_stvoidp (&rt->buckets, buckets);
|
||||
|
@ -359,10 +361,10 @@ static void ddsrt_chh_fini (struct ddsrt_chh *rt)
|
|||
}
|
||||
}
|
||||
|
||||
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 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, void *gc_buckets_arg)
|
||||
{
|
||||
struct ddsrt_chh *hh = ddsrt_malloc (sizeof (*hh));
|
||||
if (ddsrt_chh_init (hh, init_size, hash, equals, gc_buckets) < 0) {
|
||||
if (ddsrt_chh_init (hh, init_size, hash, equals, gc_buckets, gc_buckets_arg) < 0) {
|
||||
ddsrt_free (hh);
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -572,7 +574,7 @@ static void ddsrt_chh_resize (struct ddsrt_chh *rt)
|
|||
|
||||
ddsrt_atomic_fence ();
|
||||
ddsrt_atomic_stvoidp (&rt->buckets, bsary1);
|
||||
rt->gc_buckets (bsary0);
|
||||
rt->gc_buckets (bsary0, rt->gc_buckets_arg);
|
||||
}
|
||||
|
||||
int ddsrt_chh_add (struct ddsrt_chh * __restrict rt, const void * __restrict data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue