Giacomo Travaglini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/51490 )
Change subject: misc: Using OS::off_t in syscall signature
......................................................................
misc: Using OS::off_t in syscall signature
Change-Id: Iefa1e207a3e825959b0fe8df30e6be182d73a0f8
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/arch/mips/linux/se_workload.cc
M src/arch/power/linux/se_workload.cc
M src/arch/riscv/linux/se_workload.cc
M src/arch/x86/linux/syscall_tbl32.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
M src/arch/arm/linux/se_workload.cc
M src/arch/x86/linux/syscall_tbl64.cc
8 files changed, 92 insertions(+), 89 deletions(-)
diff --git a/src/arch/arm/linux/se_workload.cc
b/src/arch/arm/linux/se_workload.cc
index c715e1d..3755dec 100644
--- a/src/arch/arm/linux/se_workload.cc
+++ b/src/arch/arm/linux/se_workload.cc
@@ -223,8 +223,8 @@
{ base + 89, "readdir" },
{ base + 90, "mmap", mmapFunc<ArmLinux32> },
{ base + 91, "munmap", munmapFunc<ArmLinux32> },
- { base + 92, "truncate", truncateFunc },
- { base + 93, "ftruncate", ftruncateFunc },
+ { base + 92, "truncate", truncateFunc<ArmLinux32> },
+ { base + 93, "ftruncate", ftruncateFunc<ArmLinux32> },
{ base + 94, "fchmod" },
{ base + 95, "fchown", fchownFunc },
{ base + 96, "getpriority" },
@@ -545,7 +545,7 @@
{ base + 44, "fstatfs64" },
{ base + 45, "truncate64" },
{ base + 46, "ftruncate64", ftruncate64Func },
- { base + 47, "fallocate", fallocateFunc },
+ { base + 47, "fallocate", fallocateFunc<ArmLinux64> },
{ base + 48, "faccessat", faccessatFunc<ArmLinux64> },
{ base + 49, "chdir" },
{ base + 50, "fchdir" },
@@ -781,8 +781,8 @@
{ base + 1044, "eventfd" },
{ base + 1045, "signalfd" },
{ base + 1046, "sendfile" },
- { base + 1047, "ftruncate", ftruncateFunc },
- { base + 1048, "truncate", truncateFunc },
+ { base + 1047, "ftruncate", ftruncateFunc<ArmLinux64> },
+ { base + 1048, "truncate", truncateFunc<ArmLinux64> },
{ base + 1049, "stat", statFunc<ArmLinux64> },
{ base + 1050, "lstat" },
{ base + 1051, "fstat", fstatFunc<ArmLinux64> },
diff --git a/src/arch/mips/linux/se_workload.cc
b/src/arch/mips/linux/se_workload.cc
index 09752d1..6767bf7 100644
--- a/src/arch/mips/linux/se_workload.cc
+++ b/src/arch/mips/linux/se_workload.cc
@@ -250,8 +250,8 @@
{ 4089, "readdir" },
{ 4090, "mmap", mmapFunc<MipsLinux> },
{ 4091, "munmap",munmapFunc<MipsLinux> },
- { 4092, "truncate", truncateFunc },
- { 4093, "ftruncate", ftruncateFunc },
+ { 4092, "truncate", truncateFunc<MipsLinux> },
+ { 4093, "ftruncate", ftruncateFunc<MipsLinux> },
{ 4094, "fchmod", fchmodFunc<MipsLinux> },
{ 4095, "fchown", fchownFunc },
{ 4096, "getpriority" },
diff --git a/src/arch/power/linux/se_workload.cc
b/src/arch/power/linux/se_workload.cc
index 975d5dd..9b54fd8 100644
--- a/src/arch/power/linux/se_workload.cc
+++ b/src/arch/power/linux/se_workload.cc
@@ -199,8 +199,8 @@
{ 89, "readdir" },
{ 90, "mmap", mmapFunc<PowerLinux> },
{ 91, "munmap",munmapFunc<PowerLinux> },
- { 92, "truncate", truncateFunc },
- { 93, "ftruncate", ftruncateFunc },
+ { 92, "truncate", truncateFunc<PowerLinux> },
+ { 93, "ftruncate", ftruncateFunc<PowerLinux> },
{ 94, "fchmod" },
{ 95, "fchown" },
{ 96, "getpriority" },
diff --git a/src/arch/riscv/linux/se_workload.cc
b/src/arch/riscv/linux/se_workload.cc
index 3b0079d..2e2a7d2 100644
--- a/src/arch/riscv/linux/se_workload.cc
+++ b/src/arch/riscv/linux/se_workload.cc
@@ -169,9 +169,9 @@
{ 42, "nfsservctl" },
{ 43, "statfs", statfsFunc<RiscvLinux64> },
{ 44, "fstatfs", fstatfsFunc<RiscvLinux64> },
- { 45, "truncate", truncateFunc },
+ { 45, "truncate", truncateFunc<RiscvLinux64> },
{ 46, "ftruncate", ftruncate64Func },
- { 47, "fallocate", fallocateFunc },
+ { 47, "fallocate", fallocateFunc<RiscvLinux64> },
{ 48, "faccessat", faccessatFunc<RiscvLinux64> },
{ 49, "chdir" },
{ 50, "fchdir" },
@@ -500,9 +500,9 @@
{ 42, "nfsservctl" },
{ 43, "statfs", statfsFunc<RiscvLinux32> },
{ 44, "fstatfs", fstatfsFunc<RiscvLinux32> },
- { 45, "truncate", truncateFunc },
- { 46, "ftruncate", ftruncateFunc },
- { 47, "fallocate", fallocateFunc },
+ { 45, "truncate", truncateFunc<RiscvLinux32> },
+ { 46, "ftruncate", ftruncateFunc<RiscvLinux32> },
+ { 47, "fallocate", fallocateFunc<RiscvLinux32> },
{ 48, "faccessat", faccessatFunc<RiscvLinux32> },
{ 49, "chdir" },
{ 50, "fchdir" },
@@ -749,8 +749,8 @@
{ 1044, "eventfd" },
{ 1045, "signalfd" },
{ 1046, "sendfile" },
- { 1047, "ftruncate", ftruncateFunc },
- { 1048, "truncate", truncateFunc },
+ { 1047, "ftruncate", ftruncateFunc<RiscvLinux32> },
+ { 1048, "truncate", truncateFunc<RiscvLinux32> },
{ 1049, "stat", statFunc<RiscvLinux32> },
{ 1050, "lstat", lstatFunc<RiscvLinux32> },
{ 1051, "fstat", fstatFunc<RiscvLinux32> },
diff --git a/src/arch/x86/linux/syscall_tbl32.cc
b/src/arch/x86/linux/syscall_tbl32.cc
index 43b2a71..7f8e905 100644
--- a/src/arch/x86/linux/syscall_tbl32.cc
+++ b/src/arch/x86/linux/syscall_tbl32.cc
@@ -131,8 +131,8 @@
{ 89, "readdir" },
{ 90, "mmap" },
{ 91, "munmap", munmapFunc<X86Linux32> },
- { 92, "truncate", truncateFunc },
- { 93, "ftruncate", ftruncateFunc },
+ { 92, "truncate", truncateFunc<X86Linux32> },
+ { 93, "ftruncate", ftruncateFunc<X86Linux32> },
{ 94, "fchmod" },
{ 95, "fchown" },
{ 96, "getpriority" },
diff --git a/src/arch/x86/linux/syscall_tbl64.cc
b/src/arch/x86/linux/syscall_tbl64.cc
index b6c5103..f22ff20 100644
--- a/src/arch/x86/linux/syscall_tbl64.cc
+++ b/src/arch/x86/linux/syscall_tbl64.cc
@@ -115,8 +115,8 @@
{ 73, "flock" },
{ 74, "fsync" },
{ 75, "fdatasync", ignoreFunc },
- { 76, "truncate", truncateFunc },
- { 77, "ftruncate", ftruncateFunc },
+ { 76, "truncate", truncateFunc<X86Linux64> },
+ { 77, "ftruncate", ftruncateFunc<X86Linux64> },
#if defined(SYS_getdents)
{ 78, "getdents", getdentsFunc },
#else
@@ -332,7 +332,7 @@
{ 282, "signalfd" },
{ 283, "timerfd_create" },
{ 284, "eventfd", eventfdFunc<X86Linux64> },
- { 285, "fallocate", fallocateFunc },
+ { 285, "fallocate", fallocateFunc<X86Linux64> },
{ 286, "timerfd_settime" },
{ 287, "timerfd_gettime" },
{ 288, "accept4" },
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 45f14be..35f047d 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -486,37 +486,6 @@
SyscallReturn
-truncateFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
- off_t length)
-{
- std::string path;
- auto p = tc->getProcessPtr();
-
- if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
- return -EFAULT;
-
- // Adjust path for cwd and redirection
- path = p->checkPathRedirect(path);
-
- int result = truncate(path.c_str(), length);
- return (result == -1) ? -errno : result;
-}
-
-SyscallReturn
-ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t
length)
-{
- auto p = tc->getProcessPtr();
-
- auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
- if (!ffdp)
- return -EBADF;
- int sim_fd = ffdp->getSimFD();
-
- int result = ftruncate(sim_fd, length);
- return (result == -1) ? -errno : result;
-}
-
-SyscallReturn
truncate64Func(SyscallDesc *desc, ThreadContext *tc,
VPtr<> pathname, int64_t length)
{
@@ -927,28 +896,6 @@
}
SyscallReturn
-fallocateFunc(SyscallDesc *desc, ThreadContext *tc,
- int tgt_fd, int mode, off_t offset, off_t len)
-{
-#if defined(__linux__)
- auto p = tc->getProcessPtr();
-
- auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
- if (!ffdp)
- return -EBADF;
- int sim_fd = ffdp->getSimFD();
-
- int result = fallocate(sim_fd, mode, offset, len);
- if (result < 0)
- return -errno;
- return 0;
-#else
- warnUnsupportedOS("fallocate");
- return -1;
-#endif
-}
-
-SyscallReturn
accessFunc(SyscallDesc *desc, ThreadContext *tc,
VPtr<> pathname, mode_t mode)
{
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 0923e63..be30797 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -140,10 +140,6 @@
SyscallReturn
ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc);
-// Target fallocateFunc() handler.
-SyscallReturn fallocateFunc(SyscallDesc *desc, ThreadContext *tc,
- int tgt_fd, int mode, off_t offset, off_t len);
-
/// Target exit() handler: terminate current context.
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status);
@@ -218,17 +214,6 @@
SyscallReturn renameImpl(SyscallDesc *desc, ThreadContext *tc,
std::string oldpath, std::string newpath);
-
-/// Target truncate() handler.
-SyscallReturn truncateFunc(SyscallDesc *desc, ThreadContext *tc,
- VPtr<> pathname, off_t length);
-
-
-/// Target ftruncate() handler.
-SyscallReturn ftruncateFunc(SyscallDesc *desc, ThreadContext *tc,
- int tgt_fd, off_t length);
-
-
/// Target truncate64() handler.
SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc,
VPtr<> pathname, int64_t length);
@@ -2877,6 +2862,67 @@
return 0;
}
+// Target fallocate() handler.
+template <typename OS>
+SyscallReturn
+fallocateFunc(SyscallDesc *desc, ThreadContext *tc,
+ int tgt_fd, int mode, typename OS::off_t offset,
+ typename OS::off_t len)
+{
+#if defined(__linux__)
+ auto p = tc->getProcessPtr();
+
+ auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
+ if (!ffdp)
+ return -EBADF;
+ int sim_fd = ffdp->getSimFD();
+
+ int result = fallocate(sim_fd, mode, offset, len);
+ if (result < 0)
+ return -errno;
+ return 0;
+#else
+ warnUnsupportedOS("fallocate");
+ return -1;
+#endif
+}
+
+/// Target truncate() handler.
+template <typename OS>
+SyscallReturn
+truncateFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname,
+ typename OS::off_t length)
+{
+ std::string path;
+ auto p = tc->getProcessPtr();
+
+ if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
+ return -EFAULT;
+
+ // Adjust path for cwd and redirection
+ path = p->checkPathRedirect(path);
+
+ int result = truncate(path.c_str(), length);
+ return (result == -1) ? -errno : result;
+}
+
+/// Target ftruncate() handler.
+template <typename OS>
+SyscallReturn
+ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd,
+ typename OS::off_t length)
+{
+ auto p = tc->getProcessPtr();
+
+ auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
+ if (!ffdp)
+ return -EBADF;
+ int sim_fd = ffdp->getSimFD();
+
+ int result = ftruncate(sim_fd, length);
+ return (result == -1) ? -errno : result;
+}
+
} // namespace gem5
#endif // __SIM_SYSCALL_EMUL_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51490
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iefa1e207a3e825959b0fe8df30e6be182d73a0f8
Gerrit-Change-Number: 51490
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s