Re: Mingw GDB build fails for M16C target

DJ Delorie
2009-08-14T04:24:49Z

> There is still following issue with simulator building:

Fixed.

2009-08-14 DJ Delorie <dj@redhat.com>

* configure.in: Check for sys/select.h, termios.h, sys/socket.h,
netinet/in.h, and netinet/tcp.h.
* configure: Regenerate.
* config.in: Add those headers.
* main.c: Check for them.
(setup_tcp_console): Disable if no networking.
(main): Note missing networking or termios.
* mem.c: Check for those headers.
(stdin_ready): Disable if no termios.
(m32c_sim_restore_console): Disable if no termios.
(mem_get_byte): Disable console input if no termios.

Index: config.in
===================================================================
RCS file: /cvs/src/src/sim/m32c/config.in,v
retrieving revision 1.2
diff -p -U3 -r1.2 config.in
--- config.in 11 Jul 2008 02:37:08 -0000 1.2
+++ config.in 14 Aug 2009 04:23:06 -0000
@@ -22,6 +22,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#undef HAVE_NETINET_TCP_H
+
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL

@@ -49,15 +55,24 @@
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H

+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H

/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H

+/* Define to 1 if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
/* Define to 1 if you have the `time' function. */
#undef HAVE_TIME

Index: configure.in
===================================================================
RCS file: /cvs/src/src/sim/m32c/configure.in,v
retrieving revision 1.5
diff -p -U3 -r1.5 configure.in
--- configure.in 14 Jan 2009 10:53:07 -0000 1.5
+++ configure.in 14 Aug 2009 04:23:06 -0000
@@ -28,4 +28,6 @@ sinclude(../common/aclocal.m4)
# it by inlining the macro's contents.
sinclude(../common/common.m4)

+AC_CHECK_HEADERS(sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h)
+
SIM_AC_OUTPUT
Index: main.c
===================================================================
RCS file: /cvs/src/src/sim/m32c/main.c,v
retrieving revision 1.7
diff -p -U3 -r1.7 main.c
--- main.c 14 Jan 2009 10:53:07 -0000 1.7
+++ main.c 14 Aug 2009 04:23:06 -0000
@@ -19,6 +19,7 @@ You should have received a copy of the G
along with this program. If not, see <http://www.gnu.org/licenses/>. */

+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -26,11 +27,21 @@ along with this program. If not, see <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"
@@ -45,8 +56,10 @@ along with this program. If not, see <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;
@@ -63,6 +76,7 @@ done (int exit_code)
exit (exit_code);
}

+#ifdef HAVE_networking
static void
setup_tcp_console (char *portname)
{
@@ -109,6 +123,7 @@ setup_tcp_console (char *portname)
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)
@@ -116,7 +131,9 @@ main (int argc, char **argv)
int o;
int save_trace;
bfd *prog;
+#ifdef HAVE_networking
char *console_port_s = 0;
+#endif

setbuf (stdout, 0);

@@ -129,10 +146,18 @@ main (int argc, char **argv)
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++;
@@ -177,8 +202,10 @@ main (int argc, char **argv)
m32c_load (prog);
trace = save_trace;

+#ifdef HAVE_networking
if (console_port_s)
setup_tcp_console (console_port_s);
+#endif

sim_disasm_init (prog);

Index: mem.c
===================================================================
RCS file: /cvs/src/src/sim/m32c/mem.c,v
retrieving revision 1.9
diff -p -U3 -r1.9 mem.c
--- mem.c 14 Jan 2009 10:53:07 -0000 1.9
+++ mem.c 14 Aug 2009 04:23:07 -0000
@@ -19,6 +19,7 @@ You should have received a copy of the G
along with this program. If not, see <http://www.gnu.org/licenses/>. */

+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -26,8 +27,12 @@ along with this program. If not, see <h
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
+#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
+#endif
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif

#include "mem.h"
#include "cpu.h"
@@ -48,9 +53,13 @@ along with this program. If not, see <h

static unsigned char **pt[L1_LEN];

+#ifdef HAVE_TERMIOS_H
int m32c_console_ifd = 0;
+#endif
int m32c_console_ofd = 1;
+#ifdef HAVE_TERMIOS_H
int m32c_use_raw_console = 0;
+#endif

#ifdef TIMER_A
Timer_A timer_a;
@@ -374,6 +383,7 @@ mem_get_pc ()
return *m;
}

+#ifdef HAVE_TERMIOS_H
static int console_raw = 0;
static struct termios oattr;

@@ -399,6 +409,7 @@ m32c_sim_restore_console ()
tcsetattr (m32c_console_ifd, TCSANOW, &oattr);
console_raw = 0;
}
+#endif

static unsigned char
mem_get_byte (int address)
@@ -408,6 +419,7 @@ mem_get_byte (int address)
m = mem_ptr (address);
switch (address)
{
+#ifdef HAVE_TERMIOS_H
case 0x2ed: /* m32c uart1c1 */
case 0x3ad: /* m16c uart1c1 */

@@ -447,6 +459,7 @@ mem_get_byte (int address)
}
return c;
}
+#endif

#ifdef TIMER_A
case 0x346: /* TA0low */
@@ -457,6 +470,9 @@ mem_get_byte (int address)
return timer_a.count;
#endif

+ default:
+ /* In case both cases above are not included. */
+ ;
}