Line data Source code
1 : #include "fd_ghost.h" 2 : 3 : #define POOL_NAME blk_pool 4 24 : #define POOL_T fd_ghost_blk_t 5 : #include "../../util/tmpl/fd_pool.c" 6 : 7 : #define MAP_NAME blk_map 8 : #define MAP_ELE_T fd_ghost_blk_t 9 162 : #define MAP_KEY id 10 : #define MAP_KEY_T fd_hash_t 11 513 : #define MAP_KEY_EQ(k0,k1) (!memcmp((k0),(k1), sizeof(fd_hash_t))) 12 687 : #define MAP_KEY_HASH(key,seed) (fd_hash((seed),(key),sizeof(fd_hash_t))) 13 672 : #define MAP_NEXT next 14 : #include "../../util/tmpl/fd_map_chain.c" 15 : 16 : #define POOL_NAME vtr_pool 17 24 : #define POOL_T fd_ghost_vtr_t 18 : #include "../../util/tmpl/fd_pool.c" 19 : 20 : #define MAP_NAME vtr_map 21 : #define MAP_ELE_T fd_ghost_vtr_t 22 6 : #define MAP_KEY addr 23 : #define MAP_KEY_T fd_pubkey_t 24 6 : #define MAP_KEY_EQ(k0,k1) (!memcmp((k0),(k1), sizeof(fd_hash_t))) 25 18 : #define MAP_KEY_HASH(key,seed) (fd_hash((seed),(key),sizeof(fd_hash_t))) 26 6 : #define MAP_NEXT next 27 : #include "../../util/tmpl/fd_map_chain.c" 28 : 29 : /* fd_ghost_t is the top-level structure that holds the root of the 30 : tree, as well as the memory pools and map structures for tracking 31 : ghost eles and votes. 32 : 33 : These structures are bump-allocated and laid out contiguously in 34 : memory from the fd_ghost_t * pointer which points to the beginning of 35 : the memory region. 36 : 37 : ---------------------- <- fd_ghost_t * 38 : | root | 39 : ---------------------- 40 : | pool | 41 : ---------------------- 42 : | blk_map | 43 : ---------------------- 44 : | vtr_map | 45 : ---------------------- */ 46 : 47 : struct __attribute__((aligned(128UL))) fd_ghost { 48 : ulong root; /* pool idx of the root tree element */ 49 : ulong blk_pool_gaddr; /* memory offset of the blk_pool */ 50 : ulong blk_map_gaddr; /* memory offset of the blk_map */ 51 : ulong vtr_pool_gaddr; /* memory offset of the vtr_pool */ 52 : ulong vtr_map_gaddr; /* memory offset of the vtr_map */ 53 : }; 54 : typedef struct fd_ghost fd_ghost_t; 55 : 56 : typedef fd_ghost_blk_t blk_pool_t; 57 : typedef fd_ghost_vtr_t vtr_pool_t; 58 : 59 : static inline blk_pool_t * 60 552 : blk_pool( fd_ghost_t * ghost ) { 61 552 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 62 552 : return (blk_pool_t *)fd_wksp_laddr_fast( wksp, ghost->blk_pool_gaddr ); 63 552 : } 64 : 65 : static inline blk_pool_t const * 66 0 : blk_pool_const( fd_ghost_t const * ghost ) { 67 0 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 68 0 : return (blk_pool_t const *)fd_wksp_laddr_fast( wksp, ghost->blk_pool_gaddr ); 69 0 : } 70 : 71 : static inline blk_map_t * 72 546 : blk_map( fd_ghost_t * ghost ) { 73 546 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 74 546 : return (blk_map_t *)fd_wksp_laddr_fast( wksp, ghost->blk_map_gaddr ); 75 546 : } 76 : 77 : static inline blk_map_t const * 78 0 : blk_map_const( fd_ghost_t const * ghost ) { 79 0 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 80 0 : return (blk_map_t const *)fd_wksp_laddr_fast( wksp, ghost->blk_map_gaddr ); 81 0 : } 82 : 83 : static inline vtr_pool_t * 84 24 : vtr_pool( fd_ghost_t * ghost ) { 85 24 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 86 24 : return (vtr_pool_t *)fd_wksp_laddr_fast( wksp, ghost->vtr_pool_gaddr ); 87 24 : } 88 : 89 : static inline vtr_pool_t const * 90 0 : vtr_pool_const( fd_ghost_t const * ghost ) { 91 0 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 92 0 : return (vtr_pool_t const *)fd_wksp_laddr_fast( wksp, ghost->vtr_pool_gaddr ); 93 0 : } 94 : 95 : static inline vtr_map_t * 96 18 : vtr_map( fd_ghost_t * ghost ) { 97 18 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 98 18 : return (vtr_map_t *)fd_wksp_laddr_fast( wksp, ghost->vtr_map_gaddr ); 99 18 : } 100 : 101 : static inline vtr_map_t const * 102 0 : vtr_map_const( fd_ghost_t const * ghost ) { 103 0 : fd_wksp_t * wksp = fd_wksp_containing( ghost ); 104 0 : return (vtr_map_t const *)fd_wksp_laddr_fast( wksp, ghost->vtr_map_gaddr ); 105 0 : }