Changeset 5e5cef3 in mainline
- Timestamp:
- 2012-08-03T16:17:16Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 26d8df3
- Parents:
- 0b7bcb8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/adt/cht.c
r0b7bcb8 r5e5cef3 86 86 static size_t size_to_order(size_t bucket_cnt, size_t min_order); 87 87 static cht_buckets_t *alloc_buckets(size_t order, bool set_invalid); 88 static inline cht_link_t *find_lazy(cht_t *h, void *key); 88 89 static cht_link_t *search_bucket(cht_t *h, marked_ptr_t head, void *key, 89 90 size_t search_hash); … … 242 243 } 243 244 244 245 245 cht_link_t *cht_find_lazy(cht_t *h, void *key) 246 { 247 return find_lazy(h, key); 248 } 249 250 static inline cht_link_t *find_lazy(cht_t *h, void *key) 246 251 { 247 252 ASSERT(h); … … 280 285 } 281 286 282 static cht_link_t *search_bucket(cht_t *h, marked_ptr_t head, void *key,287 static inline cht_link_t *search_bucket(cht_t *h, marked_ptr_t head, void *key, 283 288 size_t search_hash) 284 289 { … … 291 296 * may find by following the next pointers is allocated. 292 297 */ 293 size_t cur_hash = node_hash(h, cur); 294 295 if (cur_hash >= search_hash) { 296 if (cur_hash != search_hash) 297 return 0; 298 299 int present = !(N_DELETED & get_mark(cur->link)); 300 if (present && h->op->key_equal(key, cur)) 298 if (h->op->key_equal(key, cur)) { 299 if (!(N_DELETED & get_mark(cur->link))) 301 300 return cur; 302 301 } … … 465 464 466 465 bool resizing = false; 467 bool inserted ;466 bool inserted = false; 468 467 469 468 do { … … 503 502 } 504 503 505 static bool insert_at(cht_link_t *item, const wnd_t *wnd, walk_mode_t walk_mode, 506 bool *resizing)504 inline static bool insert_at(cht_link_t *item, const wnd_t *wnd, 505 walk_mode_t walk_mode, bool *resizing) 507 506 { 508 507 marked_ptr_t ret; … … 550 549 } 551 550 552 static bool has_duplicates(cht_t *h, const cht_link_t *item, size_t hash,551 static inline bool has_duplicates(cht_t *h, const cht_link_t *item, size_t hash, 553 552 const wnd_t *wnd) 554 553 { … … 682 681 683 682 684 static bool delete_at(cht_t *h, wnd_t *wnd, walk_mode_t walk_mode,683 static inline bool delete_at(cht_t *h, wnd_t *wnd, walk_mode_t walk_mode, 685 684 bool *deleted_but_gc, bool *resizing) 686 685 { … … 711 710 } 712 711 713 static bool mark_deleted(cht_link_t *cur, walk_mode_t walk_mode, bool *resizing) 712 static inline bool mark_deleted(cht_link_t *cur, walk_mode_t walk_mode, 713 bool *resizing) 714 714 { 715 715 ASSERT(cur); … … 746 746 } 747 747 748 static bool unlink_from_pred(wnd_t *wnd, walk_mode_t walk_mode, bool *resizing) 748 static inline bool unlink_from_pred(wnd_t *wnd, walk_mode_t walk_mode, 749 bool *resizing) 749 750 { 750 751 ASSERT(wnd->cur && (N_DELETED & get_mark(wnd->cur->link))); … … 1023 1024 #endif 1024 1025 1025 static void help_head_move(marked_ptr_t *psrc_head, marked_ptr_t *pdest_head) 1026 static inline void help_head_move(marked_ptr_t *psrc_head, 1027 marked_ptr_t *pdest_head) 1026 1028 { 1027 1029 /* Head move has to in progress already when calling this func. */ … … 1357 1359 } 1358 1360 1359 static void item_removed(cht_t *h)1361 static inline void item_removed(cht_t *h) 1360 1362 { 1361 1363 size_t items = (size_t) atomic_predec(&h->item_cnt); … … 1374 1376 } 1375 1377 1376 static void item_inserted(cht_t *h)1378 static inline void item_inserted(cht_t *h) 1377 1379 { 1378 1380 size_t items = (size_t) atomic_preinc(&h->item_cnt); … … 1745 1747 1746 1748 1747 static size_t calc_split_hash(size_t split_idx, size_t order)1749 static inline size_t calc_split_hash(size_t split_idx, size_t order) 1748 1750 { 1749 1751 ASSERT(1 <= order && order <= 8 * sizeof(size_t)); … … 1751 1753 } 1752 1754 1753 static size_t calc_bucket_idx(size_t hash, size_t order)1755 static inline size_t calc_bucket_idx(size_t hash, size_t order) 1754 1756 { 1755 1757 ASSERT(1 <= order && order <= 8 * sizeof(size_t)); … … 1757 1759 } 1758 1760 1759 static size_t grow_to_split_idx(size_t old_idx)1761 static inline size_t grow_to_split_idx(size_t old_idx) 1760 1762 { 1761 1763 return grow_idx(old_idx) | 1; 1762 1764 } 1763 1765 1764 static size_t grow_idx(size_t idx)1766 static inline size_t grow_idx(size_t idx) 1765 1767 { 1766 1768 return idx << 1; 1767 1769 } 1768 1770 1769 static size_t shrink_idx(size_t idx)1771 static inline size_t shrink_idx(size_t idx) 1770 1772 { 1771 1773 return idx >> 1; … … 1773 1775 1774 1776 1775 static size_t key_hash(cht_t *h, void *key)1777 static inline size_t key_hash(cht_t *h, void *key) 1776 1778 { 1777 1779 return hash_mix(h->op->key_hash(key)); 1778 1780 } 1779 1781 1780 static size_t node_hash(cht_t *h, const cht_link_t *item)1782 static inline size_t node_hash(cht_t *h, const cht_link_t *item) 1781 1783 { 1782 1784 return hash_mix(h->op->hash(item)); … … 1784 1786 1785 1787 1786 static marked_ptr_t make_link(const cht_link_t *next, mark_t mark)1788 static inline marked_ptr_t make_link(const cht_link_t *next, mark_t mark) 1787 1789 { 1788 1790 marked_ptr_t ptr = (marked_ptr_t) next; … … 1795 1797 1796 1798 1797 static cht_link_t * get_next(marked_ptr_t link)1799 static inline cht_link_t * get_next(marked_ptr_t link) 1798 1800 { 1799 1801 return (cht_link_t*)(link & ~N_MARK_MASK); … … 1801 1803 1802 1804 1803 static mark_t get_mark(marked_ptr_t link)1805 static inline mark_t get_mark(marked_ptr_t link) 1804 1806 { 1805 1807 return (mark_t)(link & N_MARK_MASK); … … 1807 1809 1808 1810 1809 static void next_wnd(wnd_t *wnd)1811 static inline void next_wnd(wnd_t *wnd) 1810 1812 { 1811 1813 ASSERT(wnd); … … 1824 1826 } 1825 1827 1826 static marked_ptr_t cas_link(marked_ptr_t *link, const cht_link_t *cur_next,1828 static inline marked_ptr_t cas_link(marked_ptr_t *link, const cht_link_t *cur_next, 1827 1829 mark_t cur_mark, const cht_link_t *new_next, mark_t new_mark) 1828 1830 { … … 1831 1833 } 1832 1834 1833 static marked_ptr_t _cas_link(marked_ptr_t *link, marked_ptr_t cur,1835 static inline marked_ptr_t _cas_link(marked_ptr_t *link, marked_ptr_t cur, 1834 1836 marked_ptr_t new) 1835 1837 { … … 1860 1862 } 1861 1863 1862 static void cas_order_barrier(void)1864 static inline void cas_order_barrier(void) 1863 1865 { 1864 1866 /* Make sure CAS to different memory locations are ordered. */
Note:
See TracChangeset
for help on using the changeset viewer.