Change base/intmath.{cc,hh} to follow m5 style.
arch/alpha/alpha_tru64_process.cc: base/intmath.hh: base/statistics.cc: base/str.cc: cpu/o3/btb.cc: sim/process.cc: sim/syscall_emul.hh: Rename intmath.hh functions to follow m5 style (RoundUp -> roundUp, etc.). base/intmath.cc: Rename intmath.hh functions to follow m5 style (RoundUp -> roundUp, etc.). Also reindent code in m5 style. --HG-- extra : convert_revision : 57b853002bc3c9911e122599d9062b41a06d8e6a
This commit is contained in:
parent
627f540e31
commit
0cdcb08d90
|
@ -843,7 +843,7 @@ class Tru64 {
|
||||||
// Actual size includes padded string rounded up for alignment.
|
// Actual size includes padded string rounded up for alignment.
|
||||||
// Subtract 256 for dummy char array in Tru64::dirent definition.
|
// Subtract 256 for dummy char array in Tru64::dirent definition.
|
||||||
// Add 1 to namelen for terminating null char.
|
// Add 1 to namelen for terminating null char.
|
||||||
int tgt_bufsize = sizeof(Tru64::dirent) - 256 + RoundUp(namelen+1, 8);
|
int tgt_bufsize = sizeof(Tru64::dirent) - 256 + roundUp(namelen+1, 8);
|
||||||
TypedBufferArg<Tru64::dirent> tgt_dp(tgt_buf_ptr, tgt_bufsize);
|
TypedBufferArg<Tru64::dirent> tgt_dp(tgt_buf_ptr, tgt_bufsize);
|
||||||
tgt_dp->d_ino = host_dp->d_ino;
|
tgt_dp->d_ino = host_dp->d_ino;
|
||||||
tgt_dp->d_reclen = tgt_bufsize;
|
tgt_dp->d_reclen = tgt_bufsize;
|
||||||
|
|
|
@ -29,30 +29,30 @@
|
||||||
#include "base/intmath.hh"
|
#include "base/intmath.hh"
|
||||||
|
|
||||||
int
|
int
|
||||||
PrevPrime(int n)
|
prevPrime(int n)
|
||||||
{
|
{
|
||||||
int decr;
|
int decr;
|
||||||
|
|
||||||
// If the number is even, let's start with the previous odd number.
|
// If the number is even, let's start with the previous odd number.
|
||||||
if (!(n & 1))
|
if (!(n & 1))
|
||||||
--n;
|
--n;
|
||||||
|
|
||||||
// Lets test for divisibility by 3. Then we will be able to easily
|
// Lets test for divisibility by 3. Then we will be able to easily
|
||||||
// avoid numbers that are divisible by 3 in the future.
|
// avoid numbers that are divisible by 3 in the future.
|
||||||
decr = n % 3;
|
decr = n % 3;
|
||||||
if (decr == 0) {
|
if (decr == 0) {
|
||||||
n -= 2;
|
n -= 2;
|
||||||
decr = 2;
|
decr = 2;
|
||||||
}
|
}
|
||||||
else if (decr == 1)
|
else if (decr == 1)
|
||||||
decr = 4;
|
decr = 4;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (IsPrime(n))
|
if (isPrime(n))
|
||||||
return n;
|
return n;
|
||||||
n -= decr;
|
n -= decr;
|
||||||
// Toggle between 2 and 4 to prevent trying numbers that are known
|
// Toggle between 2 and 4 to prevent trying numbers that are known
|
||||||
// to be divisible by 3.
|
// to be divisible by 3.
|
||||||
decr = 6 - decr;
|
decr = 6 - decr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,12 @@
|
||||||
#include "sim/host.hh"
|
#include "sim/host.hh"
|
||||||
|
|
||||||
// Returns the prime number one less than n.
|
// Returns the prime number one less than n.
|
||||||
int PrevPrime(int n);
|
int prevPrime(int n);
|
||||||
|
|
||||||
// Determine if a number is prime
|
// Determine if a number is prime
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
IsPrime(T n)
|
isPrime(T n)
|
||||||
{
|
{
|
||||||
T i;
|
T i;
|
||||||
|
|
||||||
|
@ -60,20 +60,20 @@ IsPrime(T n)
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
LeastSigBit(T n)
|
leastSigBit(T n)
|
||||||
{
|
{
|
||||||
return n & ~(n - 1);
|
return n & ~(n - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline bool
|
inline bool
|
||||||
IsPowerOf2(T n)
|
isPowerOf2(T n)
|
||||||
{
|
{
|
||||||
return n != 0 && LeastSigBit(n) == n;
|
return n != 0 && leastSigBit(n) == n;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(unsigned x)
|
floorLog2(unsigned x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ FloorLog2(unsigned x)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(unsigned long x)
|
floorLog2(unsigned long x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ FloorLog2(unsigned long x)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(unsigned long long x)
|
floorLog2(unsigned long long x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
|
|
||||||
|
@ -125,76 +125,76 @@ FloorLog2(unsigned long long x)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(int x)
|
floorLog2(int x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
return FloorLog2((unsigned)x);
|
return floorLog2((unsigned)x);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(long x)
|
floorLog2(long x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
return FloorLog2((unsigned long)x);
|
return floorLog2((unsigned long)x);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(long long x)
|
floorLog2(long long x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
return FloorLog2((unsigned long long)x);
|
return floorLog2((unsigned long long)x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
inline int
|
inline int
|
||||||
FloorLog2(size_t x)
|
floorLog2(size_t x)
|
||||||
{
|
{
|
||||||
assert(x > 0);
|
assert(x > 0);
|
||||||
assert(sizeof(size_t) == 4 || sizeof(size_t) == 8);
|
assert(sizeof(size_t) == 4 || sizeof(size_t) == 8);
|
||||||
|
|
||||||
// It's my hope that this is optimized away?
|
// It's my hope that this is optimized away?
|
||||||
if (sizeof(size_t) == 4)
|
if (sizeof(size_t) == 4)
|
||||||
return FloorLog2((uint32_t)x);
|
return floorLog2((uint32_t)x);
|
||||||
else if (sizeof(size_t) == 8)
|
else if (sizeof(size_t) == 8)
|
||||||
return FloorLog2((uint64_t)x);
|
return floorLog2((uint64_t)x);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline int
|
inline int
|
||||||
CeilLog2(T n)
|
ceilLog2(T n)
|
||||||
{
|
{
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return FloorLog2(n - (T)1) + 1;
|
return floorLog2(n - (T)1) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
FloorPow2(T n)
|
floorPow2(T n)
|
||||||
{
|
{
|
||||||
return (T)1 << FloorLog2(n);
|
return (T)1 << floorLog2(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
CeilPow2(T n)
|
ceilPow2(T n)
|
||||||
{
|
{
|
||||||
return (T)1 << CeilLog2(n);
|
return (T)1 << ceilLog2(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
DivCeil(T a, T b)
|
divCeil(T a, T b)
|
||||||
{
|
{
|
||||||
return (a + b - 1) / b;
|
return (a + b - 1) / b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
RoundUp(T val, T align)
|
roundUp(T val, T align)
|
||||||
{
|
{
|
||||||
T mask = align - 1;
|
T mask = align - 1;
|
||||||
return (val + mask) & ~mask;
|
return (val + mask) & ~mask;
|
||||||
|
@ -202,14 +202,14 @@ RoundUp(T val, T align)
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T
|
inline T
|
||||||
RoundDown(T val, T align)
|
roundDown(T val, T align)
|
||||||
{
|
{
|
||||||
T mask = align - 1;
|
T mask = align - 1;
|
||||||
return val & ~mask;
|
return val & ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
IsHex(char c)
|
isHex(char c)
|
||||||
{
|
{
|
||||||
return c >= '0' && c <= '9' ||
|
return c >= '0' && c <= '9' ||
|
||||||
c >= 'A' && c <= 'F' ||
|
c >= 'A' && c <= 'F' ||
|
||||||
|
@ -217,19 +217,19 @@ IsHex(char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
IsOct(char c)
|
isOct(char c)
|
||||||
{
|
{
|
||||||
return c >= '0' && c <= '7';
|
return c >= '0' && c <= '7';
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
IsDec(char c)
|
isDec(char c)
|
||||||
{
|
{
|
||||||
return c >= '0' && c <= '9';
|
return c >= '0' && c <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
Hex2Int(char c)
|
hex2Int(char c)
|
||||||
{
|
{
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
return (c - '0');
|
return (c - '0');
|
||||||
|
|
|
@ -253,7 +253,7 @@ char *
|
||||||
MainBin::memory(off_t off)
|
MainBin::memory(off_t off)
|
||||||
{
|
{
|
||||||
if (memsize == -1)
|
if (memsize == -1)
|
||||||
memsize = CeilPow2((size_t) offset());
|
memsize = ceilPow2((size_t) offset());
|
||||||
|
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
mem = new char[memsize];
|
mem = new char[memsize];
|
||||||
|
|
18
base/str.cc
18
base/str.cc
|
@ -142,7 +142,7 @@ __to_number(string value, T &retval)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
char c = value[i];
|
char c = value[i];
|
||||||
if (!IsDec(c)) {
|
if (!isDec(c)) {
|
||||||
if (c == '-' && sign)
|
if (c == '-' && sign)
|
||||||
negative = true;
|
negative = true;
|
||||||
else
|
else
|
||||||
|
@ -161,7 +161,7 @@ __to_number(string value, T &retval)
|
||||||
if (sign && negative)
|
if (sign && negative)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!IsOct(c)) {
|
if (!isOct(c)) {
|
||||||
if (c == 'X' || c == 'x') {
|
if (c == 'X' || c == 'x') {
|
||||||
hex = true;
|
hex = true;
|
||||||
oct = false;
|
oct = false;
|
||||||
|
@ -170,7 +170,7 @@ __to_number(string value, T &retval)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retval += c - '0';
|
retval += c - '0';
|
||||||
} else if (!IsDec(c))
|
} else if (!isDec(c))
|
||||||
goto multiply;
|
goto multiply;
|
||||||
else {
|
else {
|
||||||
if (sign && negative && c == '0')
|
if (sign && negative && c == '0')
|
||||||
|
@ -190,18 +190,18 @@ __to_number(string value, T &retval)
|
||||||
|
|
||||||
for (i = 2; i <= last ; i++) {
|
for (i = 2; i <= last ; i++) {
|
||||||
c = value[i];
|
c = value[i];
|
||||||
if (!IsHex(c))
|
if (!isHex(c))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (retval > hexmax) return false;
|
if (retval > hexmax) return false;
|
||||||
retval *= 16;
|
retval *= 16;
|
||||||
retval += Hex2Int(c);
|
retval += hex2Int(c);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (oct) {
|
} else if (oct) {
|
||||||
for (i = 2; i <= last ; i++) {
|
for (i = 2; i <= last ; i++) {
|
||||||
c = value[i];
|
c = value[i];
|
||||||
if (!IsOct(c))
|
if (!isOct(c))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (retval > octmax) return false;
|
if (retval > octmax) return false;
|
||||||
|
@ -213,7 +213,7 @@ __to_number(string value, T &retval)
|
||||||
|
|
||||||
for (i = 2; i < last ; i++) {
|
for (i = 2; i < last ; i++) {
|
||||||
c = value[i];
|
c = value[i];
|
||||||
if (!IsDec(c))
|
if (!isDec(c))
|
||||||
goto multiply;
|
goto multiply;
|
||||||
|
|
||||||
if (retval > decmax) return false;
|
if (retval > decmax) return false;
|
||||||
|
@ -226,7 +226,7 @@ __to_number(string value, T &retval)
|
||||||
}
|
}
|
||||||
|
|
||||||
c = value[last];
|
c = value[last];
|
||||||
if (IsDec(c)) {
|
if (isDec(c)) {
|
||||||
|
|
||||||
if (retval > decmax) return false;
|
if (retval > decmax) return false;
|
||||||
bool atmax = retval == decmax;
|
bool atmax = retval == decmax;
|
||||||
|
@ -274,7 +274,7 @@ __to_number(string value, T &retval)
|
||||||
mult = 0;
|
mult = 0;
|
||||||
for (i++; i <= last; i++) {
|
for (i++; i <= last; i++) {
|
||||||
c = value[i];
|
c = value[i];
|
||||||
if (!IsDec(c))
|
if (!isDec(c))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mult *= 10;
|
mult *= 10;
|
||||||
|
|
|
@ -52,7 +52,7 @@ DefaultBTB::DefaultBTB(unsigned _numEntries,
|
||||||
|
|
||||||
tagMask = (1 << tagBits) - 1;
|
tagMask = (1 << tagBits) - 1;
|
||||||
|
|
||||||
tagShiftAmt = instShiftAmt + FloorLog2(numEntries);
|
tagShiftAmt = instShiftAmt + floorLog2(numEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
|
@ -274,7 +274,7 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile,
|
||||||
text_size = objFile->textSize();
|
text_size = objFile->textSize();
|
||||||
data_base = objFile->dataBase();
|
data_base = objFile->dataBase();
|
||||||
data_size = objFile->dataSize() + objFile->bssSize();
|
data_size = objFile->dataSize() + objFile->bssSize();
|
||||||
brk_point = RoundUp<uint64_t>(data_base + data_size, VMPageSize);
|
brk_point = roundUp<uint64_t>(data_base + data_size, VMPageSize);
|
||||||
|
|
||||||
// load object file into target memory
|
// load object file into target memory
|
||||||
objFile->loadSections(memory);
|
objFile->loadSections(memory);
|
||||||
|
|
|
@ -634,7 +634,7 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
|
||||||
if (start == 0) {
|
if (start == 0) {
|
||||||
// user didn't give an address... pick one from our "mmap region"
|
// user didn't give an address... pick one from our "mmap region"
|
||||||
start = p->mmap_end;
|
start = p->mmap_end;
|
||||||
p->mmap_end += RoundUp<Addr>(length, VMPageSize);
|
p->mmap_end += roundUp<Addr>(length, VMPageSize);
|
||||||
if (p->nxm_start != 0) {
|
if (p->nxm_start != 0) {
|
||||||
//If we have an nxm space, make sure we haven't colided
|
//If we have an nxm space, make sure we haven't colided
|
||||||
assert(p->mmap_end < p->nxm_start);
|
assert(p->mmap_end < p->nxm_start);
|
||||||
|
|
Loading…
Reference in a new issue