Re: [gem5-dev] changeset in gem5: syscall_emul: add support for x86 statfs syst...

2017-01-13 Thread Andreas Hansson
Hi Tony,

As a way of avoiding breakage, how about using OpenBSD (or similar) on a
VM in VirtualBox. It does not cost any $$ and Bjoern may even be able to
help set it up(?). It would be good to have such a setup available for
anyone who’s patches are likely to cause problems on BSD (i.e. anything
involving syscalls). If it works there, OSX should be fine. For now it
would be good to get things building again, even if that means reverting
temporarily. Makes sense?

I do not know how to best solve the bigger issue of “forking” the
functionality based on the underlying OS. Do we really need to have the
bits that would not work on BSD? If so, then perhaps just a
syscall_linux.cc/hh and then a single ifdef?

Andreas


On 12/01/2017, 17:01, "gem5-dev on behalf of Gutierrez, Anthony"
<gem5-dev-boun...@gem5.org on behalf of anthony.gutier...@amd.com> wrote:

>We do not have access to BSD or OSX, so unless somebody can give Brandon
>access to such a machine he would have no way to test any potential fix.
>
>From a high level, the only easy solution I see is to guard OS-specific
>code with #ifdefs or something similar. It seems that if we are going to
>support more advanced OS features and syscalls in SE mode a fundamental
>refactoring of SE code may be necessary, and will require help from
>everybody. Brandon has already done a lot down this path, adding support
>for dynamic linking, pthreads, and has done a lot of refactoring here.
>
>Could somebody who is more familiar with BSD, and has access, try to come
>up with a fix? Brandon is merely adding a feature here, and the fact that
>it breaks support for some other feature is an artifact of the simulator
>design, and I don't want to put the onus on individual contributors to
>fix fundamental flaws when adding useful features. Hopefully we can come
>up with a solution as a community.
>
>-Original Message-
>From: gem5-dev [mailto:gem5-dev-boun...@gem5.org] On Behalf Of Andreas
>Hansson
>Sent: Thursday, January 12, 2017 12:45 AM
>To: gem5 Developer List <gem5-dev@gem5.org>; Potter, Brandon
><brandon.pot...@amd.com>
>Cc: gem5-...@m5sim.org
>Subject: Re: [gem5-dev] changeset in gem5: syscall_emul: add support for
>x86 statfs syst...
>
>Hi Brandon,
>
>Could you have a look at this and come up with some form of solution so
>that gem5 compiles on BSD and OSX as well?
>
>Thanks,
>
>Andreas
>
>On 22/12/2016, 10:30, "gem5-dev on behalf of Bjoern A. Zeeb"
><gem5-dev-boun...@gem5.org on behalf of bzeeb-li...@lists.zabbadoz.net>
>wrote:
>
>>On 15 Dec 2016, at 18:17, Brandon Potter wrote:
>>
>>> changeset deaf82fd2e7c in /z/repo/gem5
>>> details: http://repo.gem5.org/gem5?cmd=changeset;node=deaf82fd2e7c
>>> description:
>>> syscall_emul: add support for x86 statfs system calls
>>>
>>
>>Does this compile on anything but Linux?   statfs.h doesn’t exists
>>elsewhere I guess?   statfs is historic and still more or less OS
>>specific.
>>
>>Did you actually implement statfs, or is this statvfs as in
>>http://pubs.opengroup.org/onlinepubs/95399/basedefs/sys/statvfs.h.h
>>tml
>>
>>?   Not sure what the linux syscall does there?
>>
>>
>>
>>> diffstat:
>>>
>>>  src/arch/x86/linux/linux.hh   |  18 ++
>>>  src/arch/x86/linux/process.cc |   2 +-
>>>  src/sim/syscall_emul.hh   |  32 ++--
>>>  3 files changed, 49 insertions(+), 3 deletions(-)
>>>
>>> diffs (110 lines):
>>>
>>> diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/linux.hh
>>> --- a/src/arch/x86/linux/linux.hhThu Dec 15 13:14:41 2016 -0500
>>> +++ b/src/arch/x86/linux/linux.hhThu Dec 15 13:16:03 2016 -0500
>>> @@ -67,6 +67,24 @@
>>>  int64_t unused0[3];
>>>  } tgt_stat64;
>>>
>>> +typedef struct {
>>> +long val[2];
>>> +} tgt_fsid;
>>> +
>>> +typedef struct {
>>> +long f_type;
>>> +long f_bsize;
>>> +long f_blocks;
>>> +long f_bfree;
>>> +long f_bavail;
>>> +long f_files;
>>> +long f_ffree;
>>> +tgt_fsid f_fsid;
>>> +long f_namelen;
>>> +long f_frsize;
>>> +long f_spare[5];
>>> +} tgt_statfs;
>>> +
>>>  static const int TGT_SIGHUP = 0x01;
>>>  static const int TGT_SIGINT = 0x02;
>>>  static const int TGT_SIGQUIT= 0x03;
>>> diff -r 104a404d426e -r deaf82fd2e7c src/arc

Re: [gem5-dev] changeset in gem5: syscall_emul: add support for x86 statfs syst...

2017-01-12 Thread Gutierrez, Anthony
We do not have access to BSD or OSX, so unless somebody can give Brandon access 
to such a machine he would have no way to test any potential fix.

From a high level, the only easy solution I see is to guard OS-specific code 
with #ifdefs or something similar. It seems that if we are going to support 
more advanced OS features and syscalls in SE mode a fundamental refactoring of 
SE code may be necessary, and will require help from everybody. Brandon has 
already done a lot down this path, adding support for dynamic linking, 
pthreads, and has done a lot of refactoring here.

Could somebody who is more familiar with BSD, and has access, try to come up 
with a fix? Brandon is merely adding a feature here, and the fact that it 
breaks support for some other feature is an artifact of the simulator design, 
and I don't want to put the onus on individual contributors to fix fundamental 
flaws when adding useful features. Hopefully we can come up with a solution as 
a community.

-Original Message-
From: gem5-dev [mailto:gem5-dev-boun...@gem5.org] On Behalf Of Andreas Hansson
Sent: Thursday, January 12, 2017 12:45 AM
To: gem5 Developer List <gem5-dev@gem5.org>; Potter, Brandon 
<brandon.pot...@amd.com>
Cc: gem5-...@m5sim.org
Subject: Re: [gem5-dev] changeset in gem5: syscall_emul: add support for x86 
statfs syst...

Hi Brandon,

Could you have a look at this and come up with some form of solution so that 
gem5 compiles on BSD and OSX as well?

Thanks,

Andreas

On 22/12/2016, 10:30, "gem5-dev on behalf of Bjoern A. Zeeb"
<gem5-dev-boun...@gem5.org on behalf of bzeeb-li...@lists.zabbadoz.net>
wrote:

>On 15 Dec 2016, at 18:17, Brandon Potter wrote:
>
>> changeset deaf82fd2e7c in /z/repo/gem5
>> details: http://repo.gem5.org/gem5?cmd=changeset;node=deaf82fd2e7c
>> description:
>> syscall_emul: add support for x86 statfs system calls
>>
>
>Does this compile on anything but Linux?   statfs.h doesn’t exists
>elsewhere I guess?   statfs is historic and still more or less OS
>specific.
>
>Did you actually implement statfs, or is this statvfs as in 
>http://pubs.opengroup.org/onlinepubs/95399/basedefs/sys/statvfs.h.h
>tml
>
>?   Not sure what the linux syscall does there?
>
>
>
>> diffstat:
>>
>>  src/arch/x86/linux/linux.hh   |  18 ++
>>  src/arch/x86/linux/process.cc |   2 +-
>>  src/sim/syscall_emul.hh   |  32 ++--
>>  3 files changed, 49 insertions(+), 3 deletions(-)
>>
>> diffs (110 lines):
>>
>> diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/linux.hh
>> --- a/src/arch/x86/linux/linux.hhThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/arch/x86/linux/linux.hhThu Dec 15 13:16:03 2016 -0500
>> @@ -67,6 +67,24 @@
>>  int64_t unused0[3];
>>  } tgt_stat64;
>>
>> +typedef struct {
>> +long val[2];
>> +} tgt_fsid;
>> +
>> +typedef struct {
>> +long f_type;
>> +long f_bsize;
>> +long f_blocks;
>> +long f_bfree;
>> +long f_bavail;
>> +long f_files;
>> +long f_ffree;
>> +tgt_fsid f_fsid;
>> +long f_namelen;
>> +long f_frsize;
>> +long f_spare[5];
>> +} tgt_statfs;
>> +
>>  static const int TGT_SIGHUP = 0x01;
>>  static const int TGT_SIGINT = 0x02;
>>  static const int TGT_SIGQUIT= 0x03;
>> diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/process.cc
>> --- a/src/arch/x86/linux/process.ccThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/arch/x86/linux/process.ccThu Dec 15 13:16:03 2016 -0500
>> @@ -355,7 +355,7 @@
>>  /* 134 */ SyscallDesc("uselib", unimplementedFunc),
>>  /* 135 */ SyscallDesc("personality", unimplementedFunc),
>>  /* 136 */ SyscallDesc("ustat", unimplementedFunc),
>> -/* 137 */ SyscallDesc("statfs", unimplementedFunc),
>> +/* 137 */ SyscallDesc("statfs", statfsFunc),
>>  /* 138 */ SyscallDesc("fstatfs", unimplementedFunc),
>>  /* 139 */ SyscallDesc("sysfs", unimplementedFunc),
>>  /* 140 */ SyscallDesc("getpriority", unimplementedFunc), diff -r 
>> 104a404d426e -r deaf82fd2e7c src/sim/syscall_emul.hh
>> --- a/src/sim/syscall_emul.hhThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/sim/syscall_emul.hhThu Dec 15 13:16:03 2016 -0500
>> @@ -62,6 +62,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -451,6 +452,7 @@
>>  //
>>  
>> ///

Re: [gem5-dev] changeset in gem5: syscall_emul: add support for x86 statfs syst...

2017-01-12 Thread Andreas Hansson
Hi Brandon,

Could you have a look at this and come up with some form of solution so
that gem5 compiles on BSD and OSX as well?

Thanks,

Andreas

On 22/12/2016, 10:30, "gem5-dev on behalf of Bjoern A. Zeeb"

wrote:

>On 15 Dec 2016, at 18:17, Brandon Potter wrote:
>
>> changeset deaf82fd2e7c in /z/repo/gem5
>> details: http://repo.gem5.org/gem5?cmd=changeset;node=deaf82fd2e7c
>> description:
>> syscall_emul: add support for x86 statfs system calls
>>
>
>Does this compile on anything but Linux?   statfs.h doesn’t exists
>elsewhere I guess?   statfs is historic and still more or less OS
>specific.
>
>Did you actually implement statfs, or is this statvfs as in
>http://pubs.opengroup.org/onlinepubs/95399/basedefs/sys/statvfs.h.html
>
>?   Not sure what the linux syscall does there?
>
>
>
>> diffstat:
>>
>>  src/arch/x86/linux/linux.hh   |  18 ++
>>  src/arch/x86/linux/process.cc |   2 +-
>>  src/sim/syscall_emul.hh   |  32 ++--
>>  3 files changed, 49 insertions(+), 3 deletions(-)
>>
>> diffs (110 lines):
>>
>> diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/linux.hh
>> --- a/src/arch/x86/linux/linux.hhThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/arch/x86/linux/linux.hhThu Dec 15 13:16:03 2016 -0500
>> @@ -67,6 +67,24 @@
>>  int64_t unused0[3];
>>  } tgt_stat64;
>>
>> +typedef struct {
>> +long val[2];
>> +} tgt_fsid;
>> +
>> +typedef struct {
>> +long f_type;
>> +long f_bsize;
>> +long f_blocks;
>> +long f_bfree;
>> +long f_bavail;
>> +long f_files;
>> +long f_ffree;
>> +tgt_fsid f_fsid;
>> +long f_namelen;
>> +long f_frsize;
>> +long f_spare[5];
>> +} tgt_statfs;
>> +
>>  static const int TGT_SIGHUP = 0x01;
>>  static const int TGT_SIGINT = 0x02;
>>  static const int TGT_SIGQUIT= 0x03;
>> diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/process.cc
>> --- a/src/arch/x86/linux/process.ccThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/arch/x86/linux/process.ccThu Dec 15 13:16:03 2016 -0500
>> @@ -355,7 +355,7 @@
>>  /* 134 */ SyscallDesc("uselib", unimplementedFunc),
>>  /* 135 */ SyscallDesc("personality", unimplementedFunc),
>>  /* 136 */ SyscallDesc("ustat", unimplementedFunc),
>> -/* 137 */ SyscallDesc("statfs", unimplementedFunc),
>> +/* 137 */ SyscallDesc("statfs", statfsFunc),
>>  /* 138 */ SyscallDesc("fstatfs", unimplementedFunc),
>>  /* 139 */ SyscallDesc("sysfs", unimplementedFunc),
>>  /* 140 */ SyscallDesc("getpriority", unimplementedFunc),
>> diff -r 104a404d426e -r deaf82fd2e7c src/sim/syscall_emul.hh
>> --- a/src/sim/syscall_emul.hhThu Dec 15 13:14:41 2016 -0500
>> +++ b/src/sim/syscall_emul.hhThu Dec 15 13:16:03 2016 -0500
>> @@ -62,6 +62,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -451,6 +452,7 @@
>>  //
>>  //
>>
>> +typedef struct statfs hst_statfs;
>>  #if NO_STAT64
>>  typedef struct stat hst_stat;
>>  typedef struct stat hst_stat64;
>> @@ -556,6 +558,32 @@
>>  tgt.copyOut(mem);
>>  }
>>
>> +template 
>> +static void
>> +copyOutStatfsBuf(SETranslatingPortProxy , Addr addr,
>> + hst_statfs *host)
>> +{
>> +TypedBufferArg tgt(addr);
>> +
>> +#if defined(__OpenBSD__) || defined(__APPLE__) ||
>> defined(__FreeBSD__)
>> +tgt->f_type = 0;
>> +#else
>> +tgt->f_type = TheISA::htog(host->f_type);
>> +#endif
>> +tgt->f_bsize = TheISA::htog(host->f_bsize);
>> +tgt->f_blocks = TheISA::htog(host->f_blocks);
>> +tgt->f_bfree = TheISA::htog(host->f_bfree);
>> +tgt->f_bavail = TheISA::htog(host->f_bavail);
>> +tgt->f_files = TheISA::htog(host->f_files);
>> +tgt->f_ffree = TheISA::htog(host->f_ffree);
>> +memcpy(>f_fsid, >f_fsid, sizeof(host->f_fsid));
>> +tgt->f_namelen = TheISA::htog(host->f_namelen);
>> +tgt->f_frsize = TheISA::htog(host->f_frsize);
>> +memcpy(>f_spare, >f_spare, sizeof(host->f_spare));
>> +
>> +tgt.copyOut(mem);
>> +}
>> +
>>  /// Target ioctl() handler.  For the most part, programs call ioctl()
>>  /// only to find out if their stdout is a tty, to determine whether
>> to
>>  /// do line or block buffering.  We always claim that output fds are
>> @@ -1156,7 +1184,7 @@
>>  if (result < 0)
>>  return -errno;
>>
>> -OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
>> +copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
>>
>>  return 0;
>>  }
>> @@ -1182,7 +1210,7 @@
>>  if (result < 0)
>>  return -errno;
>>
>> -OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
>> +copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
>>
>>  return 0;
>>  }
>> ___
>> gem5-dev 

Re: [gem5-dev] changeset in gem5: syscall_emul: add support for x86 statfs syst...

2016-12-22 Thread Bjoern A. Zeeb

On 15 Dec 2016, at 18:17, Brandon Potter wrote:


changeset deaf82fd2e7c in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=deaf82fd2e7c
description:
syscall_emul: add support for x86 statfs system calls



Does this compile on anything but Linux?   statfs.h doesn’t exists 
elsewhere I guess?   statfs is historic and still more or less OS 
specific.


Did you actually implement statfs, or is this statvfs as in 
http://pubs.opengroup.org/onlinepubs/95399/basedefs/sys/statvfs.h.html 
?   Not sure what the linux syscall does there?





diffstat:

 src/arch/x86/linux/linux.hh   |  18 ++
 src/arch/x86/linux/process.cc |   2 +-
 src/sim/syscall_emul.hh   |  32 ++--
 3 files changed, 49 insertions(+), 3 deletions(-)

diffs (110 lines):

diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/linux.hh
--- a/src/arch/x86/linux/linux.hh   Thu Dec 15 13:14:41 2016 -0500
+++ b/src/arch/x86/linux/linux.hh   Thu Dec 15 13:16:03 2016 -0500
@@ -67,6 +67,24 @@
 int64_t unused0[3];
 } tgt_stat64;

+typedef struct {
+long val[2];
+} tgt_fsid;
+
+typedef struct {
+long f_type;
+long f_bsize;
+long f_blocks;
+long f_bfree;
+long f_bavail;
+long f_files;
+long f_ffree;
+tgt_fsid f_fsid;
+long f_namelen;
+long f_frsize;
+long f_spare[5];
+} tgt_statfs;
+
 static const int TGT_SIGHUP = 0x01;
 static const int TGT_SIGINT = 0x02;
 static const int TGT_SIGQUIT= 0x03;
diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/process.cc
--- a/src/arch/x86/linux/process.cc Thu Dec 15 13:14:41 2016 -0500
+++ b/src/arch/x86/linux/process.cc Thu Dec 15 13:16:03 2016 -0500
@@ -355,7 +355,7 @@
 /* 134 */ SyscallDesc("uselib", unimplementedFunc),
 /* 135 */ SyscallDesc("personality", unimplementedFunc),
 /* 136 */ SyscallDesc("ustat", unimplementedFunc),
-/* 137 */ SyscallDesc("statfs", unimplementedFunc),
+/* 137 */ SyscallDesc("statfs", statfsFunc),
 /* 138 */ SyscallDesc("fstatfs", unimplementedFunc),
 /* 139 */ SyscallDesc("sysfs", unimplementedFunc),
 /* 140 */ SyscallDesc("getpriority", unimplementedFunc),
diff -r 104a404d426e -r deaf82fd2e7c src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Thu Dec 15 13:14:41 2016 -0500
+++ b/src/sim/syscall_emul.hh   Thu Dec 15 13:16:03 2016 -0500
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -451,6 +452,7 @@
 //
 //

+typedef struct statfs hst_statfs;
 #if NO_STAT64
 typedef struct stat hst_stat;
 typedef struct stat hst_stat64;
@@ -556,6 +558,32 @@
 tgt.copyOut(mem);
 }

+template 
+static void
+copyOutStatfsBuf(SETranslatingPortProxy , Addr addr,
+ hst_statfs *host)
+{
+TypedBufferArg tgt(addr);
+
+#if defined(__OpenBSD__) || defined(__APPLE__) || 
defined(__FreeBSD__)

+tgt->f_type = 0;
+#else
+tgt->f_type = TheISA::htog(host->f_type);
+#endif
+tgt->f_bsize = TheISA::htog(host->f_bsize);
+tgt->f_blocks = TheISA::htog(host->f_blocks);
+tgt->f_bfree = TheISA::htog(host->f_bfree);
+tgt->f_bavail = TheISA::htog(host->f_bavail);
+tgt->f_files = TheISA::htog(host->f_files);
+tgt->f_ffree = TheISA::htog(host->f_ffree);
+memcpy(>f_fsid, >f_fsid, sizeof(host->f_fsid));
+tgt->f_namelen = TheISA::htog(host->f_namelen);
+tgt->f_frsize = TheISA::htog(host->f_frsize);
+memcpy(>f_spare, >f_spare, sizeof(host->f_spare));
+
+tgt.copyOut(mem);
+}
+
 /// Target ioctl() handler.  For the most part, programs call ioctl()
 /// only to find out if their stdout is a tty, to determine whether 
to

 /// do line or block buffering.  We always claim that output fds are
@@ -1156,7 +1184,7 @@
 if (result < 0)
 return -errno;

-OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
+copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );

 return 0;
 }
@@ -1182,7 +1210,7 @@
 if (result < 0)
 return -errno;

-OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
+copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );

 return 0;
 }
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev


[gem5-dev] changeset in gem5: syscall_emul: add support for x86 statfs syst...

2016-12-15 Thread Brandon Potter
changeset deaf82fd2e7c in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=deaf82fd2e7c
description:
syscall_emul: add support for x86 statfs system calls

diffstat:

 src/arch/x86/linux/linux.hh   |  18 ++
 src/arch/x86/linux/process.cc |   2 +-
 src/sim/syscall_emul.hh   |  32 ++--
 3 files changed, 49 insertions(+), 3 deletions(-)

diffs (110 lines):

diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/linux.hh
--- a/src/arch/x86/linux/linux.hh   Thu Dec 15 13:14:41 2016 -0500
+++ b/src/arch/x86/linux/linux.hh   Thu Dec 15 13:16:03 2016 -0500
@@ -67,6 +67,24 @@
 int64_t unused0[3];
 } tgt_stat64;
 
+typedef struct {
+long val[2];
+} tgt_fsid;
+
+typedef struct {
+long f_type;
+long f_bsize;
+long f_blocks;
+long f_bfree;
+long f_bavail;
+long f_files;
+long f_ffree;
+tgt_fsid f_fsid;
+long f_namelen;
+long f_frsize;
+long f_spare[5];
+} tgt_statfs;
+
 static const int TGT_SIGHUP = 0x01;
 static const int TGT_SIGINT = 0x02;
 static const int TGT_SIGQUIT= 0x03;
diff -r 104a404d426e -r deaf82fd2e7c src/arch/x86/linux/process.cc
--- a/src/arch/x86/linux/process.cc Thu Dec 15 13:14:41 2016 -0500
+++ b/src/arch/x86/linux/process.cc Thu Dec 15 13:16:03 2016 -0500
@@ -355,7 +355,7 @@
 /* 134 */ SyscallDesc("uselib", unimplementedFunc),
 /* 135 */ SyscallDesc("personality", unimplementedFunc),
 /* 136 */ SyscallDesc("ustat", unimplementedFunc),
-/* 137 */ SyscallDesc("statfs", unimplementedFunc),
+/* 137 */ SyscallDesc("statfs", statfsFunc),
 /* 138 */ SyscallDesc("fstatfs", unimplementedFunc),
 /* 139 */ SyscallDesc("sysfs", unimplementedFunc),
 /* 140 */ SyscallDesc("getpriority", unimplementedFunc),
diff -r 104a404d426e -r deaf82fd2e7c src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Thu Dec 15 13:14:41 2016 -0500
+++ b/src/sim/syscall_emul.hh   Thu Dec 15 13:16:03 2016 -0500
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -451,6 +452,7 @@
 //
 //
 
+typedef struct statfs hst_statfs;
 #if NO_STAT64
 typedef struct stat hst_stat;
 typedef struct stat hst_stat64;
@@ -556,6 +558,32 @@
 tgt.copyOut(mem);
 }
 
+template 
+static void
+copyOutStatfsBuf(SETranslatingPortProxy , Addr addr,
+ hst_statfs *host)
+{
+TypedBufferArg tgt(addr);
+
+#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD__)
+tgt->f_type = 0;
+#else
+tgt->f_type = TheISA::htog(host->f_type);
+#endif
+tgt->f_bsize = TheISA::htog(host->f_bsize);
+tgt->f_blocks = TheISA::htog(host->f_blocks);
+tgt->f_bfree = TheISA::htog(host->f_bfree);
+tgt->f_bavail = TheISA::htog(host->f_bavail);
+tgt->f_files = TheISA::htog(host->f_files);
+tgt->f_ffree = TheISA::htog(host->f_ffree);
+memcpy(>f_fsid, >f_fsid, sizeof(host->f_fsid));
+tgt->f_namelen = TheISA::htog(host->f_namelen);
+tgt->f_frsize = TheISA::htog(host->f_frsize);
+memcpy(>f_spare, >f_spare, sizeof(host->f_spare));
+
+tgt.copyOut(mem);
+}
+
 /// Target ioctl() handler.  For the most part, programs call ioctl()
 /// only to find out if their stdout is a tty, to determine whether to
 /// do line or block buffering.  We always claim that output fds are
@@ -1156,7 +1184,7 @@
 if (result < 0)
 return -errno;
 
-OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
+copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
 
 return 0;
 }
@@ -1182,7 +1210,7 @@
 if (result < 0)
 return -errno;
 
-OS::copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
+copyOutStatfsBuf(tc->getMemProxy(), bufPtr, );
 
 return 0;
 }
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev