summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-11-22 00:27:52 -0800
committerGabe Black <gabeblack@google.com>2019-12-04 04:29:50 +0000
commit8b44fb7181d227d88f58d1dab7c64584070d4599 (patch)
treef78aae7314c975c06a2ffa996c1f36b7ca217f82 /src/sim
parentf135fc9cbe2adecfe0f5a5120fc2c4765390ef75 (diff)
downloadgem5-8b44fb7181d227d88f58d1dab7c64584070d4599.tar.xz
sim: Change the syscall executor to a std::function.
This will enable using other types of callable like a lambda. Jira Issue: https://gem5.atlassian.net/browse/GEM5-187 Change-Id: If9f7176205492830824b5fe3c00f2c7710f57f70 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23164 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_desc.cc3
-rw-r--r--src/sim/syscall_desc.hh13
2 files changed, 7 insertions, 9 deletions
diff --git a/src/sim/syscall_desc.cc b/src/sim/syscall_desc.cc
index fb39c11b2..345bfa114 100644
--- a/src/sim/syscall_desc.cc
+++ b/src/sim/syscall_desc.cc
@@ -43,7 +43,6 @@
#include "sim/faults.hh"
#include "sim/process.hh"
#include "sim/syscall_debug_macros.hh"
-#include "sim/syscall_return.hh"
void
SyscallDesc::doSyscall(int callnum, ThreadContext *tc, Fault *fault)
@@ -69,7 +68,7 @@ SyscallDesc::doSyscall(int callnum, ThreadContext *tc, Fault *fault)
_name, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
/** Invoke the system call */
- SyscallReturn retval = (*executor)(this, callnum, tc);
+ SyscallReturn retval = executor(this, callnum, tc);
/**
* If the system call needs to be restarted, most likely due to
diff --git a/src/sim/syscall_desc.hh b/src/sim/syscall_desc.hh
index 0b226438a..8f6e33d89 100644
--- a/src/sim/syscall_desc.hh
+++ b/src/sim/syscall_desc.hh
@@ -46,13 +46,14 @@
#ifndef __SIM_SYSCALL_DESC_HH__
#define __SIM_SYSCALL_DESC_HH__
+#include <functional>
#include <string>
#include "base/types.hh"
+#include "sim/syscall_return.hh"
class Process;
class SyscallDesc;
-class SyscallReturn;
class ThreadContext;
SyscallReturn unimplementedFunc(SyscallDesc *desc, int num,
@@ -66,15 +67,13 @@ SyscallReturn unimplementedFunc(SyscallDesc *desc, int num,
*/
class SyscallDesc {
public:
- /** Typedef the function pointer here to clean up code below */
- typedef SyscallReturn (*SyscallExecutor)(SyscallDesc*, int num,
- ThreadContext*);
+ using SyscallExecutor =
+ std::function<SyscallReturn(SyscallDesc *, int num, ThreadContext *)>;
SyscallDesc(const char *name,
- SyscallExecutor sys_exec=unimplementedFunc, int flags=0)
+ SyscallExecutor sys_exec=unimplementedFunc, int flags=0)
: _name(name), executor(sys_exec), _flags(flags), _warned(false)
- {
- }
+ {}
/** Provide a mechanism to specify behavior for abnormal system calls */
enum Flags {