diff options
Diffstat (limited to 'sim/syscall_emul.hh')
-rw-r--r-- | sim/syscall_emul.hh | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index 831708a21..5f1b8144e 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -54,7 +54,7 @@ class SyscallDesc { public: /// Typedef for target syscall handler functions. - typedef int (*FuncPtr)(SyscallDesc *, int num, + typedef SyscallReturn (*FuncPtr)(SyscallDesc *, int num, Process *, ExecContext *); const char *name; //!< Syscall name (e.g., "open"). @@ -158,46 +158,46 @@ class TypedBufferArg : public BaseBufferArg /// Handler for unimplemented syscalls that we haven't thought about. -int unimplementedFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn unimplementedFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Handler for unimplemented syscalls that we never intend to /// implement (signal handling, etc.) and should not affect the correct /// behavior of the program. Print a warning only if the appropriate /// trace flag is enabled. Return success to the target program. -int ignoreFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn ignoreFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target exit() handler: terminate simulation. -int exitFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn exitFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target getpagesize() handler. -int getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target obreak() handler: set brk address. -int obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target close() handler. -int closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target read() handler. -int readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target write() handler. -int writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target lseek() handler. -int lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target munmap() handler. -int munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target gethostname() handler. -int gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target unlink() handler. -int unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// Target rename() handler. -int renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); +SyscallReturn renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc); /// This struct is used to build an target-OS-dependent table that /// maps the target's open() flags to the host open() flags. @@ -240,7 +240,7 @@ getElapsedTime(T1 &sec, T2 &usec) /// only to find out if their stdout is a tty, to determine whether to /// do line or block buffering. template <class OS> -int +SyscallReturn ioctlFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { @@ -251,7 +251,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, Process *process, if (fd < 0 || process->sim_fd(fd) < 0) { // doesn't map to any simulator fd: not a valid target fd - return -EBADF; + return SyscallReturn(-EBADF); } switch (req) { @@ -263,7 +263,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, Process *process, case OS::TIOCGETC: case OS::TIOCGETS: case OS::TIOCGETA: - return -ENOTTY; + return SyscallReturn(-ENOTTY); default: fatal("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ 0x%llx\n", fd, req, xc->readPC()); @@ -272,20 +272,20 @@ ioctlFunc(SyscallDesc *desc, int callnum, Process *process, /// Target open() handler. template <class OS> -int +SyscallReturn openFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { std::string path; if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; + return SyscallReturn(-EFAULT); if (path == "/dev/sysdev0") { // This is a memory-mapped high-resolution timer device on Alpha. // We don't support it, so just punt. DCOUT(SyscallWarnings) << "Ignoring open(" << path << ", ...)" << std::endl; - return -ENOENT; + return SyscallReturn(-ENOENT); } int tgtFlags = xc->getSyscallArg(1); @@ -311,58 +311,58 @@ openFunc(SyscallDesc *desc, int callnum, Process *process, // open the file int fd = open(path.c_str(), hostFlags, mode); - return (fd == -1) ? -errno : process->open_fd(fd); + return (fd == -1) ? SyscallReturn(-errno) : SyscallReturn(process->open_fd(fd)); } /// Target stat() handler. template <class OS> -int +SyscallReturn statFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { std::string path; if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; + return SyscallReturn(-EFAULT); struct stat hostBuf; int result = stat(path.c_str(), &hostBuf); if (result < 0) - return -errno; + return SyscallReturn(errno); OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); - return 0; + return SyscallReturn(0); } /// Target lstat() handler. template <class OS> -int +SyscallReturn lstatFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { std::string path; if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; + return SyscallReturn(-EFAULT); struct stat hostBuf; int result = lstat(path.c_str(), &hostBuf); if (result < 0) - return -errno; + return SyscallReturn(-errno); OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); - return 0; + return SyscallReturn(0); } /// Target fstat() handler. template <class OS> -int +SyscallReturn fstatFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { @@ -371,17 +371,17 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process, // DPRINTFR(SyscallVerbose, "fstat(%d, ...)\n", fd); if (fd < 0) - return -EBADF; + return SyscallReturn(-EBADF); struct stat hostBuf; int result = fstat(fd, &hostBuf); if (result < 0) - return -errno; + return SyscallReturn(-errno); OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); - return 0; + return SyscallReturn(0); } @@ -398,7 +398,7 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process, /// file descriptor, and fail (or implement!) a non-anonymous mmap to /// anything else. template <class OS> -int +SyscallReturn mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { Addr start = xc->getSyscallArg(0); @@ -419,12 +419,12 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) "This will break if not /dev/zero.", xc->getSyscallArg(4)); } - return start; + return SyscallReturn(start); } /// Target getrlimit() handler. template <class OS> -int +SyscallReturn getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { @@ -444,12 +444,12 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, } rlp.copyOut(xc->mem); - return 0; + return SyscallReturn(0); } /// Target gettimeofday() handler. template <class OS> -int +SyscallReturn gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { @@ -460,13 +460,13 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process, tp.copyOut(xc->mem); - return 0; + return SyscallReturn(0); } /// Target getrusage() function. template <class OS> -int +SyscallReturn getrusageFunc(SyscallDesc *desc, int callnum, Process *process, ExecContext *xc) { @@ -501,7 +501,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process, rup.copyOut(xc->mem); - return 0; + return SyscallReturn(0); } #endif // __SIM_SYSCALL_EMUL_HH__ |