public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 3/3] gdbsupport: move fileio_errno_to_host to fileio.{h.cc} and rename
Date: Fri, 26 Aug 2022 15:54:59 -0400	[thread overview]
Message-ID: <20220826195459.2540898-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20220826195459.2540898-1-simon.marchi@efficios.com>

We have a downstream change in ROCm-GDB to move fileio_errno_to_host to
gdbsupport/fileio.{h,cc}, so we can use it outside of gdb_bfd.c.  Even
though there is nothing upstream that would need this, I think it's a
change that makes sense, that fileio_errno_to_host belongs there,
alongside host_to_fileio_error.

Rename it fileio_error_to_host, for symmetry with host_to_fileio_error.

Change-Id: Ib9b8807683de2f809c94a5303e708acc2251a0df
---
 gdb/gdb_bfd.c        | 53 --------------------------------------------
 gdbsupport/fileio.cc | 53 ++++++++++++++++++++++++++++++++++++++++++++
 gdbsupport/fileio.h  |  4 ++++
 3 files changed, 57 insertions(+), 53 deletions(-)

diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 46e2c357e3f..f3a0afe7b26 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -302,59 +302,6 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
 			      mem_bfd_iovec_stat);
 }
 
-/* Return the system error number corresponding to ERRNUM.  */
-
-static int
-fileio_errno_to_host (fileio_error errnum)
-{
-  switch (errnum)
-    {
-      case FILEIO_EPERM:
-	return EPERM;
-      case FILEIO_ENOENT:
-	return ENOENT;
-      case FILEIO_EINTR:
-	return EINTR;
-      case FILEIO_EIO:
-	return EIO;
-      case FILEIO_EBADF:
-	return EBADF;
-      case FILEIO_EACCES:
-	return EACCES;
-      case FILEIO_EFAULT:
-	return EFAULT;
-      case FILEIO_EBUSY:
-	return EBUSY;
-      case FILEIO_EEXIST:
-	return EEXIST;
-      case FILEIO_ENODEV:
-	return ENODEV;
-      case FILEIO_ENOTDIR:
-	return ENOTDIR;
-      case FILEIO_EISDIR:
-	return EISDIR;
-      case FILEIO_EINVAL:
-	return EINVAL;
-      case FILEIO_ENFILE:
-	return ENFILE;
-      case FILEIO_EMFILE:
-	return EMFILE;
-      case FILEIO_EFBIG:
-	return EFBIG;
-      case FILEIO_ENOSPC:
-	return ENOSPC;
-      case FILEIO_ESPIPE:
-	return ESPIPE;
-      case FILEIO_EROFS:
-	return EROFS;
-      case FILEIO_ENOSYS:
-	return ENOSYS;
-      case FILEIO_ENAMETOOLONG:
-	return ENAMETOOLONG;
-    }
-  return -1;
-}
-
 /* bfd_openr_iovec OPEN_CLOSURE data for gdb_bfd_open.  */
 struct gdb_bfd_open_closure
 {
diff --git a/gdbsupport/fileio.cc b/gdbsupport/fileio.cc
index db7c1a7c488..b3864e86c85 100644
--- a/gdbsupport/fileio.cc
+++ b/gdbsupport/fileio.cc
@@ -77,6 +77,59 @@ host_to_fileio_error (int error)
 
 /* See fileio.h.  */
 
+int
+fileio_errno_to_host (fileio_error errnum)
+{
+  switch (errnum)
+    {
+      case FILEIO_EPERM:
+	return EPERM;
+      case FILEIO_ENOENT:
+	return ENOENT;
+      case FILEIO_EINTR:
+	return EINTR;
+      case FILEIO_EIO:
+	return EIO;
+      case FILEIO_EBADF:
+	return EBADF;
+      case FILEIO_EACCES:
+	return EACCES;
+      case FILEIO_EFAULT:
+	return EFAULT;
+      case FILEIO_EBUSY:
+	return EBUSY;
+      case FILEIO_EEXIST:
+	return EEXIST;
+      case FILEIO_ENODEV:
+	return ENODEV;
+      case FILEIO_ENOTDIR:
+	return ENOTDIR;
+      case FILEIO_EISDIR:
+	return EISDIR;
+      case FILEIO_EINVAL:
+	return EINVAL;
+      case FILEIO_ENFILE:
+	return ENFILE;
+      case FILEIO_EMFILE:
+	return EMFILE;
+      case FILEIO_EFBIG:
+	return EFBIG;
+      case FILEIO_ENOSPC:
+	return ENOSPC;
+      case FILEIO_ESPIPE:
+	return ESPIPE;
+      case FILEIO_EROFS:
+	return EROFS;
+      case FILEIO_ENOSYS:
+	return ENOSYS;
+      case FILEIO_ENAMETOOLONG:
+	return ENAMETOOLONG;
+    }
+  return -1;
+}
+
+/* See fileio.h.  */
+
 int
 fileio_to_host_openflags (int fileio_open_flags, int *open_flags_p)
 {
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 6a5297c6433..619f7e9f5e6 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -139,6 +139,10 @@ struct fio_timeval
 
 extern fileio_error host_to_fileio_error (int error);
 
+/* Convert a File-I/O error number to a host-format errno value.  */
+
+extern int fileio_errno_to_host (fileio_error errnum);
+
 /* Convert File-I/O open flags FFLAGS to host format, storing
    the result in *FLAGS.  Return 0 on success, -1 on error.  */
 
-- 
2.37.1


  parent reply	other threads:[~2022-08-26 19:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 19:54 [PATCH 1/3] gdbsupport: move include/gdb/fileio.h contents to fileio.h Simon Marchi
2022-08-26 19:54 ` [PATCH 2/3] gdbsupport: convert FILEIO_* macros to an enum Simon Marchi
2022-08-26 19:54 ` Simon Marchi [this message]
2022-08-29 16:29 ` [PATCH v2 0/3] fileio error cleanups Simon Marchi
2022-08-29 16:29   ` [PATCH v2 1/3] gdbsupport: move include/gdb/fileio.h contents to fileio.h Simon Marchi
2022-09-21 18:13     ` Simon Marchi
2022-08-29 16:29   ` [PATCH v2 2/3] gdbsupport: convert FILEIO_* macros to an enum Simon Marchi
2022-08-29 16:29   ` [PATCH v2 3/3] gdbsupport: move fileio_errno_to_host to fileio.{h, cc} and rename Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220826195459.2540898-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).