Loading lib_com/control.c +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1] = ""; #endif #ifdef CONTROL_CODE_OPS Loading lib_com/control.h +13 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #ifndef _CONTROL_H #define _CONTROL_H #include <string.h> #include "stl.h" Loading @@ -45,6 +46,9 @@ extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ extern char func_name_where_last_call_to_else_occurred[]; /* Technical note : * The following 3 variables are only used for correct complexity * evaluation of the following structure : Loading Loading @@ -172,15 +176,15 @@ static __inline void incrWhile( void ) #define IF( a ) if ( a ) #else /* ifndef WMOPS */ #define IF( a ) if ( incrIf(), a ) #define IF( a ) if ( incrIf( __func__ ), a ) static __inline void incrIf( void ) static __inline void incrIf( const char *func_name ) { /* 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 ) ) if ( ( 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() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) multiCounter[currCounter].If++; call_occurred = 0; Loading @@ -205,10 +209,10 @@ static __inline void incrIf( void ) #else /* ifndef WMOPS */ #define ELSE \ else if ( incrElse(), 0 ); \ else if ( incrElse( __func__ ), 0 ); \ else static __inline void incrElse( void ) static __inline void incrElse( const char *func_name ) { multiCounter[currCounter].If++; Loading @@ -218,6 +222,10 @@ static __inline void incrElse( void ) /* 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(); /* 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'; /* call_occurred is set to 0, in order to count the next IF (if necessary) */ call_occurred = 0; } Loading Loading
lib_com/control.c +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ int funcId_where_last_call_to_else_occurred; long funcid_total_wmops_at_last_call_to_else; int call_occurred = 1; char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1] = ""; #endif #ifdef CONTROL_CODE_OPS Loading
lib_com/control.h +13 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #ifndef _CONTROL_H #define _CONTROL_H #include <string.h> #include "stl.h" Loading @@ -45,6 +46,9 @@ extern BASIC_OP multiCounter[MAXCOUNTERS]; extern int currCounter; #define MAX_FUNCTION_NAME_LENGTH 200 /* Maximum length of the function name */ extern char func_name_where_last_call_to_else_occurred[]; /* Technical note : * The following 3 variables are only used for correct complexity * evaluation of the following structure : Loading Loading @@ -172,15 +176,15 @@ static __inline void incrWhile( void ) #define IF( a ) if ( a ) #else /* ifndef WMOPS */ #define IF( a ) if ( incrIf(), a ) #define IF( a ) if ( incrIf( __func__ ), a ) static __inline void incrIf( void ) static __inline void incrIf( const char *func_name ) { /* 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 ) ) if ( ( 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() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) ) multiCounter[currCounter].If++; call_occurred = 0; Loading @@ -205,10 +209,10 @@ static __inline void incrIf( void ) #else /* ifndef WMOPS */ #define ELSE \ else if ( incrElse(), 0 ); \ else if ( incrElse( __func__ ), 0 ); \ else static __inline void incrElse( void ) static __inline void incrElse( const char *func_name ) { multiCounter[currCounter].If++; Loading @@ -218,6 +222,10 @@ static __inline void incrElse( void ) /* 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(); /* 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'; /* call_occurred is set to 0, in order to count the next IF (if necessary) */ call_occurred = 0; } Loading