1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 107 unchanged lines hidden (view full) ---

116 * Returns the bit position of the MSB that is set in the input
117 */
118inline
119int
120findMsbSet(uint64_t val) {
121 int msb = 0;
122 if (!val)
123 return 0;
124 if (bits(val, 63,32)) msb += 32;
125 val >>= 32;
126 if (bits(val, 31,16)) msb += 16;
127 val >>= 16;
128 if (bits(val, 15,8)) msb += 8;
129 val >>= 8;
130 if (bits(val, 7,4)) msb += 4;
131 val >>= 4;
132 if (bits(val, 3,2)) msb += 2;
133 val >>= 2;
134 if (bits(val, 1,1)) msb += 1;
124 if (bits(val, 63,32)) { msb += 32; val >>= 32; }
125 if (bits(val, 31,16)) { msb += 16; val >>= 16; }
126 if (bits(val, 15,8)) { msb += 8; val >>= 8; }
127 if (bits(val, 7,4)) { msb += 4; val >>= 4; }
128 if (bits(val, 3,2)) { msb += 2; val >>= 2; }
129 if (bits(val, 1,1)) { msb += 1; }
130 return msb;
131}
132
133
134
135#endif // __BASE_BITFIELD_HH__