LCOV - code coverage report
Current view: top level - vinyl/rq - fd_vinyl_rq.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 74 0.0 %
Date: 2026-03-19 18:19:27 Functions: 0 6 0.0 %

          Line data    Source code
       1             : #include "fd_vinyl_rq.h"
       2             : 
       3             : ulong
       4           0 : fd_vinyl_rq_align( void ) {
       5           0 :   return alignof(fd_vinyl_rq_t);
       6           0 : }
       7             : 
       8             : ulong
       9           0 : fd_vinyl_rq_footprint( ulong req_cnt ) {
      10           0 :   if( FD_UNLIKELY( !((4UL<=req_cnt) & (req_cnt<(1UL<<63)/sizeof(fd_vinyl_req_t)) & fd_ulong_is_pow2( req_cnt )) ) ) return 0UL;
      11           0 :   return fd_ulong_align_up( sizeof(fd_vinyl_rq_t) + req_cnt*sizeof(fd_vinyl_req_t), alignof(fd_vinyl_rq_t) );
      12           0 : }
      13             : 
      14             : void *
      15             : fd_vinyl_rq_new( void * shmem,
      16           0 :                  ulong  req_cnt ) {
      17           0 :   fd_vinyl_rq_t * rq = (fd_vinyl_rq_t *)shmem;
      18             : 
      19           0 :   if( FD_UNLIKELY( !rq ) ) {
      20           0 :     FD_LOG_WARNING(( "NULL shmem"));
      21           0 :     return NULL;
      22           0 :   }
      23             : 
      24           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)rq, fd_vinyl_rq_align() ) ) ) {
      25           0 :     FD_LOG_WARNING(( "bad align"));
      26           0 :     return NULL;
      27           0 :   }
      28             : 
      29           0 :   ulong footprint = fd_vinyl_rq_footprint( req_cnt );
      30           0 :   if( FD_UNLIKELY( !footprint) ) {
      31           0 :     FD_LOG_WARNING(( "bad req_cnt"));
      32           0 :     return NULL;
      33           0 :   }
      34             : 
      35           0 :   memset( rq, 0, footprint );
      36             : 
      37           0 :   rq->req_cnt = req_cnt;
      38           0 :   rq->seq     = 0UL;
      39             : 
      40           0 :   fd_vinyl_req_t * req = fd_vinyl_rq_req( rq );
      41             : 
      42           0 :   for( ulong seq=0UL; seq<req_cnt; seq++ ) req[ seq ].seq = seq - 1UL; /* Just before the next seq to be written to this entry */
      43             : 
      44           0 :   FD_COMPILER_MFENCE();
      45           0 :   rq->magic = FD_VINYL_RQ_MAGIC;
      46           0 :   FD_COMPILER_MFENCE();
      47             : 
      48           0 :   return rq;
      49           0 : }
      50             : 
      51             : fd_vinyl_rq_t *
      52           0 : fd_vinyl_rq_join( void * shrq ) {
      53           0 :   fd_vinyl_rq_t * rq = (fd_vinyl_rq_t *)shrq;
      54             : 
      55           0 :   if( FD_UNLIKELY( !rq ) ) {
      56           0 :     FD_LOG_WARNING(( "NULL shrq"));
      57           0 :     return NULL;
      58           0 :   }
      59             : 
      60           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)rq, fd_vinyl_rq_align() ) ) ) {
      61           0 :     FD_LOG_WARNING(( "bad align"));
      62           0 :     return NULL;
      63           0 :   }
      64             : 
      65           0 :   if( FD_UNLIKELY( rq->magic!=FD_VINYL_RQ_MAGIC ) ) {
      66           0 :     FD_LOG_WARNING(( "bad magic"));
      67           0 :     return NULL;
      68           0 :   }
      69             : 
      70           0 :   return (fd_vinyl_rq_t *)shrq;
      71           0 : }
      72             : 
      73             : void *
      74           0 : fd_vinyl_rq_leave( fd_vinyl_rq_t * rq ) {
      75             : 
      76           0 :   if( FD_UNLIKELY( !rq ) ) {
      77           0 :     FD_LOG_WARNING(( "NULL rq"));
      78           0 :     return NULL;
      79           0 :   }
      80             : 
      81           0 :   return rq;
      82           0 : }
      83             : 
      84             : void *
      85           0 : fd_vinyl_rq_delete( void * shrq ) {
      86           0 :   fd_vinyl_rq_t * rq = (fd_vinyl_rq_t *)shrq;
      87             : 
      88           0 :   if( FD_UNLIKELY( !rq ) ) {
      89           0 :     FD_LOG_WARNING(( "NULL shrq"));
      90           0 :     return NULL;
      91           0 :   }
      92             : 
      93           0 :   if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)rq, fd_vinyl_rq_align() ) ) ) {
      94           0 :     FD_LOG_WARNING(( "bad align"));
      95           0 :     return NULL;
      96           0 :   }
      97             : 
      98           0 :   if( FD_UNLIKELY( rq->magic!=FD_VINYL_RQ_MAGIC ) ) {
      99           0 :     FD_LOG_WARNING(( "bad magic"));
     100           0 :     return NULL;
     101           0 :   }
     102             : 
     103           0 :   FD_COMPILER_MFENCE();
     104           0 :   rq->magic = 0UL;
     105           0 :   FD_COMPILER_MFENCE();
     106             : 
     107           0 :   return rq;
     108           0 : }

Generated by: LCOV version 1.14