LCOV - code coverage report
Current view: top level - flamenco/types - fd_types_custom.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 19 0.0 %
Date: 2026-04-06 06:22:41 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "fd_types_custom.h"
       2             : #include "fd_bincode.h"
       3             : #include "fd_types.h"
       4             : #ifndef SOURCE_fd_src_flamenco_types_fd_types_c
       5             : #error "fd_types_custom.c is part of the fd_types.c compile uint"
       6             : #endif /* !SOURCE_fd_src_flamenco_types_fd_types_c */
       7             : 
       8             : // https://github.com/serde-rs/serde/blob/49d098debdf8b5c38bfb6868f455c6ce542c422c/serde/src/de/impls.rs#L2374
       9             : //
      10             : // During the call to Duration::new(...), it normalizes the seconds and nanoseconds automatically.  We need to
      11             : // match this behavior correctly
      12             : //
      13             : void
      14           0 : fd_rust_duration_normalize ( fd_rust_duration_t * self ) {
      15           0 :   if( self->nanoseconds < 1000000000U )
      16           0 :     return;
      17           0 :   uint secs = self->nanoseconds/1000000000U;
      18           0 :   self->seconds += secs;
      19           0 :   self->nanoseconds -= secs * 1000000000U;
      20           0 : }
      21             : 
      22             : // https://github.com/serde-rs/serde/blob/49d098debdf8b5c38bfb6868f455c6ce542c422c/serde/src/de/impls.rs#L2203
      23             : //
      24             : // There is an overflow check at line 2373 that turns an overflow into an encoding error
      25             : //
      26             : int
      27           0 : fd_rust_duration_footprint_validator ( fd_bincode_decode_ctx_t * ctx ) {
      28           0 :   if( (ulong)ctx->data + ( sizeof(ulong) + sizeof(uint) ) > (ulong)ctx->dataend )
      29           0 :     return FD_BINCODE_ERR_OVERFLOW;
      30             : 
      31           0 :   ulong seconds    = FD_LOAD( ulong, ctx->data );
      32           0 :   uint nanoseconds = FD_LOAD( uint, (uchar*)ctx->data + sizeof(ulong) );
      33             : 
      34           0 :   if( nanoseconds < 1000000000U )
      35           0 :     return FD_BINCODE_SUCCESS;
      36           0 :   ulong out;
      37           0 :   if( __builtin_uaddl_overflow( seconds, nanoseconds/1000000000U, &out ) )
      38           0 :     return FD_BINCODE_ERR_ENCODING;
      39           0 :   return FD_BINCODE_SUCCESS;
      40           0 : }

Generated by: LCOV version 1.14