whitespace -> use tabs
[satcheck.git] / mcutil.h
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
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.
8  */
9
10 #ifndef MC_UTIL_H
11 #define MC_UTIL_H
12 #include <stdint.h>
13
14 static inline unsigned int rotate_left(unsigned int val, int bytestorotate) {
15         return (val << bytestorotate) | (val >> (sizeof(val)*8-bytestorotate));
16 }
17
18 static inline unsigned int rotate_right(unsigned int val, int bytestorotate) {
19         return (val >> bytestorotate) | (val << (sizeof(val)*8-bytestorotate));
20 }
21
22 static inline uint64_t keepbytes(uint64_t val, int len) {
23         int shift=8-len;
24         return (val << shift)>>shift;
25 }
26
27 static inline uint64_t getmask(uint len) {
28         return 0xffffffffffffffff>>(64-(len*8));
29 }
30
31
32 #define NUMBITS(x) ((x==0)?0:8*sizeof(x)-__builtin_clz(x))
33
34 #endif