1 /* Copyright (c) 2015 Regents of the University of California
3 * Author: Brian Demsky <bdemsky@uci.edu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
14 static inline unsigned int rotate_left(unsigned int val, int bytestorotate) {
15 return (val << bytestorotate) | (val >> (sizeof(val)*8-bytestorotate));
18 static inline unsigned int rotate_right(unsigned int val, int bytestorotate) {
19 return (val >> bytestorotate) | (val << (sizeof(val)*8-bytestorotate));
22 static inline uint64_t keepbytes(uint64_t val, int len) {
24 return (val << shift)>>shift;
27 static inline uint64_t getmask(uint len) {
28 return 0xffffffffffffffff>>(64-(len*8));
32 #define NUMBITS(x) ((x==0) ? 0 : 8*sizeof(x)-__builtin_clz(x))