diff options
author | Richard Braun <rbraun@sceen.net> | 2017-07-25 21:09:04 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-07-25 21:09:04 +0200 |
commit | 50134de5026e9cd5b4b744b78731025ce17bc3cb (patch) | |
tree | b781fe5413a7e88db4a059eb2914d003dd3aeff1 | |
parent | 05185d96f469bd997740ac4218f168721a4bd677 (diff) |
kern/llsync: rename pointer accessors
-rw-r--r-- | kern/hlist.h | 14 | ||||
-rw-r--r-- | kern/list.h | 10 | ||||
-rw-r--r-- | kern/llsync.h | 12 | ||||
-rw-r--r-- | kern/rdxtree.c | 30 | ||||
-rw-r--r-- | kern/rdxtree.h | 2 | ||||
-rw-r--r-- | kern/slist.h | 18 | ||||
-rw-r--r-- | test/test_llsync_defer.c | 6 |
7 files changed, 46 insertions, 46 deletions
diff --git a/kern/hlist.h b/kern/hlist.h index 0d5184b7..eec05bb5 100644 --- a/kern/hlist.h +++ b/kern/hlist.h @@ -264,7 +264,7 @@ for (entry = hlist_first_entry(list, typeof(*entry), member), \ static inline struct hlist_node * hlist_llsync_first(const struct hlist *list) { - return llsync_read_ptr(list->first); + return llsync_load_ptr(list->first); } /* @@ -273,7 +273,7 @@ hlist_llsync_first(const struct hlist *list) static inline struct hlist_node * hlist_llsync_next(const struct hlist_node *node) { - return llsync_read_ptr(node->next); + return llsync_load_ptr(node->next); } /* @@ -292,7 +292,7 @@ hlist_llsync_insert_head(struct hlist *list, struct hlist_node *node) first->pprev = &node->next; } - llsync_assign_ptr(list->first, node); + llsync_store_ptr(list->first, node); } /* @@ -304,7 +304,7 @@ hlist_llsync_insert_before(struct hlist_node *next, struct hlist_node *node) node->next = next; node->pprev = next->pprev; next->pprev = &node->next; - llsync_assign_ptr(*node->pprev, node); + llsync_store_ptr(*node->pprev, node); } /* @@ -320,7 +320,7 @@ hlist_llsync_insert_after(struct hlist_node *prev, struct hlist_node *node) node->next->pprev = &node->next; } - llsync_assign_ptr(prev->next, node); + llsync_store_ptr(prev->next, node); } /* @@ -333,7 +333,7 @@ hlist_llsync_remove(struct hlist_node *node) node->next->pprev = node->pprev; } - llsync_assign_ptr(*node->pprev, node->next); + llsync_store_ptr(*node->pprev, node->next); } /* @@ -341,7 +341,7 @@ hlist_llsync_remove(struct hlist_node *node) * given node based on the given type and member. */ #define hlist_llsync_entry(node, type, member) \ - structof(llsync_read_ptr(node), type, member) + structof(llsync_load_ptr(node), type, member) /* * Get the first entry of a list. diff --git a/kern/list.h b/kern/list.h index eeb29344..f48d7d7e 100644 --- a/kern/list.h +++ b/kern/list.h @@ -387,7 +387,7 @@ for (entry = list_last_entry(list, typeof(*entry), member), \ static inline struct list * list_llsync_first(const struct list *list) { - return llsync_read_ptr(list->next); + return llsync_load_ptr(list->next); } /* @@ -396,7 +396,7 @@ list_llsync_first(const struct list *list) static inline struct list * list_llsync_next(const struct list *node) { - return llsync_read_ptr(node->next); + return llsync_load_ptr(node->next); } /* @@ -409,7 +409,7 @@ list_llsync_add(struct list *prev, struct list *next, struct list *node) { node->next = next; node->prev = prev; - llsync_assign_ptr(prev->next, node); + llsync_store_ptr(prev->next, node); next->prev = node; } @@ -458,7 +458,7 @@ static inline void list_llsync_remove(struct list *node) { node->next->prev = node->prev; - llsync_assign_ptr(node->prev->next, node->next); + llsync_store_ptr(node->prev->next, node->next); } /* @@ -466,7 +466,7 @@ list_llsync_remove(struct list *node) * given node based on the given type and member. */ #define list_llsync_entry(node, type, member) \ - structof(llsync_read_ptr(node), type, member) + structof(llsync_load_ptr(node), type, member) /* * Get the first entry of a list. diff --git a/kern/llsync.h b/kern/llsync.h index 3852b0b9..4a0d0268 100644 --- a/kern/llsync.h +++ b/kern/llsync.h @@ -38,8 +38,8 @@ * supported architectures must guarantee that, when updating a word, and * in turn a pointer, other processors reading that word obtain a valid * value, that is either the previous or the next value of the word, but not - * a mixed-up value. The llsync module provides the llsync_assign_ptr() and - * llsync_read_ptr() wrappers that take care of low level details such as + * a mixed-up value. The llsync module provides the llsync_store_ptr() and + * llsync_load_ptr() wrappers that take care of low level details such as * compiler and memory barriers, so that objects are completely built and * consistent when published and accessed. * @@ -79,14 +79,14 @@ #include <kern/work.h> /* - * Safely assign a pointer. + * Safely store a pointer. */ -#define llsync_assign_ptr(ptr, value) atomic_store(&(ptr), value, ATOMIC_RELEASE) +#define llsync_store_ptr(ptr, value) atomic_store(&(ptr), value, ATOMIC_RELEASE) /* - * Safely access a pointer. + * Safely load a pointer. */ -#define llsync_read_ptr(ptr) atomic_load(&(ptr), ATOMIC_CONSUME) +#define llsync_load_ptr(ptr) atomic_load(&(ptr), ATOMIC_CONSUME) /* * Read-side critical section enter/exit functions. diff --git a/kern/rdxtree.c b/kern/rdxtree.c index 77005b64..678ec176 100644 --- a/kern/rdxtree.c +++ b/kern/rdxtree.c @@ -238,7 +238,7 @@ rdxtree_node_insert(struct rdxtree_node *node, unsigned short index, assert(node->entries[index] == NULL); node->nr_entries++; - llsync_assign_ptr(node->entries[index], entry); + llsync_store_ptr(node->entries[index], entry); } static inline void @@ -255,7 +255,7 @@ rdxtree_node_remove(struct rdxtree_node *node, unsigned short index) assert(node->entries[index] != NULL); node->nr_entries--; - llsync_assign_ptr(node->entries[index], NULL); + llsync_store_ptr(node->entries[index], NULL); } static inline void * @@ -267,7 +267,7 @@ rdxtree_node_find(struct rdxtree_node *node, unsigned short *indexp) index = *indexp; while (index < ARRAY_SIZE(node->entries)) { - ptr = rdxtree_entry_addr(llsync_read_ptr(node->entries[index])); + ptr = rdxtree_entry_addr(llsync_load_ptr(node->entries[index])); if (ptr != NULL) { *indexp = index; @@ -355,7 +355,7 @@ rdxtree_shrink(struct rdxtree *tree) rdxtree_node_unlink(rdxtree_entry_addr(entry)); } - llsync_assign_ptr(tree->root, entry); + llsync_store_ptr(tree->root, entry); /* * There is still one valid entry (the first one) in this node. It @@ -410,7 +410,7 @@ rdxtree_grow(struct rdxtree *tree, rdxtree_key_t key) rdxtree_node_insert(node, 0, tree->root); tree->height++; - llsync_assign_ptr(tree->root, rdxtree_node_to_entry(node)); + llsync_store_ptr(tree->root, rdxtree_node_to_entry(node)); root = node; } while (new_height > tree->height); @@ -433,7 +433,7 @@ rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node) if (node->parent == NULL) { tree->height = 0; - llsync_assign_ptr(tree->root, NULL); + llsync_store_ptr(tree->root, NULL); rdxtree_node_schedule_destruction(node); break; } @@ -488,7 +488,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, return ERROR_BUSY; } - llsync_assign_ptr(tree->root, ptr); + llsync_store_ptr(tree->root, ptr); if (slotp != NULL) { *slotp = &tree->root; @@ -516,7 +516,7 @@ rdxtree_insert_common(struct rdxtree *tree, rdxtree_key_t key, } if (prev == NULL) { - llsync_assign_ptr(tree->root, rdxtree_node_to_entry(node)); + llsync_store_ptr(tree->root, rdxtree_node_to_entry(node)); } else { rdxtree_node_link(node, prev, index); rdxtree_node_insert_node(prev, index, node); @@ -565,7 +565,7 @@ rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, if (unlikely(height == 0)) { if (tree->root == NULL) { - llsync_assign_ptr(tree->root, ptr); + llsync_store_ptr(tree->root, ptr); *keyp = 0; if (slotp != NULL) { @@ -661,7 +661,7 @@ rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key) node = rdxtree_entry_addr(tree->root); if (unlikely(height == 0)) { - llsync_assign_ptr(tree->root, NULL); + llsync_store_ptr(tree->root, NULL); return node; } @@ -700,7 +700,7 @@ rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, unsigned short height, shift, index; void *entry; - entry = llsync_read_ptr(tree->root); + entry = llsync_load_ptr(tree->root); if (entry == NULL) { node = NULL; @@ -731,7 +731,7 @@ rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, prev = node; index = (unsigned short)(key >> shift) & RDXTREE_RADIX_MASK; - entry = llsync_read_ptr(node->entries[index]); + entry = llsync_load_ptr(node->entries[index]); node = rdxtree_entry_addr(entry); shift -= RDXTREE_RADIX; height--; @@ -755,7 +755,7 @@ rdxtree_replace_slot(void **slot, void *ptr) old = *slot; assert(old != NULL); rdxtree_assert_alignment(old); - llsync_assign_ptr(*slot, ptr); + llsync_store_ptr(*slot, ptr); return old; } @@ -767,7 +767,7 @@ rdxtree_walk_next(struct rdxtree *tree, struct rdxtree_iter *iter) rdxtree_key_t key; void *entry; - entry = llsync_read_ptr(tree->root); + entry = llsync_load_ptr(tree->root); if (entry == NULL) { return NULL; @@ -863,7 +863,7 @@ rdxtree_remove_all(struct rdxtree *tree) if (tree->height == 0) { if (tree->root != NULL) { - llsync_assign_ptr(tree->root, NULL); + llsync_store_ptr(tree->root, NULL); } return; diff --git a/kern/rdxtree.h b/kern/rdxtree.h index 6ae1e6e7..1430208d 100644 --- a/kern/rdxtree.h +++ b/kern/rdxtree.h @@ -160,7 +160,7 @@ rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key) static inline void * rdxtree_load_slot(void **slot) { - return llsync_read_ptr(*slot); + return llsync_load_ptr(*slot); } /* diff --git a/kern/slist.h b/kern/slist.h index 8d42db2b..0e26c05f 100644 --- a/kern/slist.h +++ b/kern/slist.h @@ -301,7 +301,7 @@ for (entry = slist_first_entry(list, typeof(*entry), member), \ static inline struct slist_node * slist_llsync_first(const struct slist *list) { - return llsync_read_ptr(list->first); + return llsync_load_ptr(list->first); } /* @@ -310,7 +310,7 @@ slist_llsync_first(const struct slist *list) static inline struct slist_node * slist_llsync_next(const struct slist_node *node) { - return llsync_read_ptr(node->next); + return llsync_load_ptr(node->next); } /* @@ -324,7 +324,7 @@ slist_llsync_insert_head(struct slist *list, struct slist_node *node) } node->next = list->first; - llsync_assign_ptr(list->first, node); + llsync_store_ptr(list->first, node); } /* @@ -336,9 +336,9 @@ slist_llsync_insert_tail(struct slist *list, struct slist_node *node) node->next = NULL; if (slist_empty(list)) { - llsync_assign_ptr(list->first, node); + llsync_store_ptr(list->first, node); } else { - llsync_assign_ptr(list->last->next, node); + llsync_store_ptr(list->last->next, node); } list->last = node; @@ -356,7 +356,7 @@ slist_llsync_insert_after(struct slist *list, struct slist_node *prev, struct slist_node *node) { node->next = prev->next; - llsync_assign_ptr(prev->next, node); + llsync_store_ptr(prev->next, node); if (list->last == prev) { list->last = node; @@ -377,14 +377,14 @@ slist_llsync_remove(struct slist *list, struct slist_node *prev) if (slist_end(prev)) { node = list->first; - llsync_assign_ptr(list->first, node->next); + llsync_store_ptr(list->first, node->next); if (list->last == node) { list->last = NULL; } } else { node = prev->next; - llsync_assign_ptr(prev->next, node->next); + llsync_store_ptr(prev->next, node->next); if (list->last == node) { list->last = prev; @@ -397,7 +397,7 @@ slist_llsync_remove(struct slist *list, struct slist_node *prev) * given node based on the given type and member. */ #define slist_llsync_entry(node, type, member) \ - structof(llsync_read_ptr(node), type, member) + structof(llsync_load_ptr(node), type, member) /* * Get the first entry of a list. diff --git a/test/test_llsync_defer.c b/test/test_llsync_defer.c index 4b8afbc7..c87aff77 100644 --- a/test/test_llsync_defer.c +++ b/test/test_llsync_defer.c @@ -87,7 +87,7 @@ test_alloc(void *arg) } } - llsync_assign_ptr(test_pdsc, pdsc); + llsync_store_ptr(test_pdsc, pdsc); condition_signal(&test_condition); if ((i % TEST_LOOPS_PER_PRINT) == 0) { @@ -130,7 +130,7 @@ test_free(void *arg) } pdsc = test_pdsc; - llsync_assign_ptr(test_pdsc, NULL); + llsync_store_ptr(test_pdsc, NULL); if (pdsc != NULL) { work_init(&pdsc->work, test_deferred_free); @@ -161,7 +161,7 @@ test_read(void *arg) for (;;) { llsync_read_enter(); - pdsc = llsync_read_ptr(test_pdsc); + pdsc = llsync_load_ptr(test_pdsc); if (pdsc != NULL) { s = (const unsigned char *)pdsc->addr; |