LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_program_util.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 18 0.0 %
Date: 2025-03-20 12:08:36 Functions: 0 468 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_native_program_util_h
       2             : #define HEADER_fd_src_flamenco_runtime_native_program_util_h
       3             : 
       4             : #include "../../fd_flamenco_base.h"
       5             : #include "../fd_executor_err.h"
       6             : 
       7             : FD_PROTOTYPES_BEGIN
       8             : 
       9             : /**********************************************************************/
      10             : /* mod instruction                                                    */
      11             : /**********************************************************************/
      12             : 
      13             : // https://github.com/firedancer-io/solana/blob/v1.17/sdk/program/src/instruction.rs#L519
      14             : static inline int
      15           0 : fd_ulong_checked_add( ulong a, ulong b, ulong * out ) {
      16           0 :   int cf = __builtin_uaddl_overflow( a, b, out );
      17           0 :   return fd_int_if( cf, FD_EXECUTOR_INSTR_ERR_INSUFFICIENT_FUNDS, FD_EXECUTOR_INSTR_SUCCESS );
      18           0 : }
      19             : 
      20             : // https://github.com/firedancer-io/solana/blob/v1.17/sdk/program/src/instruction.rs#L519
      21             : static inline int FD_FN_UNUSED
      22           0 : fd_ulong_checked_sub( ulong a, ulong b, ulong * out ) {
      23           0 :   int cf = __builtin_usubl_overflow( a, b, out );
      24           0 :   return fd_int_if( cf, FD_EXECUTOR_INSTR_ERR_INSUFFICIENT_FUNDS, FD_EXECUTOR_INSTR_SUCCESS );
      25           0 : }
      26             : 
      27             : static inline ulong
      28           0 : fd_ulong_checked_add_expect( ulong a, ulong b, char const * expect ) {
      29           0 :   ulong out = ULONG_MAX;
      30           0 :   if( FD_UNLIKELY( fd_ulong_checked_add( a, b, &out ) ) ) { FD_LOG_ERR(( "%s", expect )); }
      31           0 :   return out;
      32           0 : }
      33             : 
      34             : static inline ulong
      35           0 : fd_ulong_checked_sub_expect( ulong a, ulong b, char const * expect ) {
      36           0 :   ulong out = ULONG_MAX;
      37           0 :   if( FD_UNLIKELY( fd_ulong_checked_sub( a, b, &out ) ) ) { FD_LOG_ERR(( "%s", expect )); }
      38           0 :   return out;
      39           0 : }
      40             : 
      41             : FD_PROTOTYPES_END
      42             : 
      43             : #endif /* HEADER_fd_src_flamenco_runtime_native_program_util_h */

Generated by: LCOV version 1.14