Loading lib_debug/wmc_auto.c +32 −6 Original line number Diff line number Diff line Loading @@ -154,10 +154,13 @@ static BASIC_OP op_weight = { BASIC_OP *multiCounter = NULL; unsigned int currCounter = 0; int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; #ifdef FIX_1054_IF_ELSE_CMPLX char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; #else int funcId_where_last_call_to_else_occurred; int call_occurred = 1; #endif void reset_wmops( void ) { Loading Loading @@ -379,7 +382,9 @@ void push_wmops_fct( const char *label, ... ) /* set the ID of the current BASOP operations counter */ currCounter = index_record; #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif return; } Loading Loading @@ -423,7 +428,9 @@ void pop_wmops( void ) { currCounter = current_record; } #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif return; } Loading Loading @@ -517,7 +524,9 @@ void update_wmops( void ) #endif /* reset the BASOP operations counter */ #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif Reset_BASOP_WMOPS_counter( i ); } Loading Loading @@ -2449,29 +2458,46 @@ 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 ( ( (int) currCounter != funcId_where_last_call_to_else_occurred ) || ( 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 ) || ( call_occurred == 1 ) ) #ifdef FIX_1054_IF_ELSE_CMPLX 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'; #else 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 = -100; funcId_where_last_call_to_else_occurred = MAXCOUNTERS; #endif } void incrElse( const char *func_name ) { multiCounter[currCounter].If++; #ifndef FIX_1054_IF_ELSE_CMPLX /* Save the BASOP counter Id in the last function in which ELSE() has been called */ funcId_where_last_call_to_else_occurred = currCounter; #endif /* Save the BASOP comeplxity in the last call of the ELSE() statement */ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); /* Save the function name in the last call of the ELSE() statement */ #ifdef FIX_1054_IF_ELSE_CMPLX /* 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'; #else /* We keep track of the funcId of the last function which used ELSE {...} structure. */ funcId_where_last_call_to_else_occurred = currCounter; /* Set call_occurred to 0 to prevent counting of complexity of the next "immediate" IF statement */ /* call_occurred is set to 0, in order to count the next IF (if necessary) */ call_occurred = 0; #endif } long TotalWeightedOperation( unsigned int CounterId ) Loading lib_debug/wmc_auto.h +6 −1 Original line number Diff line number Diff line Loading @@ -961,9 +961,14 @@ typedef struct #ifdef WMOPS extern BASIC_OP *multiCounter; extern unsigned int currCounter; #ifndef FIX_1054_IF_ELSE_CMPLX extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; #endif extern long funcid_total_wmops_at_last_call_to_else; #ifdef FIX_1054_IF_ELSE_CMPLX extern char func_name_where_last_call_to_else_occurred[]; #endif long TotalWeightedOperation( unsigned int counterId ); long DeltaWeightedOperation( unsigned int counterId ); Loading Loading
lib_debug/wmc_auto.c +32 −6 Original line number Diff line number Diff line Loading @@ -154,10 +154,13 @@ static BASIC_OP op_weight = { BASIC_OP *multiCounter = NULL; unsigned int currCounter = 0; int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; #ifdef FIX_1054_IF_ELSE_CMPLX char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1]; #else int funcId_where_last_call_to_else_occurred; int call_occurred = 1; #endif void reset_wmops( void ) { Loading Loading @@ -379,7 +382,9 @@ void push_wmops_fct( const char *label, ... ) /* set the ID of the current BASOP operations counter */ currCounter = index_record; #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif return; } Loading Loading @@ -423,7 +428,9 @@ void pop_wmops( void ) { currCounter = current_record; } #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif return; } Loading Loading @@ -517,7 +524,9 @@ void update_wmops( void ) #endif /* reset the BASOP operations counter */ #ifndef FIX_1054_IF_ELSE_CMPLX call_occurred = 1; #endif Reset_BASOP_WMOPS_counter( i ); } Loading Loading @@ -2449,29 +2458,46 @@ 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 ( ( (int) currCounter != funcId_where_last_call_to_else_occurred ) || ( 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 ) || ( call_occurred == 1 ) ) #ifdef FIX_1054_IF_ELSE_CMPLX 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'; #else 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 = -100; funcId_where_last_call_to_else_occurred = MAXCOUNTERS; #endif } void incrElse( const char *func_name ) { multiCounter[currCounter].If++; #ifndef FIX_1054_IF_ELSE_CMPLX /* Save the BASOP counter Id in the last function in which ELSE() has been called */ funcId_where_last_call_to_else_occurred = currCounter; #endif /* Save the BASOP comeplxity in the last call of the ELSE() statement */ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation( currCounter ); /* Save the function name in the last call of the ELSE() statement */ #ifdef FIX_1054_IF_ELSE_CMPLX /* 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'; #else /* We keep track of the funcId of the last function which used ELSE {...} structure. */ funcId_where_last_call_to_else_occurred = currCounter; /* Set call_occurred to 0 to prevent counting of complexity of the next "immediate" IF statement */ /* call_occurred is set to 0, in order to count the next IF (if necessary) */ call_occurred = 0; #endif } long TotalWeightedOperation( unsigned int CounterId ) Loading
lib_debug/wmc_auto.h +6 −1 Original line number Diff line number Diff line Loading @@ -961,9 +961,14 @@ typedef struct #ifdef WMOPS extern BASIC_OP *multiCounter; extern unsigned int currCounter; #ifndef FIX_1054_IF_ELSE_CMPLX extern int funcId_where_last_call_to_else_occurred; extern long funcid_total_wmops_at_last_call_to_else; extern int call_occurred; #endif extern long funcid_total_wmops_at_last_call_to_else; #ifdef FIX_1054_IF_ELSE_CMPLX extern char func_name_where_last_call_to_else_occurred[]; #endif long TotalWeightedOperation( unsigned int counterId ); long DeltaWeightedOperation( unsigned int counterId ); Loading