home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / btoa5.2.tar.Z / btoa5.2.tar / btoa5.2 / chksum.h < prev    next >
C/C++ Source or Header  |  1989-04-24  |  805b  |  25 lines

  1. /* chksum.h */
  2. /* calcchecksum() was converted to a macro for effectivity reasons. */
  3. /* Don't (!!) give it an argument that has to be evaluated. This    */
  4. /* is guaranteed to slow it down.                                   */
  5.  
  6. /* Update file checksums. */
  7.  
  8. #define calcchecksum(ch)        \
  9. {                               \
  10.   extern LONG Ceor, Csum, Crot; \
  11.                                 \
  12.   Ceor ^= ch;                   \
  13.   Csum += ch + 1;               \
  14.                                 \
  15.   if (Crot & 0x80000000L)       \
  16.   {                             \
  17.     Crot <<= 1;                 \
  18.     Crot ++;                    \
  19.   }                             \
  20.   else                          \
  21.     Crot <<= 1;                 \
  22.                                 \
  23.   Crot += ch;                   \
  24. }
  25.