From b647b48bf4d980e26b4626e94f1207ad66fc324e Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Mon, 6 Aug 2012 16:52:49 -0700 Subject: str: add an overloaded startswith() utility method for various string types and use it in a few places. --- src/sim/syscall_emul.hh | 4 ++-- src/sim/system.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sim') diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 0627d8d91..b2786e572 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -640,8 +640,8 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process, DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str()); int fd; - if (!path.compare(0, 6, "/proc/") || !path.compare(0, 8, "/system/") || - !path.compare(0, 10, "/platform/") || !path.compare(0, 5, "/sys/")) { + if (startswith(path, "/proc/") || startswith(path, "/system/") || + startswith(path, "/platform/") || startswith(path, "/sys/")) { // It's a proc/sys entery and requires special handling fd = OS::openSpecialFile(path, process, tc); return (fd == -1) ? -1 : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false); diff --git a/src/sim/system.cc b/src/sim/system.cc index 67fb7480a..20fcbd948 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -51,6 +51,7 @@ #include "arch/vtophys.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" +#include "base/str.hh" #include "base/trace.hh" #include "config/the_isa.hh" #include "cpu/thread_context.hh" @@ -402,8 +403,7 @@ MasterID System::getMasterId(std::string master_name) { // strip off system name if the string starts with it - if (master_name.size() > name().size() && - master_name.compare(0, name().size(), name()) == 0) + if (startswith(master_name, name())) master_name = master_name.erase(0, name().size() + 1); // CPUs in switch_cpus ask for ids again after switching -- cgit v1.2.3