summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-01-27 01:59:20 -0500
committerGabe Black <gblack@eecs.umich.edu>2007-01-27 01:59:20 -0500
commit0358ccee23072eef0b6448e3170457037682a452 (patch)
tree378b5ba325d74536092a7f245423d81274db38b4 /src/base
parente41f54f97f9ebdea32cc6498c346636cddc9e06d (diff)
parent5c7bf74c073d0aea808046d10dfcaa6c319217a3 (diff)
downloadgem5-0358ccee23072eef0b6448e3170457037682a452.tar.xz
Merge zizzer:/bk/newmem
into zower.eecs.umich.edu:/eecshome/m5/newmem src/arch/sparc/isa/formats/mem/util.isa: src/arch/sparc/isa_traits.hh: src/arch/sparc/system.cc: Hand Merge --HG-- extra : convert_revision : d5e0c97caebb616493e2f642e915969d7028109c
Diffstat (limited to 'src/base')
-rw-r--r--src/base/compiler.hh52
-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
17 files changed, 143 insertions, 61 deletions
diff --git a/src/base/compiler.hh b/src/base/compiler.hh
new file mode 100644
index 000000000..5f2e9d7af
--- /dev/null
+++ b/src/base/compiler.hh
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2006 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Ali Saidi
+ */
+
+#ifndef __BASE_COMPILER_HH__
+#define __BASE_COMPILER_HH__
+
+//http://msdn2.microsoft.com/en-us/library/ms937669.aspx
+//http://msdn2.microsoft.com/en-us/library/aa448724.aspx
+//http://docs.sun.com/source/819-3688/sun.specific.html#marker-998278
+//http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Function-Attributes.html#Function%20Attributes
+
+#if defined(__GNUC__)
+#define M5_ATTR_NORETURN __attribute__((noreturn))
+#define M5_PRAGMA_NORETURN(x)
+#define M5_DUMMY_RETURN
+#elif defined(__SUNPRO_CC)
+// this doesn't do anything with sun cc, but why not
+#define M5_ATTR_NORETURN __sun_attr__((__noreturn__))
+#define M5_DUMMY_RETURN return (0);
+#define M5_PRAGMA_NORETURN(x) _Pragma("does_not_return(x)")
+#else
+#error "Need to define compiler options in base/compiler.hh"
+#endif
+
+#endif // __BASE_COMPILER_HH__
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 b1f50755b..988b50c65 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -631,7 +631,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;
@@ -640,6 +640,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());
@@ -937,6 +939,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