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; --- 78 unchanged lines hidden (view full) --- 87 return mbits((uint64_t)-1LL, first, last); 88} 89 90/** 91 * Sign-extend an N-bit value to 64 bits. 92 */ 93template <int N> 94inline |
95uint64_t |
96sext(uint64_t val) 97{ 98 int sign_bit = bits(val, N-1, N-1); 99 return sign_bit ? (val | ~mask(N)) : val; 100} 101 102/** 103 * Return val with bits first to last set to bit_val --- 111 unchanged lines hidden --- |