LCOV - code coverage report
Current view: top level - choreo/ghost - fd_ghost_private.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 26 42 61.9 %
Date: 2026-01-23 05:02:40 Functions: 5 16 31.2 %

          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 ghost_gaddr;    /* memory offset of the beginning of ghost region in the wksp */
      50             :   ulong blk_pool_gaddr; /* memory offset of the blk_pool */
      51             :   ulong blk_map_gaddr;  /* memory offset of the blk_map */
      52             :   ulong vtr_pool_gaddr; /* memory offset of the vtr_pool */
      53             :   ulong vtr_map_gaddr;  /* memory offset of the vtr_map */
      54             : };
      55             : typedef struct fd_ghost fd_ghost_t;
      56             : 
      57             : typedef fd_ghost_blk_t blk_pool_t;
      58             : typedef fd_ghost_vtr_t vtr_pool_t;
      59             : 
      60             : static inline blk_pool_t *
      61         552 : blk_pool( fd_ghost_t * ghost ) {
      62         552 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      63         552 :   return (blk_pool_t *)fd_wksp_laddr_fast( wksp, ghost->blk_pool_gaddr );
      64         552 : }
      65             : 
      66             : static inline blk_pool_t const *
      67           0 : blk_pool_const( fd_ghost_t const * ghost ) {
      68           0 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      69           0 :   return (blk_pool_t const *)fd_wksp_laddr_fast( wksp, ghost->blk_pool_gaddr );
      70           0 : }
      71             : 
      72             : static inline blk_map_t *
      73         546 : blk_map( fd_ghost_t * ghost ) {
      74         546 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      75         546 :   return (blk_map_t *)fd_wksp_laddr_fast( wksp, ghost->blk_map_gaddr );
      76         546 : }
      77             : 
      78             : static inline blk_map_t const *
      79           0 : blk_map_const( fd_ghost_t const * ghost ) {
      80           0 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      81           0 :   return (blk_map_t const *)fd_wksp_laddr_fast( wksp, ghost->blk_map_gaddr );
      82           0 : }
      83             : 
      84             : static inline vtr_pool_t *
      85          24 : vtr_pool( fd_ghost_t * ghost ) {
      86          24 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      87          24 :   return (vtr_pool_t *)fd_wksp_laddr_fast( wksp, ghost->vtr_pool_gaddr );
      88          24 : }
      89             : 
      90             : static inline vtr_pool_t const *
      91           0 : vtr_pool_const( fd_ghost_t const * ghost ) {
      92           0 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      93           0 :   return (vtr_pool_t const *)fd_wksp_laddr_fast( wksp, ghost->vtr_pool_gaddr );
      94           0 : }
      95             : 
      96             : static inline vtr_map_t *
      97          18 : vtr_map( fd_ghost_t * ghost ) {
      98          18 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
      99          18 :   return (vtr_map_t *)fd_wksp_laddr_fast( wksp, ghost->vtr_map_gaddr );
     100          18 : }
     101             : 
     102             : static inline vtr_map_t const *
     103           0 : vtr_map_const( fd_ghost_t const * ghost ) {
     104           0 :   fd_wksp_t * wksp = fd_wksp_containing( ghost );
     105           0 :   return (vtr_map_t const *)fd_wksp_laddr_fast( wksp, ghost->vtr_map_gaddr );
     106           0 : }

Generated by: LCOV version 1.14