Calculate Fletcher Checksums at compile time from string.
authorAdam Green <adamgr@foo.bar>
Wed, 30 Jan 2013 05:20:59 +0000 (21:20 -0800)
committerAdam Green <adamgr@foo.bar>
Wed, 30 Jan 2013 05:20:59 +0000 (21:20 -0800)
commitd4f93cf4359e4b5c80eb55e698ce5d50559c6ef8
tree6a350385e80cf80b0583d1520c6e94ebded52421
parente605a0d684bcfb052f89834717f4ce52992f7bac
Calculate Fletcher Checksums at compile time from string.

You can now just call CHECKSUM macro like the following to have the checksum
calculated for you at compile time:
 #define enable_checksum CHECKSUM("enable")

This uses a set of recursive macros from src/libs/checksumm.h to inline the
checksum calculation and then the compiler uses constant folding in optimized
builds (-O1 or higher) to pre-calculate the values.

NOTE: The macros in checksumm.h currently only support a maximum string length
      of 32 characters.  If you exceed this, the macros will return a fixed value
      of 0xFFFF which won't match your string.  You should keep your
      checksummed strings below this length.

I took a copy of main.bin from before I starting making these changes and then
kept running builds and verifying that the new main.bin was exactly the same
as the original.  This means that it created the same checksums and didn't grow
the binary size at all.
20 files changed:
src/libs/Config.cpp
src/libs/Config.h
src/libs/Kernel.cpp
src/libs/checksumm.h [new file with mode: 0644]
src/modules/communication/SerialConsole.h
src/modules/robot/Planner.h
src/modules/robot/Robot.h
src/modules/robot/Stepper.h
src/modules/robot/arm_solutions/CartesianSolution.h
src/modules/tools/endstops/Endstops.h
src/modules/tools/extruder/Extruder.h
src/modules/tools/laser/Laser.h
src/modules/tools/switch/Switch.h
src/modules/tools/switch/SwitchPool.h
src/modules/tools/temperaturecontrol/TemperatureControl.h
src/modules/tools/temperaturecontrol/TemperatureControlPool.h
src/modules/utils/configurator/Configurator.h
src/modules/utils/currentcontrol/CurrentControl.h
src/modules/utils/pausebutton/PauseButton.h
src/modules/utils/simpleshell/SimpleShell.h