(struct gdb_event) <fd>: Change type to gdb_fildes_t.
(struct file_handler) <fd>: Change type to gdb_fildes_t.
(process_event): Change local fd's type to gdb_fildes_t.
(create_file_handler): Adjust prototype.
(delete_file_handler): Adjust prototype.
(handle_file_event): Adjust prototype. Use pfildes.
(create_file_event): Adjsut prototype.
* remote-utils.c (remote_desc, listen_desc): Change type to
gdb_fildes_t.
* server.h: New gdb_fildes_t typedef.
[USE_WIN32API]: Include winsock2.h.
(delete_file_handler, add_file_handler): Adjust prototypes.
(pfildes): Declare.
* utils.c (pfildes): New.
+2010-08-27 Pedro Alves <pedro@codesourcery.com>
+
+ * event-loop.c (event_handle_func): Adjust to use gdb_fildes_t.
+ (struct gdb_event) <fd>: Change type to gdb_fildes_t.
+ (struct file_handler) <fd>: Change type to gdb_fildes_t.
+ (process_event): Change local fd's type to gdb_fildes_t.
+ (create_file_handler): Adjust prototype.
+ (delete_file_handler): Adjust prototype.
+ (handle_file_event): Adjust prototype. Use pfildes.
+ (create_file_event): Adjsut prototype.
+ * remote-utils.c (remote_desc, listen_desc): Change type to
+ gdb_fildes_t.
+ * server.h: New gdb_fildes_t typedef.
+ [USE_WIN32API]: Include winsock2.h.
+ (delete_file_handler, add_file_handler): Adjust prototypes.
+ (pfildes): Declare.
+ * utils.c (pfildes): New.
+
2010-08-27 Pedro Alves <pedro@codesourcery.com>
* configure.ac (build_warnings): Add -Wno-char-subscripts.
#endif
typedef struct gdb_event gdb_event;
-typedef int (event_handler_func) (int);
+typedef int (event_handler_func) (gdb_fildes_t);
/* Tell create_file_handler what events we are interested in. */
event_handler_func *proc;
/* File descriptor that is ready. */
- int fd;
+ gdb_fildes_t fd;
/* Next in list of events or NULL. */
struct gdb_event *next_event;
typedef struct file_handler
{
/* File descriptor. */
- int fd;
+ gdb_fildes_t fd;
/* Events we want to monitor. */
int mask;
{
gdb_event *event_ptr, *prev_ptr;
event_handler_func *proc;
- int fd;
+ gdb_fildes_t fd;
/* Look in the event queue to find an event that is ready
to be processed. */
occurs for FD. CLIENT_DATA is the argument to pass to PROC. */
static void
-create_file_handler (int fd, int mask, handler_func *proc,
+create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc,
gdb_client_data client_data)
{
file_handler *file_ptr;
/* Wrapper function for create_file_handler. */
void
-add_file_handler (int fd, handler_func *proc, gdb_client_data client_data)
+add_file_handler (gdb_fildes_t fd,
+ handler_func *proc, gdb_client_data client_data)
{
create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data);
}
i.e. we don't care anymore about events on the FD. */
void
-delete_file_handler (int fd)
+delete_file_handler (gdb_fildes_t fd)
{
file_handler *file_ptr, *prev_ptr = NULL;
int i;
event in the front of the event queue. */
static int
-handle_file_event (int event_file_desc)
+handle_file_event (gdb_fildes_t event_file_desc)
{
file_handler *file_ptr;
int mask;
if (file_ptr->ready_mask & GDB_EXCEPTION)
{
- fprintf (stderr, "Exception condition detected on fd %d\n",
- file_ptr->fd);
+ fprintf (stderr, "Exception condition detected on fd %s\n",
+ pfildes (file_ptr->fd));
file_ptr->error = 1;
}
else
associated to FD when it was registered with the event loop. */
static gdb_event *
-create_file_event (int fd)
+create_file_event (gdb_fildes_t fd)
{
gdb_event *file_event_ptr;
int remote_debug = 0;
struct ui_file *gdb_stdlog;
-static int remote_desc = INVALID_DESCRIPTOR;
-static int listen_desc = INVALID_DESCRIPTOR;
+static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
+static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
/* FIXME headerize? */
extern int using_threads;
extern int multi_process;
extern int non_stop;
+#if USE_WIN32API
+#include <winsock2.h>
+typedef SOCKET gdb_fildes_t;
+#else
+typedef int gdb_fildes_t;
+#endif
+
/* Functions from event-loop.c. */
typedef void *gdb_client_data;
typedef int (handler_func) (int, gdb_client_data);
typedef int (callback_handler_func) (gdb_client_data);
-extern void delete_file_handler (int fd);
-extern void add_file_handler (int fd, handler_func *proc,
+extern void delete_file_handler (gdb_fildes_t fd);
+extern void add_file_handler (gdb_fildes_t fd, handler_func *proc,
gdb_client_data client_data);
extern int append_callback_event (callback_handler_func *proc,
gdb_client_data client_data);
char *pulongest (ULONGEST u);
char *plongest (LONGEST l);
char *phex_nz (ULONGEST l, int sizeof_l);
+char *pfildes (gdb_fildes_t fd);
#define gdb_assert(expr) \
((void) ((expr) ? 0 : \
{
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
+}