/* Serial interface for local (hardwired) serial ports on Windows systems
- Copyright (C) 2006-2014 Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include <unistd.h>
#include <sys/types.h>
-#include <string.h>
-
#include "command.h"
void _initialize_ser_windows (void);
return -1;
}
- state = xmalloc (sizeof (struct ser_windows_state));
- memset (state, 0, sizeof (struct ser_windows_state));
+ state = XCNEW (struct ser_windows_state);
scb->state = state;
/* Create a manual reset event to watch the input buffer. */
if (GetCommState (h, &state) == 0)
return;
- state.fParity = FALSE;
state.fOutxCtsFlow = FALSE;
state.fOutxDsrFlow = FALSE;
state.fDtrControl = DTR_CONTROL_ENABLE;
state.fNull = FALSE;
state.fAbortOnError = FALSE;
state.ByteSize = 8;
- state.Parity = NOPARITY;
scb->current_timeout = 0;
return (SetCommState (h, &state) != 0) ? 0 : -1;
}
+/* Implement the "setparity" serial_ops callback. */
+
+static int
+ser_windows_setparity (struct serial *scb, int parity)
+{
+ HANDLE h = (HANDLE) _get_osfhandle (scb->fd);
+ DCB state;
+
+ if (GetCommState (h, &state) == 0)
+ return -1;
+
+ switch (parity)
+ {
+ case GDBPARITY_NONE:
+ state.Parity = NOPARITY;
+ state.fParity = FALSE;
+ break;
+ case GDBPARITY_ODD:
+ state.Parity = ODDPARITY;
+ state.fParity = TRUE;
+ break;
+ case GDBPARITY_EVEN:
+ state.Parity = EVENPARITY;
+ state.fParity = TRUE;
+ break;
+ default:
+ internal_warning (__FILE__, __LINE__,
+ "Incorrect parity value: %d", parity);
+ return -1;
+ }
+
+ return (SetCommState (h, &state) != 0) ? 0 : -1;
+}
+
static int
ser_windows_setbaudrate (struct serial *scb, int rate)
{
return;
}
- state = xmalloc (sizeof (struct ser_console_state));
- memset (state, 0, sizeof (struct ser_console_state));
+ state = XCNEW (struct ser_console_state);
scb->state = state;
if (is_tty)
{
struct ser_console_ttystate *state;
- state = (struct ser_console_ttystate *) xmalloc (sizeof *state);
+ state = XNEW (struct ser_console_ttystate);
state->is_a_tty = 1;
return state;
}
static struct pipe_state *
make_pipe_state (void)
{
- struct pipe_state *ps = XNEW (struct pipe_state);
+ struct pipe_state *ps = XCNEW (struct pipe_state);
- memset (ps, 0, sizeof (*ps));
ps->wait.read_event = INVALID_HANDLE_VALUE;
ps->wait.except_event = INVALID_HANDLE_VALUE;
ps->wait.start_select = INVALID_HANDLE_VALUE;
if (ret != 0)
return ret;
- state = xmalloc (sizeof (struct net_windows_state));
- memset (state, 0, sizeof (struct net_windows_state));
+ state = XCNEW (struct net_windows_state);
scb->state = state;
/* Associate an event with the socket. */
ser_base_noflush_set_tty_state,
ser_windows_setbaudrate,
ser_windows_setstopbits,
+ ser_windows_setparity,
ser_windows_drain_output,
ser_base_async,
ser_windows_read_prim,
ser_base_noflush_set_tty_state,
NULL,
NULL,
+ NULL,
ser_base_drain_output,
NULL,
NULL,
ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
+ ser_base_setparity,
ser_base_drain_output,
ser_base_async,
pipe_windows_read,
ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
+ ser_base_setparity,
ser_base_drain_output,
ser_base_async,
net_read_prim,