diff options
author | DJ Delorie <dj@redhat.com> | 2009-08-14 04:24:30 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2009-08-14 04:24:30 +0000 |
commit | 340cf1cfb699a8b49b8a93967a3ac5c23dd00453 (patch) | |
tree | c6c9d6571ec7afca88c7c2fd07f51a0877fef243 | |
parent | a109e2f5583d186cb85203cf65900b6dd138993d (diff) | |
download | binutils-gdb-340cf1cfb699a8b49b8a93967a3ac5c23dd00453.tar.gz |
* 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.
-rw-r--r-- | sim/m32c/ChangeLog | 14 | ||||
-rw-r--r-- | sim/m32c/config.in | 15 | ||||
-rwxr-xr-x | sim/m32c/configure | 155 | ||||
-rw-r--r-- | sim/m32c/configure.in | 2 | ||||
-rw-r--r-- | sim/m32c/main.c | 29 | ||||
-rw-r--r-- | sim/m32c/mem.c | 16 |
6 files changed, 230 insertions, 1 deletions
diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog index 24684fb5eb1..9d71093cadb 100644 --- a/sim/m32c/ChangeLog +++ b/sim/m32c/ChangeLog @@ -1,3 +1,17 @@ +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. + 2009-01-06 Joel Sherrill <joel.sherrill@oarcorp.com> * r8c.opc, m32c.opc: Add parentheses to remove warnings. diff --git a/sim/m32c/config.in b/sim/m32c/config.in index 5e29f9569bf..0cde41f6c3b 100644 --- a/sim/m32c/config.in +++ b/sim/m32c/config.in @@ -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 diff --git a/sim/m32c/configure b/sim/m32c/configure index 95fef5c67c9..77e811104f3 100755 --- a/sim/m32c/configure +++ b/sim/m32c/configure @@ -4790,6 +4790,161 @@ sim_link_links="${sim_link_links} targ-vals.def" + + + + +for ac_header in sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + ac_sources="$sim_link_files" ac_dests="$sim_link_links" while test -n "$ac_sources"; do diff --git a/sim/m32c/configure.in b/sim/m32c/configure.in index 80c1f8a6f82..bca97ba49e8 100644 --- a/sim/m32c/configure.in +++ b/sim/m32c/configure.in @@ -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 diff --git a/sim/m32c/main.c b/sim/m32c/main.c index 721f728890e..c33824364f2 100644 --- a/sim/m32c/main.c +++ b/sim/m32c/main.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License 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 <http://www.gnu.org/licenses/>. */ #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 <http://www.gnu.org/licenses/>. */ #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); diff --git a/sim/m32c/mem.c b/sim/m32c/mem.c index 51bb0ab3d9e..a8630b13ea8 100644 --- a/sim/m32c/mem.c +++ b/sim/m32c/mem.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License 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 <http://www.gnu.org/licenses/>. */ #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 <http://www.gnu.org/licenses/>. */ 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. */ + ; } S ("=>"); |