From 21cf4a46b9e9ce52266aac873aa107cad82cc847 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Sat, 4 Nov 2006 21:41:01 -0500 Subject: fixes so that M5 will compile under solaris SConstruct: Add check to see if we need to include libsocket src/arch/sparc/floatregfile.cc: src/arch/sparc/intregfile.cc: use memset rather than bzero and include the appropriate headerfile src/base/pollevent.cc: If we're compling under solaris we need sys/file.h src/base/random.cc: src/base/random.hh: solaris doesn't have random(), so use rint with the correct rounding mode if we're compiling on solaris src/base/stats/flags.hh: u_int32_t?? src/base/time.hh: grab the timersub() define from freebsd since it doesn't exist in solaris src/cpu/inst_seq.hh: we don't need to include stdint here src/sim/byteswap.hh: the method to detect endianness on Solaris is a little more complex... --HG-- extra : convert_revision : 6b7db0e900e7bccfc250d65c125065f27280dda1 --- src/base/random.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/base/random.cc') diff --git a/src/base/random.cc b/src/base/random.cc index e135b55f5..82c9e3566 100644 --- a/src/base/random.cc +++ b/src/base/random.cc @@ -32,6 +32,10 @@ #include #include +#if defined(__sun__) +#include +#endif + #include "sim/param.hh" #include "base/random.hh" #include "base/trace.hh" @@ -65,12 +69,27 @@ getLong() return mrand48(); } +double +m5round(double r) +{ +#if defined(__sun__) + double val; + fp_rnd oldrnd = fpsetround(FP_RN); + val = rint(r); + fpsetround(oldrnd); + return val; +#else + return round(r); +#endif +} + int64_t getUniform(int64_t min, int64_t max) { double r; r = drand48() * (max-min) + min; - return (int64_t)round(r); + + return (int64_t)m5round(r); } uint64_t @@ -78,7 +97,8 @@ getUniformPos(uint64_t min, uint64_t max) { double r; r = drand48() * (max-min) + min; - return (uint64_t)round(r); + + return (uint64_t)m5round(r); } -- cgit v1.2.3