Deleted Added
sdiff udiff text old ( 6215:9aed64c9f10f ) new ( 6274:117dbbf0e1e2 )
full compact
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;

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

156 if (bits(val, 31,16)) { msb += 16; val >>= 16; }
157 if (bits(val, 15,8)) { msb += 8; val >>= 8; }
158 if (bits(val, 7,4)) { msb += 4; val >>= 4; }
159 if (bits(val, 3,2)) { msb += 2; val >>= 2; }
160 if (bits(val, 1,1)) { msb += 1; }
161 return msb;
162}
163
164/**
165 * Returns the bit position of the LSB that is set in the input
166 */
167inline int
168findLsbSet(uint64_t val) {
169 int lsb = 0;
170 if (!val)
171 return sizeof(val) * 8;
172 if (!bits(val, 31,0)) { lsb += 32; val >>= 32; }
173 if (!bits(val, 15,0)) { lsb += 16; val >>= 16; }
174 if (!bits(val, 7,0)) { lsb += 8; val >>= 8; }
175 if (!bits(val, 3,0)) { lsb += 4; val >>= 4; }
176 if (!bits(val, 1,0)) { lsb += 2; val >>= 2; }
177 if (!bits(val, 0,0)) { lsb += 1; }
178 return lsb;
179}
180
181#endif // __BASE_BITFIELD_HH__