diff options
-rw-r--r-- | arch/alpha/alpha_tru64_process.cc | 53 | ||||
-rw-r--r-- | base/hostinfo.cc | 2 | ||||
-rw-r--r-- | base/inifile.cc | 5 | ||||
-rw-r--r-- | base/stats/events.cc | 11 | ||||
-rw-r--r-- | cpu/beta_cpu/btb.cc | 5 | ||||
-rw-r--r-- | cpu/beta_cpu/comm.hh | 2 | ||||
-rw-r--r-- | cpu/beta_cpu/inst_queue.hh | 2 | ||||
-rw-r--r-- | cpu/beta_cpu/sat_counter.hh | 2 |
8 files changed, 47 insertions, 35 deletions
diff --git a/arch/alpha/alpha_tru64_process.cc b/arch/alpha/alpha_tru64_process.cc index 6fe4290e8..4d73e711f 100644 --- a/arch/alpha/alpha_tru64_process.cc +++ b/arch/alpha/alpha_tru64_process.cc @@ -26,32 +26,39 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> // for host open() flags #include <sys/types.h> #include <sys/stat.h> +#if defined(__OpenBSD__) +#include <sys/param.h> +#include <sys/mount.h> +#else #include <sys/statfs.h> -#include <string.h> // for memset() +#endif + #include <dirent.h> +#include <errno.h> +#include <fcntl.h> // for host open() flags +#include <string.h> // for memset() +#include <unistd.h> -#include "sim/host.hh" +#include "arch/alpha/alpha_common_syscall_emul.hh" +#include "arch/alpha/alpha_tru64_process.hh" +#include "base/trace.hh" #include "cpu/base_cpu.hh" -#include "mem/functional_mem/functional_memory.hh" -#include "sim/process.hh" #include "cpu/exec_context.hh" +#include "mem/functional_mem/functional_memory.hh" #include "sim/fake_syscall.hh" - -#include "arch/alpha/alpha_common_syscall_emul.hh" -#include "arch/alpha/alpha_tru64_process.hh" - +#include "sim/host.hh" +#include "sim/process.hh" +#include "sim/root.hh" #include "sim/syscall_emul.hh" -#include "sim/root.hh" // for curTick & ticksPerSecond - -#include "base/trace.hh" using namespace std; +typedef struct stat global_stat; +typedef struct statfs global_statfs; +typedef struct dirent global_dirent; + /// /// This class encapsulates the types, structures, constants, /// functions, and syscall-number mappings specific to the Alpha Tru64 @@ -530,7 +537,7 @@ class Tru64 { /// memory space. Used by stat(), fstat(), and lstat(). template <class T> static void - copyOutStatBuf(FunctionalMemory *mem, Addr addr, struct ::stat *host) + copyOutStatBuf(FunctionalMemory *mem, Addr addr, global_stat *host) { TypedBufferArg<T> tgt(addr); @@ -556,11 +563,15 @@ class Tru64 { /// memory space. Used by statfs() and fstatfs(). template <class T> static void - copyOutStatfsBuf(FunctionalMemory *mem, Addr addr, struct ::statfs *host) + copyOutStatfsBuf(FunctionalMemory *mem, Addr addr, global_statfs *host) { TypedBufferArg<T> tgt(addr); +#if defined(__OpenBSD__) + tgt->f_type = 0; +#else tgt->f_type = host->f_type; +#endif tgt->f_bsize = host->f_bsize; tgt->f_blocks = host->f_blocks; tgt->f_bfree = host->f_bfree; @@ -575,13 +586,13 @@ class Tru64 { class F64 { public: static void copyOutStatBuf(FunctionalMemory *mem, Addr addr, - struct ::stat *host) + global_stat *host) { Tru64::copyOutStatBuf<Tru64::F64_stat>(mem, addr, host); } static void copyOutStatfsBuf(FunctionalMemory *mem, Addr addr, - struct ::statfs *host) + global_statfs *host) { Tru64::copyOutStatfsBuf<Tru64::F64_statfs>(mem, addr, host); } @@ -590,13 +601,13 @@ class Tru64 { class PreF64 { public: static void copyOutStatBuf(FunctionalMemory *mem, Addr addr, - struct ::stat *host) + global_stat *host) { Tru64::copyOutStatBuf<Tru64::pre_F64_stat>(mem, addr, host); } static void copyOutStatfsBuf(FunctionalMemory *mem, Addr addr, - struct ::statfs *host) + global_statfs *host) { Tru64::copyOutStatfsBuf<Tru64::pre_F64_statfs>(mem, addr, host); } @@ -826,7 +837,7 @@ class Tru64 { char *host_buf_ptr = host_buf; char *host_buf_end = host_buf + host_result; while (host_buf_ptr < host_buf_end) { - struct ::dirent *host_dp = (struct ::dirent *)host_buf_ptr; + global_dirent *host_dp = (global_dirent *)host_buf_ptr; int namelen = strlen(host_dp->d_name); // Actual size includes padded string rounded up for alignment. diff --git a/base/hostinfo.cc b/base/hostinfo.cc index cb5c04efc..6d07c957e 100644 --- a/base/hostinfo.cc +++ b/base/hostinfo.cc @@ -70,7 +70,7 @@ procInfo(char *filename, char *target) while (fp && !feof(fp) && !done) { if (fgets(line, 80, fp)) { if (strncmp(line, target, strlen(target)) == 0) { - sprintf(format, "%s %%lld", target); + snprintf(format, sizeof(format), "%s %%lld", target); sscanf(line, format, &usage); fclose(fp); diff --git a/base/inifile.cc b/base/inifile.cc index 862e4082f..cbb506c8b 100644 --- a/base/inifile.cc +++ b/base/inifile.cc @@ -79,7 +79,8 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs) tmpf.close(); - char *cfile = strcpy(new char[file.size() + 1], file.c_str()); + char *cfile = strncpy(new char[file.size() + 1], file.c_str(), + file.size()); char *dir = dirname(cfile); char *dir_arg = NULL; if (*dir != '.') { @@ -87,7 +88,7 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs) arg += dir; dir_arg = new char[arg.size() + 1]; - strcpy(dir_arg, arg.c_str()); + strncpy(dir_arg, arg.c_str(), arg.size()); } delete [] cfile; diff --git a/base/stats/events.cc b/base/stats/events.cc index dd7ec2ccf..e083cf0da 100644 --- a/base/stats/events.cc +++ b/base/stats/events.cc @@ -140,6 +140,10 @@ InsertEvent::insert(const string &stat) void InsertEvent::flush() { + static const char query_header[] = "INSERT INTO " + "events(ev_event, ev_run, ev_tick)" + "values"; + if (size) { MySQL::Connection &mysql = MySqlDB.conn(); assert(mysql.connected()); @@ -147,12 +151,9 @@ InsertEvent::flush() } query[0] = '\0'; - size = 0; + size = sizeof(query_header); first = true; - strcpy(query, "INSERT INTO " - "events(ev_event, ev_run, ev_tick)" - "values"); - size = strlen(query); + memcpy(query, query_header, size); } void diff --git a/cpu/beta_cpu/btb.cc b/cpu/beta_cpu/btb.cc index 65b7fffa4..92864dbaa 100644 --- a/cpu/beta_cpu/btb.cc +++ b/cpu/beta_cpu/btb.cc @@ -26,8 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <math.h> - +#include "base/intmath.hh" #include "base/trace.hh" #include "cpu/beta_cpu/btb.hh" @@ -53,7 +52,7 @@ DefaultBTB::DefaultBTB(unsigned _numEntries, tagMask = (1 << tagBits) - 1; - tagShiftAmt = instShiftAmt + (int)log2(numEntries); + tagShiftAmt = instShiftAmt + FloorLog2(numEntries); } inline diff --git a/cpu/beta_cpu/comm.hh b/cpu/beta_cpu/comm.hh index 61660d39f..475ab8df8 100644 --- a/cpu/beta_cpu/comm.hh +++ b/cpu/beta_cpu/comm.hh @@ -29,11 +29,11 @@ #ifndef __CPU_BETA_CPU_COMM_HH__ #define __CPU_BETA_CPU_COMM_HH__ -#include <stdint.h> #include <vector> #include "arch/alpha/isa_traits.hh" #include "cpu/inst_seq.hh" +#include "sim/host.hh" // Find better place to put this typedef. // The impl might be the best place for this. diff --git a/cpu/beta_cpu/inst_queue.hh b/cpu/beta_cpu/inst_queue.hh index 7d726c27f..02dc1222d 100644 --- a/cpu/beta_cpu/inst_queue.hh +++ b/cpu/beta_cpu/inst_queue.hh @@ -32,12 +32,12 @@ #include <list> #include <map> #include <queue> -#include <stdint.h> #include <vector> #include "base/statistics.hh" #include "base/timebuf.hh" #include "cpu/inst_seq.hh" +#include "sim/host.hh" /** * A standard instruction queue class. It holds ready instructions, in diff --git a/cpu/beta_cpu/sat_counter.hh b/cpu/beta_cpu/sat_counter.hh index 5b32774cc..5455ca56a 100644 --- a/cpu/beta_cpu/sat_counter.hh +++ b/cpu/beta_cpu/sat_counter.hh @@ -29,7 +29,7 @@ #ifndef __CPU_BETA_CPU_SAT_COUNTER_HH__ #define __CPU_BETA_CPU_SAT_COUNTER_HH__ -#include <stdint.h> +#include "sim/host.hh" /** * Private counter class for the internal saturating counters. |