[RFC 16/17] Remove gdb_fildes_t

Tom Tromey
2019-02-24T16:52:08Z

gdb_fildes_t and pfildes are no longer used, so remove them.

2019-02-24 Tom Tromey <tom@tromey.com>

* server.h (gdb_fildes_t): Remove typedef.
* remote-utils.c (remote_desc, list_desc): Now int.
(INVALID_DESCRIPTOR): Remove.
(gdb_connected, remote_close)
(check_remote_input_interrupt_request): Update.
* utils.h (pfildes): Don't declare.
* utils.c (pfildes): Remove.
---
gdb/gdbserver/ChangeLog | 10 ++++++++++
gdb/gdbserver/remote-utils.c | 16 +++++-----------
gdb/gdbserver/server.h | 7 -------
gdb/gdbserver/utils.c | 12 ------------
gdb/gdbserver/utils.h | 1 -
5 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index bda261a4a9f..b1e4e869b69 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -77,12 +77,6 @@ typedef int socklen_t;

#ifndef IN_PROCESS_AGENT

-#if USE_WIN32API
-# define INVALID_DESCRIPTOR INVALID_SOCKET
-#else
-# define INVALID_DESCRIPTOR -1
-#endif
-
/* Extra value for readchar_callback. */
enum {
/* The callback is currently not scheduled. */
@@ -110,8 +104,8 @@ struct ui_file *gdb_stdlog;

static int remote_is_stdio = 0;

-static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
-static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
+static int remote_desc = -1;
+static int listen_desc = -1;

/* FIXME headerize? */
extern int using_threads;
@@ -125,7 +119,7 @@ extern int debug_threads;
int
gdb_connected (void)
{
- return remote_desc != INVALID_DESCRIPTOR;
+ return remote_desc != -1;
}

/* Return true if the remote connection is over stdio. */
@@ -431,7 +425,7 @@ remote_close (void)
if (! remote_connection_is_stdio ())
close (remote_desc);
#endif
- remote_desc = INVALID_DESCRIPTOR;
+ remote_desc = -1;

reset_readchar ();
}
@@ -794,7 +788,7 @@ check_remote_input_interrupt_request (void)
/* This function may be called before establishing communications,
therefore we need to validate the remote descriptor. */

- if (remote_desc == INVALID_DESCRIPTOR)
+ if (remote_desc == -1)
return;

input_interrupt (0);
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 5b359c8bae0..e6a8dcc9bf1 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -78,13 +78,6 @@ extern int disable_packet_qfThreadInfo;
extern int run_once;
extern int non_stop;

-#if USE_WIN32API
-#include <winsock2.h>
-typedef SOCKET gdb_fildes_t;
-#else
-typedef int gdb_fildes_t;
-#endif
-
#include "common/event-loop.h"

/* Functions from server.c. */
diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index 79a7e80f625..ed5c7fb4e11 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -125,15 +125,3 @@ paddress (CORE_ADDR addr)
{
return phex_nz (addr, sizeof (CORE_ADDR));
}
-
-/* Convert a file descriptor into a printable string. */
-
-char *
-pfildes (gdb_fildes_t fd)
-{
-#if USE_WIN32API
- return phex_nz (fd, sizeof (gdb_fildes_t));
-#else
- return plongest (fd);
-#endif
-}
diff --git a/gdb/gdbserver/utils.h b/gdb/gdbserver/utils.h
index 2bc7a6ecab9..dfc9c936892 100644
--- a/gdb/gdbserver/utils.h
+++ b/gdb/gdbserver/utils.h
@@ -20,6 +20,5 @@
#define GDBSERVER_UTILS_H

char *paddress (CORE_ADDR addr);
-char *pfildes (gdb_fildes_t fd);

#endif /* GDBSERVER_UTILS_H */
--
2.17.2