rotating_hash.h

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