rotating_hash.h

Go to the documentation of this file.
00001 
00046 #ifndef ALGO_ROTATING_H
00047 #define ALGO_ROTATING_H
00048 
00049 #include <cfg/compiler.h>
00050 
00051 typedef uint16_t rotating_t;
00052 
00053 
00057 INLINE void rotating_init(rotating_t *rot)
00058 {
00059     *rot = 0;
00060 }
00061 
00065 INLINE void rotating_update1(uint8_t c, rotating_t *rot)
00066 {
00067     *rot = (*rot << 4) ^ (*rot >> 12) ^ c;
00068 }
00069 
00073 INLINE void rotating_update(const void *_buf, size_t len, rotating_t *rot)
00074 {
00075     const uint8_t *buf = (const uint8_t *)_buf;
00076 
00077     while (len--)
00078         rotating_update1(*buf++, rot);
00079 }
00080 
00081 
00082 #endif // ALGO_ROTATING_H