[PATCH 5/6] Move remote_fileio_data to header file

Tom Tromey
2023-12-31T20:26:47Z

This moves remote_fileio_data to remote-fileio.h, in preparation for
removing the global.
---
gdb/remote-fileio.c | 36 +-----------------------------------
gdb/remote-fileio.h | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index e001c220522..a954ab1bb55 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -37,41 +37,7 @@
#endif
#include <signal.h>

-static struct remote_fileio_data
-{
-public:
-
- void request (remote_target *remote,
- char *buf, int ctrlc_pending_p);
-
- void reset ();
-
-private:
-
- int fd_to_targetfd (int fd);
- int map_fd (int target_fd);
- void close_target_fd (int target_fd);
-
- void func_open (remote_target *remote, char *buf);
- void func_close (remote_target *remote, char *buf);
- void func_read (remote_target *remote, char *buf);
- void func_write (remote_target *remote, char *buf);
- void func_lseek (remote_target *remote, char *buf);
- void func_rename (remote_target *remote, char *buf);
- void func_unlink (remote_target *remote, char *buf);
- void func_stat (remote_target *remote, char *buf);
- void func_fstat (remote_target *remote, char *buf);
- void func_gettimeofday (remote_target *remote, char *buf);
- void func_isatty (remote_target *remote, char *buf);
- void func_system (remote_target *remote, char *buf);
- void do_request (remote_target *remote, char *buf);
-
- int init_fd_map ();
- int resize_fd_map ();
- int next_free_fd ();
-
- std::vector<int> m_fd_map;
-} remote_fio_data;
+static remote_fileio_data remote_fio_data;

#define FIO_FD_INVALID -1
#define FIO_FD_CONSOLE_IN -2
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index 71d85c618a9..c632c9e40f8 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -27,6 +27,44 @@
struct cmd_list_element;
struct remote_target;

+/* This holds the state needed by the remote fileio code. */
+
+struct remote_fileio_data
+{
+public:
+
+ void request (remote_target *remote,
+ char *buf, int ctrlc_pending_p);
+
+ void reset ();
+
+private:
+
+ int fd_to_targetfd (int fd);
+ int map_fd (int target_fd);
+ void close_target_fd (int target_fd);
+
+ void func_open (remote_target *remote, char *buf);
+ void func_close (remote_target *remote, char *buf);
+ void func_read (remote_target *remote, char *buf);
+ void func_write (remote_target *remote, char *buf);
+ void func_lseek (remote_target *remote, char *buf);
+ void func_rename (remote_target *remote, char *buf);
+ void func_unlink (remote_target *remote, char *buf);
+ void func_stat (remote_target *remote, char *buf);
+ void func_fstat (remote_target *remote, char *buf);
+ void func_gettimeofday (remote_target *remote, char *buf);
+ void func_isatty (remote_target *remote, char *buf);
+ void func_system (remote_target *remote, char *buf);
+ void do_request (remote_target *remote, char *buf);
+
+ int init_fd_map ();
+ int resize_fd_map ();
+ int next_free_fd ();
+
+ std::vector<int> m_fd_map;
+};
+
/* Unified interface to remote fileio, called in remote.c from
remote_wait () and remote_async_wait (). */
extern void remote_fileio_request (remote_target *remote,

--
2.43.0