diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 1ab20a2ee8da89fbe648a039aea4a0bce45af550..30e7733f93523460838058541cadea64972e87c5 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1,5 +1,5 @@ /* - * (C) 2022 copyright VoiceAge Corporation. All Rights Reserved. + * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved. * * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file @@ -18,6 +18,7 @@ #include #include #include +#include #ifndef _MSC_VER #include @@ -31,22 +32,26 @@ #define WMC_TOOL_SKIP /* Skip the instrumentation of this file, if invoked by accident */ -#ifdef WMOPS +#ifndef WMOPS +int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */ +#endif +#ifdef WMOPS /*-------------------------------------------------------------------* * Complexity counting tool *--------------------------------------------------------------------*/ -#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ -#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */ +#define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ +#define MAX_PARAMS_LENGTH 200 /* Maximum length of the function parameter string */ #define MAX_NUM_RECORDS 300 /* Initial maximum number of records -> might be increased during runtime, if needed */ #define MAX_NUM_RECORDS_REALLOC_STEP 50 /* When re-allocating the list of records, increase the number of records by this number */ #define MAX_CALL_TREE_DEPTH 100 /* maximum depth of the function call tree */ #define DOUBLE_MAX 0x80000000 +#define FRAMES_PER_SECOND 50.0 #define FAC ( FRAMES_PER_SECOND / 1e6 ) +#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ - -typedef struct +typedef struct { char label[MAX_FUNCTION_NAME_LENGTH]; long call_number; @@ -58,7 +63,7 @@ typedef struct double max_selfcnt; double min_selfcnt; double tot_selfcnt; - double start_cnt; + double start_cnt; /* The following take into account the decendants */ double current_cnt; double max_cnt; double min_cnt; @@ -72,7 +77,6 @@ typedef struct } wmops_record; double ops_cnt; -double prom_cnt; double inst_cnt[NUM_INST]; static wmops_record *wmops = NULL; @@ -87,10 +91,73 @@ static long fnum_cnt_wc; static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_caller_stack_index = 0; static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0; +static BASIC_OP op_weight = { + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 2, 2, 1, + 1, 1, 1, 2, 1, + + 1, 1, 1, 2, 1, + 1, 1, 18, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + 2, 2, 2, 2, 1, + + 1, 1, 1, 1, 1, + 1, 1, 1, 2, + 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 3, + 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, + 1, 1, 1, 3, 2, + 2, 6, 3, 3, 2, + + 1, 32, 1 + +/* New complex basops */ +#ifdef COMPLEX_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1 + + , + 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1 + +#endif /* #ifdef COMPLEX_OPERATOR */ + +#ifdef ENH_64_BIT_OPERATOR + /* Weights of new 64 bit basops */ + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + , + 1, 1, 1, 2, 2, 1, 1 +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + , + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +#endif /* #ifdef CONTROL_CODE_OPS */ +}; + +BASIC_OP *multiCounter = NULL; +unsigned int currCounter = 0; +long funcid_total_wmops_at_last_call_to_else; +char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; + void reset_wmops( void ) { int i, j; - unsigned int *ptr; num_wmops_records = 0; max_num_wmops_records = MAX_NUM_RECORDS; @@ -102,10 +169,10 @@ void reset_wmops( void ) start_cnt = 0.0; ops_cnt = 0.0; - /* allocate the list of wmops records */ + /* allocate the list of WMOPS records */ if ( wmops == NULL ) { - wmops = (wmops_record *)malloc( max_num_wmops_records * sizeof( wmops_record ) ); + wmops = (wmops_record *) malloc( max_num_wmops_records * sizeof( wmops_record ) ); } if ( wmops == NULL ) @@ -114,7 +181,7 @@ void reset_wmops( void ) exit( -1 ); } - /* allocate the BASOP WMOPS counter */ + /* allocate the list of BASOP WMOPS records */ if ( multiCounter == NULL ) { multiCounter = (BASIC_OP *) malloc( max_num_wmops_records * sizeof( BASIC_OP ) ); @@ -127,7 +194,7 @@ void reset_wmops( void ) } /* initilize the list of WMOPS records */ - /* initilize the BASOP WMOPS counters */ + /* initilize BASOP operation counters */ for ( i = 0; i < max_num_wmops_records; i++ ) { strcpy( &wmops[i].label[0], "\0" ); @@ -154,13 +221,8 @@ void reset_wmops( void ) wmops[i].wc_call_number = -1; #endif - /* clear all BASOP operation counters */ - ptr = (unsigned int*) &multiCounter[i]; - for ( j = 0; j < (int) ( sizeof(BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - { - *ptr++ = 0; - } - wmops[i].LastWOper = 0; + /* Reset BASOP operation counter */ + Reset_BASOP_WMOPS_counter( i ); } /* allocate the list of wmops callers to track the sequence of function calls */ @@ -182,10 +244,6 @@ void reset_wmops( void ) wmops_caller_stack[i] = -1; } - /* initialize auxiliary BASOP WMOPS variables */ - call_occurred = 1; - funcId_where_last_call_to_else_occurred = INT_MAX; - return; } @@ -193,7 +251,7 @@ void push_wmops_fct( const char *label, ... ) { int new_flag; int i, j, index_record; - unsigned int *ptr; + long tot; va_list arg; char func_name[MAX_FUNCTION_NAME_LENGTH] = ""; @@ -218,7 +276,7 @@ void push_wmops_fct( const char *label, ... ) } index_record = i; - /* Create a new record in the list */ + /* Create a new WMOPS record in the list */ if ( new_flag ) { if ( num_wmops_records >= max_num_wmops_records ) @@ -227,51 +285,42 @@ void push_wmops_fct( const char *label, ... ) max_num_wmops_records += MAX_NUM_RECORDS_REALLOC_STEP; wmops = realloc( wmops, max_num_wmops_records * sizeof( wmops_record ) ); multiCounter = realloc( multiCounter, max_num_wmops_records * sizeof( BASIC_OP ) ); + } - /* initilize newly created WMOPS records */ - for ( i = num_wmops_records; i < max_num_wmops_records; i++ ) - { - strcpy( &wmops[i].label[0], "\0" ); - wmops[i].call_number = 0; - wmops[i].update_cnt = 0; - for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) - { - wmops[i].call_tree[j] = -1; - } - wmops[i].start_selfcnt = 0.0; - wmops[i].current_selfcnt = 0.0; - wmops[i].max_selfcnt = 0.0; - wmops[i].min_selfcnt = DOUBLE_MAX; - wmops[i].tot_selfcnt = 0.0; - wmops[i].start_cnt = 0.0; - wmops[i].current_cnt = 0.0; - wmops[i].max_cnt = 0.0; - wmops[i].min_cnt = DOUBLE_MAX; - wmops[i].tot_cnt = 0.0; + /* initilize the new WMOPS record */ + strcpy( &wmops[index_record].label[0], "\0" ); + wmops[index_record].call_number = 0; + wmops[index_record].update_cnt = 0; + for ( j = 0; j < MAX_CALL_TREE_DEPTH; j++ ) + { + wmops[index_record].call_tree[j] = -1; + } + wmops[index_record].start_selfcnt = 0.0; + wmops[index_record].current_selfcnt = 0.0; + wmops[index_record].max_selfcnt = 0.0; + wmops[index_record].min_selfcnt = DOUBLE_MAX; + wmops[index_record].tot_selfcnt = 0.0; + wmops[index_record].start_cnt = 0.0; + wmops[index_record].current_cnt = 0.0; + wmops[index_record].max_cnt = 0.0; + wmops[index_record].min_cnt = DOUBLE_MAX; + wmops[index_record].tot_cnt = 0.0; #ifdef WMOPS_WC_FRAME_ANALYSIS - wmops[i].wc_cnt = 0.0; - wmops[i].wc_selfcnt = 0.0; - wmops[i].current_call_number = 0; - wmops[i].wc_call_number = -1; + wmops[index_record].wc_cnt = 0.0; + wmops[index_record].wc_selfcnt = 0.0; + wmops[index_record].current_call_number = 0; + wmops[index_record].wc_call_number = -1; #endif - /* initialize BASOP WMOPS counters */ - ptr = (unsigned int *) &multiCounter[i]; - for ( j = 0; j < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); j++ ) - { - *ptr++ = 0; - } - wmops[i].LastWOper = 0; - } - - } + /* Reset BASOP operation counter */ + Reset_BASOP_WMOPS_counter( index_record ); strcpy( wmops[index_record].label, func_name ); num_wmops_records++; } - /* Push the current context info to the new record */ + /* Update the WMOPS context info of the old record before switching to the new one */ if ( current_record >= 0 ) { if ( wmops_caller_stack_index >= max_wmops_caller_stack_index ) @@ -282,7 +331,9 @@ void push_wmops_fct( const char *label, ... ) } wmops_caller_stack[wmops_caller_stack_index++] = current_record; - /* accumulate op counts */ + /* add the BASOP complexity to the counter and update the old WMOPS counter */ + tot = DeltaWeightedOperation( current_record ); + ops_cnt += tot; wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt; /* update call tree */ @@ -300,7 +351,14 @@ void push_wmops_fct( const char *label, ... ) } } - /* update the current context info */ + /* Need to reset the BASOP operation counter of the 0th record in every push_wmops() */ + /* because currCounter can never be -1 */ + if ( current_record == -1 && index_record == 0 ) + { + wmops[index_record].LastWOper = TotalWeightedOperation( index_record ); + } + + /* switch to the new record */ current_record = index_record; wmops[index_record].start_selfcnt = ops_cnt; wmops[index_record].start_cnt = ops_cnt; @@ -309,13 +367,12 @@ void push_wmops_fct( const char *label, ... ) wmops[index_record].current_call_number++; #endif - /* set the ID of BASOP functions counters */ - Set_BASOP_WMOPS_counter( index_record ); + /* set the ID of the current BASOP operations counter */ + currCounter = index_record; return; } - void pop_wmops( void ) { long tot; @@ -328,10 +385,10 @@ void pop_wmops( void ) } /* add the BASOP complexity to the counter */ - tot = DeltaWeightedOperation(); + tot = DeltaWeightedOperation( currCounter ); ops_cnt += tot; - /* update count of current record */ + /* update count of current record */ wmops[current_record].current_selfcnt += ops_cnt - wmops[current_record].start_selfcnt; wmops[current_record].current_cnt += ops_cnt - wmops[current_record].start_cnt; @@ -340,15 +397,21 @@ void pop_wmops( void ) { current_record = wmops_caller_stack[--wmops_caller_stack_index]; wmops[current_record].start_selfcnt = ops_cnt; - - /* set the ID of the previous BASOP counter */ - Set_BASOP_WMOPS_counter( current_record ); } else { current_record = -1; } + /* set the ID of the previous BASOP operations counter */ + if ( current_record == -1 ) + { + currCounter = 0; /* Note: currCounter cannot be set to -1 because it's defined as unsigned int ! */ + } + else + { + currCounter = current_record; + } return; } @@ -441,9 +504,8 @@ void update_wmops( void ) wmops[i].current_call_number = 0; #endif - /* update the WC of all BASOP counters */ - Set_BASOP_WMOPS_counter( i ); - Reset_BASOP_WMOPS_counter(); + /* reset the BASOP operations counter */ + Reset_BASOP_WMOPS_counter( i ); } current_cnt = ops_cnt - start_cnt; @@ -477,15 +539,14 @@ void update_wmops( void ) return; } - void print_wmops( void ) { int i, label_len, max_label_len; char *sfmts = "%*s %8s %8s %7s %7s\n"; char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n"; - char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n"; - char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; + char *sfmt = "%*s %8s %8s %7s %7s %7s %7s %7s\n"; + char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f %7.3f %7.3f %7.3f\n"; #ifdef WMOPS_WC_FRAME_ANALYSIS int j; @@ -506,7 +567,7 @@ void print_wmops( void ) max_label_len += 4; fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] --- \n\n" ); - + fprintf( stdout, "%*s %33s %23s\n", max_label_len, "", "|------ SELF ------|", "|--- CUMULATIVE ---|" ); fprintf( stdout, sfmt, max_label_len, " routine", " calls", " min ", " max ", " avg ", " min ", " max ", " avg " ); fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" ); @@ -528,7 +589,7 @@ void print_wmops( void ) #ifdef WMOPS_WC_FRAME_ANALYSIS fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); - fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" ); + fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, " routine", " calls", " SELF", " CUMULATIVE" ); fprintf( stdout, "%*s %8s %10s %10s\n", max_label_len, "---------------", "------", "------", "----------" ); for ( i = 0; i < num_wmops_records; i++ ) @@ -562,7 +623,7 @@ void print_wmops( void ) fprintf( stdout, "\n\n" ); - fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); + fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc ); for ( i = 0; i < NUM_INST; i++ ) { switch ( (enum instructions) i ) @@ -654,7 +715,6 @@ void print_wmops( void ) return; } - /*-------------------------------------------------------------------* * Memory counting tool measuring RAM usage (stack and heap) * @@ -677,6 +737,7 @@ void print_wmops( void ) * #define WMC_TOOL_SKIP ... #undef WMC_TOOL_SKIP macro pair around the malloc(), calloc() and free(). *--------------------------------------------------------------------*/ + /* This is the value (in bytes) towards which the block size is rounded. For example, a block of 123 bytes, when using a 32 bits system, will end up taking 124 bytes since the last unused byte cannot be used for another block. */ #ifdef MEM_ALIGN_64BITS @@ -686,12 +747,14 @@ void print_wmops( void ) #endif #define N_32BITS_BLOCKS ( BLOCK_ROUNDING / sizeof( int32_t ) ) -#define ROUND_BLOCK_SIZE( n ) ( ( ( n ) + BLOCK_ROUNDING - 1 ) & ~( BLOCK_ROUNDING - 1 ) ) #define MAGIC_VALUE_OOB 0x12A534F0 /* Signature value which is inserted before and after each allocated memory block, used to detect out-of-bound access */ #define MAGIC_VALUE_USED ( ~MAGIC_VALUE_OOB ) /* Value used to pre-fill allocated memory blocks, used to calculate actual memory usage */ -#define OOB_START 0x1 /* Flag indicating out-of-bounds access before memory block */ -#define OOB_END 0x2 /* Flag indicating out-of-bounds access after memory block */ +#define OOB_START 0x1 /* int indicating out-of-bounds access before memory block */ +#define OOB_END 0x2 /* int indicating out-of-bounds access after memory block */ + +#define ROUND_BLOCK_SIZE( n ) ( ( ( n ) + BLOCK_ROUNDING - 1 ) & ~( BLOCK_ROUNDING - 1 ) ) +#define IS_CALLOC( str ) ( str[0] == 'c' ) #ifdef MEM_COUNT_DETAILS const char *csv_filename = "mem_analysis.csv"; @@ -704,7 +767,7 @@ typedef struct int16_t *stack_ptr; } caller_info; -static caller_info *stack_callers[2] = {NULL, NULL}; +static caller_info *stack_callers[2] = { NULL, NULL }; static int16_t *ptr_base_stack = 0; /* Pointer to the bottom of stack (base pointer). Stack grows up. */ static int16_t *ptr_current_stack = 0; /* Pointer to the current stack pointer */ @@ -713,7 +776,6 @@ static int32_t wc_stack_frame = 0; /* Frame corresponding to the worst-case static int current_calls = 0, max_num_calls = MAX_NUM_RECORDS; static char location_max_stack[256] = "undefined"; -/* Heap-related variables */ typedef struct { char name[MAX_FUNCTION_NAME_LENGTH + 1]; /* +1 for NUL */ @@ -939,7 +1001,7 @@ int push_stack( const char *filename, const char *fctname ) /* save the worst-case frame number */ /* current frame number is stored in the variable update_cnt and updated in the function update_wmops() */ - wc_stack_frame = update_cnt; + wc_stack_frame = update_cnt; strncpy( location_max_stack, fctname, sizeof( location_max_stack ) - 1 ); location_max_stack[sizeof( location_max_stack ) - 1] = '\0'; @@ -954,7 +1016,7 @@ int push_stack( const char *filename, const char *fctname ) } /* Check, if This is the New Worst-Case RAM (stack + heap) */ - current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size < 0 ) { @@ -1162,7 +1224,7 @@ void *mem_alloc( current_heap_size += ptr_record->block_size; /* Check, if this is the new Worst-Case RAM (stack + heap) */ - current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size + current_heap_size > wc_ram_size ) { wc_ram_size = current_stack_size + current_heap_size; @@ -2114,108 +2176,339 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) #endif /* WMOPS */ -#ifndef WMOPS -int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_wmops() pairs when WMOPS is not activated */ +#ifdef CONTROL_CODE_OPS + +int LT_16( short var1, short var2 ) +{ + int F_ret = 0; + + if ( var1 < var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_16++; #endif + return F_ret; +} +int GT_16( short var1, short var2 ) +{ + int F_ret = 0; + + if ( var1 > var2 ) + { + F_ret = 1; + } #ifdef WMOPS -/* Global counter for the calculation of BASOP complexity */ -BASIC_OP *multiCounter = NULL; -int currCounter = 0; -int funcId_where_last_call_to_else_occurred; -long funcid_total_wmops_at_last_call_to_else; -int call_occurred = 1; + multiCounter[currCounter].GT_16++; +#endif + return F_ret; +} -BASIC_OP op_weight = { - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, - 1, 1, 2, 2, 1, - 1, 1, 1, 3, 1, +int LE_16( short var1, short var2 ) +{ + int F_ret = 0; - 1, 1, 1, 3, 1, - 4, 1, 18, 1, 1, - 2, 1, 2, 2, 1, - 1, 1, 1, 1, 1, - 3, 3, 3, 3, 1, + if ( var1 <= var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_16++; +#endif + return F_ret; +} - 1, 1, 1, 1, 1, - 1, 1, 1, 2, - 1, 2, 2, 4, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, +int GE_16( short var1, short var2 ) +{ + int F_ret = 0; - 1, 1, 1, 1, 3, - 3, 3, 3, 3, 1, - 1, 1, 1, 1, 1, - 1, 1, 1, 4, 4, - 4, 8, 3, 4, 4, + if ( var1 >= var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_16++; +#endif + return F_ret; +} - 5, 32, 3 -}; +int EQ_16( short var1, short var2 ) +{ + int F_ret = 0; -/* Set the counter group to use, default is zero */ -void Set_BASOP_WMOPS_counter( int counterId ) + if ( var1 == var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_16++; +#endif + return F_ret; +} + +int NE_16( short var1, short var2 ) { - if ( ( counterId > num_wmops_records ) || ( counterId < 0 ) ) + int F_ret = 0; + + if ( var1 != var2 ) { - currCounter = 0; - return; + F_ret = 1; } - currCounter = counterId; - call_occurred = 1; +#ifdef WMOPS + multiCounter[currCounter].NE_16++; +#endif + return F_ret; +} + +int LT_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 < L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_32++; +#endif + return F_ret; +} + +int GT_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 > L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GT_32++; +#endif + return F_ret; +} + +int LE_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 <= L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_32++; +#endif + return F_ret; +} + +int GE_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 >= L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_32++; +#endif + return F_ret; +} + +int EQ_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 == L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_32++; +#endif + return F_ret; +} + +int NE_32( int L_var1, int L_var2 ) +{ + int F_ret = 0; + + if ( L_var1 != L_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].NE_32++; +#endif + return F_ret; +} + +int LT_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; + + if ( L64_var1 < L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LT_64++; +#endif + return F_ret; +} + +int GT_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; + + if ( L64_var1 > L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GT_64++; +#endif + return F_ret; +} + +int LE_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; + + if ( L64_var1 <= L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].LE_64++; +#endif + return F_ret; } +int GE_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; -extern int32_t frame; + if ( L64_var1 >= L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].GE_64++; +#endif + return F_ret; +} -long TotalWeightedOperation() +int EQ_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; + + if ( L64_var1 == L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].EQ_64++; +#endif + return F_ret; +} +int NE_64( long long int L64_var1, long long int L64_var2 ) +{ + int F_ret = 0; + + if ( L64_var1 != L64_var2 ) + { + F_ret = 1; + } +#ifdef WMOPS + multiCounter[currCounter].NE_64++; +#endif + return F_ret; +} + +#endif /* #ifdef CONTROL_CODE_OPS */ + +#ifdef WMOPS + +void incrIf( const char *func_name ) +{ + /* Technical note: If the "IF" operator comes just after an "ELSE", its counter must not be incremented */ + /* The following auxiliary variables are used to check if the "IF" operator doesn't immediately follow an "ELSE" operator */ + if ( ( strncmp( func_name, func_name_where_last_call_to_else_occurred, MAX_FUNCTION_NAME_LENGTH ) != 0 ) || ( TotalWeightedOperation( currCounter ) != funcid_total_wmops_at_last_call_to_else ) ) + { + + multiCounter[currCounter].If++; + } + + func_name_where_last_call_to_else_occurred[0] = '\0'; +} + +void incrElse( const char *func_name ) +{ + multiCounter[currCounter].If++; + + /* Save the BASOP comeplxity in the last call of the ELSE() statement */ + funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); + + /* We keep track of the name of the last calling function when the ELSE macro was called */ + strncpy( func_name_where_last_call_to_else_occurred, func_name, MAX_FUNCTION_NAME_LENGTH ); + func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH] = '\0'; +} + +long TotalWeightedOperation( unsigned int CounterId ) { int i; unsigned int *ptr, *ptr2; - long tot; + long tot; tot = 0; - ptr = (unsigned int *) &multiCounter[currCounter]; + ptr = (unsigned int *) &multiCounter[CounterId]; ptr2 = (unsigned int *) &op_weight; - for ( i = 0; i < ( int )( sizeof( multiCounter[currCounter] ) / sizeof( unsigned int ) ); i++ ) + for ( i = 0; i < (int) ( sizeof( multiCounter[CounterId] ) / sizeof( unsigned int ) ); i++ ) { + if ( *ptr == UINT_MAX ) + { + printf( "\nError in BASOP complexity counters: multiCounter[%d][%d] = %d !!!\n", CounterId, i, *ptr ); + exit( -1 ); + } + tot += ( ( *ptr++ ) * ( *ptr2++ ) ); } return ( tot ); } -long DeltaWeightedOperation( void ) +long DeltaWeightedOperation( unsigned int CounterId ) { long NewWOper, delta; - NewWOper = TotalWeightedOperation(); + NewWOper = TotalWeightedOperation( CounterId ); - delta = NewWOper - wmops[currCounter].LastWOper; - wmops[currCounter].LastWOper = NewWOper; + delta = NewWOper - wmops[CounterId].LastWOper; + wmops[CounterId].LastWOper = NewWOper; return ( delta ); } -/* Resets the current BASOP WMOPS counter */ -void Reset_BASOP_WMOPS_counter( void ) +/* Resets BASOP operation counter */ +void Reset_BASOP_WMOPS_counter( unsigned int counterId ) { int i; - long *ptr; + unsigned int *ptr; - /* clear the current BASOP operation counter before new frame begins */ - ptr = (long *) &multiCounter[currCounter]; - for ( i = 0; i < (int) ( sizeof( multiCounter[currCounter] ) / sizeof( long ) ); i++ ) + /* reset the current BASOP operation counter */ + ptr = (unsigned int *) &multiCounter[counterId]; + for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ ) { *ptr++ = 0; } - wmops[currCounter].LastWOper = 0; + wmops[counterId].LastWOper = 0; return; } #endif - - diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 42110465e0cf675cf631dddb44010074631f85b2..2ca5f6f9a99bf66d5f09512b23249b66a7d5adbd 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -1,5 +1,5 @@ /* - * (C) 2023 copyright VoiceAge Corporation. All Rights Reserved. + * (C) 2024 copyright VoiceAge Corporation. All Rights Reserved. * * This software is protected by copyright law and by international treaties. The source code, and all of its derivations, * is provided by VoiceAge Corporation under the "ITU-T Software Tools' General Public License". Please, read the license file @@ -23,18 +23,19 @@ #include /* stdio is needed for fprintf() */ #endif +#include "options.h" /* To Prevent "warning: '$' in identifier or number" message under GCC */ #ifdef __GNUC__ #pragma GCC system_header #endif -#ifndef INT_MAX -#define INT_MAX 32767 -#endif - -#define FRAMES_PER_SECOND 50.0 -#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ +#define ENH_32_BIT_OPERATOR +#define ENH_64_BIT_OPERATOR +#define ENH_U_32_BIT_OPERATOR +#define COMPLEX_OPERATOR +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ +/* #define WMOPS_DISABLE_FCN_CALL_PENALIZATION*/ /* do not count the complexity of function calls */ #ifdef WMOPS enum instructions @@ -62,6 +63,30 @@ enum instructions NUM_INST }; +extern double ops_cnt; +extern double inst_cnt[NUM_INST]; + +/******************************************************************/ +/* NOTES: */ +/* The 'wmc_flag_' flag is global to avoid declaration in every */ +/* function and 'static' to avoid clashing with other modules */ +/* that include this header file. */ +/* */ +/* The declarations of 'wmc_flag_' and 'wops_' in this header */ +/* file prevent the addition of a 'C' file to the Project. */ +/******************************************************************/ + +/* General Purpose Global int */ +static int wmc_flag_ = 0; + +#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL ) +void push_wmops_fct( const char *label, ... ); +void pop_wmops( void ); +void reset_wmops( void ); +void print_wmops( void ); +void update_wmops( void ); +void update_mem( void ); + #define _ADD_C 1 #define _ABS_C 1 #define _MULT_C 1 @@ -83,502 +108,167 @@ enum instructions #define _LOG_C 25 #define _MISC_C 1 -#define _ADD_P 1 -#define _ABS_P 1 -#define _MULT_P 1 -#define _MAC_P 1 -#define _MOVE_P 1 -#define _STORE_P 0 -#define _LOGIC_P 1 -#define _SHIFT_P 1 -#define _BRANCH_P 2 -#define _DIV_P 2 -#define _SQRT_P 2 -#define _TRANS_P 2 -#define _FUNC_P 2 /* need to add number of arguments */ -#define _LOOP_P 1 -#define _INDIRECT_P 2 -#define _PTR_INIT_P 1 -#define _TEST_P 1 -#define _POWER_P 2 -#define _LOG_P 2 -#define _MISC_P 1 - -#define ADD( x ) \ - { \ - { \ - ops_cnt += ( _ADD_C * ( x ) ); \ - inst_cnt[_ADD] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _ADD_P * ( x ) ); \ - } \ - } \ - } \ +#define ADD( x ) \ + { \ + ops_cnt += ( _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ } -#define ABS( x ) \ - { \ - { \ - ops_cnt += ( _ABS_C * ( x ) ); \ - inst_cnt[_ABS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _ABS_P * ( x ) ); \ - } \ - } \ - } \ +#define ABS( x ) \ + { \ + ops_cnt += ( _ABS_C * ( x ) ); \ + inst_cnt[_ABS] += ( x ); \ } -#define MULT( x ) \ - { \ - { \ - ops_cnt += ( _MULT_C * ( x ) ); \ - inst_cnt[_MULT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MULT_P * ( x ) ); \ - } \ - } \ - } \ +#define MULT( x ) \ + { \ + ops_cnt += ( _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ } -#define MAC( x ) \ - { \ - { \ - ops_cnt += ( _MAC_C * ( x ) ); \ - inst_cnt[_MAC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MAC_P * ( x ) ); \ - } \ - } \ - } \ +#define MAC( x ) \ + { \ + ops_cnt += ( _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ } -#define MOVE( x ) \ - { \ - { \ - ops_cnt += ( _MOVE_C * ( x ) ); \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define MOVE( x ) \ + { \ + ops_cnt += ( _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ } -#define STORE( x ) \ - { \ - { \ - ops_cnt += ( _STORE_C * ( x ) ); \ - inst_cnt[_STORE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _STORE_P * ( x ) ); \ - } \ - } \ - } \ +#define STORE( x ) \ + { \ + ops_cnt += ( _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ } -#define LOGIC( x ) \ - { \ - { \ - ops_cnt += ( _LOGIC_C * ( x ) ); \ - inst_cnt[_LOGIC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _LOGIC_P * ( x ) ); \ - } \ - } \ - } \ +#define LOGIC( x ) \ + { \ + ops_cnt += ( _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ } -#define SHIFT( x ) \ - { \ - { \ - ops_cnt += ( _SHIFT_C * ( x ) ); \ - inst_cnt[_SHIFT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _SHIFT_P * ( x ) ); \ - } \ - } \ - } \ +#define SHIFT( x ) \ + { \ + ops_cnt += ( _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ } -#define BRANCH( x ) \ - { \ - { \ - ops_cnt += ( _BRANCH_C * ( x ) ); \ - inst_cnt[_BRANCH] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _BRANCH_P * ( x ) ); \ - } \ - } \ - } \ +#define BRANCH( x ) \ + { \ + ops_cnt += ( _BRANCH_C * ( x ) ); \ + inst_cnt[_BRANCH] += ( x ); \ } -#define DIV( x ) \ - { \ - { \ - ops_cnt += ( _DIV_C * ( x ) ); \ - inst_cnt[_DIV] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _DIV_P * ( x ) ); \ - } \ - } \ - } \ +#define DIV( x ) \ + { \ + ops_cnt += ( _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ } -#define SQRT( x ) \ - { \ - { \ - ops_cnt += ( _SQRT_C * ( x ) ); \ - inst_cnt[_SQRT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _SQRT_P * ( x ) ); \ - } \ - } \ - } \ +#define SQRT( x ) \ + { \ + ops_cnt += ( _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ } -#define TRANS( x ) \ - { \ - { \ - ops_cnt += ( _TRANS_C * ( x ) ); \ - inst_cnt[_TRANS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _TRANS_P * ( x ) ); \ - } \ - } \ - } \ +#define TRANS( x ) \ + { \ + ops_cnt += ( _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ } -#define LOOP( x ) \ - { \ - { \ - ops_cnt += ( _LOOP_C * ( x ) ); \ - inst_cnt[_LOOP] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _LOOP_P * ( x ) ); \ - } \ - } \ - } \ +#define LOOP( x ) \ + { \ + ops_cnt += ( _LOOP_C * ( x ) ); \ + inst_cnt[_LOOP] += ( x ); \ } -#define INDIRECT( x ) \ - { \ - { \ - ops_cnt += ( _INDIRECT_C * ( x ) ); \ - inst_cnt[_INDIRECT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _INDIRECT_P * ( x ) ); \ - } \ - } \ - } \ +#define INDIRECT( x ) \ + { \ + ops_cnt += ( _INDIRECT_C * ( x ) ); \ + inst_cnt[_INDIRECT] += ( x ); \ } -#define PTR_INIT( x ) \ - { \ - { \ - ops_cnt += ( _PTR_INIT_C * ( x ) ); \ - inst_cnt[_PTR_INIT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _PTR_INIT_P * ( x ) ); \ - } \ - } \ - } \ +#define PTR_INIT( x ) \ + { \ + ops_cnt += ( _PTR_INIT_C * ( x ) ); \ + inst_cnt[_PTR_INIT] += ( x ); \ } -#define TEST( x ) \ - { \ - { \ - ops_cnt += ( _TEST_C * ( x ) ); \ - inst_cnt[_TEST] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _TEST_P * ( x ) ); \ - } \ - } \ - } \ +#define TEST( x ) \ + { \ + ops_cnt += ( _TEST_C * ( x ) ); \ + inst_cnt[_TEST] += ( x ); \ } -#define POWER( x ) \ - { \ - { \ - ops_cnt += ( _POWER_C * ( x ) ); \ - inst_cnt[_POWER] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _POWER_P * ( x ) ); \ - } \ - } \ - } \ +#define POWER( x ) \ + { \ + ops_cnt += ( _POWER_C * ( x ) ); \ + inst_cnt[_POWER] += ( x ); \ } -#define LOG( x ) \ - { \ - { \ - ops_cnt += ( _LOG_C * ( x ) ); \ - inst_cnt[_LOG] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _LOG_P * ( x ) ); \ - } \ - } \ - } \ +#define LOG( x ) \ + { \ + ops_cnt += ( _LOG_C * ( x ) ); \ + inst_cnt[_LOG] += ( x ); \ } -#define MISC( x ) \ - { \ - { \ - ops_cnt += ( _MISC_C * ( x ) ); \ - inst_cnt[_MISC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MISC_P * ( x ) ); \ - } \ - } \ - } \ +#define MISC( x ) \ + { \ + ops_cnt += ( _MISC_C * ( x ) ); \ + inst_cnt[_MISC] += ( x ); \ } - -#define FUNC( x ) \ - { \ - { \ - ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ - inst_cnt[_FUNC]++; \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _FUNC_P + _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define FUNC( x ) \ + { \ + ops_cnt += ( _FUNC_C + _MOVE_C * ( x ) ); \ + inst_cnt[_FUNC]++; \ + inst_cnt[_MOVE] += ( x ); \ } - -#define DADD( x ) \ - { \ - { \ - ops_cnt += ( 2 * _ADD_C * ( x ) ); \ - inst_cnt[_ADD] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _ADD_P * ( x ) ); \ - } \ - } \ - } \ +#define DADD( x ) \ + { \ + ops_cnt += ( 2 * _ADD_C * ( x ) ); \ + inst_cnt[_ADD] += ( x ); \ } -#define DMULT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MULT_C * ( x ) ); \ - inst_cnt[_MULT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MULT_P * ( x ) ); \ - } \ - } \ - } \ +#define DMULT( x ) \ + { \ + ops_cnt += ( 2 * _MULT_C * ( x ) ); \ + inst_cnt[_MULT] += ( x ); \ } -#define DMAC( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MAC_C * ( x ) ); \ - inst_cnt[_MAC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MAC_P * ( x ) ); \ - } \ - } \ - } \ +#define DMAC( x ) \ + { \ + ops_cnt += ( 2 * _MAC_C * ( x ) ); \ + inst_cnt[_MAC] += ( x ); \ } -#define DMOVE( x ) \ - { \ - { \ - ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ - inst_cnt[_MOVE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _MOVE_P * ( x ) ); \ - } \ - } \ - } \ +#define DMOVE( x ) \ + { \ + ops_cnt += ( 2 * _MOVE_C * ( x ) ); \ + inst_cnt[_MOVE] += ( x ); \ } -#define DSTORE( x ) \ - { \ - { \ - ops_cnt += ( 2 * _STORE_C * ( x ) ); \ - inst_cnt[_STORE] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _STORE_P * ( x ) ); \ - } \ - } \ - } \ +#define DSTORE( x ) \ + { \ + ops_cnt += ( 2 * _STORE_C * ( x ) ); \ + inst_cnt[_STORE] += ( x ); \ } -#define DLOGIC( x ) \ - { \ - { \ - ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ - inst_cnt[_LOGIC] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _LOGIC_P * ( x ) ); \ - } \ - } \ - } \ +#define DLOGIC( x ) \ + { \ + ops_cnt += ( 2 * _LOGIC_C * ( x ) ); \ + inst_cnt[_LOGIC] += ( x ); \ } -#define DSHIFT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ - inst_cnt[_SHIFT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _SHIFT_P * ( x ) ); \ - } \ - } \ - } \ +#define DSHIFT( x ) \ + { \ + ops_cnt += ( 2 * _SHIFT_C * ( x ) ); \ + inst_cnt[_SHIFT] += ( x ); \ } -#define DDIV( x ) \ - { \ - { \ - ops_cnt += ( 2 * _DIV_C * ( x ) ); \ - inst_cnt[_DIV] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _DIV_P * ( x ) ); \ - } \ - } \ - } \ +#define DDIV( x ) \ + { \ + ops_cnt += ( 2 * _DIV_C * ( x ) ); \ + inst_cnt[_DIV] += ( x ); \ } -#define DSQRT( x ) \ - { \ - { \ - ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ - inst_cnt[_SQRT] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _SQRT_P * ( x ) ); \ - } \ - } \ - } \ +#define DSQRT( x ) \ + { \ + ops_cnt += ( 2 * _SQRT_C * ( x ) ); \ + inst_cnt[_SQRT] += ( x ); \ } -#define DTRANS( x ) \ - { \ - { \ - ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ - inst_cnt[_TRANS] += ( x ); \ - { \ - static int pcnt; \ - if ( !pcnt ) \ - { \ - pcnt = 1; \ - prom_cnt += ( _TRANS_P * ( x ) ); \ - } \ - } \ - } \ +#define DTRANS( x ) \ + { \ + ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ + inst_cnt[_TRANS] += ( x ); \ } -extern double ops_cnt; -extern double prom_cnt; -extern double inst_cnt[NUM_INST]; - -void reset_wmops( void ); -#define push_wmops( ... ) push_wmops_fct( __VA_ARGS__, NULL ) -void push_wmops_fct( const char *label, ... ); -void pop_wmops( void ); -void update_wmops( void ); -void update_mem( void ); -void print_wmops( void ); - -#else /* WMOPS counting disabled */ +#else -#define reset_wmops() extern int cntr_push_pop; #define push_wmops( x ) ( cntr_push_pop++ ) #define pop_wmops() ( cntr_push_pop-- ) -#define update_wmops() ( assert( cntr_push_pop == 0 ) ) -#define update_mem() +#define reset_wmops() #define print_wmops() +#define update_wmops() ( assert( cntr_push_pop == 0 ) ) +#define update_mem() #define ADD( x ) #define ABS( x ) @@ -629,24 +319,8 @@ extern int cntr_push_pop; #else -/* '*ops_cnt_ptr' is Used to Avoid: "warning: operation on 'ops_cnt' may be undefined" with Cygwin gcc Compiler */ -static double *ops_cnt_ptr = &ops_cnt; -#define OP_COUNT_( op, x ) ( *ops_cnt_ptr += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) - -/******************************************************************/ -/* NOTES: */ -/* The 'wmc_flag_' flag is global to avoid declaration in every */ -/* function and 'static' to avoid clashing with other modules */ -/* that include this header file. */ -/* */ -/* The declarations of 'wmc_flag_' and 'wops_' in this header */ -/* file prevent the addition of a 'C' file to the Project. */ -/******************************************************************/ - -/* General Purpose Global Flag */ -static int wmc_flag_ = 0; - /* Operation Counter Wrappers */ +#define OP_COUNT_( op, x ) ( ops_cnt += ( op##_C * ( x ) ), inst_cnt[op] += ( x ) ) #define OP_COUNT_WRAPPER1_( op, val ) ( op, val ) #define OP_COUNT_WRAPPER2_( expr ) \ if ( expr, 0 ) \ @@ -678,8 +352,12 @@ static int wmc_flag_ = 0; #define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) #define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) #define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) -#define MISC_( x ) ABS_( x ) +#ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION +#define FUNC_( x ) ( x ) +#else +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#endif +#define MISC_( x ) ABS_( x ) /* Math Operations */ #define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) @@ -724,8 +402,8 @@ static int wmc_flag_ = 0; #define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf ) /* the macros below are instrumented versions of user-defined macros that might be used in the source code -/* representing some well-known and recognized mathematical operations (that are not defined in math.h) */ -/* Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ + representing some well-known and recognized mathematical operations (that are not defined in math.h) + Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ #define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) #define max_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), max( ( a ), ( b ) ) ) @@ -796,7 +474,6 @@ static int wmc_flag_ = 0; #define return_ \ OP_COUNT_WRAPPER2_( ( wmc_flag_ = stack_tree_level_, STACK_DEPTH_FCT_RETURN ) ) \ return - #define switch_ \ OP_COUNT_WRAPPER2_( ( BRANCH_( 1 ), wmc_flag_ = 1 ) ) \ switch @@ -912,7 +589,6 @@ st: /* This Shouldn't Happen */ /* These are Used to Avoid: "warning: 'name' defined but not used" with Cygwin gcc Compiler */ wmc_flag_ = wmc_flag_; - ops_cnt_ptr = ops_cnt_ptr; fct( "" ); error: default: @@ -974,7 +650,7 @@ typedef struct ROM_Size_Lookup_Table * ROM_Size_Lookup_Table Const_Data_PROM_Table[] = * { * {"../lib_enc/rom_enc.c", 0, NULL}, - * {"../lib_com/*.c", 0, NULL}, + * {"../lib_com/[star].c", 0, NULL}, * {"", -1, NULL} * }; * #endif @@ -987,22 +663,9 @@ typedef enum { USE_BYTES = 0, USE_16BITS = 1, - USE_32BITS = 2, - USE_64BITS = 3 + USE_32BITS = 2 } Counting_Size; -#if ( defined( _WIN32 ) && ( _MSC_VER <= 1800 ) && ( _MSC_VER >= 1300 ) ) -#define __func__ __FUNCTION__ -#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ < 199901L -#if ( __GNUC__ >= 2 ) -#define __func__ __FUNCTION__ -#else -#define __func__ "" -#endif -#elif defined( __GNUC__ ) -#define __func__ __extension__ __FUNCTION__ -#endif - #ifdef WMOPS @@ -1020,10 +683,10 @@ int push_stack( const char *filename, const char *fctname ); int pop_stack( const char *filename, const char *fctname ); #ifdef WMOPS_DETAIL -#define STACK_DEPTH_FCT_CALL ( push_wmops( __func__, "[WMC_AUTO]" ), push_stack( __FILE__, __func__ ) ) /* add push_wmops() in all function calls */ -#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __func__ ) ) /* add pop_wmops() in all function returns */ +#define STACK_DEPTH_FCT_CALL ( push_wmops( __func__, "[WMC_AUTO]" ), push_stack( __FILE__, __func__ ) ) /* add push_wmops() in all function calls */ +#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __func__ ) ) /* add pop_wmops() in all function returns */ #else -#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __FUNCTION__ ) +#define STACK_DEPTH_FCT_CALL push_stack( __FILE__, __func__ ) #define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __func__ ) #endif @@ -1044,7 +707,6 @@ void reset_stack( void ); #endif - /* Global counter variable for calculation of complexity weight */ typedef struct { @@ -1102,10 +764,10 @@ typedef struct unsigned int L40_max; /* Complexity Weight of 1 */ unsigned int L40_min; /* Complexity Weight of 1 */ - unsigned int shl_r; /* Complexity Weight of 3 */ - unsigned int L_shl_r; /* Complexity Weight of 3 */ - unsigned int L40_shr_r; /* Complexity Weight of 3 */ - unsigned int L40_shl_r; /* Complexity Weight of 3 */ + unsigned int shl_r; /* Complexity Weight of 2 */ + unsigned int L_shl_r; /* Complexity Weight of 2 */ + unsigned int L40_shr_r; /* Complexity Weight of 2 */ + unsigned int L40_shl_r; /* Complexity Weight of 2 */ unsigned int norm_L40; /* Complexity Weight of 1 */ unsigned int L40_shl; /* Complexity Weight of 1 */ @@ -1122,7 +784,7 @@ typedef struct unsigned int L40_msu; /* Complexity Weight of 1 */ unsigned int msu_r40; /* Complexity Weight of 2 */ unsigned int Mpy_32_16_ss; /* Complexity Weight of 2 */ - unsigned int Mpy_32_32_ss; /* Complexity Weight of 4 */ + unsigned int Mpy_32_32_ss; /* Complexity Weight of 2 */ unsigned int L_mult0; /* Complexity Weight of 1 */ unsigned int L_mac0; /* Complexity Weight of 1 */ @@ -1146,7 +808,7 @@ typedef struct unsigned int rotr; /* Complexity Weight of 3 */ unsigned int L_rotl; /* Complexity Weight of 3 */ unsigned int L_rotr; /* Complexity Weight of 3 */ - unsigned int L40_set; /* Complexity Weight of 3 */ + unsigned int L40_set; /* Complexity Weight of 1 */ unsigned int L40_deposit_h; /* Complexity Weight of 1 */ unsigned int L40_deposit_l; /* Complexity Weight of 1 */ @@ -1158,48 +820,158 @@ typedef struct unsigned int L40_round; /* Complexity Weight of 1 */ unsigned int L_saturate40; /* Complexity Weight of 1 */ unsigned int round40; /* Complexity Weight of 1 */ - unsigned int If; /* Complexity Weight of 4 */ - unsigned int Goto; /* Complexity Weight of 4 */ + unsigned int If; /* Complexity Weight of 3 */ + unsigned int Goto; /* Complexity Weight of 2 */ - unsigned int Break; /* Complexity Weight of 4 */ - unsigned int Switch; /* Complexity Weight of 8 */ + unsigned int Break; /* Complexity Weight of 2 */ + unsigned int Switch; /* Complexity Weight of 6 */ unsigned int For; /* Complexity Weight of 3 */ - unsigned int While; /* Complexity Weight of 4 */ - unsigned int Continue; /* Complexity Weight of 4 */ + unsigned int While; /* Complexity Weight of 3 */ + unsigned int Continue; /* Complexity Weight of 2 */ - unsigned int L_mls; /* Complexity Weight of 6 */ + unsigned int L_mls; /* Complexity Weight of 1 */ unsigned int div_l; /* Complexity Weight of 32 */ - unsigned int i_mult; /* Complexity Weight of 3 */ + unsigned int i_mult; /* Complexity Weight of 1 */ + +/* New complex basic operators */ +#ifdef COMPLEX_OPERATOR + unsigned int CL_shr; /* Complexity Weight of 1 */ + unsigned int CL_shl; /* Complexity Weight of 1 */ + unsigned int CL_add; /* Complexity Weight of 1 */ + unsigned int CL_sub; /* Complexity Weight of 1 */ + unsigned int CL_scale; /* Complexity Weight of 1 */ + unsigned int CL_dscale; /* Complexity Weight of 1 */ + unsigned int CL_msu_j; /* Complexity Weight of 1 */ + unsigned int CL_mac_j; /* Complexity Weight of 1 */ + unsigned int CL_move; /* Complexity Weight of 1 */ + unsigned int CL_Extract_real; /* Complexity Weight of 1 */ + unsigned int CL_Extract_imag; /* Complexity Weight of 1 */ + unsigned int CL_form; /* Complexity Weight of 1 */ + unsigned int CL_multr_32x16; /* Complexity Weight of 2 */ + unsigned int CL_negate; /* Complexity Weight of 1 */ + unsigned int CL_conjugate; /* Complexity Weight of 1 */ + unsigned int CL_mul_j; /* Complexity Weight of 1 */ + unsigned int CL_swap_real_imag; /* Complexity Weight of 1 */ + unsigned int C_add; /* Complexity Weight of 1 */ + unsigned int C_sub; /* Complexity Weight of 1 */ + unsigned int C_mul_j; /* Complexity Weight of 1 */ + unsigned int C_multr; /* Complexity Weight of 2 */ + unsigned int C_form; /* Complexity Weight of 1 */ + + unsigned int C_scale; /* Complexity Weight of 1 */ + unsigned int CL_round32_16; /* Complexity Weight of 1 */ + unsigned int CL_scale_32; /* Complexity Weight of 1 */ + unsigned int CL_dscale_32; /* Complexity Weight of 1 */ + unsigned int CL_multr_32x32; /* Complexity Weight of 2 */ + unsigned int C_mac_r; /* Complexity Weight of 2 */ + unsigned int C_msu_r; /* Complexity Weight of 2 */ + unsigned int C_Extract_real; /* Complexity Weight of 1 */ + unsigned int C_Extract_imag; /* Complexity Weight of 1 */ + unsigned int C_negate; /* Complexity Weight of 1 */ + unsigned int C_conjugate; /* Complexity Weight of 1 */ + unsigned int C_shr; /* Complexity Weight of 1 */ + unsigned int C_shl; /* Complexity Weight of 1 */ + +#endif /* #ifdef COMPLEX_OPERATOR */ + +/* New 64 bit basops */ +#ifdef ENH_64_BIT_OPERATOR + unsigned int move64; /* Complexity Weight of 1 */ + unsigned int W_add_nosat; /* Complexity Weight of 1 */ + unsigned int W_sub_nosat; /* Complexity Weight of 1 */ + unsigned int W_shl; /* Complexity Weight of 1 */ + unsigned int W_shr; /* Complexity Weight of 1 */ + unsigned int W_shl_nosat; /* Complexity Weight of 1 */ + unsigned int W_shr_nosat; /* Complexity Weight of 1 */ + unsigned int W_mac_32_16; /* Complexity Weight of 1 */ + unsigned int W_msu_32_16; /* Complexity Weight of 1 */ + unsigned int W_mult_32_16; /* Complexity Weight of 1 */ + unsigned int W_mult0_16_16; /* Complexity Weight of 1 */ + unsigned int W_mac0_16_16; /* Complexity Weight of 1 */ + unsigned int W_msu0_16_16; /* Complexity Weight of 1 */ + unsigned int W_mult_16_16; /* Complexity Weight of 1 */ + unsigned int W_mac_16_16; /* Complexity Weight of 1 */ + unsigned int W_msu_16_16; /* Complexity Weight of 1 */ + unsigned int W_shl_sat_l; /* Complexity Weight of 1 */ + unsigned int W_sat_l; /* Complexity Weight of 1 */ + unsigned int W_sat_m; /* Complexity Weight of 1 */ + unsigned int W_deposit32_l; /* Complexity Weight of 1 */ + unsigned int W_deposit32_h; /* Complexity Weight of 1 */ + unsigned int W_extract_l; /* Complexity Weight of 1 */ + unsigned int W_extract_h; /* Complexity Weight of 1 */ + unsigned int W_round48_L; /* Complexity Weight of 1 */ + unsigned int W_round32_s; /* Complexity Weight of 1 */ + unsigned int W_norm; /* Complexity Weight of 1 */ + + unsigned int W_add; /* Complexity Weight of 1 */ + unsigned int W_sub; /* Complexity Weight of 1 */ + unsigned int W_neg; /* Complexity Weight of 1 */ + unsigned int W_abs; /* Complexity Weight of 1 */ + unsigned int W_mult_32_32; /* Complexity Weight of 1 */ + unsigned int W_mult0_32_32; /* Complexity Weight of 1 */ + unsigned int W_lshl; /* Complexity Weight of 1 */ + unsigned int W_lshr; /* Complexity Weight of 1 */ + unsigned int W_round64_L; /* Complexity Weight of 1 */ + +#endif /* #ifdef ENH_64_BIT_OPERATOR */ + +#ifdef ENH_32_BIT_OPERATOR + unsigned int Mpy_32_16_1; /* Complexity Weight of 1 */ + unsigned int Mpy_32_16_r; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32_r; /* Complexity Weight of 1 */ + unsigned int Madd_32_16; /* Complexity Weight of 1 */ + unsigned int Madd_32_16_r; /* Complexity Weight of 1 */ + unsigned int Msub_32_16; /* Complexity Weight of 1 */ + unsigned int Msub_32_16_r; /* Complexity Weight of 1 */ + unsigned int Madd_32_32; /* Complexity Weight of 1 */ + unsigned int Madd_32_32_r; /* Complexity Weight of 1 */ + unsigned int Msub_32_32; /* Complexity Weight of 1 */ + unsigned int Msub_32_32_r; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ + +#ifdef ENH_U_32_BIT_OPERATOR + unsigned int UL_addNs; /* Complexity Weight of 1 */ + unsigned int UL_subNs; /* Complexity Weight of 1 */ + unsigned int UL_Mpy_32_32; /* Complexity Weight of 1 */ + unsigned int Mpy_32_32_uu; /* Complexity Weight of 2 */ + unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */ + unsigned int norm_ul_float; /* Complexity Weight of 1 */ + unsigned int UL_deposit_l; /* Complexity Weight of 1 */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ + +#ifdef CONTROL_CODE_OPS + unsigned int LT_16; /* Complexity Weight of 1 */ + unsigned int GT_16; /* Complexity Weight of 1 */ + unsigned int LE_16; /* Complexity Weight of 1 */ + unsigned int GE_16; /* Complexity Weight of 1 */ + unsigned int EQ_16; /* Complexity Weight of 1 */ + unsigned int NE_16; /* Complexity Weight of 1 */ + unsigned int LT_32; /* Complexity Weight of 1 */ + unsigned int GT_32; /* Complexity Weight of 1 */ + unsigned int LE_32; /* Complexity Weight of 1 */ + unsigned int GE_32; /* Complexity Weight of 1 */ + unsigned int EQ_32; /* Complexity Weight of 1 */ + unsigned int NE_32; /* Complexity Weight of 1 */ + unsigned int LT_64; /* Complexity Weight of 1 */ + unsigned int GT_64; /* Complexity Weight of 1 */ + unsigned int LE_64; /* Complexity Weight of 1 */ + unsigned int GE_64; /* Complexity Weight of 1 */ + unsigned int EQ_64; /* Complexity Weight of 1 */ + unsigned int NE_64; /* Complexity Weight of 1 */ + +#endif /* #ifdef CONTROL_CODE_OPS */ } BASIC_OP; #ifdef WMOPS extern BASIC_OP *multiCounter; -extern int currCounter; - -/* Technical note : - * The following 3 variables are only used for correct complexity - * evaluation of the following structure : - * IF{ - * ... - * } ELSE IF { - * ... - * } ELSE IF { - * ... - * } - * ... - * } ELSE { - * ... - * } - */ -extern int funcId_where_last_call_to_else_occurred; +extern unsigned int currCounter; extern long funcid_total_wmops_at_last_call_to_else; -extern int call_occurred; - -extern long TotalWeightedOperation( void ); -long DeltaWeightedOperation( void ); +extern char func_name_where_last_call_to_else_occurred[]; -void Set_BASOP_WMOPS_counter( int counterId ); -void Reset_BASOP_WMOPS_counter( void ); +long TotalWeightedOperation( unsigned int counterId ); +long DeltaWeightedOperation( unsigned int counterId ); +void Reset_BASOP_WMOPS_counter( unsigned int counterId ); #endif @@ -1217,15 +989,20 @@ void Reset_BASOP_WMOPS_counter( void ); * *****************************************************************************/ #ifndef WMOPS -#define FOR( a) for( a) +#define FOR( a ) for ( a ) -#else -#define FOR( a) if( incrFor(), 0); else for( a) +#else /* ifndef WMOPS */ +#define FOR( a ) \ + if ( incrFor(), 0 ) \ + ; \ + else \ + for ( a ) -static __inline void incrFor( void) { - multiCounter[currCounter].For++; +static __inline void incrFor( void ) +{ + multiCounter[currCounter].For++; } -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1242,15 +1019,16 @@ static __inline void incrFor( void) { * *****************************************************************************/ #ifndef WMOPS -#define WHILE( a) while( a) +#define WHILE( a ) while ( a ) -#else -#define WHILE( a) while( incrWhile(), a) +#else /* ifndef WMOPS */ +#define WHILE( a ) while ( incrWhile(), a ) -static __inline void incrWhile( void) { - multiCounter[currCounter].While++; +static __inline void incrWhile( void ) +{ + multiCounter[currCounter].While++; } -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1267,10 +1045,10 @@ static __inline void incrWhile( void) { #ifndef WMOPS #define DO do -#else +#else /* ifndef WMOPS */ #define DO do -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1290,29 +1068,16 @@ static __inline void incrWhile( void) { * - or when the 'if' conditions several DSP basic operations, * - or when the 'if' conditions a function call. * - * Complexity weight : 4 + * Complexity weight : 3 * *****************************************************************************/ -#ifndef WMOPS -#define IF( a) if( a) - -#else -#define IF( a) if( incrIf(), a) -static __inline void incrIf( void) { - /* Technical note : - * If the "IF" operator comes just after an "ELSE", its counter - * must not be incremented. - */ - if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) - { - multiCounter[currCounter].If++; - } - - call_occurred = 0; - funcId_where_last_call_to_else_occurred = INT_MAX; -} -#endif +#ifndef WMOPS +#define IF( a ) if ( a ) +#else /* ifndef WMOPS */ +#define IF( a ) if ( incrIf( __func__ ), a ) +void incrIf( const char *func_name ); +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1323,33 +1088,18 @@ static __inline void incrIf( void) { * * The macro ELSE should be used instead of the 'else' C statement. * - * Complexity weight : 4 + * Complexity weight : 3 * *****************************************************************************/ + #ifndef WMOPS #define ELSE else - -#else -#define ELSE else if( incrElse(), 0) ; else - -static __inline void incrElse( void) { - multiCounter[currCounter].If++; - - /* We keep track of the funcId of the last function - * which used ELSE {...} structure. - */ - funcId_where_last_call_to_else_occurred = currCounter; - - /* We keep track of the number of WMOPS of this funcId - * when the ELSE macro was called. - */ - funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation(); - - /* call_occurred is set to 0, in order to count the next IF (if necessary) - */ - call_occurred = 0; -} -#endif +#else /* ifndef WMOPS */ +#define ELSE \ + else if ( incrElse( __func__ ), 0 ); \ + else +void incrElse( const char *func_name ); +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1360,19 +1110,20 @@ static __inline void incrElse( void) { * * The macro SWITCH should be used instead of the 'switch' C statement. * - * Complexity weight : 8 + * Complexity weight : 6 * *****************************************************************************/ #ifndef WMOPS -#define SWITCH( a) switch( a) +#define SWITCH( a ) switch ( a ) -#else -#define SWITCH( a) switch( incrSwitch(), a) +#else /* ifndef WMOPS */ +#define SWITCH( a ) switch ( incrSwitch(), a ) -static __inline void incrSwitch( void) { - multiCounter[currCounter].Switch++; +static __inline void incrSwitch( void ) +{ + multiCounter[currCounter].Switch++; } -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1383,19 +1134,24 @@ static __inline void incrSwitch( void) { * * The macro CONTINUE should be used instead of the 'continue' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS #define CONTINUE continue -#else -#define CONTINUE if( incrContinue(), 0); else continue +#else /* ifndef WMOPS */ +#define CONTINUE \ + if ( incrContinue(), 0 ) \ + ; \ + else \ + continue -static __inline void incrContinue( void) { - multiCounter[currCounter].Continue++; +static __inline void incrContinue( void ) +{ + multiCounter[currCounter].Continue++; } -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1406,19 +1162,24 @@ static __inline void incrContinue( void) { * * The macro BREAK should be used instead of the 'break' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS #define BREAK break -#else -#define BREAK if( incrBreak(), 0) break; else break +#else /* ifndef WMOPS */ +#define BREAK \ + if ( incrBreak(), 0 ) \ + ; \ + else \ + break -static __inline void incrBreak( void) { - multiCounter[currCounter].Break++; +static __inline void incrBreak( void ) +{ + multiCounter[currCounter].Break++; } -#endif +#endif /* ifndef WMOPS */ /***************************************************************************** @@ -1429,20 +1190,50 @@ static __inline void incrBreak( void) { * * The macro GOTO should be used instead of the 'goto' C statement. * - * Complexity weight : 4 + * Complexity weight : 2 * *****************************************************************************/ #ifndef WMOPS #define GOTO goto -#else -#define GOTO if( incrGoto(), 0); else goto +#else /* ifndef WMOPS */ +#define GOTO \ + if ( incrGoto(), 0 ) \ + ; \ + else \ + goto -static __inline void incrGoto( void) { - multiCounter[currCounter].Goto++; +static __inline void incrGoto( void ) +{ + multiCounter[currCounter].Goto++; } -#endif +#endif /* ifndef WMOPS */ -#endif /* WMOPS_H */ +#ifdef CONTROL_CODE_OPS +extern int LT_16( short var1, short var2 ); +extern int GT_16( short var1, short var2 ); +extern int LE_16( short var1, short var2 ); +extern int GE_16( short var1, short var2 ); +extern int EQ_16( short var1, short var2 ); +extern int NE_16( short var1, short var2 ); + +extern int LT_32( int L_var1, int L_var2 ); +extern int GT_32( int L_var1, int L_var2 ); +extern int LE_32( int L_var1, int L_var2 ); +extern int GE_32( int L_var1, int L_var2 ); +extern int EQ_32( int L_var1, int L_var2 ); +extern int NE_32( int L_var1, int L_var2 ); + +extern int LT_64( long long int L64_var1, long long int L64_var2 ); +extern int GT_64( long long int L64_var1, long long int L64_var2 ); +extern int LE_64( long long int L64_var1, long long int L64_var2 ); +extern int GE_64( long long int L64_var1, long long int L64_var2 ); +extern int EQ_64( long long int L64_var1, long long int L64_var2 ); +extern int NE_64( long long int L64_var1, long long int L64_var2 ); + +#endif /* #ifdef CONTROL_CODE_OPS */ + + +#endif /* WMOPS_H */ diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 4cd4855ecc63d46c08c3e1c94f76562f85b45eeb..80ed47b718f07672ccffa2295f05a1600932c994 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1776,7 +1776,7 @@ ivas_error split_renderer_open_lc3plus( /* Alocate buffers for delay compensation */ if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - delayBufferLength = (int16_t) ( output_Fs / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + delayBufferLength = (int16_t) ( output_Fs / (int32_t) FRAMES_PER_SEC + hSplitRendWrapper->lc3plusDelaySamples ); for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) { if ( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) @@ -1905,7 +1905,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( if ( useLc3plus ) { /*this should always have the time resolution of pose correction MD. Note that this does not change frame size of LC3plus*/ - int16_t frame_size = (int16_t) ( hSplitBin->hLc3plusEnc->config.samplerate / (int32_t) FRAMES_PER_SECOND ); + int16_t frame_size = (int16_t) ( hSplitBin->hLc3plusEnc->config.samplerate / (int32_t) FRAMES_PER_SEC ); for ( i = 0; i < num_poses * BINAURAL_CHANNELS; ++i ) { diff --git a/scripts/tools/Darwin/wmc_tool b/scripts/tools/Darwin/wmc_tool index a25a5e9492910f7cdc2e9adcf0b1a3b417036f0e..855bc1a4a77ee747cc9e7b754bd1598ad1b43b7d 100755 Binary files a/scripts/tools/Darwin/wmc_tool and b/scripts/tools/Darwin/wmc_tool differ diff --git a/scripts/tools/Linux/wmc_tool b/scripts/tools/Linux/wmc_tool index 71329d879c3b6de3006abe68be1fac2b65f52956..5b58206b9ef08e2c8920817a0591f1e4ae89f2c9 100755 Binary files a/scripts/tools/Linux/wmc_tool and b/scripts/tools/Linux/wmc_tool differ diff --git a/scripts/tools/Win32/wmc_tool.exe b/scripts/tools/Win32/wmc_tool.exe index e2b515d8954866bbab6ca2bf06f4153b2b9a0ea8..87414242c34379b4a2776389e5fba5ed1cbcb649 100755 --- a/scripts/tools/Win32/wmc_tool.exe +++ b/scripts/tools/Win32/wmc_tool.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a66015f78699e42d29165f05192859c086ebd2b8e859742630ac303e9771b5e -size 264192 +oid sha256:69b3382c94f1c83864d216b7e9b4c102c0266d29bf27cb09da2b1c56e106292b +size 276480