bitfield.hh (3422:426a8ebd677c) bitfield.hh (3814:33bd4ec9d66a)
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;

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

53T
54bits(T val, int first, int last)
55{
56 int nbits = first - last + 1;
57 return (val >> last) & mask(nbits);
58}
59
60/**
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;

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

53T
54bits(T val, int first, int last)
55{
56 int nbits = first - last + 1;
57 return (val >> last) & mask(nbits);
58}
59
60/**
61 * Mask off the given bits in place like bits() but without shifting.
62 * msb = 63, lsb = 0
63 */
64template <class T>
65inline
66T
67mbits(T val, int first, int last)
68{
69 return val & (mask(first+1) & ~mask(last));
70}
71
72/**
61 * Sign-extend an N-bit value to 64 bits.
62 */
63template <int N>
64inline
65int64_t
66sext(uint64_t val)
67{
68 int sign_bit = bits(val, N-1, N-1);

--- 28 unchanged lines hidden ---
73 * Sign-extend an N-bit value to 64 bits.
74 */
75template <int N>
76inline
77int64_t
78sext(uint64_t val)
79{
80 int sign_bit = bits(val, N-1, N-1);

--- 28 unchanged lines hidden ---