Commit 99fd2b4b authored by malenov's avatar malenov
Browse files

update to be in line with BASOP main

parent 16c28aba
Loading
Loading
Loading
Loading
Loading
+9 −23
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_
 * Complexity counting tool
 *--------------------------------------------------------------------*/

#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 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 */
@@ -49,6 +48,7 @@ int cntr_push_pop = 0; /* global counter for checking balanced push_wmops()/pop_
#define MAX_CALL_TREE_DEPTH          100 /* maximum depth of the function call tree */
#define DOUBLE_MAX                   0x80000000
#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
{
@@ -151,9 +151,7 @@ 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;
char func_name_where_last_call_to_else_occurred[MAX_FUNCTION_NAME_LENGTH + 1];

void reset_wmops( void )
@@ -245,11 +243,6 @@ void reset_wmops( void )
        wmops_caller_stack[i] = -1;
    }

    /* initialize auxiliary BASOP counter variables */
    currCounter = 0; /* Note: currCounter cannot be set to -1 because it's defined as unsigned int ! */
    call_occurred = 1;
    funcId_where_last_call_to_else_occurred = -100;

    return;
}

@@ -375,7 +368,6 @@ void push_wmops_fct( const char *label, ... )

    /* set the ID of the current BASOP operations counter */
    currCounter = index_record;
    call_occurred = 1;

    return;
}
@@ -419,7 +411,6 @@ void pop_wmops( void )
    {
        currCounter = current_record;
    }
    call_occurred = 1;

    return;
}
@@ -513,7 +504,6 @@ void update_wmops( void )
#endif

        /* reset the BASOP operations counter */
        call_occurred = 1;
        Reset_BASOP_WMOPS_counter( i );
    }

@@ -2445,29 +2435,25 @@ 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 ) )
    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++;
    }

    call_occurred = 0;
    funcId_where_last_call_to_else_occurred = -100;
    func_name_where_last_call_to_else_occurred[0] = '\0';
}

void incrElse( const char *func_name )
{
    multiCounter[currCounter].If++;

    /* Save the BASOP counter Id in the last function in which ELSE() has been called */
    funcId_where_last_call_to_else_occurred = currCounter;

    /* 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 */
    /* 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';

    /* Set call_occurred to 0 to prevent counting of complexity of the next "immediate" IF statement */
    call_occurred = 0;
}

long TotalWeightedOperation( unsigned int CounterId )
+32 −25
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
#include <stdio.h> /* 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
@@ -34,6 +36,7 @@
#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
@@ -350,7 +353,11 @@ extern int cntr_push_pop;
#define LOOP_( x )     OP_COUNT_( _LOOP, ( x ) )
#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) )
#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( 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 */
@@ -960,9 +967,8 @@ typedef struct
#ifdef WMOPS
extern BASIC_OP *multiCounter;
extern unsigned int currCounter;
extern int funcId_where_last_call_to_else_occurred;
extern long funcid_total_wmops_at_last_call_to_else;
extern int call_occurred;
extern char func_name_where_last_call_to_else_occurred[];

long TotalWeightedOperation( unsigned int counterId );
long DeltaWeightedOperation( unsigned int counterId );
@@ -1090,7 +1096,9 @@ void incrIf( const char *func_name );
#ifndef WMOPS
#define ELSE else
#else /* ifndef WMOPS */
#define ELSE else if ( incrElse( __func__ ), 0 ); else
#define ELSE                             \
    else if ( incrElse( __func__ ), 0 ); \
    else
void incrElse( const char *func_name );
#endif /* ifndef WMOPS */

@@ -1230,4 +1238,3 @@ extern int NE_64( long long int L64_var1, long long int L64_var2 );


#endif /* WMOPS_H */