GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LSE / V1-2-0
Constituent: lsew     Tag: sun-gcc
This graph shows which files directly or indirectly include this file:

Defines | |
| #define | FletcherDeclare(_prefix) |
| Declares the variables needed to implement the Fletcher Checksum. | |
| #define | FletcherInitialize(_prefix) |
| Initializes the specified set of Fletcher variables. These must have been declared by FletcherDeclare. | |
| #define | FletcherConstruct(_prefix) |
| Declares and initializes the variables needed to implement the Fletcher Checksum. | |
| #define | _FletcherReduce(_prefix) |
| #define | FletcherUpdate(_prefix, _val) |
| Updates the specified set of Fletcher variables with val. | |
| #define | FletcherFinalize(_prefix) |
| Finalizes the Fletcher checksum, producing one 32-bit result. | |
CVS $Id: Fletcher.h,v 1.1 2006/11/01 21:57:27 russell Exp $
The Fletcher checksum is well documented elsewhere. The reasons it was picked here are
This is implemented as a series of macros so that it may be embedded in other code.
The first parameter of each macro is an prefix to uniquely identify the set of 3 variables needed compute the Fletcher checksum. The update macro takes, as a second parameter, the value used in updating the checksum.
A trivial example would be
unsigned int fetcher_compute (const unsigned short int *array, int cnt) { FletcherDeclare (fcs); FletcherInitialize (fcs); while (--cnt >= 0) { FletcherUpdate (fcs, *array++) } return FletchFinalize (fcs); }
Note that this would not be a very good implementation for something this trivial. The reason is that there is a check buried in the FletcherUpdate macro. But the point of these macros is to able to compute a checksum when the data is not a neatly organized array.
|
|
Value: _prefix ## sum1 = (_prefix ## sum1 &0xffff) + (_prefix ## sum1 >> 16), \ _prefix ## sum2 = (_prefix ## sum2 &0xffff) + (_prefix ## sum2 >> 16) \ |
|
|
Value: unsigned int _prefix ## sum1 = 0xffff; \ unsigned int _prefix ## sum2 = 0xffff; \ int _prefix ## cnt = 0 \
|
|
|
Value: unsigned int _prefix ## sum1; \ unsigned int _prefix ## sum2; \ int _prefix ## cnt \
|
|
|
Value: ( ((_prefix ## cnt) ? _FletcherReduce(_prefix) : 0), \ _FletcherReduce (_prefix), \ ((_prefix ## sum2 << 16) | _prefix ## sum1))
|
|
|
Value: _prefix ## sum1 = 0xffff; \ _prefix ## sum2 = 0xffff; \ _prefix ## cnt = 0
|
|
|
Value: _prefix ## sum1 += (_val); \
_prefix ## sum2 += _prefix ## sum1; \
_prefix ## cnt += 1; \
if (_prefix ## cnt == 360) \
{ \
_FletcherReduce(_prefix); \
_prefix ## cnt = 0; \
}
|
1.4.4