LCOV - code coverage report
Current view: top level - choreo/tower - fd_tower_leaves.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 20 0.0 %
Date: 2026-03-19 18:19:27 Functions: 0 44 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_choreo_tower_fd_tower_leaves_h
       2             : #define HEADER_fd_src_choreo_tower_fd_tower_leaves_h
       3             : 
       4             : #include "../fd_choreo_base.h"
       5             : #include "fd_tower_voters.h"
       6             : 
       7             : /* fd_tower_leaves maintains the leaves of every fork.
       8             : 
       9             :         /-- 3-- 4  (A)
      10             :    1-- 2
      11             :         \-- 5      (B)
      12             : 
      13             :    In the above example, fd_tower_leaves will contain [4, 5]. */
      14             : 
      15             : struct fd_tower_leaf {
      16             :   ulong slot; /* map key */
      17             :   ulong hash; /* reserved for fd_map_chain and fd_pool */
      18             :   ulong next; /* next leaf in the linked list */
      19             :   ulong prev; /* prev leaf in the linked list */
      20             : };
      21             : typedef struct fd_tower_leaf fd_tower_leaf_t;
      22             : 
      23             : #define MAP_NAME    fd_tower_leaves_map
      24             : #define MAP_ELE_T   fd_tower_leaf_t
      25           0 : #define MAP_KEY     slot
      26           0 : #define MAP_NEXT    hash
      27             : #include "../../util/tmpl/fd_map_chain.c"
      28             : 
      29             : #define POOL_NAME fd_tower_leaves_pool
      30           0 : #define POOL_T    fd_tower_leaf_t
      31           0 : #define POOL_NEXT hash
      32             : #include "../../util/tmpl/fd_pool.c"
      33             : 
      34             : #define DLIST_NAME  fd_tower_leaves_dlist
      35             : #define DLIST_ELE_T fd_tower_leaf_t
      36             : #include "../../util/tmpl/fd_dlist.c"
      37             : 
      38             : struct __attribute__((aligned(128UL))) fd_tower_leaves {
      39             :   fd_tower_leaf_t         * pool;
      40             :   fd_tower_leaves_map_t   * map;
      41             :   fd_tower_leaves_dlist_t * dlist;
      42             : };
      43             : typedef struct fd_tower_leaves fd_tower_leaves_t;
      44             : 
      45             : FD_PROTOTYPES_BEGIN
      46             : 
      47             : /* fd_tower_leaves_{align,footprint} return the required alignment and
      48             :    footprint of a memory region suitable for use as a tower_leaves. */
      49             : 
      50             : FD_FN_CONST static inline ulong
      51           0 : fd_tower_leaves_align( void ) {
      52           0 :   return alignof(fd_tower_leaves_t);
      53           0 : }
      54             : 
      55             : FD_FN_CONST static inline ulong
      56           0 : fd_tower_leaves_footprint( ulong slot_max ) {
      57           0 :   return FD_LAYOUT_FINI(
      58           0 :     FD_LAYOUT_APPEND(
      59           0 :     FD_LAYOUT_APPEND(
      60           0 :     FD_LAYOUT_APPEND(
      61           0 :     FD_LAYOUT_APPEND(
      62           0 :     FD_LAYOUT_INIT,
      63           0 :       alignof(fd_tower_leaves_t),    sizeof(fd_tower_leaves_t)                  ),
      64           0 :       fd_tower_leaves_map_align(),   fd_tower_leaves_map_footprint( slot_max )  ),
      65           0 :       fd_tower_leaves_dlist_align(), fd_tower_leaves_dlist_footprint()          ),
      66           0 :       fd_tower_leaves_pool_align(),  fd_tower_leaves_pool_footprint( slot_max ) ),
      67           0 :     fd_tower_leaves_align() );
      68           0 : }
      69             : 
      70             : /* fd_tower_leaves_new formats an unused memory region for use as a
      71             :    tower_leaves.  mem is a non-NULL pointer to this region in the local
      72             :    address space with the required footprint and alignment. */
      73             : 
      74             : void *
      75             : fd_tower_leaves_new( void * shmem,
      76             :                      ulong  slot_max,
      77             :                      ulong  seed );
      78             : 
      79             : /* fd_tower_leaves_join joins the caller to the tower_leaves. shleaves
      80             :    points to the first byte of the memory region backing the shleaves in
      81             :    the caller's address space.
      82             : 
      83             :    Returns a pointer in the local address space to leaves on success. */
      84             : 
      85             : fd_tower_leaves_t *
      86             : fd_tower_leaves_join( void * shleaves );
      87             : 
      88             : /* fd_tower_leaves_leave leaves a current local join.  Returns a pointer
      89             :    to the underlying shared memory region on success and NULL on failure
      90             :    (logs details).  Reasons for failure include leaves is NULL. */
      91             : 
      92             : void *
      93             : fd_tower_leaves_leave( fd_tower_leaves_t const * leaves );
      94             : 
      95             : /* fd_tower_leaves_delete unformats a memory region used as a leaves.
      96             :    Assumes only the local process is joined to the region.  Returns a
      97             :    pointer to the underlying shared memory region or NULL if used
      98             :    obviously in error (e.g. leaves is obviously not a leaves ...  logs
      99             :    details).  The ownership of the memory region is transferred to the
     100             :    caller. */
     101             : 
     102             : void *
     103             : fd_tower_leaves_delete( void * leaves );
     104             : 
     105             : 
     106             : void
     107             : fd_tower_leaves_upsert( fd_tower_leaves_t * leaves,
     108             :                         ulong               slot,
     109             :                         ulong               parent_slot );
     110             : 
     111             : void
     112             : fd_tower_leaves_remove( fd_tower_leaves_t * leaves,
     113             :                         ulong               slot );
     114             : 
     115             : FD_PROTOTYPES_END
     116             : 
     117             : #endif /* HEADER_fd_src_choreo_tower_fd_tower_leaves_h */

Generated by: LCOV version 1.14