Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Introduce new shared function remote_fileio_to_fio_error
@ 2015-04-09  9:51 Gary Benson
  2015-04-09 10:17 ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2015-04-09  9:51 UTC (permalink / raw)
  To: gdb-patches

Hi all,

This commit introduces a new shared function to replace three
identical functions in various places in the codebase.

Ok to commit?

Cheers,
Gary

---
gdb/ChangeLog:

	* common/common-remote-fileio.h (remote_fileio_to_fio_error):
	New declaration.
	* common/common-remote-fileio.c (remote_fileio_to_fio_error):
	New function, factored out the named functions below.
	* inf-child.c (gdb/fileio.h): Remove include.
	(common-remote-fileio.h): New include.
	(inf_child_errno_to_fileio_error): Remove function.  Update
	all callers to use remote_fileio_to_fio_error.
	* remote-fileio.c (remote_fileio_errno_to_target): Likewise.

gdb/gdbserver/ChangeLog:

	* hostio-errno.c (errno_to_fileio_error): Remove function.
	Update caller to use remote_fileio_to_fio_error.
---
 gdb/ChangeLog                     |   12 +++++++
 gdb/common/common-remote-fileio.c |   53 +++++++++++++++++++++++++++++
 gdb/common/common-remote-fileio.h |    5 +++
 gdb/gdbserver/ChangeLog           |    5 +++
 gdb/gdbserver/hostio-errno.c      |   56 +-----------------------------
 gdb/inf-child.c                   |   67 ++++--------------------------------
 gdb/remote-fileio.c               |   53 +----------------------------
 7 files changed, 86 insertions(+), 165 deletions(-)

diff --git a/gdb/common/common-remote-fileio.c b/gdb/common/common-remote-fileio.c
index f78b3f7..30c2c6b 100644
--- a/gdb/common/common-remote-fileio.c
+++ b/gdb/common/common-remote-fileio.c
@@ -21,6 +21,59 @@
 #include "common-remote-fileio.h"
 #include <sys/stat.h>
 
+/* See common-remote-fileio.h.  */
+
+int
+remote_fileio_to_fio_error (int error)
+{
+  switch (error)
+    {
+      case EPERM:
+        return FILEIO_EPERM;
+      case ENOENT:
+        return FILEIO_ENOENT;
+      case EINTR:
+        return FILEIO_EINTR;
+      case EIO:
+        return FILEIO_EIO;
+      case EBADF:
+        return FILEIO_EBADF;
+      case EACCES:
+        return FILEIO_EACCES;
+      case EFAULT:
+        return FILEIO_EFAULT;
+      case EBUSY:
+        return FILEIO_EBUSY;
+      case EEXIST:
+        return FILEIO_EEXIST;
+      case ENODEV:
+        return FILEIO_ENODEV;
+      case ENOTDIR:
+        return FILEIO_ENOTDIR;
+      case EISDIR:
+        return FILEIO_EISDIR;
+      case EINVAL:
+        return FILEIO_EINVAL;
+      case ENFILE:
+        return FILEIO_ENFILE;
+      case EMFILE:
+        return FILEIO_EMFILE;
+      case EFBIG:
+        return FILEIO_EFBIG;
+      case ENOSPC:
+        return FILEIO_ENOSPC;
+      case ESPIPE:
+        return FILEIO_ESPIPE;
+      case EROFS:
+        return FILEIO_EROFS;
+      case ENOSYS:
+        return FILEIO_ENOSYS;
+      case ENAMETOOLONG:
+        return FILEIO_ENAMETOOLONG;
+    }
+  return FILEIO_EUNKNOWN;
+}
+
 /* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
 
 static LONGEST
diff --git a/gdb/common/common-remote-fileio.h b/gdb/common/common-remote-fileio.h
index 27bc585..96e4aa5 100644
--- a/gdb/common/common-remote-fileio.h
+++ b/gdb/common/common-remote-fileio.h
@@ -23,6 +23,11 @@
 #include "gdb/fileio.h"
 #include <sys/stat.h>
 
+/* Convert a errno error number to a File-I/O error number for
+   transmission over the remote protocol.  */
+
+extern int remote_fileio_to_fio_error (int error);
+
 /* Pack a host-format integer into a byte buffer in big-endian format
    ready for transmission over the remote protocol.  BYTES specifies
    the size of the integer to pack in bytes.  */
diff --git a/gdb/gdbserver/hostio-errno.c b/gdb/gdbserver/hostio-errno.c
index b7a031e..01d4b32 100644
--- a/gdb/gdbserver/hostio-errno.c
+++ b/gdb/gdbserver/hostio-errno.c
@@ -22,64 +22,12 @@
    on top of errno.  */
 
 #include "server.h"
-#include "gdb/fileio.h"
-
-static int
-errno_to_fileio_error (int error)
-{
-  switch (error)
-    {
-    case EPERM:
-      return FILEIO_EPERM;
-    case ENOENT:
-      return FILEIO_ENOENT;
-    case EINTR:
-      return FILEIO_EINTR;
-    case EIO:
-      return FILEIO_EIO;
-    case EBADF:
-      return FILEIO_EBADF;
-    case EACCES:
-      return FILEIO_EACCES;
-    case EFAULT:
-      return FILEIO_EFAULT;
-    case EBUSY:
-      return FILEIO_EBUSY;
-    case EEXIST:
-      return FILEIO_EEXIST;
-    case ENODEV:
-      return FILEIO_ENODEV;
-    case ENOTDIR:
-      return FILEIO_ENOTDIR;
-    case EISDIR:
-      return FILEIO_EISDIR;
-    case EINVAL:
-      return FILEIO_EINVAL;
-    case ENFILE:
-      return FILEIO_ENFILE;
-    case EMFILE:
-      return FILEIO_EMFILE;
-    case EFBIG:
-      return FILEIO_EFBIG;
-    case ENOSPC:
-      return FILEIO_ENOSPC;
-    case ESPIPE:
-      return FILEIO_ESPIPE;
-    case EROFS:
-      return FILEIO_EROFS;
-    case ENOSYS:
-      return FILEIO_ENOSYS;
-    case ENAMETOOLONG:
-      return FILEIO_ENAMETOOLONG;
-    }
-
-  return FILEIO_EUNKNOWN;
-}
+#include "common-remote-fileio.h"
 
 void
 hostio_last_error_from_errno (char *buf)
 {
   int error = errno;
-  int fileio_error = errno_to_fileio_error (error);
+  int fileio_error = remote_fileio_to_fio_error (error);
   sprintf (buf, "F-1,%x", fileio_error);
 }
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index b7161ab..5e5763b 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -30,7 +30,7 @@
 #include "inferior.h"
 #include <sys/stat.h>
 #include "inf-child.h"
-#include "gdb/fileio.h"
+#include "common-remote-fileio.h"
 #include "agent.h"
 #include "gdb_wait.h"
 #include "filestuff.h"
@@ -239,57 +239,6 @@ inf_child_fileio_open_flags_to_host (int fileio_open_flags, int *open_flags_p)
   return 0;
 }
 
-static int
-inf_child_errno_to_fileio_error (int errnum)
-{
-  switch (errnum)
-    {
-      case EPERM:
-        return FILEIO_EPERM;
-      case ENOENT:
-        return FILEIO_ENOENT;
-      case EINTR:
-        return FILEIO_EINTR;
-      case EIO:
-        return FILEIO_EIO;
-      case EBADF:
-        return FILEIO_EBADF;
-      case EACCES:
-        return FILEIO_EACCES;
-      case EFAULT:
-        return FILEIO_EFAULT;
-      case EBUSY:
-        return FILEIO_EBUSY;
-      case EEXIST:
-        return FILEIO_EEXIST;
-      case ENODEV:
-        return FILEIO_ENODEV;
-      case ENOTDIR:
-        return FILEIO_ENOTDIR;
-      case EISDIR:
-        return FILEIO_EISDIR;
-      case EINVAL:
-        return FILEIO_EINVAL;
-      case ENFILE:
-        return FILEIO_ENFILE;
-      case EMFILE:
-        return FILEIO_EMFILE;
-      case EFBIG:
-        return FILEIO_EFBIG;
-      case ENOSPC:
-        return FILEIO_ENOSPC;
-      case ESPIPE:
-        return FILEIO_ESPIPE;
-      case EROFS:
-        return FILEIO_EROFS;
-      case ENOSYS:
-        return FILEIO_ENOSYS;
-      case ENAMETOOLONG:
-        return FILEIO_ENAMETOOLONG;
-    }
-  return FILEIO_EUNKNOWN;
-}
-
 /* Open FILENAME on the target, using FLAGS and MODE.  Return a
    target file descriptor, or -1 if an error occurs (and set
    *TARGET_ERRNO).  */
@@ -311,7 +260,7 @@ inf_child_fileio_open (struct target_ops *self,
      the standard values.  */
   fd = gdb_open_cloexec (filename, nat_flags, mode);
   if (fd == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return fd;
 }
@@ -340,7 +289,7 @@ inf_child_fileio_pwrite (struct target_ops *self,
     }
 
   if (ret == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return ret;
 }
@@ -369,7 +318,7 @@ inf_child_fileio_pread (struct target_ops *self,
     }
 
   if (ret == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return ret;
 }
@@ -383,7 +332,7 @@ inf_child_fileio_fstat (struct target_ops *self, int fd,
 
   ret = fstat (fd, sb);
   if (ret == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return ret;
 }
@@ -397,7 +346,7 @@ inf_child_fileio_close (struct target_ops *self, int fd, int *target_errno)
 
   ret = close (fd);
   if (ret == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return ret;
 }
@@ -412,7 +361,7 @@ inf_child_fileio_unlink (struct target_ops *self,
 
   ret = unlink (filename);
   if (ret == -1)
-    *target_errno = inf_child_errno_to_fileio_error (errno);
+    *target_errno = remote_fileio_to_fio_error (errno);
 
   return ret;
 }
@@ -434,7 +383,7 @@ inf_child_fileio_readlink (struct target_ops *self,
   len = readlink (filename, buf, sizeof buf);
   if (len < 0)
     {
-      *target_errno = inf_child_errno_to_fileio_error (errno);
+      *target_errno = remote_fileio_to_fio_error (errno);
       return NULL;
     }
 
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 3882321..36c3849 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -194,57 +194,6 @@ remote_fileio_mode_to_host (long mode, int open_call)
 }
 
 static int
-remote_fileio_errno_to_target (int error)
-{
-  switch (error)
-    {
-      case EPERM:
-        return FILEIO_EPERM;
-      case ENOENT:
-        return FILEIO_ENOENT;
-      case EINTR:
-        return FILEIO_EINTR;
-      case EIO:
-        return FILEIO_EIO;
-      case EBADF:
-        return FILEIO_EBADF;
-      case EACCES:
-        return FILEIO_EACCES;
-      case EFAULT:
-        return FILEIO_EFAULT;
-      case EBUSY:
-        return FILEIO_EBUSY;
-      case EEXIST:
-        return FILEIO_EEXIST;
-      case ENODEV:
-        return FILEIO_ENODEV;
-      case ENOTDIR:
-        return FILEIO_ENOTDIR;
-      case EISDIR:
-        return FILEIO_EISDIR;
-      case EINVAL:
-        return FILEIO_EINVAL;
-      case ENFILE:
-        return FILEIO_ENFILE;
-      case EMFILE:
-        return FILEIO_EMFILE;
-      case EFBIG:
-        return FILEIO_EFBIG;
-      case ENOSPC:
-        return FILEIO_ENOSPC;
-      case ESPIPE:
-        return FILEIO_ESPIPE;
-      case EROFS:
-        return FILEIO_EROFS;
-      case ENOSYS:
-        return FILEIO_ENOSYS;
-      case ENAMETOOLONG:
-        return FILEIO_ENAMETOOLONG;
-    }
-  return FILEIO_EUNKNOWN;
-}
-
-static int
 remote_fileio_seek_flag_to_host (long num, int *flag)
 {
   if (!flag)
@@ -459,7 +408,7 @@ static void
 remote_fileio_return_errno (int retcode)
 {
   remote_fileio_reply (retcode, retcode < 0
-		       ? remote_fileio_errno_to_target (errno) : 0);
+		       ? remote_fileio_to_fio_error (errno) : 0);
 }
 
 static void
-- 
1.7.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce new shared function remote_fileio_to_fio_error
  2015-04-09  9:51 [PATCH] Introduce new shared function remote_fileio_to_fio_error Gary Benson
@ 2015-04-09 10:17 ` Pedro Alves
  2015-04-09 10:50   ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2015-04-09 10:17 UTC (permalink / raw)
  To: Gary Benson, gdb-patches

On 04/09/2015 10:51 AM, Gary Benson wrote:
> Hi all,
> 
> This commit introduces a new shared function to replace three
> identical functions in various places in the codebase.
> 
> Ok to commit?
> 

This is OK, but I think the "remote" in the name is really wrong.
This is converting a _host_ errno to a fileio error.  I think the
function name should reflect that, and not mention remote at all.

This is a preexisting issue with remote_fileio_to_fio_stat as well
(should be called something like host_stat_to_fio_stat / stat_to_fio_stat /
stat_to_fileio_stat / fileio_host_stat_to_fio_stat), so I'm not
pushing back on this new case.  We should probably rename
the "common-remote-fileio.*" files too.

> gdb/gdbserver/ChangeLog:
> 
> 	* hostio-errno.c (errno_to_fileio_error): Remove function.

E.g., the old name here was clear.

> 	Update caller to use remote_fileio_to_fio_error.

> +int
> +remote_fileio_to_fio_error (int error)
> +{
> +  switch (error)
> +    {
> +      case EPERM:
> +        return FILEIO_EPERM;

... otherwise this is truly confusing.  Reading the function
name as "X to Y", makes one go "hmm, what has 'remote fileio' got
to do with about EPERM?' ?

>  /* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
>  
>  static LONGEST


> diff --git a/gdb/inf-child.c b/gdb/inf-child.c
> index b7161ab..5e5763b 100644
> --- a/gdb/inf-child.c
> +++ b/gdb/inf-child.c


> @@ -311,7 +260,7 @@ inf_child_fileio_open (struct target_ops *self,
>       the standard values.  */
>    fd = gdb_open_cloexec (filename, nat_flags, mode);
>    if (fd == -1)
> -    *target_errno = inf_child_errno_to_fileio_error (errno);
> +    *target_errno = remote_fileio_to_fio_error (errno);
>  

... and inf-child calling a "remote_"-named function is truly bizarre.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce new shared function remote_fileio_to_fio_error
  2015-04-09 10:17 ` Pedro Alves
@ 2015-04-09 10:50   ` Gary Benson
  2015-04-09 11:00     ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2015-04-09 10:50 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves wrote:
> On 04/09/2015 10:51 AM, Gary Benson wrote:
> > This commit introduces a new shared function to replace three
> > identical functions in various places in the codebase.
> > 
> > Ok to commit?
> 
> This is OK, but I think the "remote" in the name is really wrong.
> This is converting a _host_ errno to a fileio error.  I think the
> function name should reflect that, and not mention remote at all.

Yeah, I kind of thought this when I was writing the patch, but I was
also thinking about other things :)

I'm happy to make another patch to rename common-remote-fileio.*
to common-fileio.* and rename the functions accordingly.

Should I push this one first and then make a second, or would you
like the rename first and an updated version of this patch second?
I'd prefer the former (less work for me!) but I can do the latter
if you want it that way.

Cheers,
Gary

-- 
http://gbenson.net/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce new shared function remote_fileio_to_fio_error
  2015-04-09 10:50   ` Gary Benson
@ 2015-04-09 11:00     ` Pedro Alves
  2015-04-09 13:21       ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2015-04-09 11:00 UTC (permalink / raw)
  To: Gary Benson; +Cc: gdb-patches

On 04/09/2015 11:50 AM, Gary Benson wrote:
> Pedro Alves wrote:
>> On 04/09/2015 10:51 AM, Gary Benson wrote:
>>> This commit introduces a new shared function to replace three
>>> identical functions in various places in the codebase.
>>>
>>> Ok to commit?
>>
>> This is OK, but I think the "remote" in the name is really wrong.
>> This is converting a _host_ errno to a fileio error.  I think the
>> function name should reflect that, and not mention remote at all.
> 
> Yeah, I kind of thought this when I was writing the patch, but I was
> also thinking about other things :)
> 
> I'm happy to make another patch to rename common-remote-fileio.*
> to common-fileio.* and rename the functions accordingly.

I'd prefer even dropping the "common" from the file name.
host-fileio.* for example would indicate what the file actually does.

> 
> Should I push this one first and then make a second, or would you
> like the rename first and an updated version of this patch second?
> I'd prefer the former (less work for me!) but I can do the latter
> if you want it that way.

Yeah, push what you have first.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Introduce new shared function remote_fileio_to_fio_error
  2015-04-09 11:00     ` Pedro Alves
@ 2015-04-09 13:21       ` Gary Benson
  2015-04-09 14:12         ` [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch] Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2015-04-09 13:21 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves wrote:
> On 04/09/2015 11:50 AM, Gary Benson wrote:
> > Pedro Alves wrote:
> > > On 04/09/2015 10:51 AM, Gary Benson wrote:
> > > > This commit introduces a new shared function to replace three
> > > > identical functions in various places in the codebase.
> > > >
> > > > Ok to commit?
> > >
> > > This is OK, but I think the "remote" in the name is really wrong.
> > > This is converting a _host_ errno to a fileio error.  I think the
> > > function name should reflect that, and not mention remote at all.
> > 
> > Yeah, I kind of thought this when I was writing the patch, but I
> > was also thinking about other things :)
> > 
> > I'm happy to make another patch to rename common-remote-fileio.*
> > to common-fileio.* and rename the functions accordingly.
> 
> I'd prefer even dropping the "common" from the file name.
> host-fileio.* for example would indicate what the file actually does.

Or just fileio.*.

> > Should I push this one first and then make a second, or would you
> > like the rename first and an updated version of this patch second?
> > I'd prefer the former (less work for me!) but I can do the latter
> > if you want it that way.
> 
> Yeah, push what you have first.

I pushed it.  Will mail the renaming patch soon.

Cheers,
Gary

-- 
http://gbenson.net/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch]
  2015-04-09 13:21       ` Gary Benson
@ 2015-04-09 14:12         ` Gary Benson
  2015-04-09 14:18           ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2015-04-09 14:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

Hi all,

This commit renames common-remote-fileio.[ch] as fileio.[ch]
and renames all functions in these files.

I'll mail a git diff -M version of this patch in a separate
message.

Ok to commit?

Cheers,
Gary

---
gdb/ChangeLog:

	* common/common-remote-fileio.h: Rename to...
	* common/fileio.h: ...this.  Update all references.
	(remote_fileio_to_fio_error): Rename to...
	(host_to_fileio_error): ...this.
	(remote_fileio_to_be): Rename to...
	(host_to_bigendian): ...this.  Update all callers.
	(remote_fileio_to_fio_uint): Rename to...
	(host_to_fileio_uint): ...this.  Update all callers.
	(remote_fileio_to_fio_time): Rename to...
	(host_to_fileio_time): ...this.  Update all callers.
	(remote_fileio_to_fio_stat): Rename to...
	(host_to_fileio_stat): ...this.
	Update all references.
	* common/common-remote-fileio.c: Rename to...
	* common/fileio.c: ...this.  Update all references.
	(remote_fileio_to_fio_error): Rename to...
	(host_to_fileio_error): ...this.  Update all callers.
	(remote_fileio_mode_to_target): Rename to...
	(fileio_mode_pack): ...this.  Update all callers.
	(remote_fileio_to_fio_mode): Rename to...
	(host_to_fileio_mode): ...this.  Update all callers.
	(remote_fileio_to_fio_ulong): Rename to...
	(host_to_fileio_ulong): ...this.  Update all callers.
	(remote_fileio_to_fio_stat): Rename to...
	(host_to_fileio_stat): ...this.  Update all callers.
---
 gdb/ChangeLog                     |   28 ++++++
 gdb/Makefile.in                   |   10 +-
 gdb/common/common-remote-fileio.c |  172 -------------------------------------
 gdb/common/common-remote-fileio.h |   65 --------------
 gdb/common/fileio.c               |  171 ++++++++++++++++++++++++++++++++++++
 gdb/common/fileio.h               |   63 ++++++++++++++
 gdb/gdbserver/Makefile.in         |    6 +-
 gdb/gdbserver/hostio-errno.c      |    4 +-
 gdb/gdbserver/hostio.c            |    4 +-
 gdb/inf-child.c                   |   16 ++--
 gdb/remote-fileio.c               |   14 ++--
 gdb/remote-fileio.h               |    2 +-
 12 files changed, 290 insertions(+), 265 deletions(-)
 delete mode 100644 gdb/common/common-remote-fileio.c
 delete mode 100644 gdb/common/common-remote-fileio.h
 create mode 100644 gdb/common/fileio.c
 create mode 100644 gdb/common/fileio.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 87645cd..95104ef 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -888,7 +888,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
 	target/waitstatus.c common/print-utils.c common/rsp-low.c \
 	common/errors.c common/common-debug.c common/common-exceptions.c \
-	common/btrace-common.c common/common-remote-fileio.c \
+	common/btrace-common.c common/fileio.c \
 	$(SUBDIR_GCC_COMPILE_SRCS)
 
 LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -979,7 +979,7 @@ i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
 common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
 common/common-exceptions.h target/target.h common/symbol.h \
 common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
-common/common-remote-fileio.h nat/x86-linux.h nat/x86-linux-dregs.h
+common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
@@ -1079,7 +1079,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
 	common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \
 	format.o registry.o btrace.o record-btrace.o waitstatus.o \
 	print-utils.o rsp-low.o errors.o common-debug.o debug.o \
-	common-exceptions.o btrace-common.o common-remote-fileio.o \
+	common-exceptions.o btrace-common.o fileio.o \
 	$(SUBDIR_GCC_COMPILE_OBS)
 
 TSOBS = inflow.o
@@ -2257,8 +2257,8 @@ btrace-common.o: ${srcdir}/common/btrace-common.c
 	$(COMPILE) $(srcdir)/common/btrace-common.c
 	$(POSTCOMPILE)
 
-common-remote-fileio.o: ${srcdir}/common/common-remote-fileio.c
-	$(COMPILE) $(srcdir)/common/common-remote-fileio.c
+fileio.o: ${srcdir}/common/fileio.c
+	$(COMPILE) $(srcdir)/common/fileio.c
 	$(POSTCOMPILE)
 #
 # gdb/target/ dependencies
diff --git a/gdb/common/common-remote-fileio.c b/gdb/common/common-remote-fileio.c
deleted file mode 100644
index 30c2c6b..0000000
--- a/gdb/common/common-remote-fileio.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* Remote File-I/O communications
-
-   Copyright (C) 2003-2015 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "common-defs.h"
-#include "common-remote-fileio.h"
-#include <sys/stat.h>
-
-/* See common-remote-fileio.h.  */
-
-int
-remote_fileio_to_fio_error (int error)
-{
-  switch (error)
-    {
-      case EPERM:
-        return FILEIO_EPERM;
-      case ENOENT:
-        return FILEIO_ENOENT;
-      case EINTR:
-        return FILEIO_EINTR;
-      case EIO:
-        return FILEIO_EIO;
-      case EBADF:
-        return FILEIO_EBADF;
-      case EACCES:
-        return FILEIO_EACCES;
-      case EFAULT:
-        return FILEIO_EFAULT;
-      case EBUSY:
-        return FILEIO_EBUSY;
-      case EEXIST:
-        return FILEIO_EEXIST;
-      case ENODEV:
-        return FILEIO_ENODEV;
-      case ENOTDIR:
-        return FILEIO_ENOTDIR;
-      case EISDIR:
-        return FILEIO_EISDIR;
-      case EINVAL:
-        return FILEIO_EINVAL;
-      case ENFILE:
-        return FILEIO_ENFILE;
-      case EMFILE:
-        return FILEIO_EMFILE;
-      case EFBIG:
-        return FILEIO_EFBIG;
-      case ENOSPC:
-        return FILEIO_ENOSPC;
-      case ESPIPE:
-        return FILEIO_ESPIPE;
-      case EROFS:
-        return FILEIO_EROFS;
-      case ENOSYS:
-        return FILEIO_ENOSYS;
-      case ENAMETOOLONG:
-        return FILEIO_ENAMETOOLONG;
-    }
-  return FILEIO_EUNKNOWN;
-}
-
-/* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
-
-static LONGEST
-remote_fileio_mode_to_target (mode_t mode)
-{
-  mode_t tmode = 0;
-
-  if (S_ISREG (mode))
-    tmode |= FILEIO_S_IFREG;
-  if (S_ISDIR (mode))
-    tmode |= FILEIO_S_IFDIR;
-  if (S_ISCHR (mode))
-    tmode |= FILEIO_S_IFCHR;
-  if (mode & S_IRUSR)
-    tmode |= FILEIO_S_IRUSR;
-  if (mode & S_IWUSR)
-    tmode |= FILEIO_S_IWUSR;
-  if (mode & S_IXUSR)
-    tmode |= FILEIO_S_IXUSR;
-#ifdef S_IRGRP
-  if (mode & S_IRGRP)
-    tmode |= FILEIO_S_IRGRP;
-#endif
-#ifdef S_IWRGRP
-  if (mode & S_IWGRP)
-    tmode |= FILEIO_S_IWGRP;
-#endif
-#ifdef S_IXGRP
-  if (mode & S_IXGRP)
-    tmode |= FILEIO_S_IXGRP;
-#endif
-  if (mode & S_IROTH)
-    tmode |= FILEIO_S_IROTH;
-#ifdef S_IWOTH
-  if (mode & S_IWOTH)
-    tmode |= FILEIO_S_IWOTH;
-#endif
-#ifdef S_IXOTH
-  if (mode & S_IXOTH)
-    tmode |= FILEIO_S_IXOTH;
-#endif
-  return tmode;
-}
-
-/* Pack a host-format mode_t into an fio_mode_t.  */
-
-static void
-remote_fileio_to_fio_mode (mode_t num, fio_mode_t fnum)
-{
-  remote_fileio_to_be (remote_fileio_mode_to_target (num),
-		       (char *) fnum, 4);
-}
-
-/* Pack a host-format integer into an fio_ulong_t.  */
-
-static void
-remote_fileio_to_fio_ulong (LONGEST num, fio_ulong_t fnum)
-{
-  remote_fileio_to_be (num, (char *) fnum, 8);
-}
-
-/* See common-remote-fileio.h.  */
-
-void
-remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
-{
-  LONGEST blksize;
-
-  remote_fileio_to_fio_uint ((long) st->st_dev, fst->fst_dev);
-  remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino);
-  remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode);
-  remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink);
-  remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid);
-  remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid);
-  remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev);
-  remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size);
-#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
-  blksize = st->st_blksize;
-#else
-  blksize = 512;
-#endif
-  remote_fileio_to_fio_ulong (blksize, fst->fst_blksize);
-#if HAVE_STRUCT_STAT_ST_BLOCKS
-  remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
-#else
-  /* FIXME: This is correct for DJGPP, but other systems that don't
-     have st_blocks, if any, might prefer 512 instead of st_blksize.
-     (eliz, 30-12-2003)  */
-  remote_fileio_to_fio_ulong (((LONGEST) st->st_size + blksize - 1)
-			      / blksize,
-			      fst->fst_blocks);
-#endif
-  remote_fileio_to_fio_time (st->st_atime, fst->fst_atime);
-  remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime);
-  remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime);
-}
diff --git a/gdb/common/common-remote-fileio.h b/gdb/common/common-remote-fileio.h
deleted file mode 100644
index 96e4aa5..0000000
--- a/gdb/common/common-remote-fileio.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Remote File-I/O communications
-
-   Copyright (C) 2003-2015 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef COMMON_REMOTE_FILEIO_H
-#define COMMON_REMOTE_FILEIO_H
-
-#include "gdb/fileio.h"
-#include <sys/stat.h>
-
-/* Convert a errno error number to a File-I/O error number for
-   transmission over the remote protocol.  */
-
-extern int remote_fileio_to_fio_error (int error);
-
-/* Pack a host-format integer into a byte buffer in big-endian format
-   ready for transmission over the remote protocol.  BYTES specifies
-   the size of the integer to pack in bytes.  */
-
-static inline void
-remote_fileio_to_be (LONGEST num, char *buf, int bytes)
-{
-  int i;
-
-  for (i = 0; i < bytes; ++i)
-    buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
-}
-
-/* Pack a host-format integer into an fio_uint_t.  */
-
-static inline void
-remote_fileio_to_fio_uint (long num, fio_uint_t fnum)
-{
-  remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4);
-}
-
-/* Pack a host-format time_t into an fio_time_t.  */
-
-static inline void
-remote_fileio_to_fio_time (time_t num, fio_time_t fnum)
-{
-  remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4);
-}
-
-/* Pack a host-format struct stat into a struct fio_stat.  */
-
-extern void remote_fileio_to_fio_stat (struct stat *st,
-				       struct fio_stat *fst);
-
-#endif /* COMMON_REMOTE_FILEIO_H */
diff --git a/gdb/common/fileio.c b/gdb/common/fileio.c
new file mode 100644
index 0000000..5d3e6ae
--- /dev/null
+++ b/gdb/common/fileio.c
@@ -0,0 +1,171 @@
+/* File-I/O functions for GDB, the GNU debugger.
+
+   Copyright (C) 2003-2015 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "common-defs.h"
+#include "fileio.h"
+#include <sys/stat.h>
+
+/* See fileio.h.  */
+
+int
+host_to_fileio_error (int error)
+{
+  switch (error)
+    {
+      case EPERM:
+        return FILEIO_EPERM;
+      case ENOENT:
+        return FILEIO_ENOENT;
+      case EINTR:
+        return FILEIO_EINTR;
+      case EIO:
+        return FILEIO_EIO;
+      case EBADF:
+        return FILEIO_EBADF;
+      case EACCES:
+        return FILEIO_EACCES;
+      case EFAULT:
+        return FILEIO_EFAULT;
+      case EBUSY:
+        return FILEIO_EBUSY;
+      case EEXIST:
+        return FILEIO_EEXIST;
+      case ENODEV:
+        return FILEIO_ENODEV;
+      case ENOTDIR:
+        return FILEIO_ENOTDIR;
+      case EISDIR:
+        return FILEIO_EISDIR;
+      case EINVAL:
+        return FILEIO_EINVAL;
+      case ENFILE:
+        return FILEIO_ENFILE;
+      case EMFILE:
+        return FILEIO_EMFILE;
+      case EFBIG:
+        return FILEIO_EFBIG;
+      case ENOSPC:
+        return FILEIO_ENOSPC;
+      case ESPIPE:
+        return FILEIO_ESPIPE;
+      case EROFS:
+        return FILEIO_EROFS;
+      case ENOSYS:
+        return FILEIO_ENOSYS;
+      case ENAMETOOLONG:
+        return FILEIO_ENAMETOOLONG;
+    }
+  return FILEIO_EUNKNOWN;
+}
+
+/* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
+
+static LONGEST
+fileio_mode_pack (mode_t mode)
+{
+  mode_t tmode = 0;
+
+  if (S_ISREG (mode))
+    tmode |= FILEIO_S_IFREG;
+  if (S_ISDIR (mode))
+    tmode |= FILEIO_S_IFDIR;
+  if (S_ISCHR (mode))
+    tmode |= FILEIO_S_IFCHR;
+  if (mode & S_IRUSR)
+    tmode |= FILEIO_S_IRUSR;
+  if (mode & S_IWUSR)
+    tmode |= FILEIO_S_IWUSR;
+  if (mode & S_IXUSR)
+    tmode |= FILEIO_S_IXUSR;
+#ifdef S_IRGRP
+  if (mode & S_IRGRP)
+    tmode |= FILEIO_S_IRGRP;
+#endif
+#ifdef S_IWRGRP
+  if (mode & S_IWGRP)
+    tmode |= FILEIO_S_IWGRP;
+#endif
+#ifdef S_IXGRP
+  if (mode & S_IXGRP)
+    tmode |= FILEIO_S_IXGRP;
+#endif
+  if (mode & S_IROTH)
+    tmode |= FILEIO_S_IROTH;
+#ifdef S_IWOTH
+  if (mode & S_IWOTH)
+    tmode |= FILEIO_S_IWOTH;
+#endif
+#ifdef S_IXOTH
+  if (mode & S_IXOTH)
+    tmode |= FILEIO_S_IXOTH;
+#endif
+  return tmode;
+}
+
+/* Pack a host-format mode_t into an fio_mode_t.  */
+
+static void
+host_to_fileio_mode (mode_t num, fio_mode_t fnum)
+{
+  host_to_bigendian (fileio_mode_pack (num), (char *) fnum, 4);
+}
+
+/* Pack a host-format integer into an fio_ulong_t.  */
+
+static void
+host_to_fileio_ulong (LONGEST num, fio_ulong_t fnum)
+{
+  host_to_bigendian (num, (char *) fnum, 8);
+}
+
+/* See fileio.h.  */
+
+void
+host_to_fileio_stat (struct stat *st, struct fio_stat *fst)
+{
+  LONGEST blksize;
+
+  host_to_fileio_uint ((long) st->st_dev, fst->fst_dev);
+  host_to_fileio_uint ((long) st->st_ino, fst->fst_ino);
+  host_to_fileio_mode (st->st_mode, fst->fst_mode);
+  host_to_fileio_uint ((long) st->st_nlink, fst->fst_nlink);
+  host_to_fileio_uint ((long) st->st_uid, fst->fst_uid);
+  host_to_fileio_uint ((long) st->st_gid, fst->fst_gid);
+  host_to_fileio_uint ((long) st->st_rdev, fst->fst_rdev);
+  host_to_fileio_ulong ((LONGEST) st->st_size, fst->fst_size);
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+  blksize = st->st_blksize;
+#else
+  blksize = 512;
+#endif
+  host_to_fileio_ulong (blksize, fst->fst_blksize);
+#if HAVE_STRUCT_STAT_ST_BLOCKS
+  host_to_fileio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
+#else
+  /* FIXME: This is correct for DJGPP, but other systems that don't
+     have st_blocks, if any, might prefer 512 instead of st_blksize.
+     (eliz, 30-12-2003)  */
+  host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1)
+			/ blksize,
+			fst->fst_blocks);
+#endif
+  host_to_fileio_time (st->st_atime, fst->fst_atime);
+  host_to_fileio_time (st->st_mtime, fst->fst_mtime);
+  host_to_fileio_time (st->st_ctime, fst->fst_ctime);
+}
diff --git a/gdb/common/fileio.h b/gdb/common/fileio.h
new file mode 100644
index 0000000..69a735f
--- /dev/null
+++ b/gdb/common/fileio.h
@@ -0,0 +1,63 @@
+/* File-I/O functions for GDB, the GNU debugger.
+
+   Copyright (C) 2003-2015 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef FILEIO_H
+#define FILEIO_H
+
+#include "gdb/fileio.h"
+#include <sys/stat.h>
+
+/* Convert a host-format errno value to a File-I/O error number.  */
+
+extern int host_to_fileio_error (int error);
+
+/* Pack a host-format integer into a byte buffer in big-endian
+   format.  BYTES specifies the size of the integer to pack in
+   bytes.  */
+
+static inline void
+host_to_bigendian (LONGEST num, char *buf, int bytes)
+{
+  int i;
+
+  for (i = 0; i < bytes; ++i)
+    buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
+}
+
+/* Pack a host-format integer into an fio_uint_t.  */
+
+static inline void
+host_to_fileio_uint (long num, fio_uint_t fnum)
+{
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
+}
+
+/* Pack a host-format time_t into an fio_time_t.  */
+
+static inline void
+host_to_fileio_time (time_t num, fio_time_t fnum)
+{
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
+}
+
+/* Pack a host-format struct stat into a struct fio_stat.  */
+
+extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
+
+#endif /* FILEIO_H */
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 9d698c6..a981ee8 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -180,7 +180,7 @@ SFILES=	$(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
 	$(srcdir)/common/common-debug.c $(srcdir)/common/cleanups.c \
 	$(srcdir)/common/common-exceptions.c $(srcdir)/symbol.c \
 	$(srcdir)/common/btrace-common.c \
-	$(srcdir)/common/common-remote-fileio.c
+	$(srcdir)/common/fileio.c
 
 DEPFILES = @GDBSERVER_DEPFILES@
 
@@ -194,7 +194,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
       mem-break.o hostio.o event-loop.o tracepoint.o xml-utils.o \
       common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
       tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
-      common-exceptions.o symbol.o btrace-common.o common-remote-fileio.o \
+      common-exceptions.o symbol.o btrace-common.o fileio.o \
       $(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
 GDBREPLAY_OBS = gdbreplay.o version.o
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
@@ -573,7 +573,7 @@ common-exceptions.o: ../common/common-exceptions.c
 waitstatus.o: ../target/waitstatus.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
-common-remote-fileio.o: ../common/common-remote-fileio.c
+fileio.o: ../common/fileio.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
diff --git a/gdb/gdbserver/hostio-errno.c b/gdb/gdbserver/hostio-errno.c
index 01d4b32..452ec9f 100644
--- a/gdb/gdbserver/hostio-errno.c
+++ b/gdb/gdbserver/hostio-errno.c
@@ -22,12 +22,12 @@
    on top of errno.  */
 
 #include "server.h"
-#include "common-remote-fileio.h"
+#include "fileio.h"
 
 void
 hostio_last_error_from_errno (char *buf)
 {
   int error = errno;
-  int fileio_error = remote_fileio_to_fio_error (error);
+  int fileio_error = host_to_fileio_error (error);
   sprintf (buf, "F-1,%x", fileio_error);
 }
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index aa659e2..b03b5ad 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -27,7 +27,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "common-remote-fileio.h"
+#include "fileio.h"
 
 extern int remote_debug;
 
@@ -438,7 +438,7 @@ handle_fstat (char *own_buf, int *new_packet_len)
       return;
     }
 
-  remote_fileio_to_fio_stat (&st, &fst);
+  host_to_fileio_stat (&st, &fst);
 
   bytes_sent = hostio_reply_with_data (own_buf,
 				       (char *) &fst, sizeof (fst),
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 5e5763b..713c9d4 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -30,7 +30,7 @@
 #include "inferior.h"
 #include <sys/stat.h>
 #include "inf-child.h"
-#include "common-remote-fileio.h"
+#include "fileio.h"
 #include "agent.h"
 #include "gdb_wait.h"
 #include "filestuff.h"
@@ -260,7 +260,7 @@ inf_child_fileio_open (struct target_ops *self,
      the standard values.  */
   fd = gdb_open_cloexec (filename, nat_flags, mode);
   if (fd == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return fd;
 }
@@ -289,7 +289,7 @@ inf_child_fileio_pwrite (struct target_ops *self,
     }
 
   if (ret == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return ret;
 }
@@ -318,7 +318,7 @@ inf_child_fileio_pread (struct target_ops *self,
     }
 
   if (ret == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return ret;
 }
@@ -332,7 +332,7 @@ inf_child_fileio_fstat (struct target_ops *self, int fd,
 
   ret = fstat (fd, sb);
   if (ret == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return ret;
 }
@@ -346,7 +346,7 @@ inf_child_fileio_close (struct target_ops *self, int fd, int *target_errno)
 
   ret = close (fd);
   if (ret == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return ret;
 }
@@ -361,7 +361,7 @@ inf_child_fileio_unlink (struct target_ops *self,
 
   ret = unlink (filename);
   if (ret == -1)
-    *target_errno = remote_fileio_to_fio_error (errno);
+    *target_errno = host_to_fileio_error (errno);
 
   return ret;
 }
@@ -383,7 +383,7 @@ inf_child_fileio_readlink (struct target_ops *self,
   len = readlink (filename, buf, sizeof buf);
   if (len < 0)
     {
-      *target_errno = remote_fileio_to_fio_error (errno);
+      *target_errno = host_to_fileio_error (errno);
       return NULL;
     }
 
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 36c3849..a33acf9 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -290,13 +290,13 @@ remote_fileio_extract_ptr_w_len (char **buf, CORE_ADDR *ptrval, int *length)
 static void
 remote_fileio_to_fio_long (LONGEST num, fio_long_t fnum)
 {
-  remote_fileio_to_be (num, (char *) fnum, 8);
+  host_to_bigendian (num, (char *) fnum, 8);
 }
 
 static void
 remote_fileio_to_fio_timeval (struct timeval *tv, struct fio_timeval *ftv)
 {
-  remote_fileio_to_fio_time (tv->tv_sec, ftv->ftv_sec);
+  host_to_fileio_time (tv->tv_sec, ftv->ftv_sec);
   remote_fileio_to_fio_long (tv->tv_usec, ftv->ftv_usec);
 }
 
@@ -408,7 +408,7 @@ static void
 remote_fileio_return_errno (int retcode)
 {
   remote_fileio_reply (retcode, retcode < 0
-		       ? remote_fileio_to_fio_error (errno) : 0);
+		       ? host_to_fileio_error (errno) : 0);
 }
 
 static void
@@ -953,8 +953,8 @@ remote_fileio_func_stat (char *buf)
     }
   if (statptr)
     {
-      remote_fileio_to_fio_stat (&st, &fst);
-      remote_fileio_to_fio_uint (0, fst.fst_dev);
+      host_to_fileio_stat (&st, &fst);
+      host_to_fileio_uint (0, fst.fst_dev);
 
       errno = target_write_memory (statptr, (gdb_byte *) &fst, sizeof fst);
       if (errno != 0)
@@ -1000,7 +1000,7 @@ remote_fileio_func_fstat (char *buf)
   remote_fio_no_longjmp = 1;
   if (fd == FIO_FD_CONSOLE_IN || fd == FIO_FD_CONSOLE_OUT)
     {
-      remote_fileio_to_fio_uint (1, fst.fst_dev);
+      host_to_fileio_uint (1, fst.fst_dev);
       memset (&st, 0, sizeof (st));
       st.st_mode = S_IFCHR | (fd == FIO_FD_CONSOLE_IN ? S_IRUSR : S_IWUSR);
       st.st_nlink = 1;
@@ -1032,7 +1032,7 @@ remote_fileio_func_fstat (char *buf)
     }
   if (ptrval)
     {
-      remote_fileio_to_fio_stat (&st, &fst);
+      host_to_fileio_stat (&st, &fst);
 
       errno = target_write_memory (ptrval, (gdb_byte *) &fst, sizeof fst);
       if (errno != 0)
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index d30ae6a..21096a0 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -22,7 +22,7 @@
 #ifndef REMOTE_FILEIO_H
 #define REMOTE_FILEIO_H
 
-#include "common-remote-fileio.h"
+#include "fileio.h"
 
 struct cmd_list_element;
 
-- 
1.7.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch]
  2015-04-09 14:12         ` [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch] Gary Benson
@ 2015-04-09 14:18           ` Gary Benson
  2015-04-09 14:23             ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2015-04-09 14:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

git diff -M version as promised...

diff --git a/gdb/common/common-remote-fileio.c b/gdb/common/fileio.c
similarity index 68%
rename from gdb/common/common-remote-fileio.c
rename to gdb/common/fileio.c
index 30c2c6b..5d3e6ae 100644
--- a/gdb/common/common-remote-fileio.c
+++ b/gdb/common/fileio.c
@@ -1,4 +1,4 @@
-/* Remote File-I/O communications
+/* File-I/O functions for GDB, the GNU debugger.
 
    Copyright (C) 2003-2015 Free Software Foundation, Inc.
 
@@ -18,13 +18,13 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "common-defs.h"
-#include "common-remote-fileio.h"
+#include "fileio.h"
 #include <sys/stat.h>
 
-/* See common-remote-fileio.h.  */
+/* See fileio.h.  */
 
 int
-remote_fileio_to_fio_error (int error)
+host_to_fileio_error (int error)
 {
   switch (error)
     {
@@ -77,7 +77,7 @@ remote_fileio_to_fio_error (int error)
 /* Convert a host-format mode_t into a bitmask of File-I/O flags.  */
 
 static LONGEST
-remote_fileio_mode_to_target (mode_t mode)
+fileio_mode_pack (mode_t mode)
 {
   mode_t tmode = 0;
 
@@ -121,52 +121,51 @@ remote_fileio_mode_to_target (mode_t mode)
 /* Pack a host-format mode_t into an fio_mode_t.  */
 
 static void
-remote_fileio_to_fio_mode (mode_t num, fio_mode_t fnum)
+host_to_fileio_mode (mode_t num, fio_mode_t fnum)
 {
-  remote_fileio_to_be (remote_fileio_mode_to_target (num),
-		       (char *) fnum, 4);
+  host_to_bigendian (fileio_mode_pack (num), (char *) fnum, 4);
 }
 
 /* Pack a host-format integer into an fio_ulong_t.  */
 
 static void
-remote_fileio_to_fio_ulong (LONGEST num, fio_ulong_t fnum)
+host_to_fileio_ulong (LONGEST num, fio_ulong_t fnum)
 {
-  remote_fileio_to_be (num, (char *) fnum, 8);
+  host_to_bigendian (num, (char *) fnum, 8);
 }
 
-/* See common-remote-fileio.h.  */
+/* See fileio.h.  */
 
 void
-remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
+host_to_fileio_stat (struct stat *st, struct fio_stat *fst)
 {
   LONGEST blksize;
 
-  remote_fileio_to_fio_uint ((long) st->st_dev, fst->fst_dev);
-  remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino);
-  remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode);
-  remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink);
-  remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid);
-  remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid);
-  remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev);
-  remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size);
+  host_to_fileio_uint ((long) st->st_dev, fst->fst_dev);
+  host_to_fileio_uint ((long) st->st_ino, fst->fst_ino);
+  host_to_fileio_mode (st->st_mode, fst->fst_mode);
+  host_to_fileio_uint ((long) st->st_nlink, fst->fst_nlink);
+  host_to_fileio_uint ((long) st->st_uid, fst->fst_uid);
+  host_to_fileio_uint ((long) st->st_gid, fst->fst_gid);
+  host_to_fileio_uint ((long) st->st_rdev, fst->fst_rdev);
+  host_to_fileio_ulong ((LONGEST) st->st_size, fst->fst_size);
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
   blksize = st->st_blksize;
 #else
   blksize = 512;
 #endif
-  remote_fileio_to_fio_ulong (blksize, fst->fst_blksize);
+  host_to_fileio_ulong (blksize, fst->fst_blksize);
 #if HAVE_STRUCT_STAT_ST_BLOCKS
-  remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
+  host_to_fileio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
 #else
   /* FIXME: This is correct for DJGPP, but other systems that don't
      have st_blocks, if any, might prefer 512 instead of st_blksize.
      (eliz, 30-12-2003)  */
-  remote_fileio_to_fio_ulong (((LONGEST) st->st_size + blksize - 1)
-			      / blksize,
-			      fst->fst_blocks);
+  host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1)
+			/ blksize,
+			fst->fst_blocks);
 #endif
-  remote_fileio_to_fio_time (st->st_atime, fst->fst_atime);
-  remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime);
-  remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime);
+  host_to_fileio_time (st->st_atime, fst->fst_atime);
+  host_to_fileio_time (st->st_mtime, fst->fst_mtime);
+  host_to_fileio_time (st->st_ctime, fst->fst_ctime);
 }
diff --git a/gdb/common/common-remote-fileio.h b/gdb/common/fileio.h
similarity index 56%
rename from gdb/common/common-remote-fileio.h
rename to gdb/common/fileio.h
index 96e4aa5..69a735f 100644
--- a/gdb/common/common-remote-fileio.h
+++ b/gdb/common/fileio.h
@@ -1,4 +1,4 @@
-/* Remote File-I/O communications
+/* File-I/O functions for GDB, the GNU debugger.
 
    Copyright (C) 2003-2015 Free Software Foundation, Inc.
 
@@ -17,23 +17,22 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef COMMON_REMOTE_FILEIO_H
-#define COMMON_REMOTE_FILEIO_H
+#ifndef FILEIO_H
+#define FILEIO_H
 
 #include "gdb/fileio.h"
 #include <sys/stat.h>
 
-/* Convert a errno error number to a File-I/O error number for
-   transmission over the remote protocol.  */
+/* Convert a host-format errno value to a File-I/O error number.  */
 
-extern int remote_fileio_to_fio_error (int error);
+extern int host_to_fileio_error (int error);
 
-/* Pack a host-format integer into a byte buffer in big-endian format
-   ready for transmission over the remote protocol.  BYTES specifies
-   the size of the integer to pack in bytes.  */
+/* Pack a host-format integer into a byte buffer in big-endian
+   format.  BYTES specifies the size of the integer to pack in
+   bytes.  */
 
 static inline void
-remote_fileio_to_be (LONGEST num, char *buf, int bytes)
+host_to_bigendian (LONGEST num, char *buf, int bytes)
 {
   int i;
 
@@ -44,22 +43,21 @@ remote_fileio_to_be (LONGEST num, char *buf, int bytes)
 /* Pack a host-format integer into an fio_uint_t.  */
 
 static inline void
-remote_fileio_to_fio_uint (long num, fio_uint_t fnum)
+host_to_fileio_uint (long num, fio_uint_t fnum)
 {
-  remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4);
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
 }
 
 /* Pack a host-format time_t into an fio_time_t.  */
 
 static inline void
-remote_fileio_to_fio_time (time_t num, fio_time_t fnum)
+host_to_fileio_time (time_t num, fio_time_t fnum)
 {
-  remote_fileio_to_be ((LONGEST) num, (char *) fnum, 4);
+  host_to_bigendian ((LONGEST) num, (char *) fnum, 4);
 }
 
 /* Pack a host-format struct stat into a struct fio_stat.  */
 
-extern void remote_fileio_to_fio_stat (struct stat *st,
-				       struct fio_stat *fst);
+extern void host_to_fileio_stat (struct stat *st, struct fio_stat *fst);
 
-#endif /* COMMON_REMOTE_FILEIO_H */
+#endif /* FILEIO_H */


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch]
  2015-04-09 14:18           ` Gary Benson
@ 2015-04-09 14:23             ` Pedro Alves
  2015-04-09 16:04               ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2015-04-09 14:23 UTC (permalink / raw)
  To: Gary Benson, gdb-patches

OK.

Thanks!

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch]
  2015-04-09 14:23             ` Pedro Alves
@ 2015-04-09 16:04               ` Gary Benson
  0 siblings, 0 replies; 9+ messages in thread
From: Gary Benson @ 2015-04-09 16:04 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves wrote:
> OK.
> 
> Thanks!

Cool, I pushed it.

Thanks,
Gary

-- 
http://gbenson.net/


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-04-09 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09  9:51 [PATCH] Introduce new shared function remote_fileio_to_fio_error Gary Benson
2015-04-09 10:17 ` Pedro Alves
2015-04-09 10:50   ` Gary Benson
2015-04-09 11:00     ` Pedro Alves
2015-04-09 13:21       ` Gary Benson
2015-04-09 14:12         ` [PATCH] Rename common-remote-fileio.[ch] as fileio.[ch] Gary Benson
2015-04-09 14:18           ` Gary Benson
2015-04-09 14:23             ` Pedro Alves
2015-04-09 16:04               ` Gary Benson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox