Merge zeep.pool:/z/saidi/work/m5.newmem

into  zeep.pool:/z/saidi/work/m5.suncc

--HG--
extra : convert_revision : 20f61a524a3b53fc0afcf53a24b5a1fe1d96f579
This commit is contained in:
Ali Saidi
2007-01-26 18:49:40 -05:00
52 changed files with 236 additions and 134 deletions

View File

@@ -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;

View File

@@ -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
}
};

View File

@@ -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())
}

View File

@@ -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 {

View File

@@ -33,6 +33,7 @@
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <string>

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -32,6 +32,10 @@
#define _GLIBCPP_USE_C99 1
#endif
#if defined(__sun)
#include <math.h>
#endif
#include <iostream>
#include <sstream>
#include <fstream>

View File

@@ -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;
}

View File

@@ -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; \

View File

@@ -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;
}

View File

@@ -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