summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2007-01-26 18:50:28 -0500
committerAli Saidi <saidi@eecs.umich.edu>2007-01-26 18:50:28 -0500
commit6d9d0c68b574ceba53fc36d34b83f7109e00b1d0 (patch)
tree8004fcb5879cd81d738bd750441fbc900208e049 /src/base
parentc215d54aac6925cf13079d8d8fe3691451a77ce1 (diff)
parentfd8a4ff5a8a9ea65e227f0b4000dfcda06d4764f (diff)
downloadgem5-6d9d0c68b574ceba53fc36d34b83f7109e00b1d0.tar.xz
Merge zizzer:/bk/newmem
into zeep.pool:/z/saidi/work/m5.suncc --HG-- extra : convert_revision : 1706f6218abec7eb575dcff3ad4aef83894f64ab
Diffstat (limited to 'src/base')
-rw-r--r--src/base/compression/lzss_compression.cc6
-rw-r--r--src/base/compression/null_compression.hh2
-rw-r--r--src/base/cprintf.hh24
-rw-r--r--src/base/hashmap.hh2
-rw-r--r--src/base/hostinfo.cc1
-rw-r--r--src/base/loader/object_file.cc4
-rw-r--r--src/base/misc.hh45
-rw-r--r--src/base/pollevent.cc2
-rw-r--r--src/base/random.cc13
-rw-r--r--src/base/remote_gdb.cc5
-rw-r--r--src/base/statistics.hh5
-rw-r--r--src/base/stats/text.cc4
-rw-r--r--src/base/time.cc4
-rw-r--r--src/base/time.hh2
-rw-r--r--src/base/timebuf.hh5
-rw-r--r--src/base/trace.hh28
16 files changed, 91 insertions, 61 deletions
diff --git a/src/base/compression/lzss_compression.cc b/src/base/compression/lzss_compression.cc
index eb35fb8f1..bd16d82c9 100644
--- a/src/base/compression/lzss_compression.cc
+++ b/src/base/compression/lzss_compression.cc
@@ -32,8 +32,8 @@
* LZSSCompression definitions.
*/
-#include <assert.h>
-
+#include <cassert>
+#include <cstring>
#include "base/compression/lzss_compression.hh"
#include "base/misc.hh" //for fatal
@@ -134,7 +134,7 @@ LZSSCompression::compress(uint8_t *dest, uint8_t *src, int size)
if (dest_index >= size) {
// Have expansion instead of compression, just copy.
- memcpy(dest,src,size);
+ std::memcpy(dest,src,size);
return size;
}
return dest_index;
diff --git a/src/base/compression/null_compression.hh b/src/base/compression/null_compression.hh
index ff110807a..798acb77a 100644
--- a/src/base/compression/null_compression.hh
+++ b/src/base/compression/null_compression.hh
@@ -50,11 +50,13 @@ class NullCompression : public CompressionAlgorithm
int uncompress(uint8_t * dest, uint8_t *src, int size)
{
fatal("Can't uncompress data");
+ M5_DUMMY_RETURN
}
int compress(uint8_t *dest, uint8_t *src, int size)
{
fatal("Can't compress data");
+ M5_DUMMY_RETURN
}
};
diff --git a/src/base/cprintf.hh b/src/base/cprintf.hh
index 9967b0578..dd2256e69 100644
--- a/src/base/cprintf.hh
+++ b/src/base/cprintf.hh
@@ -136,10 +136,10 @@ operator,(ArgList &alist, ArgListNull)
inline void
__cprintf(const std::string &format, ArgList &args)
{ args.dump(format); delete &args; }
-#define __cprintf__(format, args...) \
- cp::__cprintf(format, (*(new cp::ArgList), args))
-#define cprintf(args...) \
- __cprintf__(args, cp::ArgListNull())
+#define __cprintf__(format, ...) \
+ cp::__cprintf(format, (*(new cp::ArgList), __VA_ARGS__))
+#define cprintf(...) \
+ __cprintf__(__VA_ARGS__, cp::ArgListNull())
//
// ccprintf(stream, format, args, ...) prints to the specified stream
@@ -148,10 +148,10 @@ __cprintf(const std::string &format, ArgList &args)
inline void
__ccprintf(std::ostream &stream, const std::string &format, ArgList &args)
{ args.dump(stream, format); delete &args; }
-#define __ccprintf__(stream, format, args...) \
- cp::__ccprintf(stream, format, (*(new cp::ArgList), args))
-#define ccprintf(stream, args...) \
- __ccprintf__(stream, args, cp::ArgListNull())
+#define __ccprintf__(stream, format, ...) \
+ cp::__ccprintf(stream, format, (*(new cp::ArgList), __VA_ARGS__))
+#define ccprintf(stream, ...) \
+ __ccprintf__(stream, __VA_ARGS__, cp::ArgListNull())
//
// csprintf(format, args, ...) returns a string
@@ -160,10 +160,10 @@ __ccprintf(std::ostream &stream, const std::string &format, ArgList &args)
inline std::string
__csprintf(const std::string &format, ArgList &args)
{ std::string s = args.dumpToString(format); delete &args; return s; }
-#define __csprintf__(format, args...) \
- cp::__csprintf(format, (*(new cp::ArgList), args))
-#define csprintf(args...) \
- __csprintf__(args, cp::ArgListNull())
+#define __csprintf__(format, ...) \
+ cp::__csprintf(format, (*(new cp::ArgList), __VA_ARGS__))
+#define csprintf(...) \
+ __csprintf__(__VA_ARGS__, cp::ArgListNull())
}
diff --git a/src/base/hashmap.hh b/src/base/hashmap.hh
index 570cbc152..b78cc02e8 100644
--- a/src/base/hashmap.hh
+++ b/src/base/hashmap.hh
@@ -59,7 +59,7 @@ namespace m5 {
//
namespace __hash_namespace {
-#if !defined(__LP64__) && !defined(__alpha__)
+#if !defined(__LP64__) && !defined(__alpha__) && !defined(__SUNPRO_CC)
template<>
struct hash<uint64_t> {
size_t operator()(uint64_t r) const {
diff --git a/src/base/hostinfo.cc b/src/base/hostinfo.cc
index a7c93e712..7cc07c11e 100644
--- a/src/base/hostinfo.cc
+++ b/src/base/hostinfo.cc
@@ -33,6 +33,7 @@
#include <math.h>
#include <unistd.h>
+#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <string>
diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc
index da5aa9552..7424b9305 100644
--- a/src/base/loader/object_file.cc
+++ b/src/base/loader/object_file.cc
@@ -101,7 +101,7 @@ ObjectFile::close()
}
if (fileData) {
- ::munmap(fileData, len);
+ ::munmap((char*)fileData, len);
fileData = NULL;
}
}
@@ -147,7 +147,7 @@ createObjectFile(const string &fname, bool raw)
// don't know what it is
close(fd);
- munmap(fileData, len);
+ munmap((char*)fileData, len);
return NULL;
}
diff --git a/src/base/misc.hh b/src/base/misc.hh
index 1c5720ce1..c12c2fe20 100644
--- a/src/base/misc.hh
+++ b/src/base/misc.hh
@@ -33,8 +33,13 @@
#define __MISC_HH__
#include <assert.h>
+#include "base/compiler.hh"
#include "base/cprintf.hh"
+#if defined(__SUNPRO_CC)
+#define __FUNCTION__ "how to fix me?"
+#endif
+
//
// This implements a cprintf based panic() function. panic() should
// be called when something happens that should never ever happen
@@ -43,12 +48,13 @@
//
//
void __panic(const std::string&, cp::ArgList &, const char*, const char*, int)
- __attribute__((noreturn));
-#define __panic__(format, args...) \
- __panic(format, (*(new cp::ArgList), args), \
- __FUNCTION__, __FILE__, __LINE__)
-#define panic(args...) \
- __panic__(args, cp::ArgListNull())
+ M5_ATTR_NORETURN;
+#define __panic__(format, ...) \
+ __panic(format, (*(new cp::ArgList), __VA_ARGS__), \
+ __FUNCTION__ , __FILE__, __LINE__)
+#define panic(...) \
+ __panic__(__VA_ARGS__, cp::ArgListNull())
+M5_PRAGMA_NORETURN(__panic)
//
// This implements a cprintf based fatal() function. fatal() should
@@ -59,32 +65,33 @@ void __panic(const std::string&, cp::ArgList &, const char*, const char*, int)
// panic() does.
//
void __fatal(const std::string&, cp::ArgList &, const char*, const char*, int)
- __attribute__((noreturn));
-#define __fatal__(format, args...) \
- __fatal(format, (*(new cp::ArgList), args), \
- __FUNCTION__, __FILE__, __LINE__)
-#define fatal(args...) \
- __fatal__(args, cp::ArgListNull())
+ M5_ATTR_NORETURN;
+#define __fatal__(format, ...) \
+ __fatal(format, (*(new cp::ArgList), __VA_ARGS__), \
+ __FUNCTION__ , __FILE__, __LINE__)
+#define fatal(...) \
+ __fatal__(__VA_ARGS__, cp::ArgListNull())
+M5_PRAGMA_NORETURN(__fatal)
//
// This implements a cprintf based warn
//
void __warn(const std::string&, cp::ArgList &, const char*, const char*, int);
-#define __warn__(format, args...) \
- __warn(format, (*(new cp::ArgList), args), \
- __FUNCTION__, __FILE__, __LINE__)
-#define warn(args...) \
- __warn__(args, cp::ArgListNull())
+#define __warn__(format, ...) \
+ __warn(format, (*(new cp::ArgList), __VA_ARGS__), \
+ __FUNCTION__ , __FILE__, __LINE__)
+#define warn(...) \
+ __warn__(__VA_ARGS__, cp::ArgListNull())
// Only print the warning message the first time it is seen. This
// doesn't check the warning string itself, it just only lets one
// warning come from the statement. So, even if the arguments change
// and that would have resulted in a different warning message,
// subsequent messages would still be supressed.
-#define warn_once(args...) do { \
+#define warn_once(...) do { \
static bool once = false; \
if (!once) { \
- __warn__(args, cp::ArgListNull()); \
+ __warn__(__VA_ARGS__, cp::ArgListNull()); \
once = true; \
} \
} while (0)
diff --git a/src/base/pollevent.cc b/src/base/pollevent.cc
index fd5b09d28..32724b74d 100644
--- a/src/base/pollevent.cc
+++ b/src/base/pollevent.cc
@@ -30,7 +30,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
-#if defined(__sun__)
+#if defined(__sun__) || defined(__SUNPRO_CC)
#include <sys/file.h>
#endif
diff --git a/src/base/random.cc b/src/base/random.cc
index 82c9e3566..0ccedcb00 100644
--- a/src/base/random.cc
+++ b/src/base/random.cc
@@ -29,12 +29,17 @@
* Ali Saidi
*/
+#if defined(__sun)
+#include <ieeefp.h>
+#endif
+#ifdef __SUNPRO_CC
+#include <stdlib.h>
+#include <math.h>
+#endif
+
#include <cstdlib>
#include <cmath>
-#if defined(__sun__)
-#include <ieeefp.h>
-#endif
#include "sim/param.hh"
#include "base/random.hh"
@@ -72,7 +77,7 @@ getLong()
double
m5round(double r)
{
-#if defined(__sun__)
+#if defined(__sun)
double val;
fp_rnd oldrnd = fpsetround(FP_RN);
val = rint(r);
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 59a9b87d5..2c0da48f0 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -610,7 +610,7 @@ BaseRemoteGDB::trap(int type)
uint64_t val;
size_t datalen, len;
char data[GDBPacketBufLen + 1];
- char buffer[gdbregs.bytes() * 2 + 256];
+ char *buffer;
const char *p;
char command, subcmd;
string var;
@@ -619,6 +619,8 @@ BaseRemoteGDB::trap(int type)
if (!attached)
return false;
+ buffer = (char*)malloc(gdbregs.bytes() * 2 + 256);
+
DPRINTF(GDBMisc, "trap: PC=%#x NPC=%#x\n",
context->readPC(), context->readNextPC());
@@ -916,6 +918,7 @@ BaseRemoteGDB::trap(int type)
}
out:
+ free(buffer);
return true;
}
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 577ea5eab..d8e8b4c15 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -50,6 +50,9 @@
#include <algorithm>
#include <cassert>
+#ifdef __SUNPRO_CC
+#include <math.h>
+#endif
#include <cmath>
#include <functional>
#include <iosfwd>
@@ -1410,7 +1413,7 @@ struct DistStor
else if (val > params.max)
overflow += number;
else {
- int index = (int)floor((val - params.min) / params.bucket_size);
+ int index = (int)std::floor((val - params.min) / params.bucket_size);
assert(index < size(params));
cvec[index] += number;
}
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index c4448efc9..ae0d65537 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -32,6 +32,10 @@
#define _GLIBCPP_USE_C99 1
#endif
+#if defined(__sun)
+#include <math.h>
+#endif
+
#include <iostream>
#include <sstream>
#include <fstream>
diff --git a/src/base/time.cc b/src/base/time.cc
index cbc7256ee..76ba355b7 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -105,7 +105,11 @@ Time::date(string format) const
char buf[256];
if (format.empty()) {
+#ifdef __SUNPRO_CC
+ ctime_r(&sec, buf, 256);
+#else
ctime_r(&sec, buf);
+#endif
buf[24] = '\0';
return buf;
}
diff --git a/src/base/time.hh b/src/base/time.hh
index 7aa4c50db..f10cc5d6c 100644
--- a/src/base/time.hh
+++ b/src/base/time.hh
@@ -97,7 +97,7 @@ std::ostream &operator<<(std::ostream &out, const Time &time);
* @(#)time.h 8.2 (Berkeley) 7/10/94
*/
-#if defined(__sun__)
+#if defined(__sun)
#define timersub(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
diff --git a/src/base/timebuf.hh b/src/base/timebuf.hh
index 1d0de8278..348f7a673 100644
--- a/src/base/timebuf.hh
+++ b/src/base/timebuf.hh
@@ -33,6 +33,7 @@
#define __BASE_TIMEBUF_HH__
#include <cassert>
+#include <cstring>
#include <vector>
template <class T>
@@ -143,7 +144,7 @@ class TimeBuffer
char *ptr = data;
for (int i = 0; i < size; i++) {
index[i] = ptr;
- memset(ptr, 0, sizeof(T));
+ std::memset(ptr, 0, sizeof(T));
new (ptr) T;
ptr += sizeof(T);
}
@@ -171,7 +172,7 @@ class TimeBuffer
if (ptr >= size)
ptr -= size;
(reinterpret_cast<T *>(index[ptr]))->~T();
- memset(index[ptr], 0, sizeof(T));
+ std::memset(index[ptr], 0, sizeof(T));
new (index[ptr]) T;
}
diff --git a/src/base/trace.hh b/src/base/trace.hh
index 9b053990c..a46643159 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -186,39 +186,39 @@ do { \
Trace::dataDump(curTick, name(), data, count); \
} while (0)
-#define __dprintf(cycle, name, format, args...) \
- Trace::dprintf(format, (*(new cp::ArgList), args), cycle, name)
+#define __dprintf(cycle, name, format, ...) \
+ Trace::dprintf(format, (*(new cp::ArgList), __VA_ARGS__), cycle, name)
-#define DPRINTF(x, args...) \
+#define DPRINTF(x, ...) \
do { \
if (Trace::IsOn(Trace::x)) \
- __dprintf(curTick, name(), args, cp::ArgListNull()); \
+ __dprintf(curTick, name(), __VA_ARGS__, cp::ArgListNull()); \
} while (0)
-#define DPRINTFR(x, args...) \
+#define DPRINTFR(x, ...) \
do { \
if (Trace::IsOn(Trace::x)) \
- __dprintf((Tick)-1, std::string(), args, cp::ArgListNull()); \
+ __dprintf((Tick)-1, std::string(), __VA_ARGS__, cp::ArgListNull()); \
} while (0)
-#define DPRINTFN(args...) \
+#define DPRINTFN(...) \
do { \
- __dprintf(curTick, name(), args, cp::ArgListNull()); \
+ __dprintf(curTick, name(), __VA_ARGS__, cp::ArgListNull()); \
} while (0)
-#define DPRINTFNR(args...) \
+#define DPRINTFNR(...) \
do { \
- __dprintf((Tick)-1, string(), args, cp::ArgListNull()); \
+ __dprintf((Tick)-1, string(), __VA_ARGS__, cp::ArgListNull()); \
} while (0)
#else // !TRACING_ON
#define DTRACE(x) (false)
#define DCOUT(x) if (0) DebugOut()
-#define DPRINTF(x, args...) do {} while (0)
-#define DPRINTFR(args...) do {} while (0)
-#define DPRINTFN(args...) do {} while (0)
-#define DPRINTFNR(args...) do {} while (0)
+#define DPRINTF(x, ...) do {} while (0)
+#define DPRINTFR(...) do {} while (0)
+#define DPRINTFN(...) do {} while (0)
+#define DPRINTFNR(...) do {} while (0)
#define DDUMP(x, data, count) do {} while (0)
#endif // TRACING_ON