Show
Ignore:
Timestamp:
11/11/07 07:52:01 (13 years ago)
Author:
ppalmers
Message:

almost there...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ppalmers-streaming/src/libstreaming/util/cycletimer.h

    r707 r712  
    156156    return x; 
    157157 
     158} 
     159 
     160/** 
     161 * @brief Computes the sum of two cycle values 
     162 * 
     163 * This function computes a sum between cycles 
     164 * such that it respects wrapping (at 8000 cycles). 
     165 * 
     166 * The passed arguments are assumed to be valid cycle numbers, 
     167 * i.e. they should be wrapped at 8000 cycles 
     168 * 
     169 * See addTicks 
     170 * 
     171 * @param x First cycle value 
     172 * @param y Second cycle value 
     173 * @return the sum x+y, wrapped 
     174 */ 
     175static inline unsigned int addCycles(unsigned int x, unsigned int y) { 
     176    unsigned int sum = x + y; 
     177#ifdef DEBUG 
     178    if (x >= CYCLES_PER_SECOND || y >= CYCLES_PER_SECOND ) { 
     179        debugWarning("At least one argument not wrapped correctly: x=%u, y=%u\n",x,y); 
     180    } 
     181#endif 
     182 
     183    // since both x and y are < CYCLES_PER_SECOND this should be enough to unwrap 
     184    if (sum > CYCLES_PER_SECOND) sum -= CYCLES_PER_SECOND; 
     185    return sum; 
    158186} 
    159187