/* main.c --- main function for stand-alone M32C simulator.
-Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005-2019 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of the GNU simulators.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <setjmp.h>
#include <signal.h>
-
#include <sys/types.h>
+
+#ifdef HAVE_SYS_SOCKET_H
+#ifdef HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_TCP_H
+#define HAVE_networking
+#endif
+#endif
+#endif
+
+#ifdef HAVE_networking
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#endif
#include "bfd.h"
#include "timer_a.h"
#endif
+#ifdef HAVE_networking
extern int m32c_console_ofd;
extern int m32c_console_ifd;
+#endif
int m32c_disassemble = 0;
static unsigned int cycles = 0;
exit (exit_code);
}
+#ifdef HAVE_networking
static void
setup_tcp_console (char *portname)
{
address.sin_port = htons (port);
isocket = socket (AF_INET, SOCK_STREAM, 0);
- if (isocket < 0)
+ if (isocket == -1)
{
perror ("socket");
exit (1);
printf ("connection from %d.%d.%d.%d\n", a[0], a[1], a[2], a[3]);
m32c_console_ofd = m32c_console_ifd;
}
+#endif
int
main (int argc, char **argv)
int o;
int save_trace;
bfd *prog;
+#ifdef HAVE_networking
char *console_port_s = 0;
+#endif
setbuf (stdout, 0);
trace++;
break;
case 'c':
+#ifdef HAVE_networking
console_port_s = optarg;
+#else
+ fprintf (stderr, "Nework console not available in this build.\n");
+#endif
break;
case 'C':
+#ifdef HAVE_TERMIOS_H
m32c_use_raw_console = 1;
+#else
+ fprintf (stderr, "Raw console not available in this build.\n");
+#endif
break;
case 'v':
verbose++;
m32c_load (prog);
trace = save_trace;
+#ifdef HAVE_networking
if (console_port_s)
setup_tcp_console (console_port_s);
+#endif
sim_disasm_init (prog);