Line data Source code
1 : #include "fd_version.h" 2 : #include "cstr/fd_cstr.h" 3 : #include "fd_version_generated.h" 4 : 5 : /* Firedancer version */ 6 : __attribute__((weak)) ulong const fd_major_version = FD_VERSION_MAJOR; 7 : __attribute__((weak)) ulong const fd_minor_version = FD_VERSION_MINOR; 8 : __attribute__((weak)) ulong const fd_patch_version = FD_VERSION_PATCH; 9 : char const * fd_version_cstr = ""; /* set on boot */ 10 : 11 : /* Commit information */ 12 : __attribute__((weak)) char const fd_commit_ref_private[] = FIREDANCER_COMMIT_REF_CSTR; 13 : char const * fd_commit_ref_cstr = ""; /* cstr */ 14 : uint fd_commit_ref_u32 = 0; /* set on boot */ 15 : 16 : static inline int 17 21440 : unhex( int c ) { 18 21440 : if( c>='0' && c<='9' ) return c-'0'; 19 10720 : if( c>='a' && c<='f' ) return c-'a'+0xa; 20 0 : if( c>='A' && c<='F' ) return c-'A'+0xa; 21 0 : return -1; 22 0 : } 23 : 24 : void 25 2680 : fd_version_private_commit_ref_init( void ) { 26 2680 : char const * str = fd_commit_ref_private; 27 2680 : fd_commit_ref_cstr = str; 28 2680 : uint ref = 0; 29 2680 : char tmp[9] = {0}; fd_cstr_ncpy( tmp, str, 9 ); 30 13400 : for( ulong i=0UL; i<8UL; i+=2 ) { 31 10720 : int hi = unhex( tmp[ i ] ); 32 10720 : int lo = unhex( tmp[ i+1 ] ); 33 10720 : if( FD_UNLIKELY( hi<0 || lo<0 ) ) { 34 0 : ref = 0; 35 0 : break; 36 0 : } 37 10720 : ref <<= 8; 38 10720 : ref |= (uint)( (hi<<4) | lo ); 39 10720 : } 40 2680 : fd_commit_ref_u32 = ref; 41 2680 : } 42 : 43 : __attribute__((weak)) void 44 : fd_version_private_boot( int * pargc, 45 2680 : char *** pargv ) { 46 2680 : (void)pargc; (void)pargv; 47 2680 : static char ver_cstr[ 512 ]; 48 : fd_cstr_printf( ver_cstr, sizeof(ver_cstr), NULL, "%lu.%lu.%lu", 49 2680 : fd_major_version, fd_minor_version, fd_patch_version ); 50 2680 : fd_version_cstr = ver_cstr; 51 2680 : fd_version_private_commit_ref_init(); 52 2680 : }