Deleted Added
sdiff udiff text old ( 4649:899f745b3c21 ) new ( 4661:44458219add1 )
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;

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

54T
55bits(T val, int first, int last)
56{
57 int nbits = first - last + 1;
58 return (val >> last) & mask(nbits);
59}
60
61/**
62 * Mask off the given bits in place like bits() but without shifting.
63 * msb = 63, lsb = 0
64 */
65template <class T>
66inline
67T
68mbits(T val, int first, int last)
69{

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

97insertBits(T val, int first, int last, B bit_val)
98{
99 T t_bit_val = bit_val;
100 T bmask = mask(first - last + 1) << last;
101 return ((t_bit_val << last) & bmask) | (val & ~bmask);
102}
103
104/**
105 * A convenience function to replace bits first to last of val with bit_val
106 * in place.
107 */
108template <class T, class B>
109inline
110void
111replaceBits(T& val, int first, int last, B bit_val)
112{
113 val = insertBits(val, first, last, bit_val);
114}
115
116/**
117 * Returns the bit position of the MSB that is set in the input
118 */
119inline
120int
121findMsbSet(uint64_t val) {
122 int msb = 0;
123 if (!val)

--- 280 unchanged lines hidden ---