summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-12-23 13:32:31 -0500
committerSteve Reinhardt <stever@eecs.umich.edu>2005-12-23 13:32:31 -0500
commit0cdcb08d908bc20f614dd164f8e43287406e81a3 (patch)
treeba6da1e59f9ca5c67c9aa067f374c77129722a52 /base
parent627f540e3119e09747005e208daa8153b22d9967 (diff)
downloadgem5-0cdcb08d908bc20f614dd164f8e43287406e81a3.tar.xz
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
Diffstat (limited to 'base')
-rw-r--r--base/intmath.cc44
-rw-r--r--base/intmath.hh60
-rw-r--r--base/statistics.cc2
-rw-r--r--base/str.cc18
4 files changed, 62 insertions, 62 deletions
diff --git a/base/intmath.cc b/base/intmath.cc
index 099ab1c9a..f1c1651ba 100644
--- a/base/intmath.cc
+++ b/base/intmath.cc
@@ -29,30 +29,30 @@
#include "base/intmath.hh"
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 (!(n & 1))
- --n;
+ // If the number is even, let's start with the previous odd number.
+ if (!(n & 1))
+ --n;
- // Lets test for divisibility by 3. Then we will be able to easily
- // avoid numbers that are divisible by 3 in the future.
- decr = n % 3;
- if (decr == 0) {
- n -= 2;
- decr = 2;
- }
- else if (decr == 1)
- decr = 4;
+ // Lets test for divisibility by 3. Then we will be able to easily
+ // avoid numbers that are divisible by 3 in the future.
+ decr = n % 3;
+ if (decr == 0) {
+ n -= 2;
+ decr = 2;
+ }
+ else if (decr == 1)
+ decr = 4;
- for (;;) {
- if (IsPrime(n))
- return n;
- n -= decr;
- // Toggle between 2 and 4 to prevent trying numbers that are known
- // to be divisible by 3.
- decr = 6 - decr;
- }
+ for (;;) {
+ if (isPrime(n))
+ return n;
+ n -= decr;
+ // Toggle between 2 and 4 to prevent trying numbers that are known
+ // to be divisible by 3.
+ decr = 6 - decr;
+ }
}
diff --git a/base/intmath.hh b/base/intmath.hh
index 28d47fadd..3922a326b 100644
--- a/base/intmath.hh
+++ b/base/intmath.hh
@@ -34,12 +34,12 @@
#include "sim/host.hh"
// Returns the prime number one less than n.
-int PrevPrime(int n);
+int prevPrime(int n);
// Determine if a number is prime
template <class T>
inline bool
-IsPrime(T n)
+isPrime(T n)
{
T i;
@@ -60,20 +60,20 @@ IsPrime(T n)
template <class T>
inline T
-LeastSigBit(T n)
+leastSigBit(T n)
{
return n & ~(n - 1);
}
template <class T>
inline bool
-IsPowerOf2(T n)
+isPowerOf2(T n)
{
- return n != 0 && LeastSigBit(n) == n;
+ return n != 0 && leastSigBit(n) == n;
}
inline int
-FloorLog2(unsigned x)
+floorLog2(unsigned x)
{
assert(x > 0);
@@ -89,7 +89,7 @@ FloorLog2(unsigned x)
}
inline int
-FloorLog2(unsigned long x)
+floorLog2(unsigned long x)
{
assert(x > 0);
@@ -108,7 +108,7 @@ FloorLog2(unsigned long x)
}
inline int
-FloorLog2(unsigned long long x)
+floorLog2(unsigned long long x)
{
assert(x > 0);
@@ -125,76 +125,76 @@ FloorLog2(unsigned long long x)
}
inline int
-FloorLog2(int x)
+floorLog2(int x)
{
assert(x > 0);
- return FloorLog2((unsigned)x);
+ return floorLog2((unsigned)x);
}
inline int
-FloorLog2(long x)
+floorLog2(long x)
{
assert(x > 0);
- return FloorLog2((unsigned long)x);
+ return floorLog2((unsigned long)x);
}
inline int
-FloorLog2(long long x)
+floorLog2(long long x)
{
assert(x > 0);
- return FloorLog2((unsigned long long)x);
+ return floorLog2((unsigned long long)x);
}
#if defined(__APPLE__)
inline int
-FloorLog2(size_t x)
+floorLog2(size_t x)
{
assert(x > 0);
assert(sizeof(size_t) == 4 || sizeof(size_t) == 8);
// It's my hope that this is optimized away?
if (sizeof(size_t) == 4)
- return FloorLog2((uint32_t)x);
+ return floorLog2((uint32_t)x);
else if (sizeof(size_t) == 8)
- return FloorLog2((uint64_t)x);
+ return floorLog2((uint64_t)x);
}
#endif
template <class T>
inline int
-CeilLog2(T n)
+ceilLog2(T n)
{
if (n == 1)
return 0;
- return FloorLog2(n - (T)1) + 1;
+ return floorLog2(n - (T)1) + 1;
}
template <class T>
inline T
-FloorPow2(T n)
+floorPow2(T n)
{
- return (T)1 << FloorLog2(n);
+ return (T)1 << floorLog2(n);
}
template <class T>
inline T
-CeilPow2(T n)
+ceilPow2(T n)
{
- return (T)1 << CeilLog2(n);
+ return (T)1 << ceilLog2(n);
}
template <class T>
inline T
-DivCeil(T a, T b)
+divCeil(T a, T b)
{
return (a + b - 1) / b;
}
template <class T>
inline T
-RoundUp(T val, T align)
+roundUp(T val, T align)
{
T mask = align - 1;
return (val + mask) & ~mask;
@@ -202,14 +202,14 @@ RoundUp(T val, T align)
template <class T>
inline T
-RoundDown(T val, T align)
+roundDown(T val, T align)
{
T mask = align - 1;
return val & ~mask;
}
inline bool
-IsHex(char c)
+isHex(char c)
{
return c >= '0' && c <= '9' ||
c >= 'A' && c <= 'F' ||
@@ -217,19 +217,19 @@ IsHex(char c)
}
inline bool
-IsOct(char c)
+isOct(char c)
{
return c >= '0' && c <= '7';
}
inline bool
-IsDec(char c)
+isDec(char c)
{
return c >= '0' && c <= '9';
}
inline int
-Hex2Int(char c)
+hex2Int(char c)
{
if (c >= '0' && c <= '9')
return (c - '0');
diff --git a/base/statistics.cc b/base/statistics.cc
index eaefd5f15..c97564641 100644
--- a/base/statistics.cc
+++ b/base/statistics.cc
@@ -253,7 +253,7 @@ char *
MainBin::memory(off_t off)
{
if (memsize == -1)
- memsize = CeilPow2((size_t) offset());
+ memsize = ceilPow2((size_t) offset());
if (!mem) {
mem = new char[memsize];
diff --git a/base/str.cc b/base/str.cc
index 15f44dad2..5f7f50286 100644
--- a/base/str.cc
+++ b/base/str.cc
@@ -142,7 +142,7 @@ __to_number(string value, T &retval)
int i = 0;
char c = value[i];
- if (!IsDec(c)) {
+ if (!isDec(c)) {
if (c == '-' && sign)
negative = true;
else
@@ -161,7 +161,7 @@ __to_number(string value, T &retval)
if (sign && negative)
return false;
- if (!IsOct(c)) {
+ if (!isOct(c)) {
if (c == 'X' || c == 'x') {
hex = true;
oct = false;
@@ -170,7 +170,7 @@ __to_number(string value, T &retval)
}
else
retval += c - '0';
- } else if (!IsDec(c))
+ } else if (!isDec(c))
goto multiply;
else {
if (sign && negative && c == '0')
@@ -190,18 +190,18 @@ __to_number(string value, T &retval)
for (i = 2; i <= last ; i++) {
c = value[i];
- if (!IsHex(c))
+ if (!isHex(c))
return false;
if (retval > hexmax) return false;
retval *= 16;
- retval += Hex2Int(c);
+ retval += hex2Int(c);
}
return true;
} else if (oct) {
for (i = 2; i <= last ; i++) {
c = value[i];
- if (!IsOct(c))
+ if (!isOct(c))
return false;
if (retval > octmax) return false;
@@ -213,7 +213,7 @@ __to_number(string value, T &retval)
for (i = 2; i < last ; i++) {
c = value[i];
- if (!IsDec(c))
+ if (!isDec(c))
goto multiply;
if (retval > decmax) return false;
@@ -226,7 +226,7 @@ __to_number(string value, T &retval)
}
c = value[last];
- if (IsDec(c)) {
+ if (isDec(c)) {
if (retval > decmax) return false;
bool atmax = retval == decmax;
@@ -274,7 +274,7 @@ __to_number(string value, T &retval)
mult = 0;
for (i++; i <= last; i++) {
c = value[i];
- if (!IsDec(c))
+ if (!isDec(c))
return false;
mult *= 10;