[rtems-tools commit] gdb patch to add leon2/3 support to sis
Sebastian Huber
sebh at rtems.org
Thu Dec 4 12:03:26 UTC 2014
Module: rtems-tools
Branch: master
Commit: af8c147a572933c47d2b1e126e9f71c5be11ec43
Changeset: http://git.rtems.org/rtems-tools/commit/?id=af8c147a572933c47d2b1e126e9f71c5be11ec43
Author: Jiri Gaisler <jiri at gaisler.se>
Date: Fri Nov 14 23:19:09 2014 +0100
gdb patch to add leon2/3 support to sis
This fixes the commit 4bdba3e552f22bbd82ffc9ab2c915a7b4f2eadd5 which
added a patch patch.
---
.../sparc/gdb-7.7-7.8-sis-leon2-leon3-fixup.diff | 17839 +++++++++----------
1 file changed, 8910 insertions(+), 8929 deletions(-)
diff --git a/tools/4.11/gdb/sparc/gdb-7.7-7.8-sis-leon2-leon3-fixup.diff b/tools/4.11/gdb/sparc/gdb-7.7-7.8-sis-leon2-leon3-fixup.diff
index 242a8ab..e19e30a 100644
--- a/tools/4.11/gdb/sparc/gdb-7.7-7.8-sis-leon2-leon3-fixup.diff
+++ b/tools/4.11/gdb/sparc/gdb-7.7-7.8-sis-leon2-leon3-fixup.diff
@@ -1,8934 +1,8915 @@
-From 458324b419f29cd473a6ed13ed7c61005453ab7a Mon Sep 17 00:00:00 2001
-From: Jiri Gaisler <jiri at gaisler.se>
-Date: Fri, 14 Nov 2014 23:19:09 +0100
-Subject: [PATCH] gdb patch to add leon2/3 support to sis
-
----
- .../gdb/sparc/gdb-7.7-sis-leon2-leon3-fixup.diff | 8915 ++++++++++++++++++++
- 1 file changed, 8915 insertions(+)
- create mode 100644 tools/4.11/gdb/sparc/gdb-7.7-sis-leon2-leon3-fixup.diff
-
-diff --git a/tools/4.11/gdb/sparc/gdb-7.7-sis-leon2-leon3-fixup.diff b/tools/4.11/gdb/sparc/gdb-7.7-sis-leon2-leon3-fixup.diff
+diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
+index 66ef84e..424e390 100644
+--- a/gdb/sparc-tdep.c
++++ b/gdb/sparc-tdep.c
+@@ -1713,6 +1713,8 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+ /* Hook in ABI-specific overrides, if they have been registered. */
+ gdbarch_init_osabi (info, gdbarch);
+
++ dwarf2_append_unwinders (gdbarch); /* DWARF CFI frame unwinder */
++
+ frame_unwind_append_unwinder (gdbarch, &sparc32_frame_unwind);
+
+ /* If we have register sets, enable the generic core file support. */
+diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in
+index 0ce58a6..3f09b0e 100644
+--- a/sim/erc32/Makefile.in
++++ b/sim/erc32/Makefile.in
+@@ -21,7 +21,7 @@
+ TERMCAP_LIB = @TERMCAP@
+ READLINE_LIB = @READLINE@
+
+-SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
++SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o leon2.o leon3.o grlib.o
+ SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
+ SIM_EXTRA_ALL = sis
+ SIM_EXTRA_INSTALL = install-sis
+@@ -30,32 +30,24 @@ SIM_EXTRA_CLEAN = clean-sis
+ # UARTS run at about 115200 baud (simulator time). Add -DFAST_UART to
+ # CFLAGS if faster (infinite) UART speed is desired. Might affect the
+ # behaviour of UART interrupt routines ...
+-SIM_EXTRA_CFLAGS = -DSTAT -DFAST_UART -DIUREV0 -DMECREV0
++SIM_EXTRA_CFLAGS = -DFAST_UART -I$(srcdir)/../..
+
+ ## COMMON_POST_CONFIG_FRAG
+
+ # `sis' doesn't need interf.o.
+-SIS_OFILES = exec.o erc32.o func.o help.o float.o
++SIS_OFILES = exec.o erc32.o func.o help.o float.o grlib.o leon2.o leon3.o
+
+ sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
+ $(CC) $(ALL_CFLAGS) -o sis \
+ sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
+
+-# FIXME: This computes the build host's endianness, doesn't it?
+-# There is AC_C_BIGENDIAN but it doesn't handle float endianness.
+-# [Are int/float endians every different on a sparc?]
+-end: $(srcdir)/end.c
+- $(CC_FOR_BUILD) -I. $(srcdir)/end.c -o end
+-end.h: end
+- ./end > end.h
+-
+ # Copy the files into directories where they will be run.
+ install-sis: installdirs
+ n=`echo sis | sed '$(program_transform_name)'`; \
+ $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
+
+ clean-sis:
+- rm -f sis end end.h
++ rm -f sis
+
+ configure:
+ @echo "Rebuilding configure..."
+@@ -65,10 +57,13 @@ configure:
+ (cd $${srcdir}; autoconf --localdir=../common)
+
+ # Circumvent Sun Make bug with VPATH.
+-erc32.o: erc32.c sis.h end.h
+-exec.o: exec.c sis.h end.h
+-float.o: float.c sis.h end.h
+-func.o: func.c sis.h end.h
+-help.o: help.c sis.h end.h
+-interf.o: interf.c sis.h end.h
+-sis.o: sis.c sis.h end.h
++erc32.o: erc32.c sis.h
++exec.o: exec.c sis.h
++float.o: float.c sis.h
++func.o: func.c sis.h
++help.o: help.c sis.h
++interf.o: interf.c sis.h
++sis.o: sis.c sis.h
++grlib.o: grlib.c sis.h grlib.h
++leon3.o: leon3.c sis.h grlib.h
++leon2.o: leon2.c sis.h
+diff --git a/sim/erc32/NEWS b/sim/erc32/NEWS
+deleted file mode 100644
+index dd24b7b..0000000
+--- a/sim/erc32/NEWS
++++ /dev/null
+@@ -1,108 +0,0 @@
+-
+-version 2.0 05-02-96
+---------------------
+-
+-* Switched to bfd library. Any supported format (elf, coff, ...) can be used.
+-* The UART devices can be set through -uart1 and -uart2 switches.
+-* Switched to GNU readline.
+-* Added -c option to run batch files at startup
+-* 'reg' command can show different register windows (eg 'reg w3').
+-* Use 'help' for online help on simulator commands
+-
+-version 1.8.1 20-01-96
+---------------------
+-
+-* added -mevrev0 switch to simulate MEC rev.0 bugs in timer and uart
+-
+-* added -iurev0 switch to simulate IU rev.0 jmpl/restore bug
+-
+-* Added sis command 'batch' to run batch files
+-
+-
+-version 1.8 30-10-95
+---------------------
+-
+-* Added s-record support. Use the '-s' switch with sis or the 'load' command.
+-
+-* IU load dependencies are now modelled
+-
+-version 1.7 30-10-95
+---------------------
+-
+-* Power-down mode implemented in erc32.c.
+-
+-* Performance display shows the ratio between simulator-time and real-time.
+-
+-
+-version 1.6.2 25-10-95
+---------------------
+-
+-* The UARTs can now be run at a given speed (simulator time) to better
+- simulate the behaviour of interrupt routines. The "true mode" is
+- selected through a compile switch in the makefile.
+-
+-
+-version 1.6 28-09-95
+---------------------
+-
+-* Major reorganisation of the code. mec.c and mem.c merged into erc32.c.
+-
+-* The load command does NOT longer load the initialised data at an address
+- defined by .bdata. This is done in srt0.s using _environ.
+-
+-* Additional MEC functionallity added - software reset, memory access
+- protection and waitstate configuration register.
+-
+-* interf.c - a GDB interface added
+-
+-* -v switch (verbose) added
+-
+-version 1.5 14-09-95
+---------------------
+-
+-* Added a instruction trace buffer, enabled through the 'hist' command.
+-
+-* Added a 'perf' command to display statistics such as instruction mix,
+- CPI, FPU holds etc.
+-
+-* Added -nfp switch to disable FPU.
+-
+-* Added -freq switch to set simulated frequency.
+-
+-version 1.4 22-08-95
+---------------------
+-
+-* A -g is provided for those who have problems with GNU readline().
+-
+-version 1.3 26-07-95
+---------------------
+-
+-* No major news, just a bug fix release ...
+-
+-
+-version 1.2 13-07-95
+---------------------
+-
+-* Added setting of IU registers through the 'reg' command. See README.
+-
+-* The GNU readline() function is used for command input. However, a
+-ctrl-D still kills the simulator ...
+-
+-
+-version 1.1 07-07-95
+---------------------
+-
+-
+-* Added a 'go' command
+-
+-* Added cycle counting for interrupt overhead.
+-
+-* Function 'get_mem_ptr' takes one more parameter to avoid segmentation
+- faults if a.out files are loaded outside the simulated memory. See README.
+-
+-* Added user-defined function sim_stop().
+-
+-* Added a reset command. See README.
+-
+-* Implemented buffered output for MEC uarts to improve output speed.
+-
+diff --git a/sim/erc32/README.gdb b/sim/erc32/README.gdb
+deleted file mode 100644
+index 619fcb3..0000000
+--- a/sim/erc32/README.gdb
++++ /dev/null
+@@ -1,67 +0,0 @@
+-How to use SIS with GDB
+------------------------
+-
+-1. Building GDB with SIS
+-
+-To build GDB with the SIS/ERC32 simulator, configure with option
+-'--target sparc-erc32-aout' and build as usual.
+-
+-2. Attaching the simulator
+-
+-To attach GDB to the simulator, use:
+-
+-target sim [options] [files]
+-
+-The following options are supported:
+-
+- -nfp Disable FPU. FPops will cause an FPU disabled trap.
+-
+- -freq <f> Set the simulated "system clock" to <f> MHz.
+-
+- -v Verbose mode.
+-
+- -nogdb Disable GDB breakpoint handling (see below)
+-
+-The listed [files] are expected to be in aout format and will be
+-loaded in the simulator memory prior. This could be used to load
+-a boot block at address 0x0 if the application is linked to run
+-from RAM (0x2000000).
+-
+-To start debugging a program type 'load <program>' and debug as
+-usual.
+-
+-The native simulator commands can be reached using the GDB 'sim'
+-command:
+-
+-sim <sis_command>
+-
+-Direct simulator commands during a GDB session must be issued
+-with care not to disturb GDB's operation ...
+-
+-For info on supported ERC32 functionality, see README.sis.
+-
+-
+-3. Loading aout files
+-
+-The GDB load command loads an aout file into the simulator
+-memory with the data section starting directly after the text
+-section regardless of wich start address was specified for the data
+-at link time! This means that your applications either has to include
+-a routine that initialise the data segment at the proper address or
+-link with the data placed directly after the text section.
+-
+-A copying routine is fairly simple, just copy all data between
+-_etext and _data to a memory loaction starting at _environ. This
+-should be done at the same time as the bss is cleared (in srt0.s).
+-
+-
+-4. GDB breakpoint handling
+-
+-GDB inserts breakpoint in the form of the 'ta 1' instruction. The
+-GDB-integrated simulator will therefore recognize the breakpoint
+-instruction and return control to GDB. If the application uses
+-'ta 1', the breakpoint detection can be disabled with the -nogdb
+-switch. In this case however, GDB breakpoints will not work.
+-
+-
+-Report problems to Jiri Gaisler ESA/ESTEC (jgais at wd.estec.esa.nl)
+diff --git a/sim/erc32/README.leon2 b/sim/erc32/README.leon2
new file mode 100644
-index 0000000..e19e30a
+index 0000000..3820eca
--- /dev/null
-+++ b/tools/4.11/gdb/sparc/gdb-7.7-sis-leon2-leon3-fixup.diff
-@@ -0,0 +1,8915 @@
-+diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
-+index 66ef84e..424e390 100644
-+--- a/gdb/sparc-tdep.c
-++++ b/gdb/sparc-tdep.c
-+@@ -1713,6 +1713,8 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
-+ /* Hook in ABI-specific overrides, if they have been registered. */
-+ gdbarch_init_osabi (info, gdbarch);
-+
-++ dwarf2_append_unwinders (gdbarch); /* DWARF CFI frame unwinder */
-++
-+ frame_unwind_append_unwinder (gdbarch, &sparc32_frame_unwind);
-+
-+ /* If we have register sets, enable the generic core file support. */
-+diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in
-+index 0ce58a6..3f09b0e 100644
-+--- a/sim/erc32/Makefile.in
-++++ b/sim/erc32/Makefile.in
-+@@ -21,7 +21,7 @@
-+ TERMCAP_LIB = @TERMCAP@
-+ READLINE_LIB = @READLINE@
-+
-+-SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
-++SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o leon2.o leon3.o grlib.o
-+ SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
-+ SIM_EXTRA_ALL = sis
-+ SIM_EXTRA_INSTALL = install-sis
-+@@ -30,32 +30,24 @@ SIM_EXTRA_CLEAN = clean-sis
-+ # UARTS run at about 115200 baud (simulator time). Add -DFAST_UART to
-+ # CFLAGS if faster (infinite) UART speed is desired. Might affect the
-+ # behaviour of UART interrupt routines ...
-+-SIM_EXTRA_CFLAGS = -DSTAT -DFAST_UART -DIUREV0 -DMECREV0
-++SIM_EXTRA_CFLAGS = -DFAST_UART -I$(srcdir)/../..
-+
-+ ## COMMON_POST_CONFIG_FRAG
-+
-+ # `sis' doesn't need interf.o.
-+-SIS_OFILES = exec.o erc32.o func.o help.o float.o
-++SIS_OFILES = exec.o erc32.o func.o help.o float.o grlib.o leon2.o leon3.o
-+
-+ sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
-+ $(CC) $(ALL_CFLAGS) -o sis \
-+ sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
-+
-+-# FIXME: This computes the build host's endianness, doesn't it?
-+-# There is AC_C_BIGENDIAN but it doesn't handle float endianness.
-+-# [Are int/float endians every different on a sparc?]
-+-end: $(srcdir)/end.c
-+- $(CC_FOR_BUILD) -I. $(srcdir)/end.c -o end
-+-end.h: end
-+- ./end > end.h
-+-
-+ # Copy the files into directories where they will be run.
-+ install-sis: installdirs
-+ n=`echo sis | sed '$(program_transform_name)'`; \
-+ $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
-+
-+ clean-sis:
-+- rm -f sis end end.h
-++ rm -f sis
-+
-+ configure:
-+ @echo "Rebuilding configure..."
-+@@ -65,10 +57,13 @@ configure:
-+ (cd $${srcdir}; autoconf --localdir=../common)
-+
-+ # Circumvent Sun Make bug with VPATH.
-+-erc32.o: erc32.c sis.h end.h
-+-exec.o: exec.c sis.h end.h
-+-float.o: float.c sis.h end.h
-+-func.o: func.c sis.h end.h
-+-help.o: help.c sis.h end.h
-+-interf.o: interf.c sis.h end.h
-+-sis.o: sis.c sis.h end.h
-++erc32.o: erc32.c sis.h
-++exec.o: exec.c sis.h
-++float.o: float.c sis.h
-++func.o: func.c sis.h
-++help.o: help.c sis.h
-++interf.o: interf.c sis.h
-++sis.o: sis.c sis.h
-++grlib.o: grlib.c sis.h grlib.h
-++leon3.o: leon3.c sis.h grlib.h
-++leon2.o: leon2.c sis.h
-+diff --git a/sim/erc32/NEWS b/sim/erc32/NEWS
-+deleted file mode 100644
-+index dd24b7b..0000000
-+--- a/sim/erc32/NEWS
-++++ /dev/null
-+@@ -1,108 +0,0 @@
-+-
-+-version 2.0 05-02-96
-+---------------------
-+-
-+-* Switched to bfd library. Any supported format (elf, coff, ...) can be used.
-+-* The UART devices can be set through -uart1 and -uart2 switches.
-+-* Switched to GNU readline.
-+-* Added -c option to run batch files at startup
-+-* 'reg' command can show different register windows (eg 'reg w3').
-+-* Use 'help' for online help on simulator commands
-+-
-+-version 1.8.1 20-01-96
-+---------------------
-+-
-+-* added -mevrev0 switch to simulate MEC rev.0 bugs in timer and uart
-+-
-+-* added -iurev0 switch to simulate IU rev.0 jmpl/restore bug
-+-
-+-* Added sis command 'batch' to run batch files
-+-
-+-
-+-version 1.8 30-10-95
-+---------------------
-+-
-+-* Added s-record support. Use the '-s' switch with sis or the 'load' command.
-+-
-+-* IU load dependencies are now modelled
-+-
-+-version 1.7 30-10-95
-+---------------------
-+-
-+-* Power-down mode implemented in erc32.c.
-+-
-+-* Performance display shows the ratio between simulator-time and real-time.
-+-
-+-
-+-version 1.6.2 25-10-95
-+---------------------
-+-
-+-* The UARTs can now be run at a given speed (simulator time) to better
-+- simulate the behaviour of interrupt routines. The "true mode" is
-+- selected through a compile switch in the makefile.
-+-
-+-
-+-version 1.6 28-09-95
-+---------------------
-+-
-+-* Major reorganisation of the code. mec.c and mem.c merged into erc32.c.
-+-
-+-* The load command does NOT longer load the initialised data at an address
-+- defined by .bdata. This is done in srt0.s using _environ.
-+-
-+-* Additional MEC functionallity added - software reset, memory access
-+- protection and waitstate configuration register.
-+-
-+-* interf.c - a GDB interface added
-+-
-+-* -v switch (verbose) added
-+-
-+-version 1.5 14-09-95
-+---------------------
-+-
-+-* Added a instruction trace buffer, enabled through the 'hist' command.
-+-
-+-* Added a 'perf' command to display statistics such as instruction mix,
-+- CPI, FPU holds etc.
-+-
-+-* Added -nfp switch to disable FPU.
-+-
-+-* Added -freq switch to set simulated frequency.
-+-
-+-version 1.4 22-08-95
-+---------------------
-+-
-+-* A -g is provided for those who have problems with GNU readline().
-+-
-+-version 1.3 26-07-95
-+---------------------
-+-
-+-* No major news, just a bug fix release ...
-+-
-+-
-+-version 1.2 13-07-95
-+---------------------
-+-
-+-* Added setting of IU registers through the 'reg' command. See README.
-+-
-+-* The GNU readline() function is used for command input. However, a
-+-ctrl-D still kills the simulator ...
-+-
-+-
-+-version 1.1 07-07-95
-+---------------------
-+-
-+-
-+-* Added a 'go' command
-+-
-+-* Added cycle counting for interrupt overhead.
-+-
-+-* Function 'get_mem_ptr' takes one more parameter to avoid segmentation
-+- faults if a.out files are loaded outside the simulated memory. See README.
-+-
-+-* Added user-defined function sim_stop().
-+-
-+-* Added a reset command. See README.
-+-
-+-* Implemented buffered output for MEC uarts to improve output speed.
-+-
-+diff --git a/sim/erc32/README.gdb b/sim/erc32/README.gdb
-+deleted file mode 100644
-+index 619fcb3..0000000
-+--- a/sim/erc32/README.gdb
-++++ /dev/null
-+@@ -1,67 +0,0 @@
-+-How to use SIS with GDB
-+------------------------
-+-
-+-1. Building GDB with SIS
-+-
-+-To build GDB with the SIS/ERC32 simulator, configure with option
-+-'--target sparc-erc32-aout' and build as usual.
-+-
-+-2. Attaching the simulator
-+-
-+-To attach GDB to the simulator, use:
-+-
-+-target sim [options] [files]
-+-
-+-The following options are supported:
-+-
-+- -nfp Disable FPU. FPops will cause an FPU disabled trap.
-+-
-+- -freq <f> Set the simulated "system clock" to <f> MHz.
-+-
-+- -v Verbose mode.
-+-
-+- -nogdb Disable GDB breakpoint handling (see below)
-+-
-+-The listed [files] are expected to be in aout format and will be
-+-loaded in the simulator memory prior. This could be used to load
-+-a boot block at address 0x0 if the application is linked to run
-+-from RAM (0x2000000).
-+-
-+-To start debugging a program type 'load <program>' and debug as
-+-usual.
-+-
-+-The native simulator commands can be reached using the GDB 'sim'
-+-command:
-+-
-+-sim <sis_command>
-+-
-+-Direct simulator commands during a GDB session must be issued
-+-with care not to disturb GDB's operation ...
-+-
-+-For info on supported ERC32 functionality, see README.sis.
-+-
-+-
-+-3. Loading aout files
-+-
-+-The GDB load command loads an aout file into the simulator
-+-memory with the data section starting directly after the text
-+-section regardless of wich start address was specified for the data
-+-at link time! This means that your applications either has to include
-+-a routine that initialise the data segment at the proper address or
-+-link with the data placed directly after the text section.
-+-
-+-A copying routine is fairly simple, just copy all data between
-+-_etext and _data to a memory loaction starting at _environ. This
-+-should be done at the same time as the bss is cleared (in srt0.s).
-+-
-+-
-+-4. GDB breakpoint handling
-+-
-+-GDB inserts breakpoint in the form of the 'ta 1' instruction. The
-+-GDB-integrated simulator will therefore recognize the breakpoint
-+-instruction and return control to GDB. If the application uses
-+-'ta 1', the breakpoint detection can be disabled with the -nogdb
-+-switch. In this case however, GDB breakpoints will not work.
-+-
-+-
-+-Report problems to Jiri Gaisler ESA/ESTEC (jgais at wd.estec.esa.nl)
-+diff --git a/sim/erc32/README.leon2 b/sim/erc32/README.leon2
-+new file mode 100644
-+index 0000000..3820eca
-+--- /dev/null
-++++ b/sim/erc32/README.leon2
-+@@ -0,0 +1,53 @@
-++
-++1. LEON2 emulation
-++
-++The file 'leon2.c' contains a model of simple LEON2 sub-system. It
-++contains 16 Mbyte ROM and 16 Mbyte RAM. Standard peripherals
-++such as interrupt controller, UART and timer are provided.
-++The model can execute leon2 binaries that do not require an
-++MMU.
-++
-++To start sis in Leon2 mode, add the -leon2 switch. In gdb,
-++use 'target sim -leon2' .
-++
-++1.1 UART
-++
-++One LEON2 UART is emaulted, and is located at address 0x80000070.
-++The following registers are implemeted:
-++
-++- UART RX and TX register (0x80000070)
-++- UART status register (0x80000074)
-++
-++The UART generates interrupt 3.
-++
-++1.2 Timer unit
-++
-++The LEON2 timer unit is emulated and located at address 0x80000040.
-++It is configured with two timers and separate interrupts (8 and 9).
-++The scaler is configured to 16 bits, while the counters are 32 bits.
-++
-++1.3 Interrupt controller
-++
-++The interrupt controller is implemented as described in the
-++LEON2 IP manual, with the exception of the interrupt level register.
-++Secondary interrupts are not supported. The registers are located
-++at address 0x80000090.
-++
-++1.5 Memory interface
-++
-++The following memory areas are valid for the Leon3 simulator:
-++
-++0x00000000 - 0x01000000 ROM (16 Mbyte, loaded at start-up)
-++0x40000000 - 0x41000000 RAM (16 Mbyte, loaded at start-up)
-++0x80000000 - 0x81000000 APB bus, including plug&play
-++0xFFFFF000 - 0xFFFFFFFF AHB plug&play area
-++
-++Access to non-existing memory will result in a memory exception trap.
-++
-++1.8 Power-down mode
-++
-++The Leon2 power-down register (0x80000018) is supported. When power-down is
-++entered, time is skipped forward until the next event in the event queue.
-++However, if the simulator event queue is empty, power-down mode is not
-++entered since no interrupt would be generated to exit from the mode. A
-++Ctrl-C in the simulator window will exit the power-down mode.
-+diff --git a/sim/erc32/README.leon3 b/sim/erc32/README.leon3
-+new file mode 100644
-+index 0000000..00ab14a
-+--- /dev/null
-++++ b/sim/erc32/README.leon3
-+@@ -0,0 +1,53 @@
-++
-++1. LEON3 emulation
-++
-++The file 'leon3.c' contains a model of simple LEON3 sub-system. It
-++contains 16 Mbyte ROM and 16 Mbyte RAM. Standard peripherals
-++such as interrupt controller, UART and timer are provided.
-++The model can execute leon3 binaries that do not require an
-++MMU.
-++
-++To start sis in Leon3 mode, add the -leon3 switch. In gdb,
-++use 'target sim -leon3' .
-++
-++1.1 UART
-++
-++The UART emulates an APBUART and is located at address 0x80000100.
-++The following registers are implemeted:
-++
-++- UART RX and TX register (0x80000100)
-++- UART status register (0x80000104)
-++
-++The UART generates interrupt 3.
-++
-++1.2 Timer unit (GPTIMER)
-++
-++The GPTIMER programmable counter is emulated and located at
-++address 0x80000300. It is configured with two timers and separate
-++interrupts (8 and 9).
-++
-++1.3 Interrupt controller
-++
-++The IRQMP interrupt controller is implemented as described in the
-++GRLIB IP manual, with the exception of the interrupt level register.
-++Extended interrupts are not supported. The registers are located
-++at address 0x80000200.
-++
-++1.5 Memory interface
-++
-++The following memory areas are valid for the Leon3 simulator:
-++
-++0x00000000 - 0x01000000 ROM (16 Mbyte, loaded at start-up)
-++0x40000000 - 0x41000000 RAM (16 Mbyte, loaded at start-up)
-++0x80000000 - 0x81000000 APB bus, including plug&play
-++0xFFFFF000 - 0xFFFFFFFF AHB plug&play area
-++
-++Access to non-existing memory will result in a memory exception trap.
-++
-++1.8 Power-down mode
-++
-++The Leon3 power-down feature (%asr19) is supported. When power-down is
-++entered, time is skipped forward until the next event in the event queue.
-++However, if the simulator event queue is empty, power-down mode is not
-++entered since no interrupt would be generated to exit from the mode. A
-++Ctrl-C in the simulator window will exit the power-down mode.
-+diff --git a/sim/erc32/README.sis b/sim/erc32/README.sis
-+index b119f03..59c4c64 100644
-+--- a/sim/erc32/README.sis
-++++ b/sim/erc32/README.sis
-+@@ -1,10 +1,10 @@
-+
-+-SIS - Sparc Instruction Simulator README file (v2.0, 05-02-1996)
-++SIS - Sparc Instruction Simulator README file (v2.8, 10-11-2014)
-+ -------------------------------------------------------------------
-+
-+ 1. Introduction
-+
-+-The SIS is a SPARC V7 architecture simulator. It consist of two parts,
-++The SIS is a SPARC V7/V8 architecture simulator. It consist of two parts,
-+ the simulator core and a user defined memory module. The simulator
-+ core executes the instructions while the memory module emulates memory
-+ and peripherals.
-+@@ -13,28 +13,29 @@ and peripherals.
-+
-+ The simulator is started as follows:
-+
-+-sis [-uart1 uart_device1] [-uart2 uart_device2]
-++sis [-leon2] [-leon3] [-uart1 uart_device1] [-uart2 uart_device2]
-+ [-nfp] [-freq frequency] [-c batch_file] [files]
-+
-+-The default uart devices for SIS are /dev/ptypc and /dev/ptypd. The
-+--uart[1,2] switch can be used to connect the uarts to other devices.
-+-Use 'tip /dev/ttypc' to connect a terminal emulator to the uarts.
-++By default, SIS emaultes an ERC32 system. The -leon2 switch enables
-++LEON2 emaultion, while the -leon3 switch enables emulation of a
-++LEON3 SOC system.
-++
-++The emulated console uart is connected stdin/stdout. The -uart[1,2]
-++switch can be used to connect the uarts to other devices.
-++
-+ The '-nfp' will disable the simulated FPU, so each FPU instruction will
-+ generate a FPU disabled trap. The '-freq' switch can be used to define
-+ which "frequency" the simulator runs at. This is used by the 'perf'
-+ command to calculated the MIPS figure for a particular configuration.
-+-The give frequency must be an integer indicating the frequency in MHz.
-++The frequency must be an integer indicating the frequency in MHz.
-+
-+ The -c option indicates that sis commands should be read from 'batch_file'
-+ at startup.
-+
-+-Files to be loaded must be in one of the supported formats (see INSTALLATION),
-+-and will be loaded into the simulated memory. The file formats are
-+-automatically recognised.
-++Files to be loaded must be in one of the supported formats (elf, a.out, srec),
-++and will be loaded into the simulated memory.
-+
-+-The script 'startsim' will start the simulator in one xterm window and
-+-open a terminal emulator (tip) connected to the UART A in a second
-+-xterm window. Below is description of commands that are recognized by
-++Below is description of commands that are recognized by
-+ the simulator. The command-line is parsed using GNU readline. A command
-+ history of 64 commands is maintained. Use the up/down arrows to recall
-+ previous commands. For more details, see the readline documentation.
-+@@ -77,8 +78,8 @@ Prints the FPU registers
-+ go <address> [inst_count]
-+
-+ The go command will set pc to <address> and npc to <address> + 4, and start
-+-execution. No other initialisation will be done. If inst_count is given,
-+-execution will stop after the specified number of instructions.
-++execution. If inst_count is given, execution will stop after the specified
-++number of instructions.
-+
-+ help
-+
-+@@ -143,136 +144,67 @@ Typing a 'Ctrl-C' will interrupt a running simulator.
-+ Short forms of the commands are allowed, e.g 'c' 'co' or 'con' are all
-+ interpreted as 'cont'.
-+
-++2 Using SIS with gdb
-++
-++2.1 Attaching the simulator
-++
-++To attach GDB to the simulator, use:
-++
-++target sim [options]
-++
-++The following options are supported:
-++
-++ -leon2 Emulate a LEON2 system
-++
-++ -leon3 Emulate a LEON3 system
-++
-++ -nfp Disable FPU. FPops will cause an FPU disabled trap.
-++
-++ -freq <f> Set the simulated "system clock" to <f> MHz.
-++
-++ -v Verbose mode.
-++
-++ -nogdb Disable GDB breakpoint handling (see below)
-++
-++To start debugging a program type 'load <program>' and debug as
-++usual.
-++
-++The native simulator commands can be reached using the GDB 'sim'
-++command:
-++
-++sim <sis_command>
-++
-++Direct simulator commands during a GDB session must be issued
-++with care not to disturb GDB's operation ...
-++
-++A program can be restarted in gdb by first issuing the load command,
-++followed by run.
-++
-++2.2 GDB breakpoint handling
-++
-++GDB inserts breakpoint in the form of the 'ta 1' instruction. The
-++GDB-integrated simulator will therefore recognize the breakpoint
-++instruction and return control to GDB. If the application uses
-++'ta 1', the breakpoint detection can be disabled with the -nogdb
-++switch. In this case however, GDB breakpoints will not work.
-++
-+
-+ 3. Simulator core
-+
-+-The SIS emulates the behavior of the 90C601E and 90C602E sparc IU and
-+-FPU from Matra MHS. These are roughly equivalent to the Cypress C601
-+-and C602. The simulator is cycle true, i.e a simulator time is
-++In ERC32 mode, SIS emulates the behavior of the 90C601E and 90C602E
-++sparc IU and FPU from Matra MHS. These are roughly equivalent to the
-++Cypress C601 and C602. The simulator is cycle true, i.e a simulator time is
-+ maintained and inremented according the IU and FPU instruction timing.
-+ The parallel execution between the IU and FPU is modelled, as well as
-+-stalls due to operand dependencies (FPU). The core interacts with the
-+-user-defined memory modules through a number of functions. The memory
-+-module must provide the following functions:
-+-
-+-int memory_read(asi,addr,data,ws)
-+-int asi;
-+-unsigned int addr;
-+-unsigned int *data;
-+-int *ws;
-+-
-+-int memory_write(asi,addr,data,sz,ws)
-+-int asi;
-+-unsigned int addr;
-+-unsigned int *data;
-+-int sz;
-+-int *ws;
-+-
-+-int sis_memory_read(addr, data, length)
-+-unsigned int addr;
-+-char *data;
-+-unsigned int length;
-+-
-+-int sis_memory_write(addr, data, length)
-+-unsigned int addr;
-+-char *data;
-+-unsigned int length;
-+-
-+-int init_sim()
-+-
-+-int reset()
-+-
-+-int error_mode(pc)
-+-unsigned int pc;
-+-
-+-memory_read() is used by the simulator to fetch instructions and
-+-operands. The address space identifier (asi) and address is passed as
-+-parameters. The read data should be assigned to the data pointer
-+-(*data) and the number of waitstate to *ws. 'memory_read' should return
-+-0 on success and 1 on failure. A failure will cause a data or
-+-instruction fetch trap. memory_read() always reads one 32-bit word.
-+-
-+-sis_memory_read() is used by the simulator to display and disassemble
-+-memory contants. The function should copy 'length' bytes of the simulated
-+-memory starting at 'addr' to '*data'.
-+-The sis_memory_read() should return 1 on success and 0 on failure.
-+-Failure should only be indicated if access to unimplemented memory is attempted.
-+-
-+-memory_write() is used to write to memory. In addition to the asi
-+-and address parameters, the size of the written data is given by 'sz'.
-+-The pointer *data points to the data to be written. The 'sz' is coded
-+-as follows:
-+-
-+- sz access type
-+- 0 byte
-+- 1 halfword
-+- 2 word
-+- 3 double-word
-+-
-+-If a double word is written, the most significant word is in data[0] and
-+-the least significant in data[1].
-+-
-+-sis_memory_write() is used by the simulator during loading of programs.
-+-The function should copy 'length' bytes from *data to the simulated
-+-memory starting at 'addr'. sis_memory_write() should return 1 on
-+-success and 0 on failure. Failure should only be indicated if access
-+-to unimplemented memory is attempted. See erc32.c for more details
-+-on how to define the memory emulation functions.
-+-
-+-The 'init_sim' is called once when the simulator is started. This function
-+-should be used to perform initialisations of user defined memory or
-+-peripherals that only have to be done once, such as opening files etc.
-+-
-+-The 'reset' is called every time the simulator is reset, i.e. when a
-+-'run' command is given. This function should be used to simulate a power
-+-on reset of memory and peripherals.
-+-
-+-error_mode() is called by the simulator when the IU goes into error mode,
-+-typically if a trap is caused when traps are disabled. The memory module
-+-can then take actions, such as issue a reset.
-+-
-+-sys_reset() can be called by the memory module to reset the simulator. A
-+-reset will empty the event queue and perform a power-on reset.
-+-
-+-4. Events and interrupts
-+-
-+-The simulator supports an event queue and the generation of processor
-+-interrupts. The following functions are available to the user-defined
-+-memory module:
-+-
-+-event(cfunc,arg,delta)
-+-void (*cfunc)();
-+-int arg;
-+-unsigned int delta;
-+-
-+-set_int(level,callback,arg)
-+-int level;
-+-void (*callback)();
-+-int arg;
-+-
-+-clear_int(level)
-+-int level;
-+-
-+-sim_stop()
-+-
-+-The 'event' functions will schedule the execution of the function 'cfunc'
-+-at time 'now + delta' clock cycles. The parameter 'arg' is passed as a
-+-parameter to 'cfunc'.
-+-
-+-The 'set_int' function set the processor interrupt 'level'. When the interrupt
-+-is taken, the function 'callback' is called with the argument 'arg'. This
-+-will also clear the interrupt. An interrupt can be cleared before it is
-+-taken by calling 'clear_int' with the appropriate interrupt level.
-+-
-+-The sim_stop function is called each time the simulator stops execution.
-+-It can be used to flush buffered devices to get a clean state during
-+-single stepping etc.
-++stalls due to operand dependencies (FPU).
-+
-+-See 'erc32.c' for examples on how to use events and interrupts.
-++In Leon2/3 mode, the core emulates the Leon2/3 SPARC V8 core from
-++Gaisler Research. All SPARC V8 instructions are supported but
-++emaultion is not fully cycle-true as the cache is not emulated.
-+
-+ 5. Memory module
-+
-+-The supplied memory module (erc32.c) emulates the functions of memory and
-++The ERC32 memory module (erc32.c) emulates the functions of memory and
-+ the MEC asic developed for the 90C601/2. It includes the following functions:
-+
-+ * UART A & B
-+@@ -284,28 +216,38 @@ the MEC asic developed for the 90C601/2. It includes the following functions:
-+ * 512 Kbyte ROM
-+ * 4 Mbyte RAM
-+
-+-See README.erc32 on how the MEC functions are emulated. For a detailed MEC
-+-specification, look at the ERC32 home page at URL:
-++See README.erc32 on how the MEC functions are emulated.
-++
-++The Leon2 memory module (leon2.c) emulates on-chip peripherals and
-++external memory for a simple Leon2 system. The modules includes the
-++following functions:
-++
-++* AHB and APB buses
-++* One UART
-++* Interrupt controller
-++* Timer unit with two timers
-++* PROM/SRAM memory controller
-++* 16 Mbyte PROM, 16 Mbyte SRAM
-+
-+-http://www.estec.esa.nl/wsmwww/erc32
-++See README.leon2 for further details on Leon3 emulation.
-+
-+-6. Compile and linking programs
-++The Leon3 memory module (leon3.c) emulates on-chip peripherals and
-++external memory for a simple Leon3 system. The modules includes the
-++following functions:
-+
-+-The directory 'examples' contain some code fragments for SIS.
-+-The script gccx indicates how the native sunos gcc and linker can be used
-+-to produce executables for the simulator. To compile and link the provided
-+-'hello.c', type 'gccx hello.c'. This will build the executable 'hello'.
-+-Start the simulator by running 'startsim hello', and issue the command 'run.
-+-After the program is terminated, the IU will be force to error mode through
-+-a software trap and halt.
-++* AHB and APB buses with plug&play
-++* UART (APBUART)
-++* Interrupt controller (IRQMP)
-++* Timer unit with two timers (GPTIMER)
-++* PROM/SRAM memory controller (SRCTRL)
-++* 16 Mbyte PROM, 16 Mbyte SRAM
-+
-+-The programs are linked with a start-up file, srt0.S. This file includes
-+-the traptable and window underflow/overflow trap routines.
-++See README.leon3 for further details on Leon3 emulation.
-+
-+-7. IU and FPU instruction timing.
-++6. IU and FPU instruction timing.
-+
-+-The simulator provides cycle true simulation. The following table shows
-+-the emulated instruction timing for 90C601E & 90C602E:
-++The simulator provides cycle true simulation for ERC32. The following table
-++shows the emulated instruction timing for 90C601E & 90C602E:
-+
-+ Instructions Cycles
-+
-+diff --git a/sim/erc32/config.in b/sim/erc32/config.in
-+index 0db6f1e..0f712af 100644
-+--- a/sim/erc32/config.in
-++++ b/sim/erc32/config.in
-+@@ -1,5 +1,8 @@
-+ /* config.in. Generated from configure.ac by autoheader. */
-+
-++/* Define if building universal (internal helper macro) */
-++#undef AC_APPLE_UNIVERSAL_BUILD
-++
-+ /* Define to 1 if translation of program messages to the user's native
-+ language is requested. */
-+ #undef ENABLE_NLS
-+@@ -73,6 +76,10 @@
-+ /* Define to 1 if you have the `__setfpucw' function. */
-+ #undef HAVE___SETFPUCW
-+
-++/* Define to the sub-directory in which libtool stores uninstalled libraries.
-++ */
-++#undef LT_OBJDIR
-++
-+ /* Name of this package. */
-+ #undef PACKAGE
-+
-+@@ -128,6 +135,18 @@
-+ #endif
-+
-+
-++/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-++ significant byte first (like Motorola and SPARC, unlike Intel). */
-++#if defined AC_APPLE_UNIVERSAL_BUILD
-++# if defined __BIG_ENDIAN__
-++# define WORDS_BIGENDIAN 1
-++# endif
-++#else
-++# ifndef WORDS_BIGENDIAN
-++# undef WORDS_BIGENDIAN
-++# endif
-++#endif
-++
-+ /* Define to 1 if on MINIX. */
-+ #undef _MINIX
-+
-+diff --git a/sim/erc32/configure b/sim/erc32/configure
-+index b8fd852..9d1b373 100755
-+--- a/sim/erc32/configure
-++++ b/sim/erc32/configure
-+@@ -1,10 +1,10 @@
-+ #! /bin/sh
-+ # Guess values for system-dependent variables and create Makefiles.
-+-# Generated by GNU Autoconf 2.64.
-++# Generated by GNU Autoconf 2.69.
-++#
-++#
-++# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-+ #
-+-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-+-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
-+-# Foundation, Inc.
-+ #
-+ # This configure script is free software; the Free Software Foundation
-+ # gives unlimited permission to copy, distribute and modify it.
-+@@ -87,6 +87,7 @@ fi
-+ IFS=" "" $as_nl"
-+
-+ # Find who we are. Look in the path if we contain no directory separator.
-++as_myself=
-+ case $0 in #((
-+ *[\\/]* ) as_myself=$0 ;;
-+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+@@ -131,6 +132,31 @@ export LANGUAGE
-+ # CDPATH.
-+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-+
-++# Use a proper internal environment variable to ensure we don't fall
-++ # into an infinite loop, continuously re-executing ourselves.
-++ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-++ _as_can_reexec=no; export _as_can_reexec;
-++ # We cannot yet assume a decent shell, so we have to provide a
-++# neutralization value for shells without unset; and this also
-++# works around shells that cannot unset nonexistent variables.
-++# Preserve -v and -x to the replacement shell.
-++BASH_ENV=/dev/null
-++ENV=/dev/null
-++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-++case $- in # ((((
-++ *v*x* | *x*v* ) as_opts=-vx ;;
-++ *v* ) as_opts=-v ;;
-++ *x* ) as_opts=-x ;;
-++ * ) as_opts= ;;
-++esac
-++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-++# Admittedly, this is quite paranoid, since all the known shells bail
-++# out after a failed `exec'.
-++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-++as_fn_exit 255
-++ fi
-++ # We don't want this to propagate to other subprocesses.
-++ { _as_can_reexec=; unset _as_can_reexec;}
-+ if test "x$CONFIG_SHELL" = x; then
-+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-+ emulate sh
-+@@ -164,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-+ else
-+ exitcode=1; echo positional parameters were not saved.
-+ fi
-+-test x\$exitcode = x0 || exit 1"
-++test x\$exitcode = x0 || exit 1
-++test -x / || exit 1"
-+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-+@@ -217,14 +244,25 @@ IFS=$as_save_IFS
-+
-+
-+ if test "x$CONFIG_SHELL" != x; then :
-+- # We cannot yet assume a decent shell, so we have to provide a
-+- # neutralization value for shells without unset; and this also
-+- # works around shells that cannot unset nonexistent variables.
-+- BASH_ENV=/dev/null
-+- ENV=/dev/null
-+- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-+- export CONFIG_SHELL
-+- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
-++ export CONFIG_SHELL
-++ # We cannot yet assume a decent shell, so we have to provide a
-++# neutralization value for shells without unset; and this also
-++# works around shells that cannot unset nonexistent variables.
-++# Preserve -v and -x to the replacement shell.
-++BASH_ENV=/dev/null
-++ENV=/dev/null
-++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-++case $- in # ((((
-++ *v*x* | *x*v* ) as_opts=-vx ;;
-++ *v* ) as_opts=-v ;;
-++ *x* ) as_opts=-x ;;
-++ * ) as_opts= ;;
-++esac
-++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-++# Admittedly, this is quite paranoid, since all the known shells bail
-++# out after a failed `exec'.
-++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-++exit 255
-+ fi
-+
-+ if test x$as_have_required = xno; then :
-+@@ -322,10 +360,18 @@ $as_echo X"$as_dir" |
-+ test -d "$as_dir" && break
-+ done
-+ test -z "$as_dirs" || eval "mkdir $as_dirs"
-+- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
-++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-+
-+
-+ } # as_fn_mkdir_p
-++
-++# as_fn_executable_p FILE
-++# -----------------------
-++# Test if FILE is an executable regular file.
-++as_fn_executable_p ()
-++{
-++ test -f "$1" && test -x "$1"
-++} # as_fn_executable_p
-+ # as_fn_append VAR VALUE
-+ # ----------------------
-+ # Append the text in VALUE to the end of the definition contained in VAR. Take
-+@@ -362,19 +408,19 @@ else
-+ fi # as_fn_arith
-+
-+
-+-# as_fn_error ERROR [LINENO LOG_FD]
-+-# ---------------------------------
-++# as_fn_error STATUS ERROR [LINENO LOG_FD]
-++# ----------------------------------------
-+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-+-# script with status $?, using 1 if that was 0.
-++# script with STATUS, using 1 if that was 0.
-+ as_fn_error ()
-+ {
-+- as_status=$?; test $as_status -eq 0 && as_status=1
-+- if test "$3"; then
-+- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-++ as_status=$1; test $as_status -eq 0 && as_status=1
-++ if test "$4"; then
-++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-+ fi
-+- $as_echo "$as_me: error: $1" >&2
-++ $as_echo "$as_me: error: $2" >&2
-+ as_fn_exit $as_status
-+ } # as_fn_error
-+
-+@@ -447,6 +493,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
-+ chmod +x "$as_me.lineno" ||
-+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-+
-++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-++ # already done that, so ensure we don't try to do so again and fall
-++ # in an infinite loop. This has already happened in practice.
-++ _as_can_reexec=no; export _as_can_reexec
-+ # Don't try to exec as it changes $[0], causing all sort of problems
-+ # (the dirname of $[0] is not the place where we might find the
-+ # original and so on. Autoconf is especially sensitive to this).
-+@@ -481,16 +531,16 @@ if (echo >conf$$.file) 2>/dev/null; then
-+ # ... but there are two gotchas:
-+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-+- # In both cases, we have to default to `cp -p'.
-++ # In both cases, we have to default to `cp -pR'.
-+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ elif ln conf$$.file conf$$ 2>/dev/null; then
-+ as_ln_s=ln
-+ else
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ fi
-+ else
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ fi
-+ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-+ rmdir conf$$.dir 2>/dev/null
-+@@ -502,28 +552,8 @@ else
-+ as_mkdir_p=false
-+ fi
-+
-+-if test -x / >/dev/null 2>&1; then
-+- as_test_x='test -x'
-+-else
-+- if ls -dL / >/dev/null 2>&1; then
-+- as_ls_L_option=L
-+- else
-+- as_ls_L_option=
-+- fi
-+- as_test_x='
-+- eval sh -c '\''
-+- if test -d "$1"; then
-+- test -d "$1/.";
-+- else
-+- case $1 in #(
-+- -*)set "./$1";;
-+- esac;
-+- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-+- ???[sx]*):;;*)false;;esac;fi
-+- '\'' sh
-+- '
-+-fi
-+-as_executable_p=$as_test_x
-++as_test_x='test -x'
-++as_executable_p=as_fn_executable_p
-+
-+ # Sed expression to map a string onto a valid CPP name.
-+ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-+@@ -534,10 +564,11 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-+ SHELL=${CONFIG_SHELL-/bin/sh}
-+
-+
-+-exec 7<&0 </dev/null 6>&1
-++test -n "$DJDIR" || exec 7<&0 </dev/null
-++exec 6>&1
-+
-+ # Name of the host.
-+-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-++# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-+ # so uname gets run too.
-+ ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-+
-+@@ -833,8 +864,9 @@ do
-+ fi
-+
-+ case $ac_option in
-+- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-+- *) ac_optarg=yes ;;
-++ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-++ *=) ac_optarg= ;;
-++ *) ac_optarg=yes ;;
-+ esac
-+
-+ # Accept the important Cygnus configure options, so we can diagnose typos.
-+@@ -879,7 +911,7 @@ do
-+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-+ # Reject names that are not valid shell variable names.
-+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-+- as_fn_error "invalid feature name: $ac_useropt"
-++ as_fn_error $? "invalid feature name: $ac_useropt"
-+ ac_useropt_orig=$ac_useropt
-+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-+ case $ac_user_opts in
-+@@ -905,7 +937,7 @@ do
-+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-+ # Reject names that are not valid shell variable names.
-+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-+- as_fn_error "invalid feature name: $ac_useropt"
-++ as_fn_error $? "invalid feature name: $ac_useropt"
-+ ac_useropt_orig=$ac_useropt
-+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-+ case $ac_user_opts in
-+@@ -1109,7 +1141,7 @@ do
-+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-+ # Reject names that are not valid shell variable names.
-+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-+- as_fn_error "invalid package name: $ac_useropt"
-++ as_fn_error $? "invalid package name: $ac_useropt"
-+ ac_useropt_orig=$ac_useropt
-+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-+ case $ac_user_opts in
-+@@ -1125,7 +1157,7 @@ do
-+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-+ # Reject names that are not valid shell variable names.
-+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-+- as_fn_error "invalid package name: $ac_useropt"
-++ as_fn_error $? "invalid package name: $ac_useropt"
-+ ac_useropt_orig=$ac_useropt
-+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-+ case $ac_user_opts in
-+@@ -1155,8 +1187,8 @@ do
-+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-+ x_libraries=$ac_optarg ;;
-+
-+- -*) as_fn_error "unrecognized option: \`$ac_option'
-+-Try \`$0 --help' for more information."
-++ -*) as_fn_error $? "unrecognized option: \`$ac_option'
-++Try \`$0 --help' for more information"
-+ ;;
-+
-+ *=*)
-+@@ -1164,7 +1196,7 @@ Try \`$0 --help' for more information."
-+ # Reject names that are not valid shell variable names.
-+ case $ac_envvar in #(
-+ '' | [0-9]* | *[!_$as_cr_alnum]* )
-+- as_fn_error "invalid variable name: \`$ac_envvar'" ;;
-++ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-+ esac
-+ eval $ac_envvar=\$ac_optarg
-+ export $ac_envvar ;;
-+@@ -1174,7 +1206,7 @@ Try \`$0 --help' for more information."
-+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-+- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
-++ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
-+ ;;
-+
-+ esac
-+@@ -1182,13 +1214,13 @@ done
-+
-+ if test -n "$ac_prev"; then
-+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-+- as_fn_error "missing argument to $ac_option"
-++ as_fn_error $? "missing argument to $ac_option"
-+ fi
-+
-+ if test -n "$ac_unrecognized_opts"; then
-+ case $enable_option_checking in
-+ no) ;;
-+- fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
-++ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
-+ esac
-+ fi
-+@@ -1211,7 +1243,7 @@ do
-+ [\\/$]* | ?:[\\/]* ) continue;;
-+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
-+ esac
-+- as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
-++ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-+ done
-+
-+ # There might be people who depend on the old broken behavior: `$host'
-+@@ -1225,8 +1257,6 @@ target=$target_alias
-+ if test "x$host_alias" != x; then
-+ if test "x$build_alias" = x; then
-+ cross_compiling=maybe
-+- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-+- If a cross compiler is detected then cross compile mode will be used." >&2
-+ elif test "x$build_alias" != "x$host_alias"; then
-+ cross_compiling=yes
-+ fi
-+@@ -1241,9 +1271,9 @@ test "$silent" = yes && exec 6>/dev/null
-+ ac_pwd=`pwd` && test -n "$ac_pwd" &&
-+ ac_ls_di=`ls -di .` &&
-+ ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-+- as_fn_error "working directory cannot be determined"
-++ as_fn_error $? "working directory cannot be determined"
-+ test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-+- as_fn_error "pwd does not report name of working directory"
-++ as_fn_error $? "pwd does not report name of working directory"
-+
-+
-+ # Find the source files, if location was not specified.
-+@@ -1282,11 +1312,11 @@ else
-+ fi
-+ if test ! -r "$srcdir/$ac_unique_file"; then
-+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-+- as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
-++ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-+ fi
-+ ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-+ ac_abs_confdir=`(
-+- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
-++ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
-+ pwd)`
-+ # When building in place, set srcdir=.
-+ if test "$ac_abs_confdir" = "$ac_pwd"; then
-+@@ -1326,7 +1356,7 @@ Configuration:
-+ --help=short display options specific to this package
-+ --help=recursive display the short help of all the included packages
-+ -V, --version display version information and exit
-+- -q, --quiet, --silent do not print \`checking...' messages
-++ -q, --quiet, --silent do not print \`checking ...' messages
-+ --cache-file=FILE cache test results in FILE [disabled]
-+ -C, --config-cache alias for \`--cache-file=config.cache'
-+ -n, --no-create do not create output files
-+@@ -1420,7 +1450,7 @@ Some influential environment variables:
-+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
-+ nonstandard directory <lib dir>
-+ LIBS libraries to pass to the linker, e.g. -l<library>
-+- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
-++ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-+ you have headers in a nonstandard directory <include dir>
-+ CPP C preprocessor
-+
-+@@ -1491,9 +1521,9 @@ test -n "$ac_init_help" && exit $ac_status
-+ if $ac_init_version; then
-+ cat <<\_ACEOF
-+ configure
-+-generated by GNU Autoconf 2.64
-++generated by GNU Autoconf 2.69
-+
-+-Copyright (C) 2009 Free Software Foundation, Inc.
-++Copyright (C) 2012 Free Software Foundation, Inc.
-+ This configure script is free software; the Free Software Foundation
-+ gives unlimited permission to copy, distribute and modify it.
-+ _ACEOF
-+@@ -1537,8 +1567,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=1
-+ fi
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-+- return $ac_retval
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-++ as_fn_set_status $ac_retval
-+
-+ } # ac_fn_c_try_compile
-+
-+@@ -1563,7 +1593,7 @@ $as_echo "$ac_try_echo"; } >&5
-+ mv -f conftest.er1 conftest.err
-+ fi
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+- test $ac_status = 0; } >/dev/null && {
-++ test $ac_status = 0; } > conftest.i && {
-+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-+ test ! -s conftest.err
-+ }; then :
-+@@ -1574,8 +1604,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ ac_retval=1
-+ fi
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-+- return $ac_retval
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-++ as_fn_set_status $ac_retval
-+
-+ } # ac_fn_c_try_cpp
-+
-+@@ -1587,10 +1617,10 @@ fi
-+ ac_fn_c_check_header_mongrel ()
-+ {
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-++ if eval \${$3+:} false; then :
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-+ $as_echo_n "checking for $2... " >&6; }
-+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-++if eval \${$3+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ fi
-+ eval ac_res=\$$3
-+@@ -1626,7 +1656,7 @@ if ac_fn_c_try_cpp "$LINENO"; then :
-+ else
-+ ac_header_preproc=no
-+ fi
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.err conftest.i conftest.$ac_ext
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-+ $as_echo "$ac_header_preproc" >&6; }
-+
-+@@ -1653,7 +1683,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-+ esac
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-+ $as_echo_n "checking for $2... " >&6; }
-+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-++if eval \${$3+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ eval "$3=\$ac_header_compiler"
-+@@ -1662,7 +1692,7 @@ eval ac_res=\$$3
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-+ $as_echo "$ac_res" >&6; }
-+ fi
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+
-+ } # ac_fn_c_check_header_mongrel
-+
-+@@ -1703,8 +1733,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
-+ ac_retval=$ac_status
-+ fi
-+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-+- return $ac_retval
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-++ as_fn_set_status $ac_retval
-+
-+ } # ac_fn_c_try_run
-+
-+@@ -1717,7 +1747,7 @@ ac_fn_c_check_header_compile ()
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-+ $as_echo_n "checking for $2... " >&6; }
-+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-++if eval \${$3+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -1735,7 +1765,7 @@ fi
-+ eval ac_res=\$$3
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-+ $as_echo "$ac_res" >&6; }
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+
-+ } # ac_fn_c_check_header_compile
-+
-+@@ -1766,7 +1796,7 @@ $as_echo "$ac_try_echo"; } >&5
-+ test ! -s conftest.err
-+ } && test -s conftest$ac_exeext && {
-+ test "$cross_compiling" = yes ||
-+- $as_test_x conftest$ac_exeext
-++ test -x conftest$ac_exeext
-+ }; then :
-+ ac_retval=0
-+ else
-+@@ -1780,8 +1810,8 @@ fi
-+ # interfere with the next link command; also delete a directory that is
-+ # left behind by Apple's compiler. We do this before executing the actions.
-+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-+- return $ac_retval
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-++ as_fn_set_status $ac_retval
-+
-+ } # ac_fn_c_try_link
-+
-+@@ -1793,7 +1823,7 @@ ac_fn_c_check_func ()
-+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-+ $as_echo_n "checking for $2... " >&6; }
-+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-++if eval \${$3+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -1848,7 +1878,7 @@ fi
-+ eval ac_res=\$$3
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-+ $as_echo "$ac_res" >&6; }
-+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-+
-+ } # ac_fn_c_check_func
-+ cat >config.log <<_ACEOF
-+@@ -1856,7 +1886,7 @@ This file contains any messages produced by compilers while
-+ running configure, to aid debugging if configure makes a mistake.
-+
-+ It was created by $as_me, which was
-+-generated by GNU Autoconf 2.64. Invocation command line was
-++generated by GNU Autoconf 2.69. Invocation command line was
-+
-+ $ $0 $@
-+
-+@@ -1966,11 +1996,9 @@ trap 'exit_status=$?
-+ {
-+ echo
-+
-+- cat <<\_ASBOX
-+-## ---------------- ##
-++ $as_echo "## ---------------- ##
-+ ## Cache variables. ##
-+-## ---------------- ##
-+-_ASBOX
-++## ---------------- ##"
-+ echo
-+ # The following way of writing the cache mishandles newlines in values,
-+ (
-+@@ -2004,11 +2032,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-+ )
-+ echo
-+
-+- cat <<\_ASBOX
-+-## ----------------- ##
-++ $as_echo "## ----------------- ##
-+ ## Output variables. ##
-+-## ----------------- ##
-+-_ASBOX
-++## ----------------- ##"
-+ echo
-+ for ac_var in $ac_subst_vars
-+ do
-+@@ -2021,11 +2047,9 @@ _ASBOX
-+ echo
-+
-+ if test -n "$ac_subst_files"; then
-+- cat <<\_ASBOX
-+-## ------------------- ##
-++ $as_echo "## ------------------- ##
-+ ## File substitutions. ##
-+-## ------------------- ##
-+-_ASBOX
-++## ------------------- ##"
-+ echo
-+ for ac_var in $ac_subst_files
-+ do
-+@@ -2039,11 +2063,9 @@ _ASBOX
-+ fi
-+
-+ if test -s confdefs.h; then
-+- cat <<\_ASBOX
-+-## ----------- ##
-++ $as_echo "## ----------- ##
-+ ## confdefs.h. ##
-+-## ----------- ##
-+-_ASBOX
-++## ----------- ##"
-+ echo
-+ cat confdefs.h
-+ echo
-+@@ -2098,7 +2120,12 @@ _ACEOF
-+ ac_site_file1=NONE
-+ ac_site_file2=NONE
-+ if test -n "$CONFIG_SITE"; then
-+- ac_site_file1=$CONFIG_SITE
-++ # We do not want a PATH search for config.site.
-++ case $CONFIG_SITE in #((
-++ -*) ac_site_file1=./$CONFIG_SITE;;
-++ */*) ac_site_file1=$CONFIG_SITE;;
-++ *) ac_site_file1=./$CONFIG_SITE;;
-++ esac
-+ elif test "x$prefix" != xNONE; then
-+ ac_site_file1=$prefix/share/config.site
-+ ac_site_file2=$prefix/etc/config.site
-+@@ -2109,18 +2136,22 @@ fi
-+ for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-+ do
-+ test "x$ac_site_file" = xNONE && continue
-+- if test -r "$ac_site_file"; then
-++ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-+ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
-+ sed 's/^/| /' "$ac_site_file" >&5
-+- . "$ac_site_file"
-++ . "$ac_site_file" \
-++ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-++as_fn_error $? "failed to load site script $ac_site_file
-++See \`config.log' for more details" "$LINENO" 5; }
-+ fi
-+ done
-+
-+ if test -r "$cache_file"; then
-+- # Some versions of bash will fail to source /dev/null (special
-+- # files actually), so we avoid doing that.
-+- if test -f "$cache_file"; then
-++ # Some versions of bash will fail to source /dev/null (special files
-++ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
-++ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-+ $as_echo "$as_me: loading cache $cache_file" >&6;}
-+ case $cache_file in
-+@@ -2189,7 +2220,7 @@ if $ac_cache_corrupted; then
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-+ $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-+- as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-++ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-+ fi
-+ ## -------------------- ##
-+ ## Main body of script. ##
-+@@ -2249,21 +2280,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-+
-+
-+
-+-# _AC_CHECK_DECL_BODY
-+-# -------------------
-+-# Shell function body for AC_CHECK_DECL.
-+-# _AC_CHECK_DECL_BODY
-+-
-+-# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
-+-# INCLUDES)
-+-# -------------------------------------------------------------
-+-# Helper to AC_CHECK_DECLS, which generates the check for a single
-+-# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
-+-# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
-+-
-+-
-+-
-+-
-+
-+
-+
-+@@ -4057,7 +4073,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}gcc; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_CC+set}" = set; then :
-++if ${ac_cv_prog_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$CC"; then
-+@@ -4069,7 +4085,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -4097,7 +4113,7 @@ if test -z "$ac_cv_prog_CC"; then
-+ set dummy gcc; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_CC"; then
-+@@ -4109,7 +4125,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_CC="gcc"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -4150,7 +4166,7 @@ if test -z "$CC"; then
-+ set dummy ${ac_tool_prefix}cc; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_CC+set}" = set; then :
-++if ${ac_cv_prog_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$CC"; then
-+@@ -4162,7 +4178,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_CC="${ac_tool_prefix}cc"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -4190,7 +4206,7 @@ if test -z "$CC"; then
-+ set dummy cc; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_CC+set}" = set; then :
-++if ${ac_cv_prog_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$CC"; then
-+@@ -4203,7 +4219,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-+ ac_prog_rejected=yes
-+ continue
-+@@ -4249,7 +4265,7 @@ if test -z "$CC"; then
-+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_CC+set}" = set; then :
-++if ${ac_cv_prog_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$CC"; then
-+@@ -4261,7 +4277,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -4293,7 +4309,7 @@ do
-+ set dummy $ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_CC+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_CC"; then
-+@@ -4305,7 +4321,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_CC="$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -4347,8 +4363,8 @@ fi
-+
-+ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-as_fn_error "no acceptable C compiler found in \$PATH
-+-See \`config.log' for more details." "$LINENO" 5; }
-++as_fn_error $? "no acceptable C compiler found in \$PATH
-++See \`config.log' for more details" "$LINENO" 5; }
-+
-+ # Provide some information about the compiler.
-+ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-+@@ -4369,8 +4385,8 @@ $as_echo "$ac_try_echo"; } >&5
-+ ... rest of stderr output deleted ...
-+ 10q' conftest.err >conftest.er1
-+ cat conftest.er1 >&5
-+- rm -f conftest.er1 conftest.err
-+ fi
-++ rm -f conftest.er1 conftest.err
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }
-+ done
-+@@ -4387,12 +4403,12 @@ main ()
-+ }
-+ _ACEOF
-+ ac_clean_files_save=$ac_clean_files
-+-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out"
-++ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-+ # Try to create an executable without -o first, disregard a.out.
-+ # It will help us diagnose broken compilers, and finding out an intuition
-+ # of exeext.
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-+-$as_echo_n "checking for C compiler default output file name... " >&6; }
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-++$as_echo_n "checking whether the C compiler works... " >&6; }
-+ ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-+
-+ # The possible output files:
-+@@ -4454,62 +4470,28 @@ test "$ac_cv_exeext" = no && ac_cv_exeext=
-+ else
-+ ac_file=''
-+ fi
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-+-$as_echo "$ac_file" >&6; }
-+ if test -z "$ac_file"; then :
-+- $as_echo "$as_me: failed program was:" >&5
-++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-++$as_echo "no" >&6; }
-++$as_echo "$as_me: failed program was:" >&5
-+ sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-{ as_fn_set_status 77
-+-as_fn_error "C compiler cannot create executables
-+-See \`config.log' for more details." "$LINENO" 5; }; }
-++as_fn_error 77 "C compiler cannot create executables
-++See \`config.log' for more details" "$LINENO" 5; }
-++else
-++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-++$as_echo "yes" >&6; }
-+ fi
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-++$as_echo_n "checking for C compiler default output file name... " >&6; }
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-++$as_echo "$ac_file" >&6; }
-+ ac_exeext=$ac_cv_exeext
-+
-+-# Check that the compiler produces executables we can run. If not, either
-+-# the compiler is broken, or we cross compile.
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-+-$as_echo_n "checking whether the C compiler works... " >&6; }
-+-# If not cross compiling, check that we can run a simple program.
-+-if test "$cross_compiling" != yes; then
-+- if { ac_try='./$ac_file'
-+- { { case "(($ac_try" in
-+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+- *) ac_try_echo=$ac_try;;
-+-esac
-+-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-+-$as_echo "$ac_try_echo"; } >&5
-+- (eval "$ac_try") 2>&5
-+- ac_status=$?
-+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+- test $ac_status = 0; }; }; then
-+- cross_compiling=no
-+- else
-+- if test "$cross_compiling" = maybe; then
-+- cross_compiling=yes
-+- else
-+- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-as_fn_error "cannot run C compiled programs.
-+-If you meant to cross compile, use \`--host'.
-+-See \`config.log' for more details." "$LINENO" 5; }
-+- fi
-+- fi
-+-fi
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+-$as_echo "yes" >&6; }
-+-
-+-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out
-++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-+ ac_clean_files=$ac_clean_files_save
-+-# Check that the compiler produces executables we can run. If not, either
-+-# the compiler is broken, or we cross compile.
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-+-$as_echo_n "checking whether we are cross compiling... " >&6; }
-+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-+-$as_echo "$cross_compiling" >&6; }
-+-
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-+ $as_echo_n "checking for suffix of executables... " >&6; }
-+ if { { ac_try="$ac_link"
-+@@ -4539,19 +4521,78 @@ done
-+ else
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-as_fn_error "cannot compute suffix of executables: cannot compile and link
-+-See \`config.log' for more details." "$LINENO" 5; }
-++as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-++See \`config.log' for more details" "$LINENO" 5; }
-+ fi
-+-rm -f conftest$ac_cv_exeext
-++rm -f conftest conftest$ac_cv_exeext
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-+ $as_echo "$ac_cv_exeext" >&6; }
-+
-+ rm -f conftest.$ac_ext
-+ EXEEXT=$ac_cv_exeext
-+ ac_exeext=$EXEEXT
-++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#include <stdio.h>
-++int
-++main ()
-++{
-++FILE *f = fopen ("conftest.out", "w");
-++ return ferror (f) || fclose (f) != 0;
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++ac_clean_files="$ac_clean_files conftest.out"
-++# Check that the compiler produces executables we can run. If not, either
-++# the compiler is broken, or we cross compile.
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-++$as_echo_n "checking whether we are cross compiling... " >&6; }
-++if test "$cross_compiling" != yes; then
-++ { { ac_try="$ac_link"
-++case "(($ac_try" in
-++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-++ *) ac_try_echo=$ac_try;;
-++esac
-++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-++$as_echo "$ac_try_echo"; } >&5
-++ (eval "$ac_link") 2>&5
-++ ac_status=$?
-++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-++ test $ac_status = 0; }
-++ if { ac_try='./conftest$ac_cv_exeext'
-++ { { case "(($ac_try" in
-++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-++ *) ac_try_echo=$ac_try;;
-++esac
-++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-++$as_echo "$ac_try_echo"; } >&5
-++ (eval "$ac_try") 2>&5
-++ ac_status=$?
-++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-++ test $ac_status = 0; }; }; then
-++ cross_compiling=no
-++ else
-++ if test "$cross_compiling" = maybe; then
-++ cross_compiling=yes
-++ else
-++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-++as_fn_error $? "cannot run C compiled programs.
-++If you meant to cross compile, use \`--host'.
-++See \`config.log' for more details" "$LINENO" 5; }
-++ fi
-++ fi
-++fi
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-++$as_echo "$cross_compiling" >&6; }
-++
-++rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-++ac_clean_files=$ac_clean_files_save
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-+ $as_echo_n "checking for suffix of object files... " >&6; }
-+-if test "${ac_cv_objext+set}" = set; then :
-++if ${ac_cv_objext+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -4591,8 +4632,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-as_fn_error "cannot compute suffix of object files: cannot compile
-+-See \`config.log' for more details." "$LINENO" 5; }
-++as_fn_error $? "cannot compute suffix of object files: cannot compile
-++See \`config.log' for more details" "$LINENO" 5; }
-+ fi
-+ rm -f conftest.$ac_cv_objext conftest.$ac_ext
-+ fi
-+@@ -4602,7 +4643,7 @@ OBJEXT=$ac_cv_objext
-+ ac_objext=$OBJEXT
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-+ $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-+-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
-++if ${ac_cv_c_compiler_gnu+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -4639,7 +4680,7 @@ ac_test_CFLAGS=${CFLAGS+set}
-+ ac_save_CFLAGS=$CFLAGS
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-+ $as_echo_n "checking whether $CC accepts -g... " >&6; }
-+-if test "${ac_cv_prog_cc_g+set}" = set; then :
-++if ${ac_cv_prog_cc_g+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_save_c_werror_flag=$ac_c_werror_flag
-+@@ -4717,7 +4758,7 @@ else
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-+ $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-+-if test "${ac_cv_prog_cc_c89+set}" = set; then :
-++if ${ac_cv_prog_cc_c89+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_cv_prog_cc_c89=no
-+@@ -4726,8 +4767,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+ /* end confdefs.h. */
-+ #include <stdarg.h>
-+ #include <stdio.h>
-+-#include <sys/types.h>
-+-#include <sys/stat.h>
-++struct stat;
-+ /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-+ struct buf { int x; };
-+ FILE * (*rcsopen) (struct buf *, struct stat *, int);
-+@@ -4814,16 +4854,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-+
-+ ac_aux_dir=
-+ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-+- for ac_t in install-sh install.sh shtool; do
-+- if test -f "$ac_dir/$ac_t"; then
-+- ac_aux_dir=$ac_dir
-+- ac_install_sh="$ac_aux_dir/$ac_t -c"
-+- break 2
-+- fi
-+- done
-++ if test -f "$ac_dir/install-sh"; then
-++ ac_aux_dir=$ac_dir
-++ ac_install_sh="$ac_aux_dir/install-sh -c"
-++ break
-++ elif test -f "$ac_dir/install.sh"; then
-++ ac_aux_dir=$ac_dir
-++ ac_install_sh="$ac_aux_dir/install.sh -c"
-++ break
-++ elif test -f "$ac_dir/shtool"; then
-++ ac_aux_dir=$ac_dir
-++ ac_install_sh="$ac_aux_dir/shtool install -c"
-++ break
-++ fi
-+ done
-+ if test -z "$ac_aux_dir"; then
-+- as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-++ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-+ fi
-+
-+ # These three variables are undocumented and unsupported,
-+@@ -4837,27 +4883,27 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-+
-+ # Make sure we can run config.sub.
-+ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-+- as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-++ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-+ $as_echo_n "checking build system type... " >&6; }
-+-if test "${ac_cv_build+set}" = set; then :
-++if ${ac_cv_build+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_build_alias=$build_alias
-+ test "x$ac_build_alias" = x &&
-+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-+ test "x$ac_build_alias" = x &&
-+- as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
-++ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-+ ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-+- as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-+
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-+ $as_echo "$ac_cv_build" >&6; }
-+ case $ac_cv_build in
-+ *-*-*) ;;
-+-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
-++*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-+ esac
-+ build=$ac_cv_build
-+ ac_save_IFS=$IFS; IFS='-'
-+@@ -4875,14 +4921,14 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-+ $as_echo_n "checking host system type... " >&6; }
-+-if test "${ac_cv_host+set}" = set; then :
-++if ${ac_cv_host+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test "x$host_alias" = x; then
-+ ac_cv_host=$ac_cv_build
-+ else
-+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-+- as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-+ fi
-+
-+ fi
-+@@ -4890,7 +4936,7 @@ fi
-+ $as_echo "$ac_cv_host" >&6; }
-+ case $ac_cv_host in
-+ *-*-*) ;;
-+-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
-++*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-+ esac
-+ host=$ac_cv_host
-+ ac_save_IFS=$IFS; IFS='-'
-+@@ -4908,14 +4954,14 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
-+ $as_echo_n "checking target system type... " >&6; }
-+-if test "${ac_cv_target+set}" = set; then :
-++if ${ac_cv_target+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test "x$target_alias" = x; then
-+ ac_cv_target=$ac_cv_host
-+ else
-+ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-+- as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-+ fi
-+
-+ fi
-+@@ -4923,7 +4969,7 @@ fi
-+ $as_echo "$ac_cv_target" >&6; }
-+ case $ac_cv_target in
-+ *-*-*) ;;
-+-*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
-++*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
-+ esac
-+ target=$ac_cv_target
-+ ac_save_IFS=$IFS; IFS='-'
-+@@ -4958,7 +5004,7 @@ if test -n "$CPP" && test -d "$CPP"; then
-+ CPP=
-+ fi
-+ if test -z "$CPP"; then
-+- if test "${ac_cv_prog_CPP+set}" = set; then :
-++ if ${ac_cv_prog_CPP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ # Double quotes because CPP needs to be expanded
-+@@ -4988,7 +5034,7 @@ else
-+ # Broken: fails on valid input.
-+ continue
-+ fi
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.err conftest.i conftest.$ac_ext
-+
-+ # OK, works on sane cases. Now check whether nonexistent headers
-+ # can be detected and how.
-+@@ -5004,11 +5050,11 @@ else
-+ ac_preproc_ok=:
-+ break
-+ fi
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.err conftest.i conftest.$ac_ext
-+
-+ done
-+ # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.i conftest.err conftest.$ac_ext
-+ if $ac_preproc_ok; then :
-+ break
-+ fi
-+@@ -5047,7 +5093,7 @@ else
-+ # Broken: fails on valid input.
-+ continue
-+ fi
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.err conftest.i conftest.$ac_ext
-+
-+ # OK, works on sane cases. Now check whether nonexistent headers
-+ # can be detected and how.
-+@@ -5063,18 +5109,18 @@ else
-+ ac_preproc_ok=:
-+ break
-+ fi
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.err conftest.i conftest.$ac_ext
-+
-+ done
-+ # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-+-rm -f conftest.err conftest.$ac_ext
-++rm -f conftest.i conftest.err conftest.$ac_ext
-+ if $ac_preproc_ok; then :
-+
-+ else
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-+-See \`config.log' for more details." "$LINENO" 5; }
-++as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-++See \`config.log' for more details" "$LINENO" 5; }
-+ fi
-+
-+ ac_ext=c
-+@@ -5086,7 +5132,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-+ $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-+-if test "${ac_cv_path_GREP+set}" = set; then :
-++if ${ac_cv_path_GREP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -z "$GREP"; then
-+@@ -5100,7 +5146,7 @@ do
-+ for ac_prog in grep ggrep; do
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-+- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-++ as_fn_executable_p "$ac_path_GREP" || continue
-+ # Check for GNU ac_path_GREP and select it if it is found.
-+ # Check for GNU $ac_path_GREP
-+ case `"$ac_path_GREP" --version 2>&1` in
-+@@ -5135,7 +5181,7 @@ esac
-+ done
-+ IFS=$as_save_IFS
-+ if test -z "$ac_cv_path_GREP"; then
-+- as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-++ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-+ fi
-+ else
-+ ac_cv_path_GREP=$GREP
-+@@ -5149,7 +5195,7 @@ $as_echo "$ac_cv_path_GREP" >&6; }
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-+ $as_echo_n "checking for egrep... " >&6; }
-+-if test "${ac_cv_path_EGREP+set}" = set; then :
-++if ${ac_cv_path_EGREP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-+@@ -5166,7 +5212,7 @@ do
-+ for ac_prog in egrep; do
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-+- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-++ as_fn_executable_p "$ac_path_EGREP" || continue
-+ # Check for GNU ac_path_EGREP and select it if it is found.
-+ # Check for GNU $ac_path_EGREP
-+ case `"$ac_path_EGREP" --version 2>&1` in
-+@@ -5201,7 +5247,7 @@ esac
-+ done
-+ IFS=$as_save_IFS
-+ if test -z "$ac_cv_path_EGREP"; then
-+- as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-++ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-+ fi
-+ else
-+ ac_cv_path_EGREP=$EGREP
-+@@ -5216,7 +5262,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; }
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-+ $as_echo_n "checking for ANSI C header files... " >&6; }
-+-if test "${ac_cv_header_stdc+set}" = set; then :
-++if ${ac_cv_header_stdc+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -5333,8 +5379,7 @@ do :
-+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-+ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-+ "
-+-eval as_val=\$$as_ac_Header
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -5346,7 +5391,7 @@ done
-+
-+
-+ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
-+-if test "x$ac_cv_header_minix_config_h" = x""yes; then :
-++if test "x$ac_cv_header_minix_config_h" = xyes; then :
-+ MINIX=yes
-+ else
-+ MINIX=
-+@@ -5368,14 +5413,14 @@ $as_echo "#define _MINIX 1" >>confdefs.h
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
-+ $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
-+-if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
-++if ${ac_cv_safe_to_define___extensions__+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+ /* end confdefs.h. */
-+
-+-# define __EXTENSIONS__ 1
-+- $ac_includes_default
-++# define __EXTENSIONS__ 1
-++ $ac_includes_default
-+ int
-+ main ()
-+ {
-+@@ -5432,7 +5477,7 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-+ $as_echo_n "checking for a BSD-compatible install... " >&6; }
-+ if test -z "$INSTALL"; then
-+-if test "${ac_cv_path_install+set}" = set; then :
-++if ${ac_cv_path_install+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+@@ -5452,7 +5497,7 @@ case $as_dir/ in #((
-+ # by default.
-+ for ac_prog in ginstall scoinst install; do
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
-+ if test $ac_prog = install &&
-+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-+ # AIX install. It has an incompatible calling convention.
-+@@ -5615,7 +5660,7 @@ esac
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
-+ $as_echo_n "checking for a sed that does not truncate output... " >&6; }
-+-if test "${ac_cv_path_SED+set}" = set; then :
-++if ${ac_cv_path_SED+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
-+@@ -5635,7 +5680,7 @@ do
-+ for ac_prog in sed gsed; do
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-+- { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
-++ as_fn_executable_p "$ac_path_SED" || continue
-+ # Check for GNU ac_path_SED and select it if it is found.
-+ # Check for GNU $ac_path_SED
-+ case `"$ac_path_SED" --version 2>&1` in
-+@@ -5670,7 +5715,7 @@ esac
-+ done
-+ IFS=$as_save_IFS
-+ if test -z "$ac_cv_path_SED"; then
-+- as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5
-++ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
-+ fi
-+ else
-+ ac_cv_path_SED=$SED
-+@@ -5697,7 +5742,7 @@ Xsed="$SED -e 1s/^X//"
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
-+ $as_echo_n "checking for fgrep... " >&6; }
-+-if test "${ac_cv_path_FGREP+set}" = set; then :
-++if ${ac_cv_path_FGREP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
-+@@ -5714,7 +5759,7 @@ do
-+ for ac_prog in fgrep; do
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
-+- { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
-++ as_fn_executable_p "$ac_path_FGREP" || continue
-+ # Check for GNU ac_path_FGREP and select it if it is found.
-+ # Check for GNU $ac_path_FGREP
-+ case `"$ac_path_FGREP" --version 2>&1` in
-+@@ -5749,7 +5794,7 @@ esac
-+ done
-+ IFS=$as_save_IFS
-+ if test -z "$ac_cv_path_FGREP"; then
-+- as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-++ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-+ fi
-+ else
-+ ac_cv_path_FGREP=$FGREP
-+@@ -5828,7 +5873,7 @@ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-+ $as_echo_n "checking for non-GNU ld... " >&6; }
-+ fi
-+-if test "${lt_cv_path_LD+set}" = set; then :
-++if ${lt_cv_path_LD+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -z "$LD"; then
-+@@ -5865,10 +5910,10 @@ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+ $as_echo "no" >&6; }
-+ fi
-+-test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
-++test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-+ $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-+-if test "${lt_cv_prog_gnu_ld+set}" = set; then :
-++if ${lt_cv_prog_gnu_ld+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
-+@@ -5895,7 +5940,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
-+ $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
-+-if test "${lt_cv_path_NM+set}" = set; then :
-++if ${lt_cv_path_NM+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$NM"; then
-+@@ -5958,7 +6003,7 @@ else
-+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_DUMPBIN+set}" = set; then :
-++if ${ac_cv_prog_DUMPBIN+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$DUMPBIN"; then
-+@@ -5970,7 +6015,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6002,7 +6047,7 @@ do
-+ set dummy $ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_DUMPBIN"; then
-+@@ -6014,7 +6059,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6074,7 +6119,7 @@ test -z "$NM" && NM=nm
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
-+ $as_echo_n "checking the name lister ($NM) interface... " >&6; }
-+-if test "${lt_cv_nm_interface+set}" = set; then :
-++if ${lt_cv_nm_interface+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_nm_interface="BSD nm"
-+@@ -6109,7 +6154,7 @@ fi
-+ # find the maximum length of command line arguments
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
-+ $as_echo_n "checking the maximum length of command line arguments... " >&6; }
-+-if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
-++if ${lt_cv_sys_max_cmd_len+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ i=0
-+@@ -6306,7 +6351,7 @@ esac
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
-+ $as_echo_n "checking for $LD option to reload object files... " >&6; }
-+-if test "${lt_cv_ld_reload_flag+set}" = set; then :
-++if ${lt_cv_ld_reload_flag+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_ld_reload_flag='-r'
-+@@ -6342,7 +6387,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}objdump; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_OBJDUMP+set}" = set; then :
-++if ${ac_cv_prog_OBJDUMP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$OBJDUMP"; then
-+@@ -6354,7 +6399,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6382,7 +6427,7 @@ if test -z "$ac_cv_prog_OBJDUMP"; then
-+ set dummy objdump; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_OBJDUMP"; then
-+@@ -6394,7 +6439,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_OBJDUMP="objdump"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6441,7 +6486,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
-+ $as_echo_n "checking how to recognize dependent libraries... " >&6; }
-+-if test "${lt_cv_deplibs_check_method+set}" = set; then :
-++if ${lt_cv_deplibs_check_method+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_file_magic_cmd='$MAGIC_CMD'
-+@@ -6662,7 +6707,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}ar; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_AR+set}" = set; then :
-++if ${ac_cv_prog_AR+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$AR"; then
-+@@ -6674,7 +6719,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_AR="${ac_tool_prefix}ar"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6702,7 +6747,7 @@ if test -z "$ac_cv_prog_AR"; then
-+ set dummy ar; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_AR+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_AR"; then
-+@@ -6714,7 +6759,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_AR="ar"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6767,7 +6812,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}strip; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_STRIP+set}" = set; then :
-++if ${ac_cv_prog_STRIP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$STRIP"; then
-+@@ -6779,7 +6824,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6807,7 +6852,7 @@ if test -z "$ac_cv_prog_STRIP"; then
-+ set dummy strip; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_STRIP"; then
-+@@ -6819,7 +6864,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_STRIP="strip"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6866,7 +6911,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_RANLIB+set}" = set; then :
-++if ${ac_cv_prog_RANLIB+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$RANLIB"; then
-+@@ -6878,7 +6923,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -6906,7 +6951,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
-+ set dummy ranlib; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_RANLIB"; then
-+@@ -6918,7 +6963,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_RANLIB="ranlib"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7010,7 +7055,7 @@ do
-+ set dummy $ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_AWK+set}" = set; then :
-++if ${ac_cv_prog_AWK+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$AWK"; then
-+@@ -7022,7 +7067,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_AWK="$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7077,7 +7122,7 @@ compiler=$CC
-+ # Check for command to grab the raw symbol name followed by C symbol from nm.
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
-+ $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
-+-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
-++if ${lt_cv_sys_global_symbol_pipe+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+
-+@@ -7461,7 +7506,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-+ CFLAGS="$CFLAGS -belf"
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
-+ $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
-+-if test "${lt_cv_cc_needs_belf+set}" = set; then :
-++if ${lt_cv_cc_needs_belf+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_ext=c
-+@@ -7537,7 +7582,7 @@ need_locks="$enable_libtool_lock"
-+ set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_DSYMUTIL+set}" = set; then :
-++if ${ac_cv_prog_DSYMUTIL+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$DSYMUTIL"; then
-+@@ -7549,7 +7594,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7577,7 +7622,7 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then
-+ set dummy dsymutil; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_DSYMUTIL"; then
-+@@ -7589,7 +7634,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7629,7 +7674,7 @@ fi
-+ set dummy ${ac_tool_prefix}nmedit; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_NMEDIT+set}" = set; then :
-++if ${ac_cv_prog_NMEDIT+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$NMEDIT"; then
-+@@ -7641,7 +7686,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7669,7 +7714,7 @@ if test -z "$ac_cv_prog_NMEDIT"; then
-+ set dummy nmedit; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_NMEDIT"; then
-+@@ -7681,7 +7726,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_NMEDIT="nmedit"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7721,7 +7766,7 @@ fi
-+ set dummy ${ac_tool_prefix}lipo; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_LIPO+set}" = set; then :
-++if ${ac_cv_prog_LIPO+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$LIPO"; then
-+@@ -7733,7 +7778,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7761,7 +7806,7 @@ if test -z "$ac_cv_prog_LIPO"; then
-+ set dummy lipo; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_LIPO"; then
-+@@ -7773,7 +7818,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_LIPO="lipo"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7813,7 +7858,7 @@ fi
-+ set dummy ${ac_tool_prefix}otool; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_OTOOL+set}" = set; then :
-++if ${ac_cv_prog_OTOOL+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$OTOOL"; then
-+@@ -7825,7 +7870,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7853,7 +7898,7 @@ if test -z "$ac_cv_prog_OTOOL"; then
-+ set dummy otool; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_OTOOL"; then
-+@@ -7865,7 +7910,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_OTOOL="otool"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7905,7 +7950,7 @@ fi
-+ set dummy ${ac_tool_prefix}otool64; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_OTOOL64+set}" = set; then :
-++if ${ac_cv_prog_OTOOL64+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$OTOOL64"; then
-+@@ -7917,7 +7962,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -7945,7 +7990,7 @@ if test -z "$ac_cv_prog_OTOOL64"; then
-+ set dummy otool64; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_OTOOL64"; then
-+@@ -7957,7 +8002,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_OTOOL64="otool64"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -8020,7 +8065,7 @@ fi
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
-+ $as_echo_n "checking for -single_module linker flag... " >&6; }
-+-if test "${lt_cv_apple_cc_single_mod+set}" = set; then :
-++if ${lt_cv_apple_cc_single_mod+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_apple_cc_single_mod=no
-+@@ -8049,7 +8094,7 @@ fi
-+ $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
-+ $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
-+-if test "${lt_cv_ld_exported_symbols_list+set}" = set; then :
-++if ${lt_cv_ld_exported_symbols_list+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_ld_exported_symbols_list=no
-+@@ -8081,7 +8126,7 @@ fi
-+ $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
-+ $as_echo_n "checking for -force_load linker flag... " >&6; }
-+-if test "${lt_cv_ld_force_load+set}" = set; then :
-++if ${lt_cv_ld_force_load+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_ld_force_load=no
-+@@ -8148,7 +8193,7 @@ for ac_header in dlfcn.h
-+ do :
-+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
-+ "
-+-if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
-++if test "x$ac_cv_header_dlfcn_h" = xyes; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define HAVE_DLFCN_H 1
-+ _ACEOF
-+@@ -8184,7 +8229,7 @@ if test -n "$ac_tool_prefix"; then
-+ set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_RANLIB+set}" = set; then :
-++if ${ac_cv_prog_RANLIB+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$RANLIB"; then
-+@@ -8196,7 +8241,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -8224,7 +8269,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
-+ set dummy ranlib; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
-++if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$ac_ct_RANLIB"; then
-+@@ -8236,7 +8281,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_ac_ct_RANLIB="ranlib"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -8292,7 +8337,7 @@ depcc="$CC" am_compiler_list=
-+ am_depcomp=$ac_aux_dir/depcomp
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
-+ $as_echo_n "checking dependency style of $depcc... " >&6; }
-+-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
-++if ${am_cv_CC_dependencies_compiler_type+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -f "$am_depcomp"; then
-+@@ -8378,7 +8423,7 @@ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
-+ $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
-+ if test x${am_cv_CC_dependencies_compiler_type-none} = xnone
-+-then as_fn_error "no usable dependency style found" "$LINENO" 5
-++then as_fn_error $? "no usable dependency style found" "$LINENO" 5
-+ else CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-+
-+ fi
-+@@ -8391,7 +8436,7 @@ do
-+ set dummy $ac_prog; ac_word=$2
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+ $as_echo_n "checking for $ac_word... " >&6; }
-+-if test "${ac_cv_prog_MAKE+set}" = set; then :
-++if ${ac_cv_prog_MAKE+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test -n "$MAKE"; then
-+@@ -8403,7 +8448,7 @@ do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-+ ac_cv_prog_MAKE="$ac_prog"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+@@ -8521,8 +8566,7 @@ for ac_header in stdlib.h string.h strings.h unistd.h time.h
-+ do :
-+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-+-eval as_val=\$$as_ac_Header
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -8535,8 +8579,7 @@ for ac_header in sys/time.h sys/resource.h
-+ do :
-+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-+-eval as_val=\$$as_ac_Header
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -8549,8 +8592,7 @@ for ac_header in fcntl.h fpu_control.h
-+ do :
-+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-+-eval as_val=\$$as_ac_Header
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -8563,8 +8605,7 @@ for ac_header in dlfcn.h errno.h sys/stat.h
-+ do :
-+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-+-eval as_val=\$$as_ac_Header
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -8577,8 +8618,7 @@ for ac_func in getrusage time sigaction __setfpucw
-+ do :
-+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-+ ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-+-eval as_val=\$$as_ac_var
-+- if test "x$as_val" = x""yes; then :
-++if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-+ _ACEOF
-+@@ -8590,7 +8630,7 @@ done
-+ # Check for socket libraries
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lsocket" >&5
-+ $as_echo_n "checking for bind in -lsocket... " >&6; }
-+-if test "${ac_cv_lib_socket_bind+set}" = set; then :
-++if ${ac_cv_lib_socket_bind+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -8624,7 +8664,7 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_bind" >&5
-+ $as_echo "$ac_cv_lib_socket_bind" >&6; }
-+-if test "x$ac_cv_lib_socket_bind" = x""yes; then :
-++if test "x$ac_cv_lib_socket_bind" = xyes; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define HAVE_LIBSOCKET 1
-+ _ACEOF
-+@@ -8635,7 +8675,7 @@ fi
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
-+ $as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
-+-if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then :
-++if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -8669,7 +8709,7 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
-+ $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
-+-if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then :
-++if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define HAVE_LIBNSL 1
-+ _ACEOF
-+@@ -8695,7 +8735,7 @@ fi
-+ if test "$with_zlib" != "no"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-+ $as_echo_n "checking for library containing zlibVersion... " >&6; }
-+-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-++if ${ac_cv_search_zlibVersion+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_func_search_save_LIBS=$LIBS
-+@@ -8729,11 +8769,11 @@ for ac_lib in '' z; do
-+ fi
-+ rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext
-+- if test "${ac_cv_search_zlibVersion+set}" = set; then :
-++ if ${ac_cv_search_zlibVersion+:} false; then :
-+ break
-+ fi
-+ done
-+-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-++if ${ac_cv_search_zlibVersion+:} false; then :
-+
-+ else
-+ ac_cv_search_zlibVersion=no
-+@@ -8749,7 +8789,7 @@ if test "$ac_res" != no; then :
-+ for ac_header in zlib.h
-+ do :
-+ ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
-+-if test "x$ac_cv_header_zlib_h" = x""yes; then :
-++if test "x$ac_cv_header_zlib_h" = xyes; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define HAVE_ZLIB_H 1
-+ _ACEOF
-+@@ -8761,7 +8801,7 @@ done
-+ fi
-+
-+ if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
-+- as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
-++ as_fn_error $? "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
-+ fi
-+ fi
-+
-+@@ -8965,7 +9005,7 @@ fi
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
-+ $as_echo_n "checking for objdir... " >&6; }
-+-if test "${lt_cv_objdir+set}" = set; then :
-++if ${lt_cv_objdir+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ rm -f .libs 2>/dev/null
-+@@ -9043,7 +9083,7 @@ file_magic*)
-+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
-+ $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
-+-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
-++if ${lt_cv_path_MAGIC_CMD+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ case $MAGIC_CMD in
-+@@ -9109,7 +9149,7 @@ if test -z "$lt_cv_path_MAGIC_CMD"; then
-+ if test -n "$ac_tool_prefix"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
-+ $as_echo_n "checking for file... " >&6; }
-+-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
-++if ${lt_cv_path_MAGIC_CMD+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ case $MAGIC_CMD in
-+@@ -9251,7 +9291,7 @@ if test "$GCC" = yes; then
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-+ $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
-+-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
-++if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler_rtti_exceptions=no
-+@@ -9604,7 +9644,7 @@ $as_echo "$lt_prog_compiler_pic" >&6; }
-+ if test -n "$lt_prog_compiler_pic"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-+ $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
-+-if test "${lt_cv_prog_compiler_pic_works+set}" = set; then :
-++if ${lt_cv_prog_compiler_pic_works+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler_pic_works=no
-+@@ -9663,7 +9703,7 @@ fi
-+ wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-+ $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-+-if test "${lt_cv_prog_compiler_static_works+set}" = set; then :
-++if ${lt_cv_prog_compiler_static_works+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler_static_works=no
-+@@ -9706,7 +9746,7 @@ fi
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-+ $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-+-if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
-++if ${lt_cv_prog_compiler_c_o+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler_c_o=no
-+@@ -9761,7 +9801,7 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-+ $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-+-if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
-++if ${lt_cv_prog_compiler_c_o+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler_c_o=no
-+@@ -10577,7 +10617,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
-+ $as_echo_n "checking if $CC understands -b... " >&6; }
-+-if test "${lt_cv_prog_compiler__b+set}" = set; then :
-++if ${lt_cv_prog_compiler__b+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_prog_compiler__b=no
-+@@ -10949,7 +10989,7 @@ x|xyes)
-+ # to ld, don't add -lc before -lgcc.
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-+ $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-+-if test "${lt_cv_archive_cmds_need_lc+set}" = set; then :
-++if ${lt_cv_archive_cmds_need_lc+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ $RM conftest*
-+@@ -11587,7 +11627,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)
-+ shlibpath_overrides_runpath=no
-+
-+ # Some binutils ld are patched to set DT_RUNPATH
-+- if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then :
-++ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ lt_cv_shlibpath_overrides_runpath=no
-+@@ -12007,7 +12047,7 @@ else
-+ # if libdl is installed we need to link against it
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-+ $as_echo_n "checking for dlopen in -ldl... " >&6; }
-+-if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
-++if ${ac_cv_lib_dl_dlopen+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -12041,7 +12081,7 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-+ $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-+-if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
-++if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-+ else
-+
-+@@ -12055,12 +12095,12 @@ fi
-+
++++ b/sim/erc32/README.leon2
+@@ -0,0 +1,53 @@
++
++1. LEON2 emulation
++
++The file 'leon2.c' contains a model of simple LEON2 sub-system. It
++contains 16 Mbyte ROM and 16 Mbyte RAM. Standard peripherals
++such as interrupt controller, UART and timer are provided.
++The model can execute leon2 binaries that do not require an
++MMU.
++
++To start sis in Leon2 mode, add the -leon2 switch. In gdb,
++use 'target sim -leon2' .
++
++1.1 UART
++
++One LEON2 UART is emaulted, and is located at address 0x80000070.
++The following registers are implemeted:
++
++- UART RX and TX register (0x80000070)
++- UART status register (0x80000074)
++
++The UART generates interrupt 3.
++
++1.2 Timer unit
++
++The LEON2 timer unit is emulated and located at address 0x80000040.
++It is configured with two timers and separate interrupts (8 and 9).
++The scaler is configured to 16 bits, while the counters are 32 bits.
++
++1.3 Interrupt controller
++
++The interrupt controller is implemented as described in the
++LEON2 IP manual, with the exception of the interrupt level register.
++Secondary interrupts are not supported. The registers are located
++at address 0x80000090.
++
++1.5 Memory interface
++
++The following memory areas are valid for the Leon3 simulator:
++
++0x00000000 - 0x01000000 ROM (16 Mbyte, loaded at start-up)
++0x40000000 - 0x41000000 RAM (16 Mbyte, loaded at start-up)
++0x80000000 - 0x81000000 APB bus, including plug&play
++0xFFFFF000 - 0xFFFFFFFF AHB plug&play area
++
++Access to non-existing memory will result in a memory exception trap.
++
++1.8 Power-down mode
++
++The Leon2 power-down register (0x80000018) is supported. When power-down is
++entered, time is skipped forward until the next event in the event queue.
++However, if the simulator event queue is empty, power-down mode is not
++entered since no interrupt would be generated to exit from the mode. A
++Ctrl-C in the simulator window will exit the power-down mode.
+diff --git a/sim/erc32/README.leon3 b/sim/erc32/README.leon3
+new file mode 100644
+index 0000000..00ab14a
+--- /dev/null
++++ b/sim/erc32/README.leon3
+@@ -0,0 +1,53 @@
++
++1. LEON3 emulation
++
++The file 'leon3.c' contains a model of simple LEON3 sub-system. It
++contains 16 Mbyte ROM and 16 Mbyte RAM. Standard peripherals
++such as interrupt controller, UART and timer are provided.
++The model can execute leon3 binaries that do not require an
++MMU.
++
++To start sis in Leon3 mode, add the -leon3 switch. In gdb,
++use 'target sim -leon3' .
++
++1.1 UART
++
++The UART emulates an APBUART and is located at address 0x80000100.
++The following registers are implemeted:
++
++- UART RX and TX register (0x80000100)
++- UART status register (0x80000104)
++
++The UART generates interrupt 3.
++
++1.2 Timer unit (GPTIMER)
++
++The GPTIMER programmable counter is emulated and located at
++address 0x80000300. It is configured with two timers and separate
++interrupts (8 and 9).
++
++1.3 Interrupt controller
++
++The IRQMP interrupt controller is implemented as described in the
++GRLIB IP manual, with the exception of the interrupt level register.
++Extended interrupts are not supported. The registers are located
++at address 0x80000200.
++
++1.5 Memory interface
++
++The following memory areas are valid for the Leon3 simulator:
++
++0x00000000 - 0x01000000 ROM (16 Mbyte, loaded at start-up)
++0x40000000 - 0x41000000 RAM (16 Mbyte, loaded at start-up)
++0x80000000 - 0x81000000 APB bus, including plug&play
++0xFFFFF000 - 0xFFFFFFFF AHB plug&play area
++
++Access to non-existing memory will result in a memory exception trap.
++
++1.8 Power-down mode
++
++The Leon3 power-down feature (%asr19) is supported. When power-down is
++entered, time is skipped forward until the next event in the event queue.
++However, if the simulator event queue is empty, power-down mode is not
++entered since no interrupt would be generated to exit from the mode. A
++Ctrl-C in the simulator window will exit the power-down mode.
+diff --git a/sim/erc32/README.sis b/sim/erc32/README.sis
+index b119f03..59c4c64 100644
+--- a/sim/erc32/README.sis
++++ b/sim/erc32/README.sis
+@@ -1,10 +1,10 @@
+
+-SIS - Sparc Instruction Simulator README file (v2.0, 05-02-1996)
++SIS - Sparc Instruction Simulator README file (v2.8, 10-11-2014)
+ -------------------------------------------------------------------
+
+ 1. Introduction
+
+-The SIS is a SPARC V7 architecture simulator. It consist of two parts,
++The SIS is a SPARC V7/V8 architecture simulator. It consist of two parts,
+ the simulator core and a user defined memory module. The simulator
+ core executes the instructions while the memory module emulates memory
+ and peripherals.
+@@ -13,28 +13,29 @@ and peripherals.
+
+ The simulator is started as follows:
+
+-sis [-uart1 uart_device1] [-uart2 uart_device2]
++sis [-leon2] [-leon3] [-uart1 uart_device1] [-uart2 uart_device2]
+ [-nfp] [-freq frequency] [-c batch_file] [files]
+
+-The default uart devices for SIS are /dev/ptypc and /dev/ptypd. The
+--uart[1,2] switch can be used to connect the uarts to other devices.
+-Use 'tip /dev/ttypc' to connect a terminal emulator to the uarts.
++By default, SIS emaultes an ERC32 system. The -leon2 switch enables
++LEON2 emaultion, while the -leon3 switch enables emulation of a
++LEON3 SOC system.
++
++The emulated console uart is connected stdin/stdout. The -uart[1,2]
++switch can be used to connect the uarts to other devices.
++
+ The '-nfp' will disable the simulated FPU, so each FPU instruction will
+ generate a FPU disabled trap. The '-freq' switch can be used to define
+ which "frequency" the simulator runs at. This is used by the 'perf'
+ command to calculated the MIPS figure for a particular configuration.
+-The give frequency must be an integer indicating the frequency in MHz.
++The frequency must be an integer indicating the frequency in MHz.
+
+ The -c option indicates that sis commands should be read from 'batch_file'
+ at startup.
+
+-Files to be loaded must be in one of the supported formats (see INSTALLATION),
+-and will be loaded into the simulated memory. The file formats are
+-automatically recognised.
++Files to be loaded must be in one of the supported formats (elf, a.out, srec),
++and will be loaded into the simulated memory.
+
+-The script 'startsim' will start the simulator in one xterm window and
+-open a terminal emulator (tip) connected to the UART A in a second
+-xterm window. Below is description of commands that are recognized by
++Below is description of commands that are recognized by
+ the simulator. The command-line is parsed using GNU readline. A command
+ history of 64 commands is maintained. Use the up/down arrows to recall
+ previous commands. For more details, see the readline documentation.
+@@ -77,8 +78,8 @@ Prints the FPU registers
+ go <address> [inst_count]
+
+ The go command will set pc to <address> and npc to <address> + 4, and start
+-execution. No other initialisation will be done. If inst_count is given,
+-execution will stop after the specified number of instructions.
++execution. If inst_count is given, execution will stop after the specified
++number of instructions.
+
+ help
+
+@@ -143,136 +144,67 @@ Typing a 'Ctrl-C' will interrupt a running simulator.
+ Short forms of the commands are allowed, e.g 'c' 'co' or 'con' are all
+ interpreted as 'cont'.
+
++2 Using SIS with gdb
++
++2.1 Attaching the simulator
++
++To attach GDB to the simulator, use:
++
++target sim [options]
++
++The following options are supported:
++
++ -leon2 Emulate a LEON2 system
++
++ -leon3 Emulate a LEON3 system
++
++ -nfp Disable FPU. FPops will cause an FPU disabled trap.
++
++ -freq <f> Set the simulated "system clock" to <f> MHz.
++
++ -v Verbose mode.
++
++ -nogdb Disable GDB breakpoint handling (see below)
++
++To start debugging a program type 'load <program>' and debug as
++usual.
++
++The native simulator commands can be reached using the GDB 'sim'
++command:
++
++sim <sis_command>
++
++Direct simulator commands during a GDB session must be issued
++with care not to disturb GDB's operation ...
++
++A program can be restarted in gdb by first issuing the load command,
++followed by run.
++
++2.2 GDB breakpoint handling
++
++GDB inserts breakpoint in the form of the 'ta 1' instruction. The
++GDB-integrated simulator will therefore recognize the breakpoint
++instruction and return control to GDB. If the application uses
++'ta 1', the breakpoint detection can be disabled with the -nogdb
++switch. In this case however, GDB breakpoints will not work.
++
+
+ 3. Simulator core
+
+-The SIS emulates the behavior of the 90C601E and 90C602E sparc IU and
+-FPU from Matra MHS. These are roughly equivalent to the Cypress C601
+-and C602. The simulator is cycle true, i.e a simulator time is
++In ERC32 mode, SIS emulates the behavior of the 90C601E and 90C602E
++sparc IU and FPU from Matra MHS. These are roughly equivalent to the
++Cypress C601 and C602. The simulator is cycle true, i.e a simulator time is
+ maintained and inremented according the IU and FPU instruction timing.
+ The parallel execution between the IU and FPU is modelled, as well as
+-stalls due to operand dependencies (FPU). The core interacts with the
+-user-defined memory modules through a number of functions. The memory
+-module must provide the following functions:
+-
+-int memory_read(asi,addr,data,ws)
+-int asi;
+-unsigned int addr;
+-unsigned int *data;
+-int *ws;
+-
+-int memory_write(asi,addr,data,sz,ws)
+-int asi;
+-unsigned int addr;
+-unsigned int *data;
+-int sz;
+-int *ws;
+-
+-int sis_memory_read(addr, data, length)
+-unsigned int addr;
+-char *data;
+-unsigned int length;
+-
+-int sis_memory_write(addr, data, length)
+-unsigned int addr;
+-char *data;
+-unsigned int length;
+-
+-int init_sim()
+-
+-int reset()
+-
+-int error_mode(pc)
+-unsigned int pc;
+-
+-memory_read() is used by the simulator to fetch instructions and
+-operands. The address space identifier (asi) and address is passed as
+-parameters. The read data should be assigned to the data pointer
+-(*data) and the number of waitstate to *ws. 'memory_read' should return
+-0 on success and 1 on failure. A failure will cause a data or
+-instruction fetch trap. memory_read() always reads one 32-bit word.
+-
+-sis_memory_read() is used by the simulator to display and disassemble
+-memory contants. The function should copy 'length' bytes of the simulated
+-memory starting at 'addr' to '*data'.
+-The sis_memory_read() should return 1 on success and 0 on failure.
+-Failure should only be indicated if access to unimplemented memory is attempted.
+-
+-memory_write() is used to write to memory. In addition to the asi
+-and address parameters, the size of the written data is given by 'sz'.
+-The pointer *data points to the data to be written. The 'sz' is coded
+-as follows:
+-
+- sz access type
+- 0 byte
+- 1 halfword
+- 2 word
+- 3 double-word
+-
+-If a double word is written, the most significant word is in data[0] and
+-the least significant in data[1].
+-
+-sis_memory_write() is used by the simulator during loading of programs.
+-The function should copy 'length' bytes from *data to the simulated
+-memory starting at 'addr'. sis_memory_write() should return 1 on
+-success and 0 on failure. Failure should only be indicated if access
+-to unimplemented memory is attempted. See erc32.c for more details
+-on how to define the memory emulation functions.
+-
+-The 'init_sim' is called once when the simulator is started. This function
+-should be used to perform initialisations of user defined memory or
+-peripherals that only have to be done once, such as opening files etc.
+-
+-The 'reset' is called every time the simulator is reset, i.e. when a
+-'run' command is given. This function should be used to simulate a power
+-on reset of memory and peripherals.
+-
+-error_mode() is called by the simulator when the IU goes into error mode,
+-typically if a trap is caused when traps are disabled. The memory module
+-can then take actions, such as issue a reset.
+-
+-sys_reset() can be called by the memory module to reset the simulator. A
+-reset will empty the event queue and perform a power-on reset.
+-
+-4. Events and interrupts
+-
+-The simulator supports an event queue and the generation of processor
+-interrupts. The following functions are available to the user-defined
+-memory module:
+-
+-event(cfunc,arg,delta)
+-void (*cfunc)();
+-int arg;
+-unsigned int delta;
+-
+-set_int(level,callback,arg)
+-int level;
+-void (*callback)();
+-int arg;
+-
+-clear_int(level)
+-int level;
+-
+-sim_stop()
+-
+-The 'event' functions will schedule the execution of the function 'cfunc'
+-at time 'now + delta' clock cycles. The parameter 'arg' is passed as a
+-parameter to 'cfunc'.
+-
+-The 'set_int' function set the processor interrupt 'level'. When the interrupt
+-is taken, the function 'callback' is called with the argument 'arg'. This
+-will also clear the interrupt. An interrupt can be cleared before it is
+-taken by calling 'clear_int' with the appropriate interrupt level.
+-
+-The sim_stop function is called each time the simulator stops execution.
+-It can be used to flush buffered devices to get a clean state during
+-single stepping etc.
++stalls due to operand dependencies (FPU).
+
+-See 'erc32.c' for examples on how to use events and interrupts.
++In Leon2/3 mode, the core emulates the Leon2/3 SPARC V8 core from
++Gaisler Research. All SPARC V8 instructions are supported but
++emaultion is not fully cycle-true as the cache is not emulated.
+
+ 5. Memory module
+
+-The supplied memory module (erc32.c) emulates the functions of memory and
++The ERC32 memory module (erc32.c) emulates the functions of memory and
+ the MEC asic developed for the 90C601/2. It includes the following functions:
+
+ * UART A & B
+@@ -284,28 +216,38 @@ the MEC asic developed for the 90C601/2. It includes the following functions:
+ * 512 Kbyte ROM
+ * 4 Mbyte RAM
+
+-See README.erc32 on how the MEC functions are emulated. For a detailed MEC
+-specification, look at the ERC32 home page at URL:
++See README.erc32 on how the MEC functions are emulated.
++
++The Leon2 memory module (leon2.c) emulates on-chip peripherals and
++external memory for a simple Leon2 system. The modules includes the
++following functions:
++
++* AHB and APB buses
++* One UART
++* Interrupt controller
++* Timer unit with two timers
++* PROM/SRAM memory controller
++* 16 Mbyte PROM, 16 Mbyte SRAM
+
+-http://www.estec.esa.nl/wsmwww/erc32
++See README.leon2 for further details on Leon3 emulation.
+
+-6. Compile and linking programs
++The Leon3 memory module (leon3.c) emulates on-chip peripherals and
++external memory for a simple Leon3 system. The modules includes the
++following functions:
+
+-The directory 'examples' contain some code fragments for SIS.
+-The script gccx indicates how the native sunos gcc and linker can be used
+-to produce executables for the simulator. To compile and link the provided
+-'hello.c', type 'gccx hello.c'. This will build the executable 'hello'.
+-Start the simulator by running 'startsim hello', and issue the command 'run.
+-After the program is terminated, the IU will be force to error mode through
+-a software trap and halt.
++* AHB and APB buses with plug&play
++* UART (APBUART)
++* Interrupt controller (IRQMP)
++* Timer unit with two timers (GPTIMER)
++* PROM/SRAM memory controller (SRCTRL)
++* 16 Mbyte PROM, 16 Mbyte SRAM
+
+-The programs are linked with a start-up file, srt0.S. This file includes
+-the traptable and window underflow/overflow trap routines.
++See README.leon3 for further details on Leon3 emulation.
+
+-7. IU and FPU instruction timing.
++6. IU and FPU instruction timing.
+
+-The simulator provides cycle true simulation. The following table shows
+-the emulated instruction timing for 90C601E & 90C602E:
++The simulator provides cycle true simulation for ERC32. The following table
++shows the emulated instruction timing for 90C601E & 90C602E:
+
+ Instructions Cycles
+
+diff --git a/sim/erc32/config.in b/sim/erc32/config.in
+index 0db6f1e..0f712af 100644
+--- a/sim/erc32/config.in
++++ b/sim/erc32/config.in
+@@ -1,5 +1,8 @@
+ /* config.in. Generated from configure.ac by autoheader. */
+
++/* Define if building universal (internal helper macro) */
++#undef AC_APPLE_UNIVERSAL_BUILD
++
+ /* Define to 1 if translation of program messages to the user's native
+ language is requested. */
+ #undef ENABLE_NLS
+@@ -73,6 +76,10 @@
+ /* Define to 1 if you have the `__setfpucw' function. */
+ #undef HAVE___SETFPUCW
+
++/* Define to the sub-directory in which libtool stores uninstalled libraries.
++ */
++#undef LT_OBJDIR
++
+ /* Name of this package. */
+ #undef PACKAGE
+
+@@ -128,6 +135,18 @@
+ #endif
+
+
++/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
++ significant byte first (like Motorola and SPARC, unlike Intel). */
++#if defined AC_APPLE_UNIVERSAL_BUILD
++# if defined __BIG_ENDIAN__
++# define WORDS_BIGENDIAN 1
++# endif
++#else
++# ifndef WORDS_BIGENDIAN
++# undef WORDS_BIGENDIAN
++# endif
++#endif
++
+ /* Define to 1 if on MINIX. */
+ #undef _MINIX
+
+diff --git a/sim/erc32/configure b/sim/erc32/configure
+index b8fd852..9d1b373 100755
+--- a/sim/erc32/configure
++++ b/sim/erc32/configure
+@@ -1,10 +1,10 @@
+ #! /bin/sh
+ # Guess values for system-dependent variables and create Makefiles.
+-# Generated by GNU Autoconf 2.64.
++# Generated by GNU Autoconf 2.69.
++#
++#
++# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+ #
+-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+-# Foundation, Inc.
+ #
+ # This configure script is free software; the Free Software Foundation
+ # gives unlimited permission to copy, distribute and modify it.
+@@ -87,6 +87,7 @@ fi
+ IFS=" "" $as_nl"
+
+ # Find who we are. Look in the path if we contain no directory separator.
++as_myself=
+ case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+@@ -131,6 +132,31 @@ export LANGUAGE
+ # CDPATH.
+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
++# Use a proper internal environment variable to ensure we don't fall
++ # into an infinite loop, continuously re-executing ourselves.
++ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
++ _as_can_reexec=no; export _as_can_reexec;
++ # We cannot yet assume a decent shell, so we have to provide a
++# neutralization value for shells without unset; and this also
++# works around shells that cannot unset nonexistent variables.
++# Preserve -v and -x to the replacement shell.
++BASH_ENV=/dev/null
++ENV=/dev/null
++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
++case $- in # ((((
++ *v*x* | *x*v* ) as_opts=-vx ;;
++ *v* ) as_opts=-v ;;
++ *x* ) as_opts=-x ;;
++ * ) as_opts= ;;
++esac
++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
++# Admittedly, this is quite paranoid, since all the known shells bail
++# out after a failed `exec'.
++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
++as_fn_exit 255
++ fi
++ # We don't want this to propagate to other subprocesses.
++ { _as_can_reexec=; unset _as_can_reexec;}
+ if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+@@ -164,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+ else
+ exitcode=1; echo positional parameters were not saved.
+ fi
+-test x\$exitcode = x0 || exit 1"
++test x\$exitcode = x0 || exit 1
++test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+@@ -217,14 +244,25 @@ IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+- # We cannot yet assume a decent shell, so we have to provide a
+- # neutralization value for shells without unset; and this also
+- # works around shells that cannot unset nonexistent variables.
+- BASH_ENV=/dev/null
+- ENV=/dev/null
+- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+- export CONFIG_SHELL
+- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
++ export CONFIG_SHELL
++ # We cannot yet assume a decent shell, so we have to provide a
++# neutralization value for shells without unset; and this also
++# works around shells that cannot unset nonexistent variables.
++# Preserve -v and -x to the replacement shell.
++BASH_ENV=/dev/null
++ENV=/dev/null
++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
++case $- in # ((((
++ *v*x* | *x*v* ) as_opts=-vx ;;
++ *v* ) as_opts=-v ;;
++ *x* ) as_opts=-x ;;
++ * ) as_opts= ;;
++esac
++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
++# Admittedly, this is quite paranoid, since all the known shells bail
++# out after a failed `exec'.
++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
++exit 255
+ fi
+
+ if test x$as_have_required = xno; then :
+@@ -322,10 +360,18 @@ $as_echo X"$as_dir" |
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+ } # as_fn_mkdir_p
++
++# as_fn_executable_p FILE
++# -----------------------
++# Test if FILE is an executable regular file.
++as_fn_executable_p ()
++{
++ test -f "$1" && test -x "$1"
++} # as_fn_executable_p
+ # as_fn_append VAR VALUE
+ # ----------------------
+ # Append the text in VALUE to the end of the definition contained in VAR. Take
+@@ -362,19 +408,19 @@ else
+ fi # as_fn_arith
+
+
+-# as_fn_error ERROR [LINENO LOG_FD]
+-# ---------------------------------
++# as_fn_error STATUS ERROR [LINENO LOG_FD]
++# ----------------------------------------
+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+-# script with status $?, using 1 if that was 0.
++# script with STATUS, using 1 if that was 0.
+ as_fn_error ()
+ {
+- as_status=$?; test $as_status -eq 0 && as_status=1
+- if test "$3"; then
+- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
++ as_status=$1; test $as_status -eq 0 && as_status=1
++ if test "$4"; then
++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+- $as_echo "$as_me: error: $1" >&2
++ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+ } # as_fn_error
+
+@@ -447,6 +493,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
++ # already done that, so ensure we don't try to do so again and fall
++ # in an infinite loop. This has already happened in practice.
++ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+@@ -481,16 +531,16 @@ if (echo >conf$$.file) 2>/dev/null; then
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+- # In both cases, we have to default to `cp -p'.
++ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ fi
+ else
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ fi
+ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+ rmdir conf$$.dir 2>/dev/null
+@@ -502,28 +552,8 @@ else
+ as_mkdir_p=false
+ fi
+
+-if test -x / >/dev/null 2>&1; then
+- as_test_x='test -x'
+-else
+- if ls -dL / >/dev/null 2>&1; then
+- as_ls_L_option=L
+- else
+- as_ls_L_option=
+- fi
+- as_test_x='
+- eval sh -c '\''
+- if test -d "$1"; then
+- test -d "$1/.";
+- else
+- case $1 in #(
+- -*)set "./$1";;
+- esac;
+- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+- ???[sx]*):;;*)false;;esac;fi
+- '\'' sh
+- '
+-fi
+-as_executable_p=$as_test_x
++as_test_x='test -x'
++as_executable_p=as_fn_executable_p
+
+ # Sed expression to map a string onto a valid CPP name.
+ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+@@ -534,10 +564,11 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+ SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+-exec 7<&0 </dev/null 6>&1
++test -n "$DJDIR" || exec 7<&0 </dev/null
++exec 6>&1
+
+ # Name of the host.
+-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
++# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+ # so uname gets run too.
+ ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+@@ -833,8 +864,9 @@ do
+ fi
+
+ case $ac_option in
+- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+- *) ac_optarg=yes ;;
++ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
++ *=) ac_optarg= ;;
++ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+@@ -879,7 +911,7 @@ do
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+- as_fn_error "invalid feature name: $ac_useropt"
++ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+@@ -905,7 +937,7 @@ do
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+- as_fn_error "invalid feature name: $ac_useropt"
++ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+@@ -1109,7 +1141,7 @@ do
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+- as_fn_error "invalid package name: $ac_useropt"
++ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+@@ -1125,7 +1157,7 @@ do
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+- as_fn_error "invalid package name: $ac_useropt"
++ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+@@ -1155,8 +1187,8 @@ do
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+- -*) as_fn_error "unrecognized option: \`$ac_option'
+-Try \`$0 --help' for more information."
++ -*) as_fn_error $? "unrecognized option: \`$ac_option'
++Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+@@ -1164,7 +1196,7 @@ Try \`$0 --help' for more information."
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+- as_fn_error "invalid variable name: \`$ac_envvar'" ;;
++ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+@@ -1174,7 +1206,7 @@ Try \`$0 --help' for more information."
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
++ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+@@ -1182,13 +1214,13 @@ done
+
+ if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+- as_fn_error "missing argument to $ac_option"
++ as_fn_error $? "missing argument to $ac_option"
+ fi
+
+ if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+- fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
++ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+ fi
+@@ -1211,7 +1243,7 @@ do
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+- as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
++ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+ done
+
+ # There might be people who depend on the old broken behavior: `$host'
+@@ -1225,8 +1257,6 @@ target=$target_alias
+ if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+- If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+@@ -1241,9 +1271,9 @@ test "$silent" = yes && exec 6>/dev/null
+ ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ ac_ls_di=`ls -di .` &&
+ ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+- as_fn_error "working directory cannot be determined"
++ as_fn_error $? "working directory cannot be determined"
+ test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+- as_fn_error "pwd does not report name of working directory"
++ as_fn_error $? "pwd does not report name of working directory"
+
+
+ # Find the source files, if location was not specified.
+@@ -1282,11 +1312,11 @@ else
+ fi
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+- as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
++ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+ fi
+ ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ ac_abs_confdir=`(
+- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
++ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+ # When building in place, set srcdir=.
+ if test "$ac_abs_confdir" = "$ac_pwd"; then
+@@ -1326,7 +1356,7 @@ Configuration:
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+- -q, --quiet, --silent do not print \`checking...' messages
++ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+@@ -1420,7 +1450,7 @@ Some influential environment variables:
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
++ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+@@ -1491,9 +1521,9 @@ test -n "$ac_init_help" && exit $ac_status
+ if $ac_init_version; then
+ cat <<\_ACEOF
+ configure
+-generated by GNU Autoconf 2.64
++generated by GNU Autoconf 2.69
+
+-Copyright (C) 2009 Free Software Foundation, Inc.
++Copyright (C) 2012 Free Software Foundation, Inc.
+ This configure script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it.
+ _ACEOF
+@@ -1537,8 +1567,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+ fi
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+- return $ac_retval
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
++ as_fn_set_status $ac_retval
+
+ } # ac_fn_c_try_compile
+
+@@ -1563,7 +1593,7 @@ $as_echo "$ac_try_echo"; } >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; } >/dev/null && {
++ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+@@ -1574,8 +1604,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+ fi
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+- return $ac_retval
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
++ as_fn_set_status $ac_retval
+
+ } # ac_fn_c_try_cpp
+
+@@ -1587,10 +1617,10 @@ fi
+ ac_fn_c_check_header_mongrel ()
+ {
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+ fi
+ eval ac_res=\$$3
+@@ -1626,7 +1656,7 @@ if ac_fn_c_try_cpp "$LINENO"; then :
+ else
+ ac_header_preproc=no
+ fi
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.err conftest.i conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+ $as_echo "$ac_header_preproc" >&6; }
+
+@@ -1653,7 +1683,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ eval "$3=\$ac_header_compiler"
+@@ -1662,7 +1692,7 @@ eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+ $as_echo "$ac_res" >&6; }
+ fi
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+ } # ac_fn_c_check_header_mongrel
+
+@@ -1703,8 +1733,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
+ ac_retval=$ac_status
+ fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+- return $ac_retval
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
++ as_fn_set_status $ac_retval
+
+ } # ac_fn_c_try_run
+
+@@ -1717,7 +1747,7 @@ ac_fn_c_check_header_compile ()
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -1735,7 +1765,7 @@ fi
+ eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+ $as_echo "$ac_res" >&6; }
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+ } # ac_fn_c_check_header_compile
+
+@@ -1766,7 +1796,7 @@ $as_echo "$ac_try_echo"; } >&5
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+- $as_test_x conftest$ac_exeext
++ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+ else
+@@ -1780,8 +1810,8 @@ fi
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+- return $ac_retval
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
++ as_fn_set_status $ac_retval
+
+ } # ac_fn_c_try_link
+
+@@ -1793,7 +1823,7 @@ ac_fn_c_check_func ()
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+ $as_echo_n "checking for $2... " >&6; }
+-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
++if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -1848,7 +1878,7 @@ fi
+ eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+ $as_echo "$ac_res" >&6; }
+- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+ } # ac_fn_c_check_func
+ cat >config.log <<_ACEOF
+@@ -1856,7 +1886,7 @@ This file contains any messages produced by compilers while
+ running configure, to aid debugging if configure makes a mistake.
+
+ It was created by $as_me, which was
+-generated by GNU Autoconf 2.64. Invocation command line was
++generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+@@ -1966,11 +1996,9 @@ trap 'exit_status=$?
+ {
+ echo
+
+- cat <<\_ASBOX
+-## ---------------- ##
++ $as_echo "## ---------------- ##
+ ## Cache variables. ##
+-## ---------------- ##
+-_ASBOX
++## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+ (
+@@ -2004,11 +2032,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ )
+ echo
+
+- cat <<\_ASBOX
+-## ----------------- ##
++ $as_echo "## ----------------- ##
+ ## Output variables. ##
+-## ----------------- ##
+-_ASBOX
++## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+@@ -2021,11 +2047,9 @@ _ASBOX
+ echo
+
+ if test -n "$ac_subst_files"; then
+- cat <<\_ASBOX
+-## ------------------- ##
++ $as_echo "## ------------------- ##
+ ## File substitutions. ##
+-## ------------------- ##
+-_ASBOX
++## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+@@ -2039,11 +2063,9 @@ _ASBOX
+ fi
+
+ if test -s confdefs.h; then
+- cat <<\_ASBOX
+-## ----------- ##
++ $as_echo "## ----------- ##
+ ## confdefs.h. ##
+-## ----------- ##
+-_ASBOX
++## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+@@ -2098,7 +2120,12 @@ _ACEOF
+ ac_site_file1=NONE
+ ac_site_file2=NONE
+ if test -n "$CONFIG_SITE"; then
+- ac_site_file1=$CONFIG_SITE
++ # We do not want a PATH search for config.site.
++ case $CONFIG_SITE in #((
++ -*) ac_site_file1=./$CONFIG_SITE;;
++ */*) ac_site_file1=$CONFIG_SITE;;
++ *) ac_site_file1=./$CONFIG_SITE;;
++ esac
+ elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+@@ -2109,18 +2136,22 @@ fi
+ for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+ do
+ test "x$ac_site_file" = xNONE && continue
+- if test -r "$ac_site_file"; then
++ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+- . "$ac_site_file"
++ . "$ac_site_file" \
++ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "failed to load site script $ac_site_file
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ done
+
+ if test -r "$cache_file"; then
+- # Some versions of bash will fail to source /dev/null (special
+- # files actually), so we avoid doing that.
+- if test -f "$cache_file"; then
++ # Some versions of bash will fail to source /dev/null (special files
++ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
++ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+ $as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+@@ -2189,7 +2220,7 @@ if $ac_cache_corrupted; then
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+ $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+- as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
++ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+ fi
+ ## -------------------- ##
+ ## Main body of script. ##
+@@ -2249,21 +2280,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+-# _AC_CHECK_DECL_BODY
+-# -------------------
+-# Shell function body for AC_CHECK_DECL.
+-# _AC_CHECK_DECL_BODY
+-
+-# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
+-# INCLUDES)
+-# -------------------------------------------------------------
+-# Helper to AC_CHECK_DECLS, which generates the check for a single
+-# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
+-# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
+-
+-
+-
+-
+
+
+
+@@ -4057,7 +4073,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}gcc; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_CC+set}" = set; then :
++if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$CC"; then
+@@ -4069,7 +4085,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -4097,7 +4113,7 @@ if test -z "$ac_cv_prog_CC"; then
+ set dummy gcc; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
++if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_CC"; then
+@@ -4109,7 +4125,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -4150,7 +4166,7 @@ if test -z "$CC"; then
+ set dummy ${ac_tool_prefix}cc; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_CC+set}" = set; then :
++if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$CC"; then
+@@ -4162,7 +4178,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -4190,7 +4206,7 @@ if test -z "$CC"; then
+ set dummy cc; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_CC+set}" = set; then :
++if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$CC"; then
+@@ -4203,7 +4219,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+@@ -4249,7 +4265,7 @@ if test -z "$CC"; then
+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_CC+set}" = set; then :
++if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$CC"; then
+@@ -4261,7 +4277,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -4293,7 +4309,7 @@ do
+ set dummy $ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
++if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_CC"; then
+@@ -4305,7 +4321,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -4347,8 +4363,8 @@ fi
+
+ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "no acceptable C compiler found in \$PATH
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "no acceptable C compiler found in \$PATH
++See \`config.log' for more details" "$LINENO" 5; }
+
+ # Provide some information about the compiler.
+ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+@@ -4369,8 +4385,8 @@ $as_echo "$ac_try_echo"; } >&5
+ ... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+- rm -f conftest.er1 conftest.err
+ fi
++ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ done
+@@ -4387,12 +4403,12 @@ main ()
+ }
+ _ACEOF
+ ac_clean_files_save=$ac_clean_files
+-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out"
++ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+ # Try to create an executable without -o first, disregard a.out.
+ # It will help us diagnose broken compilers, and finding out an intuition
+ # of exeext.
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+-$as_echo_n "checking for C compiler default output file name... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
++$as_echo_n "checking whether the C compiler works... " >&6; }
+ ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+ # The possible output files:
+@@ -4454,62 +4470,28 @@ test "$ac_cv_exeext" = no && ac_cv_exeext=
+ else
+ ac_file=''
+ fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+-$as_echo "$ac_file" >&6; }
+ if test -z "$ac_file"; then :
+- $as_echo "$as_me: failed program was:" >&5
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++$as_echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-{ as_fn_set_status 77
+-as_fn_error "C compiler cannot create executables
+-See \`config.log' for more details." "$LINENO" 5; }; }
++as_fn_error 77 "C compiler cannot create executables
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
+ fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
++$as_echo_n "checking for C compiler default output file name... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
++$as_echo "$ac_file" >&6; }
+ ac_exeext=$ac_cv_exeext
+
+-# Check that the compiler produces executables we can run. If not, either
+-# the compiler is broken, or we cross compile.
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+-$as_echo_n "checking whether the C compiler works... " >&6; }
+-# If not cross compiling, check that we can run a simple program.
+-if test "$cross_compiling" != yes; then
+- if { ac_try='./$ac_file'
+- { { case "(($ac_try" in
+- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+- *) ac_try_echo=$ac_try;;
+-esac
+-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+-$as_echo "$ac_try_echo"; } >&5
+- (eval "$ac_try") 2>&5
+- ac_status=$?
+- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+- test $ac_status = 0; }; }; then
+- cross_compiling=no
+- else
+- if test "$cross_compiling" = maybe; then
+- cross_compiling=yes
+- else
+- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot run C compiled programs.
+-If you meant to cross compile, use \`--host'.
+-See \`config.log' for more details." "$LINENO" 5; }
+- fi
+- fi
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+-
+-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out
++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ ac_clean_files=$ac_clean_files_save
+-# Check that the compiler produces executables we can run. If not, either
+-# the compiler is broken, or we cross compile.
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+-$as_echo_n "checking whether we are cross compiling... " >&6; }
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+-$as_echo "$cross_compiling" >&6; }
+-
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+ $as_echo_n "checking for suffix of executables... " >&6; }
+ if { { ac_try="$ac_link"
+@@ -4539,19 +4521,78 @@ done
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot compute suffix of executables: cannot compile and link
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "cannot compute suffix of executables: cannot compile and link
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+-rm -f conftest$ac_cv_exeext
++rm -f conftest conftest$ac_cv_exeext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+ $as_echo "$ac_cv_exeext" >&6; }
+
+ rm -f conftest.$ac_ext
+ EXEEXT=$ac_cv_exeext
+ ac_exeext=$EXEEXT
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <stdio.h>
++int
++main ()
++{
++FILE *f = fopen ("conftest.out", "w");
++ return ferror (f) || fclose (f) != 0;
++
++ ;
++ return 0;
++}
++_ACEOF
++ac_clean_files="$ac_clean_files conftest.out"
++# Check that the compiler produces executables we can run. If not, either
++# the compiler is broken, or we cross compile.
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
++$as_echo_n "checking whether we are cross compiling... " >&6; }
++if test "$cross_compiling" != yes; then
++ { { ac_try="$ac_link"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
++$as_echo "$ac_try_echo"; } >&5
++ (eval "$ac_link") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }
++ if { ac_try='./conftest$ac_cv_exeext'
++ { { case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
++$as_echo "$ac_try_echo"; } >&5
++ (eval "$ac_try") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; }; then
++ cross_compiling=no
++ else
++ if test "$cross_compiling" = maybe; then
++ cross_compiling=yes
++ else
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run C compiled programs.
++If you meant to cross compile, use \`--host'.
++See \`config.log' for more details" "$LINENO" 5; }
++ fi
++ fi
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
++$as_echo "$cross_compiling" >&6; }
++
++rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
++ac_clean_files=$ac_clean_files_save
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+ $as_echo_n "checking for suffix of object files... " >&6; }
+-if test "${ac_cv_objext+set}" = set; then :
++if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -4591,8 +4632,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
+
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "cannot compute suffix of object files: cannot compile
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "cannot compute suffix of object files: cannot compile
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ rm -f conftest.$ac_cv_objext conftest.$ac_ext
+ fi
+@@ -4602,7 +4643,7 @@ OBJEXT=$ac_cv_objext
+ ac_objext=$OBJEXT
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+ $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
++if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -4639,7 +4680,7 @@ ac_test_CFLAGS=${CFLAGS+set}
+ ac_save_CFLAGS=$CFLAGS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+ $as_echo_n "checking whether $CC accepts -g... " >&6; }
+-if test "${ac_cv_prog_cc_g+set}" = set; then :
++if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+@@ -4717,7 +4758,7 @@ else
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+ $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+-if test "${ac_cv_prog_cc_c89+set}" = set; then :
++if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_cv_prog_cc_c89=no
+@@ -4726,8 +4767,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+ #include <stdarg.h>
+ #include <stdio.h>
+-#include <sys/types.h>
+-#include <sys/stat.h>
++struct stat;
+ /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+ struct buf { int x; };
+ FILE * (*rcsopen) (struct buf *, struct stat *, int);
+@@ -4814,16 +4854,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ ac_aux_dir=
+ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+- for ac_t in install-sh install.sh shtool; do
+- if test -f "$ac_dir/$ac_t"; then
+- ac_aux_dir=$ac_dir
+- ac_install_sh="$ac_aux_dir/$ac_t -c"
+- break 2
+- fi
+- done
++ if test -f "$ac_dir/install-sh"; then
++ ac_aux_dir=$ac_dir
++ ac_install_sh="$ac_aux_dir/install-sh -c"
++ break
++ elif test -f "$ac_dir/install.sh"; then
++ ac_aux_dir=$ac_dir
++ ac_install_sh="$ac_aux_dir/install.sh -c"
++ break
++ elif test -f "$ac_dir/shtool"; then
++ ac_aux_dir=$ac_dir
++ ac_install_sh="$ac_aux_dir/shtool install -c"
++ break
++ fi
+ done
+ if test -z "$ac_aux_dir"; then
+- as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
++ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+ fi
+
+ # These three variables are undocumented and unsupported,
+@@ -4837,27 +4883,27 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+ # Make sure we can run config.sub.
+ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+- as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
++ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+ $as_echo_n "checking build system type... " >&6; }
+-if test "${ac_cv_build+set}" = set; then :
++if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_build_alias=$build_alias
+ test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+ test "x$ac_build_alias" = x &&
+- as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
++ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+- as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+ $as_echo "$ac_cv_build" >&6; }
+ case $ac_cv_build in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+ esac
+ build=$ac_cv_build
+ ac_save_IFS=$IFS; IFS='-'
+@@ -4875,14 +4921,14 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+ $as_echo_n "checking host system type... " >&6; }
+-if test "${ac_cv_host+set}" = set; then :
++if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+ else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+- as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+ fi
+
+ fi
+@@ -4890,7 +4936,7 @@ fi
+ $as_echo "$ac_cv_host" >&6; }
+ case $ac_cv_host in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+ esac
+ host=$ac_cv_host
+ ac_save_IFS=$IFS; IFS='-'
+@@ -4908,14 +4954,14 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
+ $as_echo_n "checking target system type... " >&6; }
+-if test "${ac_cv_target+set}" = set; then :
++if ${ac_cv_target+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test "x$target_alias" = x; then
+ ac_cv_target=$ac_cv_host
+ else
+ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+- as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
++ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+ fi
+
+ fi
+@@ -4923,7 +4969,7 @@ fi
+ $as_echo "$ac_cv_target" >&6; }
+ case $ac_cv_target in
+ *-*-*) ;;
+-*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
++*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
+ esac
+ target=$ac_cv_target
+ ac_save_IFS=$IFS; IFS='-'
+@@ -4958,7 +5004,7 @@ if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+ fi
+ if test -z "$CPP"; then
+- if test "${ac_cv_prog_CPP+set}" = set; then :
++ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ # Double quotes because CPP needs to be expanded
+@@ -4988,7 +5034,7 @@ else
+ # Broken: fails on valid input.
+ continue
+ fi
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+@@ -5004,11 +5050,11 @@ else
+ ac_preproc_ok=:
+ break
+ fi
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.err conftest.i conftest.$ac_ext
+
+ done
+ # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.i conftest.err conftest.$ac_ext
+ if $ac_preproc_ok; then :
+ break
+ fi
+@@ -5047,7 +5093,7 @@ else
+ # Broken: fails on valid input.
+ continue
+ fi
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+@@ -5063,18 +5109,18 @@ else
+ ac_preproc_ok=:
+ break
+ fi
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.err conftest.i conftest.$ac_ext
+
+ done
+ # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+-rm -f conftest.err conftest.$ac_ext
++rm -f conftest.i conftest.err conftest.$ac_ext
+ if $ac_preproc_ok; then :
+
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error "C preprocessor \"$CPP\" fails sanity check
+-See \`config.log' for more details." "$LINENO" 5; }
++as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
++See \`config.log' for more details" "$LINENO" 5; }
+ fi
+
+ ac_ext=c
+@@ -5086,7 +5132,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+ $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+-if test "${ac_cv_path_GREP+set}" = set; then :
++if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -z "$GREP"; then
+@@ -5100,7 +5146,7 @@ do
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
++ as_fn_executable_p "$ac_path_GREP" || continue
+ # Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+ case `"$ac_path_GREP" --version 2>&1` in
+@@ -5135,7 +5181,7 @@ esac
+ done
+ IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+- as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
++ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+ else
+ ac_cv_path_GREP=$GREP
+@@ -5149,7 +5195,7 @@ $as_echo "$ac_cv_path_GREP" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+ $as_echo_n "checking for egrep... " >&6; }
+-if test "${ac_cv_path_EGREP+set}" = set; then :
++if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+@@ -5166,7 +5212,7 @@ do
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
++ as_fn_executable_p "$ac_path_EGREP" || continue
+ # Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+ case `"$ac_path_EGREP" --version 2>&1` in
+@@ -5201,7 +5247,7 @@ esac
+ done
+ IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+- as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
++ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+ else
+ ac_cv_path_EGREP=$EGREP
+@@ -5216,7 +5262,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+ $as_echo_n "checking for ANSI C header files... " >&6; }
+-if test "${ac_cv_header_stdc+set}" = set; then :
++if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -5333,8 +5379,7 @@ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+ "
+-eval as_val=\$$as_ac_Header
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -5346,7 +5391,7 @@ done
+
+
+ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
+-if test "x$ac_cv_header_minix_config_h" = x""yes; then :
++if test "x$ac_cv_header_minix_config_h" = xyes; then :
+ MINIX=yes
+ else
+ MINIX=
+@@ -5368,14 +5413,14 @@ $as_echo "#define _MINIX 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
+ $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+-if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
++if ${ac_cv_safe_to_define___extensions__+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+-# define __EXTENSIONS__ 1
+- $ac_includes_default
++# define __EXTENSIONS__ 1
++ $ac_includes_default
+ int
+ main ()
+ {
+@@ -5432,7 +5477,7 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+ $as_echo_n "checking for a BSD-compatible install... " >&6; }
+ if test -z "$INSTALL"; then
+-if test "${ac_cv_path_install+set}" = set; then :
++if ${ac_cv_path_install+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+@@ -5452,7 +5497,7 @@ case $as_dir/ in #((
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+@@ -5615,7 +5660,7 @@ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+ $as_echo_n "checking for a sed that does not truncate output... " >&6; }
+-if test "${ac_cv_path_SED+set}" = set; then :
++if ${ac_cv_path_SED+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+@@ -5635,7 +5680,7 @@ do
+ for ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+- { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
++ as_fn_executable_p "$ac_path_SED" || continue
+ # Check for GNU ac_path_SED and select it if it is found.
+ # Check for GNU $ac_path_SED
+ case `"$ac_path_SED" --version 2>&1` in
+@@ -5670,7 +5715,7 @@ esac
+ done
+ IFS=$as_save_IFS
+ if test -z "$ac_cv_path_SED"; then
+- as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5
++ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+ fi
+ else
+ ac_cv_path_SED=$SED
+@@ -5697,7 +5742,7 @@ Xsed="$SED -e 1s/^X//"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+ $as_echo_n "checking for fgrep... " >&6; }
+-if test "${ac_cv_path_FGREP+set}" = set; then :
++if ${ac_cv_path_FGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+@@ -5714,7 +5759,7 @@ do
+ for ac_prog in fgrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+- { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
++ as_fn_executable_p "$ac_path_FGREP" || continue
+ # Check for GNU ac_path_FGREP and select it if it is found.
+ # Check for GNU $ac_path_FGREP
+ case `"$ac_path_FGREP" --version 2>&1` in
+@@ -5749,7 +5794,7 @@ esac
+ done
+ IFS=$as_save_IFS
+ if test -z "$ac_cv_path_FGREP"; then
+- as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
++ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+ else
+ ac_cv_path_FGREP=$FGREP
+@@ -5828,7 +5873,7 @@ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+ $as_echo_n "checking for non-GNU ld... " >&6; }
+ fi
+-if test "${lt_cv_path_LD+set}" = set; then :
++if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -z "$LD"; then
+@@ -5865,10 +5910,10 @@ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+ fi
+-test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
++test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+ $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+-if test "${lt_cv_prog_gnu_ld+set}" = set; then :
++if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+@@ -5895,7 +5940,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+ $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+-if test "${lt_cv_path_NM+set}" = set; then :
++if ${lt_cv_path_NM+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$NM"; then
+@@ -5958,7 +6003,7 @@ else
+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_DUMPBIN+set}" = set; then :
++if ${ac_cv_prog_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$DUMPBIN"; then
+@@ -5970,7 +6015,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6002,7 +6047,7 @@ do
+ set dummy $ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then :
++if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_DUMPBIN"; then
+@@ -6014,7 +6059,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6074,7 +6119,7 @@ test -z "$NM" && NM=nm
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+ $as_echo_n "checking the name lister ($NM) interface... " >&6; }
+-if test "${lt_cv_nm_interface+set}" = set; then :
++if ${lt_cv_nm_interface+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_nm_interface="BSD nm"
+@@ -6109,7 +6154,7 @@ fi
+ # find the maximum length of command line arguments
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+ $as_echo_n "checking the maximum length of command line arguments... " >&6; }
+-if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
++if ${lt_cv_sys_max_cmd_len+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ i=0
+@@ -6306,7 +6351,7 @@ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+ $as_echo_n "checking for $LD option to reload object files... " >&6; }
+-if test "${lt_cv_ld_reload_flag+set}" = set; then :
++if ${lt_cv_ld_reload_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_ld_reload_flag='-r'
+@@ -6342,7 +6387,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}objdump; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_OBJDUMP+set}" = set; then :
++if ${ac_cv_prog_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$OBJDUMP"; then
+@@ -6354,7 +6399,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6382,7 +6427,7 @@ if test -z "$ac_cv_prog_OBJDUMP"; then
+ set dummy objdump; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then :
++if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_OBJDUMP"; then
+@@ -6394,7 +6439,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OBJDUMP="objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6441,7 +6486,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+ $as_echo_n "checking how to recognize dependent libraries... " >&6; }
+-if test "${lt_cv_deplibs_check_method+set}" = set; then :
++if ${lt_cv_deplibs_check_method+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_file_magic_cmd='$MAGIC_CMD'
+@@ -6662,7 +6707,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}ar; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_AR+set}" = set; then :
++if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$AR"; then
+@@ -6674,7 +6719,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6702,7 +6747,7 @@ if test -z "$ac_cv_prog_AR"; then
+ set dummy ar; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
++if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_AR"; then
+@@ -6714,7 +6759,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6767,7 +6812,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}strip; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_STRIP+set}" = set; then :
++if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$STRIP"; then
+@@ -6779,7 +6824,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6807,7 +6852,7 @@ if test -z "$ac_cv_prog_STRIP"; then
+ set dummy strip; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
++if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_STRIP"; then
+@@ -6819,7 +6864,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6866,7 +6911,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_RANLIB+set}" = set; then :
++if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$RANLIB"; then
+@@ -6878,7 +6923,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -6906,7 +6951,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
+ set dummy ranlib; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
++if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_RANLIB"; then
+@@ -6918,7 +6963,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7010,7 +7055,7 @@ do
+ set dummy $ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_AWK+set}" = set; then :
++if ${ac_cv_prog_AWK+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$AWK"; then
+@@ -7022,7 +7067,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AWK="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7077,7 +7122,7 @@ compiler=$CC
+ # Check for command to grab the raw symbol name followed by C symbol from nm.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+ $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
++if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+
+@@ -7461,7 +7506,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ CFLAGS="$CFLAGS -belf"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+ $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+-if test "${lt_cv_cc_needs_belf+set}" = set; then :
++if ${lt_cv_cc_needs_belf+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_ext=c
+@@ -7537,7 +7582,7 @@ need_locks="$enable_libtool_lock"
+ set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_DSYMUTIL+set}" = set; then :
++if ${ac_cv_prog_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$DSYMUTIL"; then
+@@ -7549,7 +7594,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7577,7 +7622,7 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then
+ set dummy dsymutil; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then :
++if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_DSYMUTIL"; then
+@@ -7589,7 +7634,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7629,7 +7674,7 @@ fi
+ set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_NMEDIT+set}" = set; then :
++if ${ac_cv_prog_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$NMEDIT"; then
+@@ -7641,7 +7686,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7669,7 +7714,7 @@ if test -z "$ac_cv_prog_NMEDIT"; then
+ set dummy nmedit; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then :
++if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_NMEDIT"; then
+@@ -7681,7 +7726,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_NMEDIT="nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7721,7 +7766,7 @@ fi
+ set dummy ${ac_tool_prefix}lipo; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_LIPO+set}" = set; then :
++if ${ac_cv_prog_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$LIPO"; then
+@@ -7733,7 +7778,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7761,7 +7806,7 @@ if test -z "$ac_cv_prog_LIPO"; then
+ set dummy lipo; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then :
++if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_LIPO"; then
+@@ -7773,7 +7818,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_LIPO="lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7813,7 +7858,7 @@ fi
+ set dummy ${ac_tool_prefix}otool; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_OTOOL+set}" = set; then :
++if ${ac_cv_prog_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$OTOOL"; then
+@@ -7825,7 +7870,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7853,7 +7898,7 @@ if test -z "$ac_cv_prog_OTOOL"; then
+ set dummy otool; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then :
++if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_OTOOL"; then
+@@ -7865,7 +7910,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL="otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7905,7 +7950,7 @@ fi
+ set dummy ${ac_tool_prefix}otool64; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_OTOOL64+set}" = set; then :
++if ${ac_cv_prog_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$OTOOL64"; then
+@@ -7917,7 +7962,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -7945,7 +7990,7 @@ if test -z "$ac_cv_prog_OTOOL64"; then
+ set dummy otool64; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then :
++if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_OTOOL64"; then
+@@ -7957,7 +8002,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL64="otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -8020,7 +8065,7 @@ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+ $as_echo_n "checking for -single_module linker flag... " >&6; }
+-if test "${lt_cv_apple_cc_single_mod+set}" = set; then :
++if ${lt_cv_apple_cc_single_mod+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_apple_cc_single_mod=no
+@@ -8049,7 +8094,7 @@ fi
+ $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+ $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+-if test "${lt_cv_ld_exported_symbols_list+set}" = set; then :
++if ${lt_cv_ld_exported_symbols_list+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_ld_exported_symbols_list=no
+@@ -8081,7 +8126,7 @@ fi
+ $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+ $as_echo_n "checking for -force_load linker flag... " >&6; }
+-if test "${lt_cv_ld_force_load+set}" = set; then :
++if ${lt_cv_ld_force_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_ld_force_load=no
+@@ -8148,7 +8193,7 @@ for ac_header in dlfcn.h
+ do :
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+ "
+-if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
++if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_DLFCN_H 1
+ _ACEOF
+@@ -8184,7 +8229,7 @@ if test -n "$ac_tool_prefix"; then
+ set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_RANLIB+set}" = set; then :
++if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$RANLIB"; then
+@@ -8196,7 +8241,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -8224,7 +8269,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
+ set dummy ranlib; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
++if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$ac_ct_RANLIB"; then
+@@ -8236,7 +8281,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -8292,7 +8337,7 @@ depcc="$CC" am_compiler_list=
+ am_depcomp=$ac_aux_dir/depcomp
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+ $as_echo_n "checking dependency style of $depcc... " >&6; }
+-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
++if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -f "$am_depcomp"; then
+@@ -8378,7 +8423,7 @@ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+ $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+ if test x${am_cv_CC_dependencies_compiler_type-none} = xnone
+-then as_fn_error "no usable dependency style found" "$LINENO" 5
++then as_fn_error $? "no usable dependency style found" "$LINENO" 5
+ else CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ fi
+@@ -8391,7 +8436,7 @@ do
+ set dummy $ac_prog; ac_word=$2
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ $as_echo_n "checking for $ac_word... " >&6; }
+-if test "${ac_cv_prog_MAKE+set}" = set; then :
++if ${ac_cv_prog_MAKE+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test -n "$MAKE"; then
+@@ -8403,7 +8448,7 @@ do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_MAKE="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+@@ -8521,8 +8566,7 @@ for ac_header in stdlib.h string.h strings.h unistd.h time.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+-eval as_val=\$$as_ac_Header
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8535,8 +8579,7 @@ for ac_header in sys/time.h sys/resource.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+-eval as_val=\$$as_ac_Header
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8549,8 +8592,7 @@ for ac_header in fcntl.h fpu_control.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+-eval as_val=\$$as_ac_Header
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8563,8 +8605,7 @@ for ac_header in dlfcn.h errno.h sys/stat.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+-eval as_val=\$$as_ac_Header
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8577,8 +8618,7 @@ for ac_func in getrusage time sigaction __setfpucw
+ do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+-eval as_val=\$$as_ac_var
+- if test "x$as_val" = x""yes; then :
++if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+ #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+ _ACEOF
+@@ -8590,7 +8630,7 @@ done
+ # Check for socket libraries
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lsocket" >&5
+ $as_echo_n "checking for bind in -lsocket... " >&6; }
+-if test "${ac_cv_lib_socket_bind+set}" = set; then :
++if ${ac_cv_lib_socket_bind+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -8624,7 +8664,7 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_bind" >&5
+ $as_echo "$ac_cv_lib_socket_bind" >&6; }
+-if test "x$ac_cv_lib_socket_bind" = x""yes; then :
++if test "x$ac_cv_lib_socket_bind" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_LIBSOCKET 1
+ _ACEOF
+@@ -8635,7 +8675,7 @@ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
+ $as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
+-if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then :
++if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -8669,7 +8709,7 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
+ $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
+-if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then :
++if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_LIBNSL 1
+ _ACEOF
+@@ -8695,7 +8735,7 @@ fi
+ if test "$with_zlib" != "no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
+ $as_echo_n "checking for library containing zlibVersion... " >&6; }
+-if test "${ac_cv_search_zlibVersion+set}" = set; then :
++if ${ac_cv_search_zlibVersion+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_func_search_save_LIBS=$LIBS
+@@ -8729,11 +8769,11 @@ for ac_lib in '' z; do
+ fi
+ rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+- if test "${ac_cv_search_zlibVersion+set}" = set; then :
++ if ${ac_cv_search_zlibVersion+:} false; then :
+ break
+ fi
+ done
+-if test "${ac_cv_search_zlibVersion+set}" = set; then :
++if ${ac_cv_search_zlibVersion+:} false; then :
+
+ else
+ ac_cv_search_zlibVersion=no
+@@ -8749,7 +8789,7 @@ if test "$ac_res" != no; then :
+ for ac_header in zlib.h
+ do :
+ ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
+-if test "x$ac_cv_header_zlib_h" = x""yes; then :
++if test "x$ac_cv_header_zlib_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_ZLIB_H 1
+ _ACEOF
+@@ -8761,7 +8801,7 @@ done
+ fi
+
+ if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+- as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
++ as_fn_error $? "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
+ fi
+ fi
+
+@@ -8965,7 +9005,7 @@ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+ $as_echo_n "checking for objdir... " >&6; }
+-if test "${lt_cv_objdir+set}" = set; then :
++if ${lt_cv_objdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ rm -f .libs 2>/dev/null
+@@ -9043,7 +9083,7 @@ file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+ $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
++if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ case $MAGIC_CMD in
+@@ -9109,7 +9149,7 @@ if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+ $as_echo_n "checking for file... " >&6; }
+-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
++if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ case $MAGIC_CMD in
+@@ -9251,7 +9291,7 @@ if test "$GCC" = yes; then
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+ $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
++if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler_rtti_exceptions=no
+@@ -9604,7 +9644,7 @@ $as_echo "$lt_prog_compiler_pic" >&6; }
+ if test -n "$lt_prog_compiler_pic"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+ $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+-if test "${lt_cv_prog_compiler_pic_works+set}" = set; then :
++if ${lt_cv_prog_compiler_pic_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler_pic_works=no
+@@ -9663,7 +9703,7 @@ fi
+ wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+ $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+-if test "${lt_cv_prog_compiler_static_works+set}" = set; then :
++if ${lt_cv_prog_compiler_static_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler_static_works=no
+@@ -9706,7 +9746,7 @@ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+ $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+-if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
++if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler_c_o=no
+@@ -9761,7 +9801,7 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+ $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+-if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
++if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler_c_o=no
+@@ -10577,7 +10617,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+ $as_echo_n "checking if $CC understands -b... " >&6; }
+-if test "${lt_cv_prog_compiler__b+set}" = set; then :
++if ${lt_cv_prog_compiler__b+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_prog_compiler__b=no
+@@ -10949,7 +10989,7 @@ x|xyes)
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+ $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+-if test "${lt_cv_archive_cmds_need_lc+set}" = set; then :
++if ${lt_cv_archive_cmds_need_lc+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ $RM conftest*
+@@ -11587,7 +11627,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+- if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then :
++ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ lt_cv_shlibpath_overrides_runpath=no
+@@ -12007,7 +12047,7 @@ else
+ # if libdl is installed we need to link against it
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+ $as_echo_n "checking for dlopen in -ldl... " >&6; }
+-if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
++if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -12041,7 +12081,7 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+ $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+-if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
++if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+ else
+
+@@ -12055,12 +12095,12 @@ fi
+
+ *)
+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+-if test "x$ac_cv_func_shl_load" = x""yes; then :
++if test "x$ac_cv_func_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+ $as_echo_n "checking for shl_load in -ldld... " >&6; }
+-if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
++if ${ac_cv_lib_dld_shl_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -12094,16 +12134,16 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+ $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+-if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
++if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+ else
+ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+-if test "x$ac_cv_func_dlopen" = x""yes; then :
++if test "x$ac_cv_func_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+ $as_echo_n "checking for dlopen in -ldl... " >&6; }
+-if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
++if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -12137,12 +12177,12 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+ $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+-if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
++if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+ $as_echo_n "checking for dlopen in -lsvld... " >&6; }
+-if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
++if ${ac_cv_lib_svld_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -12176,12 +12216,12 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+ $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+-if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
++if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+ $as_echo_n "checking for dld_link in -ldld... " >&6; }
+-if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
++if ${ac_cv_lib_dld_dld_link+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -12215,7 +12255,7 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+ $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+-if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
++if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+ fi
+
+@@ -12256,7 +12296,7 @@ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
+-if test "${lt_cv_dlopen_self+set}" = set; then :
++if ${lt_cv_dlopen_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test "$cross_compiling" = yes; then :
+@@ -12265,7 +12305,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 12268 "configure"
++#line 12308 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -12362,7 +12402,7 @@ $as_echo "$lt_cv_dlopen_self" >&6; }
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+ $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+-if test "${lt_cv_dlopen_self_static+set}" = set; then :
++if ${lt_cv_dlopen_self_static+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ if test "$cross_compiling" = yes; then :
+@@ -12371,7 +12411,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 12374 "configure"
++#line 12414 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -12644,7 +12684,7 @@ if test "${enable_sim_bswap+set}" = set; then :
+ enableval=$enable_sim_bswap; case "${enableval}" in
+ yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
+ no) sim_bswap="-DWITH_BSWAP=0";;
+- *) as_fn_error "\"--enable-sim-bswap does not take a value\"" "$LINENO" 5; sim_bswap="";;
++ *) as_fn_error $? "\"--enable-sim-bswap does not take a value\"" "$LINENO" 5; sim_bswap="";;
+ esac
+ if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
+ echo "Setting bswap flags = $sim_bswap" 6>&1
+@@ -12659,7 +12699,7 @@ fi
+ if test "${enable_sim_cflags+set}" = set; then :
+ enableval=$enable_sim_cflags; case "${enableval}" in
+ yes) sim_cflags="-O2 -fomit-frame-pointer";;
+- trace) as_fn_error "\"Please use --enable-sim-debug instead.\"" "$LINENO" 5; sim_cflags="";;
++ trace) as_fn_error $? "\"Please use --enable-sim-debug instead.\"" "$LINENO" 5; sim_cflags="";;
+ no) sim_cflags="";;
+ *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+ esac
+@@ -12693,7 +12733,7 @@ if test "${enable_sim_stdio+set}" = set; then :
+ enableval=$enable_sim_stdio; case "${enableval}" in
+ yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
+ no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
+- *) as_fn_error "\"Unknown value $enableval passed to --enable-sim-stdio\"" "$LINENO" 5; sim_stdio="";;
++ *) as_fn_error $? "\"Unknown value $enableval passed to --enable-sim-stdio\"" "$LINENO" 5; sim_stdio="";;
+ esac
+ if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
+ echo "Setting stdio flags = $sim_stdio" 6>&1
+@@ -12762,7 +12802,7 @@ fi
+ # Check whether --with-pkgversion was given.
+ if test "${with_pkgversion+set}" = set; then :
+ withval=$with_pkgversion; case "$withval" in
+- yes) as_fn_error "package version not specified" "$LINENO" 5 ;;
++ yes) as_fn_error $? "package version not specified" "$LINENO" 5 ;;
+ no) PKGVERSION= ;;
+ *) PKGVERSION="($withval) " ;;
+ esac
+@@ -12778,7 +12818,7 @@ fi
+ # Check whether --with-bugurl was given.
+ if test "${with_bugurl+set}" = set; then :
+ withval=$with_bugurl; case "$withval" in
+- yes) as_fn_error "bug URL not specified" "$LINENO" 5 ;;
++ yes) as_fn_error $? "bug URL not specified" "$LINENO" 5 ;;
+ no) BUGURL=
+ ;;
+ *) BUGURL="$withval"
+@@ -12815,7 +12855,7 @@ _ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
+ $as_echo_n "checking return type of signal handlers... " >&6; }
+-if test "${ac_cv_type_signal+set}" = set; then :
++if ${ac_cv_type_signal+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12872,7 +12912,7 @@ sim_link_links="${sim_link_links} targ-vals.def"
+ for ac_header in stdlib.h
+ do :
+ ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
+-if test "x$ac_cv_header_stdlib_h" = x""yes; then :
++if test "x$ac_cv_header_stdlib_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_STDLIB_H 1
+ _ACEOF
+@@ -12885,7 +12925,7 @@ done
+ # In the Cygwin environment, we need some additional flags.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cygwin" >&5
+ $as_echo_n "checking for cygwin... " >&6; }
+-if test "${sim_cv_os_cygwin+set}" = set; then :
++if ${sim_cv_os_cygwin+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12913,7 +12953,7 @@ else
+ # Keep in sync with gdb's configure.ac list.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
+ $as_echo_n "checking for library containing tgetent... " >&6; }
+-if test "${ac_cv_search_tgetent+set}" = set; then :
++if ${ac_cv_search_tgetent+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_func_search_save_LIBS=$LIBS
+@@ -12947,11 +12987,11 @@ for ac_lib in '' termcap tinfo curses ncurses; do
+ fi
+ rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+- if test "${ac_cv_search_tgetent+set}" = set; then :
++ if ${ac_cv_search_tgetent+:} false; then :
+ break
+ fi
+ done
+-if test "${ac_cv_search_tgetent+set}" = set; then :
++if ${ac_cv_search_tgetent+:} false; then :
+
+ else
+ ac_cv_search_tgetent=no
+@@ -12979,7 +13019,7 @@ if test -r ../../readline/Makefile; then
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
+ $as_echo_n "checking for readline in -lreadline... " >&6; }
+-if test "${ac_cv_lib_readline_readline+set}" = set; then :
++if ${ac_cv_lib_readline_readline+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+@@ -13013,14 +13053,238 @@ LIBS=$ac_check_lib_save_LIBS
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
+ $as_echo "$ac_cv_lib_readline_readline" >&6; }
+-if test "x$ac_cv_lib_readline_readline" = x""yes; then :
++if test "x$ac_cv_lib_readline_readline" = xyes; then :
+ READLINE=-lreadline
+ else
+- as_fn_error "the required \"readline\" library is missing" "$LINENO" 5
++ as_fn_error $? "the required \"readline\" library is missing" "$LINENO" 5
+ fi
+
+ fi
+
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
++$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
++if ${ac_cv_c_bigendian+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ ac_cv_c_bigendian=unknown
++ # See if we're dealing with a universal compiler.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#ifndef __APPLE_CC__
++ not a universal capable compiler
++ #endif
++ typedef int dummy;
++
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++
++ # Check for potential -arch flags. It is not universal unless
++ # there are at least two -arch flags with different values.
++ ac_arch=
++ ac_prev=
++ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
++ if test -n "$ac_prev"; then
++ case $ac_word in
++ i?86 | x86_64 | ppc | ppc64)
++ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
++ ac_arch=$ac_word
++ else
++ ac_cv_c_bigendian=universal
++ break
++ fi
++ ;;
++ esac
++ ac_prev=
++ elif test "x$ac_word" = "x-arch"; then
++ ac_prev=arch
++ fi
++ done
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ if test $ac_cv_c_bigendian = unknown; then
++ # See if sys/param.h defines the BYTE_ORDER macro.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <sys/types.h>
++ #include <sys/param.h>
++
++int
++main ()
++{
++#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
++ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
++ && LITTLE_ENDIAN)
++ bogus endian macros
++ #endif
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ # It does; now see whether it defined to BIG_ENDIAN or not.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <sys/types.h>
++ #include <sys/param.h>
++
++int
++main ()
++{
++#if BYTE_ORDER != BIG_ENDIAN
++ not big endian
++ #endif
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_c_bigendian=yes
++else
++ ac_cv_c_bigendian=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ fi
++ if test $ac_cv_c_bigendian = unknown; then
++ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <limits.h>
++
++int
++main ()
++{
++#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
++ bogus endian macros
++ #endif
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ # It does; now see whether it defined to _BIG_ENDIAN or not.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <limits.h>
++
++int
++main ()
++{
++#ifndef _BIG_ENDIAN
++ not big endian
++ #endif
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ ac_cv_c_bigendian=yes
++else
++ ac_cv_c_bigendian=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ fi
++ if test $ac_cv_c_bigendian = unknown; then
++ # Compile a test program.
++ if test "$cross_compiling" = yes; then :
++ # Try to guess by grepping values from an object file.
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++short int ascii_mm[] =
++ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
++ short int ascii_ii[] =
++ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
++ int use_ascii (int i) {
++ return ascii_mm[i] + ascii_ii[i];
++ }
++ short int ebcdic_ii[] =
++ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
++ short int ebcdic_mm[] =
++ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
++ int use_ebcdic (int i) {
++ return ebcdic_mm[i] + ebcdic_ii[i];
++ }
++ extern int foo;
++
++int
++main ()
++{
++return use_ascii (foo) == use_ebcdic (foo);
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++ if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
++ ac_cv_c_bigendian=yes
++ fi
++ if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
++ if test "$ac_cv_c_bigendian" = unknown; then
++ ac_cv_c_bigendian=no
++ else
++ # finding both strings is unlikely to happen, but who knows?
++ ac_cv_c_bigendian=unknown
++ fi
++ fi
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++$ac_includes_default
++int
++main ()
++{
++
++ /* Are we little or big endian? From Harbison&Steele. */
++ union
++ {
++ long int l;
++ char c[sizeof (long int)];
++ } u;
++ u.l = 1;
++ return u.c[sizeof (long int) - 1] == 1;
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ ac_cv_c_bigendian=no
++else
++ ac_cv_c_bigendian=yes
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ fi
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
++$as_echo "$ac_cv_c_bigendian" >&6; }
++ case $ac_cv_c_bigendian in #(
++ yes)
++ $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
++;; #(
++ no)
++ ;; #(
++ universal)
++
++$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
++
++ ;; #(
+ *)
-+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
-+-if test "x$ac_cv_func_shl_load" = x""yes; then :
-++if test "x$ac_cv_func_shl_load" = xyes; then :
-+ lt_cv_dlopen="shl_load"
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-+ $as_echo_n "checking for shl_load in -ldld... " >&6; }
-+-if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
-++if ${ac_cv_lib_dld_shl_load+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -12094,16 +12134,16 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-+ $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-+-if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
-++if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
-+ else
-+ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
-+-if test "x$ac_cv_func_dlopen" = x""yes; then :
-++if test "x$ac_cv_func_dlopen" = xyes; then :
-+ lt_cv_dlopen="dlopen"
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-+ $as_echo_n "checking for dlopen in -ldl... " >&6; }
-+-if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
-++if ${ac_cv_lib_dl_dlopen+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -12137,12 +12177,12 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-+ $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-+-if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
-++if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
-+ $as_echo_n "checking for dlopen in -lsvld... " >&6; }
-+-if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
-++if ${ac_cv_lib_svld_dlopen+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -12176,12 +12216,12 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
-+ $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
-+-if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
-++if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
-+ $as_echo_n "checking for dld_link in -ldld... " >&6; }
-+-if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
-++if ${ac_cv_lib_dld_dld_link+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -12215,7 +12255,7 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
-+ $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
-+-if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
-++if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
-+ fi
-+
-+@@ -12256,7 +12296,7 @@ fi
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
-+ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
-+-if test "${lt_cv_dlopen_self+set}" = set; then :
-++if ${lt_cv_dlopen_self+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test "$cross_compiling" = yes; then :
-+@@ -12265,7 +12305,7 @@ else
-+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-+ lt_status=$lt_dlunknown
-+ cat > conftest.$ac_ext <<_LT_EOF
-+-#line 12268 "configure"
-++#line 12308 "configure"
-+ #include "confdefs.h"
-+
-+ #if HAVE_DLFCN_H
-+@@ -12362,7 +12402,7 @@ $as_echo "$lt_cv_dlopen_self" >&6; }
-+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
-+ $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
-+-if test "${lt_cv_dlopen_self_static+set}" = set; then :
-++if ${lt_cv_dlopen_self_static+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ if test "$cross_compiling" = yes; then :
-+@@ -12371,7 +12411,7 @@ else
-+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-+ lt_status=$lt_dlunknown
-+ cat > conftest.$ac_ext <<_LT_EOF
-+-#line 12374 "configure"
-++#line 12414 "configure"
-+ #include "confdefs.h"
-+
-+ #if HAVE_DLFCN_H
-+@@ -12644,7 +12684,7 @@ if test "${enable_sim_bswap+set}" = set; then :
-+ enableval=$enable_sim_bswap; case "${enableval}" in
-+ yes) sim_bswap="-DWITH_BSWAP=1 -DUSE_BSWAP=1";;
-+ no) sim_bswap="-DWITH_BSWAP=0";;
-+- *) as_fn_error "\"--enable-sim-bswap does not take a value\"" "$LINENO" 5; sim_bswap="";;
-++ *) as_fn_error $? "\"--enable-sim-bswap does not take a value\"" "$LINENO" 5; sim_bswap="";;
++ as_fn_error $? "unknown endianness
++ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
-+ if test x"$silent" != x"yes" && test x"$sim_bswap" != x""; then
-+ echo "Setting bswap flags = $sim_bswap" 6>&1
-+@@ -12659,7 +12699,7 @@ fi
-+ if test "${enable_sim_cflags+set}" = set; then :
-+ enableval=$enable_sim_cflags; case "${enableval}" in
-+ yes) sim_cflags="-O2 -fomit-frame-pointer";;
-+- trace) as_fn_error "\"Please use --enable-sim-debug instead.\"" "$LINENO" 5; sim_cflags="";;
-++ trace) as_fn_error $? "\"Please use --enable-sim-debug instead.\"" "$LINENO" 5; sim_cflags="";;
-+ no) sim_cflags="";;
-+ *) sim_cflags=`echo "${enableval}" | sed -e "s/,/ /g"`;;
-+ esac
-+@@ -12693,7 +12733,7 @@ if test "${enable_sim_stdio+set}" = set; then :
-+ enableval=$enable_sim_stdio; case "${enableval}" in
-+ yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
-+ no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
-+- *) as_fn_error "\"Unknown value $enableval passed to --enable-sim-stdio\"" "$LINENO" 5; sim_stdio="";;
-++ *) as_fn_error $? "\"Unknown value $enableval passed to --enable-sim-stdio\"" "$LINENO" 5; sim_stdio="";;
-+ esac
-+ if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
-+ echo "Setting stdio flags = $sim_stdio" 6>&1
-+@@ -12762,7 +12802,7 @@ fi
-+ # Check whether --with-pkgversion was given.
-+ if test "${with_pkgversion+set}" = set; then :
-+ withval=$with_pkgversion; case "$withval" in
-+- yes) as_fn_error "package version not specified" "$LINENO" 5 ;;
-++ yes) as_fn_error $? "package version not specified" "$LINENO" 5 ;;
-+ no) PKGVERSION= ;;
-+ *) PKGVERSION="($withval) " ;;
-+ esac
-+@@ -12778,7 +12818,7 @@ fi
-+ # Check whether --with-bugurl was given.
-+ if test "${with_bugurl+set}" = set; then :
-+ withval=$with_bugurl; case "$withval" in
-+- yes) as_fn_error "bug URL not specified" "$LINENO" 5 ;;
-++ yes) as_fn_error $? "bug URL not specified" "$LINENO" 5 ;;
-+ no) BUGURL=
-+ ;;
-+ *) BUGURL="$withval"
-+@@ -12815,7 +12855,7 @@ _ACEOF
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
-+ $as_echo_n "checking return type of signal handlers... " >&6; }
-+-if test "${ac_cv_type_signal+set}" = set; then :
-++if ${ac_cv_type_signal+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -12872,7 +12912,7 @@ sim_link_links="${sim_link_links} targ-vals.def"
-+ for ac_header in stdlib.h
-+ do :
-+ ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
-+-if test "x$ac_cv_header_stdlib_h" = x""yes; then :
-++if test "x$ac_cv_header_stdlib_h" = xyes; then :
-+ cat >>confdefs.h <<_ACEOF
-+ #define HAVE_STDLIB_H 1
-+ _ACEOF
-+@@ -12885,7 +12925,7 @@ done
-+ # In the Cygwin environment, we need some additional flags.
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cygwin" >&5
-+ $as_echo_n "checking for cygwin... " >&6; }
-+-if test "${sim_cv_os_cygwin+set}" = set; then :
-++if ${sim_cv_os_cygwin+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+@@ -12913,7 +12953,7 @@ else
-+ # Keep in sync with gdb's configure.ac list.
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
-+ $as_echo_n "checking for library containing tgetent... " >&6; }
-+-if test "${ac_cv_search_tgetent+set}" = set; then :
-++if ${ac_cv_search_tgetent+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_func_search_save_LIBS=$LIBS
-+@@ -12947,11 +12987,11 @@ for ac_lib in '' termcap tinfo curses ncurses; do
-+ fi
-+ rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext
-+- if test "${ac_cv_search_tgetent+set}" = set; then :
-++ if ${ac_cv_search_tgetent+:} false; then :
-+ break
-+ fi
-+ done
-+-if test "${ac_cv_search_tgetent+set}" = set; then :
-++if ${ac_cv_search_tgetent+:} false; then :
-+
-+ else
-+ ac_cv_search_tgetent=no
-+@@ -12979,7 +13019,7 @@ if test -r ../../readline/Makefile; then
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
-+ $as_echo_n "checking for readline in -lreadline... " >&6; }
-+-if test "${ac_cv_lib_readline_readline+set}" = set; then :
-++if ${ac_cv_lib_readline_readline+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+ else
-+ ac_check_lib_save_LIBS=$LIBS
-+@@ -13013,14 +13053,238 @@ LIBS=$ac_check_lib_save_LIBS
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
-+ $as_echo "$ac_cv_lib_readline_readline" >&6; }
-+-if test "x$ac_cv_lib_readline_readline" = x""yes; then :
-++if test "x$ac_cv_lib_readline_readline" = xyes; then :
-+ READLINE=-lreadline
-+ else
-+- as_fn_error "the required \"readline\" library is missing" "$LINENO" 5
-++ as_fn_error $? "the required \"readline\" library is missing" "$LINENO" 5
-+ fi
-+
-+ fi
-+
-++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
-++$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-++if ${ac_cv_c_bigendian+:} false; then :
-++ $as_echo_n "(cached) " >&6
-++else
-++ ac_cv_c_bigendian=unknown
-++ # See if we're dealing with a universal compiler.
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#ifndef __APPLE_CC__
-++ not a universal capable compiler
-++ #endif
-++ typedef int dummy;
-++
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++
-++ # Check for potential -arch flags. It is not universal unless
-++ # there are at least two -arch flags with different values.
-++ ac_arch=
-++ ac_prev=
-++ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
-++ if test -n "$ac_prev"; then
-++ case $ac_word in
-++ i?86 | x86_64 | ppc | ppc64)
-++ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
-++ ac_arch=$ac_word
-++ else
-++ ac_cv_c_bigendian=universal
-++ break
-++ fi
-++ ;;
-++ esac
-++ ac_prev=
-++ elif test "x$ac_word" = "x-arch"; then
-++ ac_prev=arch
-++ fi
-++ done
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++ if test $ac_cv_c_bigendian = unknown; then
-++ # See if sys/param.h defines the BYTE_ORDER macro.
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#include <sys/types.h>
-++ #include <sys/param.h>
-++
-++int
-++main ()
-++{
-++#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
-++ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
-++ && LITTLE_ENDIAN)
-++ bogus endian macros
-++ #endif
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++ # It does; now see whether it defined to BIG_ENDIAN or not.
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#include <sys/types.h>
-++ #include <sys/param.h>
-++
-++int
-++main ()
-++{
-++#if BYTE_ORDER != BIG_ENDIAN
-++ not big endian
-++ #endif
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++ ac_cv_c_bigendian=yes
-++else
-++ ac_cv_c_bigendian=no
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++ fi
-++ if test $ac_cv_c_bigendian = unknown; then
-++ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#include <limits.h>
-++
-++int
-++main ()
-++{
-++#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
-++ bogus endian macros
-++ #endif
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++ # It does; now see whether it defined to _BIG_ENDIAN or not.
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++#include <limits.h>
-++
-++int
-++main ()
-++{
-++#ifndef _BIG_ENDIAN
-++ not big endian
-++ #endif
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++ ac_cv_c_bigendian=yes
-++else
-++ ac_cv_c_bigendian=no
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++ fi
-++ if test $ac_cv_c_bigendian = unknown; then
-++ # Compile a test program.
-++ if test "$cross_compiling" = yes; then :
-++ # Try to guess by grepping values from an object file.
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++short int ascii_mm[] =
-++ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-++ short int ascii_ii[] =
-++ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
-++ int use_ascii (int i) {
-++ return ascii_mm[i] + ascii_ii[i];
-++ }
-++ short int ebcdic_ii[] =
-++ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-++ short int ebcdic_mm[] =
-++ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
-++ int use_ebcdic (int i) {
-++ return ebcdic_mm[i] + ebcdic_ii[i];
-++ }
-++ extern int foo;
-++
-++int
-++main ()
-++{
-++return use_ascii (foo) == use_ebcdic (foo);
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_compile "$LINENO"; then :
-++ if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
-++ ac_cv_c_bigendian=yes
-++ fi
-++ if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
-++ if test "$ac_cv_c_bigendian" = unknown; then
-++ ac_cv_c_bigendian=no
-++ else
-++ # finding both strings is unlikely to happen, but who knows?
-++ ac_cv_c_bigendian=unknown
-++ fi
-++ fi
-++fi
-++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-++else
-++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-++/* end confdefs.h. */
-++$ac_includes_default
-++int
-++main ()
-++{
-++
-++ /* Are we little or big endian? From Harbison&Steele. */
-++ union
-++ {
-++ long int l;
-++ char c[sizeof (long int)];
-++ } u;
-++ u.l = 1;
-++ return u.c[sizeof (long int) - 1] == 1;
-++
-++ ;
-++ return 0;
-++}
-++_ACEOF
-++if ac_fn_c_try_run "$LINENO"; then :
-++ ac_cv_c_bigendian=no
-++else
-++ ac_cv_c_bigendian=yes
-++fi
-++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-++ conftest.$ac_objext conftest.beam conftest.$ac_ext
-++fi
-++
-++ fi
-++fi
-++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
-++$as_echo "$ac_cv_c_bigendian" >&6; }
-++ case $ac_cv_c_bigendian in #(
-++ yes)
-++ $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
-++;; #(
-++ no)
-++ ;; #(
-++ universal)
-++
-++$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
-++
-++ ;; #(
-++ *)
-++ as_fn_error $? "unknown endianness
-++ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
-++ esac
-++
-+
-+ ac_sources="$sim_link_files"
-+ ac_dests="$sim_link_links"
-+@@ -13110,10 +13374,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-+ :end' >>confcache
-+ if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-+ if test -w "$cache_file"; then
-+- test "x$cache_file" != "x/dev/null" &&
-++ if test "x$cache_file" != "x/dev/null"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-+ $as_echo "$as_me: updating cache $cache_file" >&6;}
-+- cat confcache >$cache_file
-++ if test ! -f "$cache_file" || test -h "$cache_file"; then
-++ cat confcache >"$cache_file"
-++ else
-++ case $cache_file in #(
-++ */* | ?:*)
-++ mv -f confcache "$cache_file"$$ &&
-++ mv -f "$cache_file"$$ "$cache_file" ;; #(
-++ *)
-++ mv -f confcache "$cache_file" ;;
-++ esac
-++ fi
-++ fi
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-+ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-+@@ -13129,6 +13404,7 @@ DEFS=-DHAVE_CONFIG_H
-+
-+ ac_libobjs=
-+ ac_ltlibobjs=
-++U=
-+ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-+ # 1. Remove the extension, and $U if already installed.
-+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-+@@ -13144,19 +13420,20 @@ LTLIBOBJS=$ac_ltlibobjs
-+
-+
-+ if test -z "${GMAKE_TRUE}" && test -z "${GMAKE_FALSE}"; then
-+- as_fn_error "conditional \"GMAKE\" was never defined.
-++ as_fn_error $? "conditional \"GMAKE\" was never defined.
-+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+ fi
-+ if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
-+- as_fn_error "conditional \"PLUGINS\" was never defined.
-++ as_fn_error $? "conditional \"PLUGINS\" was never defined.
-+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+ fi
-+ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
-+- as_fn_error "conditional \"MAINTAINER_MODE\" was never defined.
-++ as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
-+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
-+ fi
-+
-+-: ${CONFIG_STATUS=./config.status}
-++
-++: "${CONFIG_STATUS=./config.status}"
-+ ac_write_fail=0
-+ ac_clean_files_save=$ac_clean_files
-+ ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-+@@ -13257,6 +13534,7 @@ fi
-+ IFS=" "" $as_nl"
-+
-+ # Find who we are. Look in the path if we contain no directory separator.
-++as_myself=
-+ case $0 in #((
-+ *[\\/]* ) as_myself=$0 ;;
-+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+@@ -13302,19 +13580,19 @@ export LANGUAGE
-+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-+
-+
-+-# as_fn_error ERROR [LINENO LOG_FD]
-+-# ---------------------------------
-++# as_fn_error STATUS ERROR [LINENO LOG_FD]
-++# ----------------------------------------
-+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-+-# script with status $?, using 1 if that was 0.
-++# script with STATUS, using 1 if that was 0.
-+ as_fn_error ()
-+ {
-+- as_status=$?; test $as_status -eq 0 && as_status=1
-+- if test "$3"; then
-+- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-+- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-++ as_status=$1; test $as_status -eq 0 && as_status=1
-++ if test "$4"; then
-++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-+ fi
-+- $as_echo "$as_me: error: $1" >&2
-++ $as_echo "$as_me: error: $2" >&2
-+ as_fn_exit $as_status
-+ } # as_fn_error
-+
-+@@ -13452,16 +13730,16 @@ if (echo >conf$$.file) 2>/dev/null; then
-+ # ... but there are two gotchas:
-+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-+- # In both cases, we have to default to `cp -p'.
-++ # In both cases, we have to default to `cp -pR'.
-+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ elif ln conf$$.file conf$$ 2>/dev/null; then
-+ as_ln_s=ln
-+ else
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ fi
-+ else
-+- as_ln_s='cp -p'
-++ as_ln_s='cp -pR'
-+ fi
-+ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-+ rmdir conf$$.dir 2>/dev/null
-+@@ -13510,7 +13788,7 @@ $as_echo X"$as_dir" |
-+ test -d "$as_dir" && break
-+ done
-+ test -z "$as_dirs" || eval "mkdir $as_dirs"
-+- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
-++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-+
-+
-+ } # as_fn_mkdir_p
-+@@ -13521,28 +13799,16 @@ else
-+ as_mkdir_p=false
-+ fi
-+
-+-if test -x / >/dev/null 2>&1; then
-+- as_test_x='test -x'
-+-else
-+- if ls -dL / >/dev/null 2>&1; then
-+- as_ls_L_option=L
-+- else
-+- as_ls_L_option=
-+- fi
-+- as_test_x='
-+- eval sh -c '\''
-+- if test -d "$1"; then
-+- test -d "$1/.";
-+- else
-+- case $1 in #(
-+- -*)set "./$1";;
-+- esac;
-+- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-+- ???[sx]*):;;*)false;;esac;fi
-+- '\'' sh
-+- '
-+-fi
-+-as_executable_p=$as_test_x
-++
-++# as_fn_executable_p FILE
-++# -----------------------
-++# Test if FILE is an executable regular file.
-++as_fn_executable_p ()
-++{
-++ test -f "$1" && test -x "$1"
-++} # as_fn_executable_p
-++as_test_x='test -x'
-++as_executable_p=as_fn_executable_p
-+
-+ # Sed expression to map a string onto a valid CPP name.
-+ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-+@@ -13564,7 +13830,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-+ # values after options handling.
-+ ac_log="
-+ This file was extended by $as_me, which was
-+-generated by GNU Autoconf 2.64. Invocation command line was
-++generated by GNU Autoconf 2.69. Invocation command line was
-+
-+ CONFIG_FILES = $CONFIG_FILES
-+ CONFIG_HEADERS = $CONFIG_HEADERS
-+@@ -13605,6 +13871,7 @@ Usage: $0 [OPTION]... [TAG]...
-+
-+ -h, --help print this help, then exit
-+ -V, --version print version number and configuration settings, then exit
-++ --config print configuration, then exit
-+ -q, --quiet, --silent
-+ do not print progress messages
-+ -d, --debug don't remove temporary files
-+@@ -13630,12 +13897,13 @@ Report bugs to the package provider."
-+
-+ _ACEOF
-+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-++ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-+ ac_cs_version="\\
-+ config.status
-+-configured by $0, generated by GNU Autoconf 2.64,
-+- with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
-++configured by $0, generated by GNU Autoconf 2.69,
-++ with options \\"\$ac_cs_config\\"
-+
-+-Copyright (C) 2009 Free Software Foundation, Inc.
-++Copyright (C) 2012 Free Software Foundation, Inc.
-+ This config.status script is free software; the Free Software Foundation
-+ gives unlimited permission to copy, distribute and modify it."
-+
-+@@ -13652,11 +13920,16 @@ ac_need_defaults=:
-+ while test $# != 0
-+ do
-+ case $1 in
-+- --*=*)
-++ --*=?*)
-+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
-+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-+ ac_shift=:
-+ ;;
-++ --*=)
-++ ac_option=`expr "X$1" : 'X\([^=]*\)='`
-++ ac_optarg=
-++ ac_shift=:
-++ ;;
-+ *)
-+ ac_option=$1
-+ ac_optarg=$2
-+@@ -13670,12 +13943,15 @@ do
-+ ac_cs_recheck=: ;;
-+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-+ $as_echo "$ac_cs_version"; exit ;;
-++ --config | --confi | --conf | --con | --co | --c )
-++ $as_echo "$ac_cs_config"; exit ;;
-+ --debug | --debu | --deb | --de | --d | -d )
-+ debug=: ;;
-+ --file | --fil | --fi | --f )
-+ $ac_shift
-+ case $ac_optarg in
-+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-++ '') as_fn_error $? "missing file argument" ;;
-+ esac
-+ as_fn_append CONFIG_FILES " '$ac_optarg'"
-+ ac_need_defaults=false;;
-+@@ -13688,7 +13964,7 @@ do
-+ ac_need_defaults=false;;
-+ --he | --h)
-+ # Conflict between --help and --header
-+- as_fn_error "ambiguous option: \`$1'
-++ as_fn_error $? "ambiguous option: \`$1'
-+ Try \`$0 --help' for more information.";;
-+ --help | --hel | -h )
-+ $as_echo "$ac_cs_usage"; exit ;;
-+@@ -13697,7 +13973,7 @@ Try \`$0 --help' for more information.";;
-+ ac_cs_silent=: ;;
-+
-+ # This is an error.
-+- -*) as_fn_error "unrecognized option: \`$1'
-++ -*) as_fn_error $? "unrecognized option: \`$1'
-+ Try \`$0 --help' for more information." ;;
-+
-+ *) as_fn_append ac_config_targets " $1"
-+@@ -13717,7 +13993,7 @@ fi
-+ _ACEOF
-+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+ if \$ac_cs_recheck; then
-+- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-++ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-+ shift
-+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-+ CONFIG_SHELL='$SHELL'
-+@@ -14021,7 +14297,7 @@ do
-+ "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
-+ "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
-+
-+- *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-++ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-+ esac
-+ done
-+
-+@@ -14045,9 +14321,10 @@ fi
-+ # after its creation but before its name has been assigned to `$tmp'.
-+ $debug ||
-+ {
-+- tmp=
-++ tmp= ac_tmp=
-+ trap 'exit_status=$?
-+- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
-++ : "${ac_tmp:=$tmp}"
-++ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-+ ' 0
-+ trap 'as_fn_exit 1' 1 2 13 15
-+ }
-+@@ -14055,12 +14332,13 @@ $debug ||
-+
-+ {
-+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-+- test -n "$tmp" && test -d "$tmp"
-++ test -d "$tmp"
-+ } ||
-+ {
-+ tmp=./conf$$-$RANDOM
-+ (umask 077 && mkdir "$tmp")
-+-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
-++} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-++ac_tmp=$tmp
-+
-+ # Set up the scripts for CONFIG_FILES section.
-+ # No need to generate them if there are no CONFIG_FILES.
-+@@ -14077,12 +14355,12 @@ if test "x$ac_cr" = x; then
-+ fi
-+ ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-+ if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-+- ac_cs_awk_cr='\r'
-++ ac_cs_awk_cr='\\r'
-+ else
-+ ac_cs_awk_cr=$ac_cr
-+ fi
-+
-+-echo 'BEGIN {' >"$tmp/subs1.awk" &&
-++echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-+ _ACEOF
-+
-+
-+@@ -14091,18 +14369,18 @@ _ACEOF
-+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-+ echo "_ACEOF"
-+ } >conf$$subs.sh ||
-+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-+-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
-++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-++ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-+ ac_delim='%!_!# '
-+ for ac_last_try in false false false false false :; do
-+ . ./conf$$subs.sh ||
-+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-+
-+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-+ if test $ac_delim_n = $ac_delim_num; then
-+ break
-+ elif $ac_last_try; then
-+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-+ else
-+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-+ fi
-+@@ -14110,7 +14388,7 @@ done
-+ rm -f conf$$subs.sh
-+
-+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
-++cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-+ _ACEOF
-+ sed -n '
-+ h
-+@@ -14124,7 +14402,7 @@ s/'"$ac_delim"'$//
-+ t delim
-+ :nl
-+ h
-+-s/\(.\{148\}\).*/\1/
-++s/\(.\{148\}\)..*/\1/
-+ t more1
-+ s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-+ p
-+@@ -14138,7 +14416,7 @@ s/.\{148\}//
-+ t nl
-+ :delim
-+ h
-+-s/\(.\{148\}\).*/\1/
-++s/\(.\{148\}\)..*/\1/
-+ t more2
-+ s/["\\]/\\&/g; s/^/"/; s/$/"/
-+ p
-+@@ -14158,7 +14436,7 @@ t delim
-+ rm -f conf$$subs.awk
-+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+ _ACAWK
-+-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
-++cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
-+ for (key in S) S_is_set[key] = 1
-+ FS = ""
-+
-+@@ -14190,21 +14468,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-+ else
-+ cat
-+-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-+- || as_fn_error "could not setup config files machinery" "$LINENO" 5
-++fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-++ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-+ _ACEOF
-+
-+-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-+-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-++# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-++# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-+ # trailing colons and then remove the whole line if VPATH becomes empty
-+ # (actually we leave an empty line to preserve line numbers).
-+ if test "x$srcdir" = x.; then
-+- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-+-s/:*\$(srcdir):*/:/
-+-s/:*\${srcdir}:*/:/
-+-s/:*@srcdir@:*/:/
-+-s/^\([^=]*=[ ]*\):*/\1/
-++ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
-++h
-++s///
-++s/^/:/
-++s/[ ]*$/:/
-++s/:\$(srcdir):/:/g
-++s/:\${srcdir}:/:/g
-++s/:@srcdir@:/:/g
-++s/^:*//
-+ s/:*$//
-++x
-++s/\(=[ ]*\).*/\1/
-++G
-++s/\n//
-+ s/^[^=]*=[ ]*$//
-+ }'
-+ fi
-+@@ -14216,7 +14502,7 @@ fi # test -n "$CONFIG_FILES"
-+ # No need to generate them if there are no CONFIG_HEADERS.
-+ # This happens for instance with `./config.status Makefile'.
-+ if test -n "$CONFIG_HEADERS"; then
-+-cat >"$tmp/defines.awk" <<\_ACAWK ||
-++cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-+ BEGIN {
-+ _ACEOF
-+
-+@@ -14228,11 +14514,11 @@ _ACEOF
-+ # handling of long lines.
-+ ac_delim='%!_!# '
-+ for ac_last_try in false false :; do
-+- ac_t=`sed -n "/$ac_delim/p" confdefs.h`
-+- if test -z "$ac_t"; then
-++ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
-++ if test -z "$ac_tt"; then
-+ break
-+ elif $ac_last_try; then
-+- as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
-++ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
-+ else
-+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-+ fi
-+@@ -14317,7 +14603,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-+ _ACAWK
-+ _ACEOF
-+ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-+- as_fn_error "could not setup config headers machinery" "$LINENO" 5
-++ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-+ fi # test -n "$CONFIG_HEADERS"
-+
-+
-+@@ -14330,7 +14616,7 @@ do
-+ esac
-+ case $ac_mode$ac_tag in
-+ :[FHL]*:*);;
-+- :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
-++ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
-+ :[FH]-) ac_tag=-:-;;
-+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-+ esac
-+@@ -14349,7 +14635,7 @@ do
-+ for ac_f
-+ do
-+ case $ac_f in
-+- -) ac_f="$tmp/stdin";;
-++ -) ac_f="$ac_tmp/stdin";;
-+ *) # Look for the file first in the build tree, then in the source tree
-+ # (if the path is not absolute). The absolute path cannot be DOS-style,
-+ # because $ac_f cannot contain `:'.
-+@@ -14358,7 +14644,7 @@ do
-+ [\\/$]*) false;;
-+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-+ esac ||
-+- as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-++ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-+ esac
-+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-+ as_fn_append ac_file_inputs " '$ac_f'"
-+@@ -14384,8 +14670,8 @@ $as_echo "$as_me: creating $ac_file" >&6;}
-+ esac
-+
-+ case $ac_tag in
-+- *:-:* | *:-) cat >"$tmp/stdin" \
-+- || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
-++ *:-:* | *:-) cat >"$ac_tmp/stdin" \
-++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
-+ esac
-+ ;;
-+ esac
-+@@ -14515,23 +14801,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-+ s&@INSTALL@&$ac_INSTALL&;t t
-+ $ac_datarootdir_hack
-+ "
-+-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
-+- || as_fn_error "could not create $ac_file" "$LINENO" 5
-++eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-++ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-+
-+ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-+- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-+- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
-++ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-++ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
-++ "$ac_tmp/out"`; test -z "$ac_out"; } &&
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-+-which seems to be undefined. Please make sure it is defined." >&5
-++which seems to be undefined. Please make sure it is defined" >&5
-+ $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-+-which seems to be undefined. Please make sure it is defined." >&2;}
-++which seems to be undefined. Please make sure it is defined" >&2;}
-+
-+- rm -f "$tmp/stdin"
-++ rm -f "$ac_tmp/stdin"
-+ case $ac_file in
-+- -) cat "$tmp/out" && rm -f "$tmp/out";;
-+- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
-++ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-++ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
-+ esac \
-+- || as_fn_error "could not create $ac_file" "$LINENO" 5
-++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-+ ;;
-+ :H)
-+ #
-+@@ -14540,21 +14827,21 @@ which seems to be undefined. Please make sure it is defined." >&2;}
-+ if test x"$ac_file" != x-; then
-+ {
-+ $as_echo "/* $configure_input */" \
-+- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
-+- } >"$tmp/config.h" \
-+- || as_fn_error "could not create $ac_file" "$LINENO" 5
-+- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
-++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
-++ } >"$ac_tmp/config.h" \
-++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-++ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-+ $as_echo "$as_me: $ac_file is unchanged" >&6;}
-+ else
-+ rm -f "$ac_file"
-+- mv "$tmp/config.h" "$ac_file" \
-+- || as_fn_error "could not create $ac_file" "$LINENO" 5
-++ mv "$ac_tmp/config.h" "$ac_file" \
-++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-+ fi
-+ else
-+ $as_echo "/* $configure_input */" \
-+- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-+- || as_fn_error "could not create -" "$LINENO" 5
-++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
-++ || as_fn_error $? "could not create -" "$LINENO" 5
-+ fi
-+ ;;
-+ :L)
-+@@ -14574,19 +14861,19 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;}
-+ $as_echo "$as_me: linking $ac_source to $ac_file" >&6;}
-+
-+ if test ! -r "$ac_source"; then
-+- as_fn_error "$ac_source: file not found" "$LINENO" 5
-++ as_fn_error $? "$ac_source: file not found" "$LINENO" 5
-+ fi
-+ rm -f "$ac_file"
-+
-+ # Try a relative symlink, then a hard link, then a copy.
-+- case $srcdir in
-++ case $ac_source in
-+ [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;;
-+ *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
-+ esac
-+ ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
-+ ln "$ac_source" "$ac_file" 2>/dev/null ||
-+ cp -p "$ac_source" "$ac_file" ||
-+- as_fn_error "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
-++ as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
-+ fi
-+ ;;
-+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-+@@ -15256,7 +15543,7 @@ _ACEOF
-+ ac_clean_files=$ac_clean_files_save
-+
-+ test $ac_write_fail = 0 ||
-+- as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
-++ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-+
-+
-+ # configure is writing to config.log, and then calls config.status.
-+@@ -15277,7 +15564,7 @@ if test "$no_create" != yes; then
-+ exec 5>>config.log
-+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-+ # would make configure fail if this is the last instruction.
-+- $ac_cs_success || as_fn_exit $?
-++ $ac_cs_success || as_fn_exit 1
-+ fi
-+ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-+diff --git a/sim/erc32/configure.ac b/sim/erc32/configure.ac
-+index bc46091..1646cc5 100644
-+--- a/sim/erc32/configure.ac
-++++ b/sim/erc32/configure.ac
-+@@ -32,4 +32,5 @@ else
-+ AC_ERROR([the required "readline" library is missing]), $TERMCAP)
-+ fi
-+ AC_SUBST(READLINE)
-++AC_C_BIGENDIAN
-+ SIM_AC_OUTPUT
-+diff --git a/sim/erc32/end.c b/sim/erc32/end.c
-+deleted file mode 100644
-+index 9337198..0000000
-+--- a/sim/erc32/end.c
-++++ /dev/null
-+@@ -1,27 +0,0 @@
-+-#include "config.h"
-+-#include <stdio.h>
-+-
-+-int
-+-main()
-+-{
-+-
-+- unsigned int u1;
-+- char *c;
-+- double d1;
-+- float *f1;
-+-
-+- c = (char *) &u1;
-+- u1 = 0x0F;
-+- if (c[0] == 0x0F)
-+- puts("#define HOST_LITTLE_ENDIAN\n");
-+- else
-+- puts("#define HOST_BIG_ENDIAN\n");
-+-
-+- d1 = 1.0;
-+- f1 = (float *) &d1;
-+- if (*((int *) f1) != 0x3ff00000)
-+- puts("#define HOST_LITTLE_ENDIAN_FLOAT\n");
-+- else
-+- puts("#define HOST_BIG_ENDIAN_FLOAT\n");
-+- return 0;
-+-}
-+diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
-+index 4d4177e..0846bab 100644
-+--- a/sim/erc32/erc32.c
-++++ b/sim/erc32/erc32.c
-+@@ -22,6 +22,7 @@
-+ /* The control space devices */
-+
-+ #include "config.h"
-++#include <errno.h>
-+ #include <sys/types.h>
-+ #include <stdio.h>
-+ #include <string.h>
-+@@ -30,16 +31,9 @@
-+ #include <sys/file.h>
-+ #include <unistd.h>
-+ #include "sis.h"
-+-#include "end.h"
-+ #include "sim-config.h"
-+
-+-extern int ctrl_c;
-+-extern int32 sis_verbose;
-+-extern int32 sparclite, sparclite_board;
-+-extern int rom8,wrp,uben;
-+-extern char uart_dev1[], uart_dev2[];
-+-
-+-int dumbio = 0; /* normal, smart, terminal oriented IO by default */
-++static int tty_setup = 1; /* default setup if not a tty */
-+
-+ /* MEC registers */
-+ #define MEC_START 0x01f80000
-+@@ -55,11 +49,6 @@ int dumbio = 0; /* normal, smart, terminal oriented IO by default */
-+ extern int errmec;
-+ #endif
-+
-+-/* The target's byte order is big-endian by default until we load a
-+- little-endian program. */
-+-
-+-int current_target_byte_order = BIG_ENDIAN;
-+-
-+ #define MEC_WS 0 /* Waitstates per MEC access (0 ws) */
-+ #define MOK 0
-+
-+@@ -297,26 +286,24 @@ static void gpt_reload_set (uint32 val);
-+ static void timer_ctrl (uint32 val);
-+ static unsigned char *
-+ get_mem_ptr (uint32 addr, uint32 size);
-++static void store_bytes (unsigned char *mem, uint32 waddr,
-++ uint32 *data, int sz, int32 *ws);
-+
-+-static void fetch_bytes (int asi, unsigned char *mem,
-+- uint32 *data, int sz);
-+-
-+-static void store_bytes (unsigned char *mem, uint32 *data, int sz);
-+-
-+-extern int ext_irl;
-++static host_callback *callback;
-+
-+
-+ /* One-time init */
-+
-+-void
-++static void
-+ init_sim()
-+ {
-++ callback = sim_callback;
-+ port_init();
-+ }
-+
-+ /* Power-on reset init */
-+
-+-void
-++static void
-+ reset()
-+ {
-+ mec_reset();
-+@@ -396,7 +383,7 @@ mecparerror()
-+
-+ /* IU error mode manager */
-+
-+-void
-++static void
-+ error_mode(pc)
-+ uint32 pc;
-+ {
-+@@ -467,7 +454,7 @@ decode_mcr()
-+
-+ /* Flush ports when simulator stops */
-+
-+-void
-++static void
-+ sim_halt()
-+ {
-+ #ifdef FAST_UART
-+@@ -475,13 +462,6 @@ sim_halt()
-+ #endif
-+ }
-+
-+-int
-+-sim_stop(SIM_DESC sd)
-+-{
-+- ctrl_c = 1;
-+- return 1;
-+-}
-+-
-+ static void
-+ close_port()
-+ {
-+@@ -491,7 +471,7 @@ close_port()
-+ fclose(f2in);
-+ }
-+
-+-void
-++static void
-+ exit_sim()
-+ {
-+ close_port();
-+@@ -743,6 +723,14 @@ mec_read(addr, asi, data)
-+ *data = read_uart(addr);
-+ break;
-+
-++ case 0xF4: /* simulator RAM size in bytes */
-++ *data = 4096*1024;
-++ break;
-++
-++ case 0xF8: /* simulator ROM size in bytes */
-++ *data = 1024*1024;
-++ break;
-++
-+ default:
-+ set_sfsr(MEC_ACC, addr, asi, 1);
-+ return (1);
-+@@ -935,32 +923,38 @@ mec_write(addr, data)
-+
-+ static int ifd1 = -1, ifd2 = -1, ofd1 = -1, ofd2 = -1;
-+
-+-void
-++static void
-+ init_stdio()
-+ {
-+ if (dumbio)
-+ return; /* do nothing */
-+- if (!ifd1)
-++ if (ifd1 == 0 && f1open) {
-+ tcsetattr(0, TCSANOW, &ioc1);
-+- if (!ifd2)
-++ tcflush(ifd1, TCIFLUSH);
-++ }
-++ if (ifd2 == 0 && f1open) {
-+ tcsetattr(0, TCSANOW, &ioc2);
-++ tcflush(ifd2, TCIFLUSH);
-++ }
-+ }
-+
-+-void
-++static void
-+ restore_stdio()
-+ {
-+ if (dumbio)
-+ return; /* do nothing */
-+- if (!ifd1)
-++ if (ifd1 == 0 && f1open && tty_setup)
-+ tcsetattr(0, TCSANOW, &iocold1);
-+- if (!ifd2)
-++ if (ifd2 == 0 && f2open && tty_setup)
-+ tcsetattr(0, TCSANOW, &iocold2);
-+ }
-+
-+ #define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
-+- ( dumbio \
-++ ( dumbio || nouartrx \
-+ ? (0) /* no bytes read, no delay */ \
-+- : read( _fd_, _buf_, _len_ ) )
-++ : (_fd_) == 1 && callback ? \
-++ callback->read_stdin (callback, _buf_, _len_) : \
-++ read( _fd_, _buf_, _len_ ) )
-+
-+
-+ static void
-+@@ -990,21 +984,26 @@ port_init()
-+ }
-+ if (f1in) ifd1 = fileno(f1in);
-+ if (ifd1 == 0) {
-++ if (callback && !callback->isatty(callback, ifd1)) {
-++ tty_setup = 0;
-++ }
-+ if (sis_verbose)
-+ printf("serial port A on stdin/stdout\n");
-+ if (!dumbio) {
-+ tcgetattr(ifd1, &ioc1);
-++ if (tty_setup) {
-+ iocold1 = ioc1;
-+ ioc1.c_lflag &= ~(ICANON | ECHO);
-+ ioc1.c_cc[VMIN] = 0;
-+ ioc1.c_cc[VTIME] = 0;
-+ }
-++ }
-+ f1open = 1;
-+ }
-+
-+ if (f1out) {
-+ ofd1 = fileno(f1out);
-+- if (!dumbio && ofd1 == 1) setbuf(f1out, NULL);
-++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
-+ }
-+
-+ if (uart_dev2[0] != 0)
-+@@ -1023,17 +1022,19 @@ port_init()
-+ printf("serial port B on stdin/stdout\n");
-+ if (!dumbio) {
-+ tcgetattr(ifd2, &ioc2);
-++ if (tty_setup) {
-+ iocold2 = ioc2;
-+ ioc2.c_lflag &= ~(ICANON | ECHO);
-+ ioc2.c_cc[VMIN] = 0;
-+ ioc2.c_cc[VTIME] = 0;
-+ }
-++ }
-+ f2open = 1;
-+ }
-+
-+ if (f2out) {
-+ ofd2 = fileno(f2out);
-+- if (!dumbio && ofd2 == 1) setbuf(f2out, NULL);
-++ if (!dumbio && tty_setup && ofd2 == 1) setbuf(f2out, NULL);
-+ }
-+
-+ wnuma = wnumb = 0;
-+@@ -1062,6 +1063,9 @@ read_uart(addr)
-+ if (f1open) {
-+ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-+ }
-++ else {
-++ anum = 0;
-++ }
-+ if (anum > 0) {
-+ aind = 0;
-+ if ((aind + 1) < anum)
-+@@ -1094,6 +1098,9 @@ read_uart(addr)
-+ if (f2open) {
-+ bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
-+ }
-++ else {
-++ bnum = 0;
-++ }
-+ if (bnum > 0) {
-+ bind = 0;
-+ if ((bind + 1) < bnum)
-+@@ -1126,6 +1133,9 @@ read_uart(addr)
-+ if (f1open) {
-+ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-+ }
-++ else {
-++ anum = 0;
-++ }
-+ if (anum > 0) {
-+ Ucontrol |= 0x00000001;
-+ aind = 0;
-+@@ -1138,6 +1148,9 @@ read_uart(addr)
-+ if (f2open) {
-+ bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
-+ }
-++ else {
-++ bnum = 0;
-++ }
-+ if (bnum > 0) {
-+ Ucontrol |= 0x00010000;
-+ bind = 0;
-+@@ -1178,8 +1191,12 @@ write_uart(addr, data)
-+ if (wnuma < UARTBUF)
-+ wbufa[wnuma++] = c;
-+ else {
-+- while (wnuma)
-++ while (wnuma) {
-++ if (ofd1 == 1 && callback)
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ else
-+ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-++ }
-+ wbufa[wnuma++] = c;
-+ }
-+ }
-+@@ -1202,8 +1219,12 @@ write_uart(addr, data)
-+ if (wnumb < UARTBUF)
-+ wbufb[wnumb++] = c;
-+ else {
-+- while (wnumb)
-++ while (wnumb) {
-++ if (ofd1 == 1 && callback)
-++ wnumb -= callback->write_stdout(callback, wbufb, wnumb);
-++ else
-+ wnumb -= fwrite(wbufb, 1, wnumb, f2out);
-++ }
-+ wbufb[wnumb++] = c;
-+ }
-+ }
-+@@ -1241,19 +1262,37 @@ write_uart(addr, data)
-+ static void
-+ flush_uart()
-+ {
-+- while (wnuma && f1open)
-++ while (wnuma && f1open) {
-++ if (ofd1 == 1 && callback) {
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ callback->flush_stdout(callback);
-++ }
-++ else
-+ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-+- while (wnumb && f2open)
-++ }
-++ while (wnumb && f2open) {
-++ if (ofd2 == 1 && callback) {
-++ wnuma -= callback->write_stdout(callback, wbufb, wnuma);
-++ callback->flush_stdout(callback);
-++ }
-++ else
-+ wnumb -= fwrite(wbufb, 1, wnumb, f2out);
-+ }
-++}
-+
-+
-+
-+ static void
-+ uarta_tx()
-+ {
-+-
-+- while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1);
-++ while (f1open) {
-++ if (ofd1 == 1 && callback) {
-++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
-++ }
-++ else {
-++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
-++ }
-++ }
-+ if (uart_stat_reg & UARTA_HRE) {
-+ uart_stat_reg |= UARTA_SRE;
-+ } else {
-+@@ -1267,7 +1306,14 @@ uarta_tx()
-+ static void
-+ uartb_tx()
-+ {
-+- while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1);
-++ while (f2open) {
-++ if (ofd2 == 1 && callback) {
-++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
-++ }
-++ else {
-++ while (fwrite(&uartb_sreg, 1, 1, f2out) != 1);
-++ }
-++ }
-+ if (uart_stat_reg & UARTB_HRE) {
-+ uart_stat_reg |= UARTB_SRE;
-+ } else {
-+@@ -1289,6 +1335,8 @@ uart_rx(arg)
-+ rsize = 0;
-+ if (f1open)
-+ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
-++ else
-++ rsize = 0;
-+ if (rsize > 0) {
-+ uarta_data = UART_DR | rxd;
-+ if (uart_stat_reg & UARTA_HRE)
-+@@ -1305,6 +1353,8 @@ uart_rx(arg)
-+ rsize = 0;
-+ if (f2open)
-+ rsize = DO_STDIO_READ(ifd2, &rxd, 1);
-++ else
-++ rsize = 0;
-+ if (rsize) {
-+ uartb_data = UART_DR | rxd;
-+ if (uart_stat_reg & UARTB_HRE)
-+@@ -1517,143 +1567,89 @@ timer_ctrl(val)
-+ gpt_start();
-+ }
-+
-+-
-+-/* Retrieve data from target memory. MEM points to location from which
-+- to read the data; DATA points to words where retrieved data will be
-+- stored in host byte order. SZ contains log(2) of the number of bytes
-+- to retrieve, and can be 0 (1 byte), 1 (one half-word), 2 (one word),
-+- or 3 (two words). */
-++/* Store data in host byte order. MEM points to the beginning of the
-++ emulated memory; WADDR contains the index the emulated memory,
-++ DATA points to words in host byte order to be stored. SZ contains log(2)
-++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
-++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
-+
-+ static void
-+-fetch_bytes (asi, mem, data, sz)
-+- int asi;
-++store_bytes (mem, waddr, data, sz, ws)
-+ unsigned char *mem;
-++ uint32 waddr;
-+ uint32 *data;
-+- int sz;
-++ int32 sz;
-++ int32 *ws;
-+ {
-+- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN
-+- || asi == 8 || asi == 9) {
-+- switch (sz) {
-+- case 3:
-+- data[1] = (((uint32) mem[7]) & 0xff) |
-+- ((((uint32) mem[6]) & 0xff) << 8) |
-+- ((((uint32) mem[5]) & 0xff) << 16) |
-+- ((((uint32) mem[4]) & 0xff) << 24);
-+- /* Fall through to 2 */
-+- case 2:
-+- data[0] = (((uint32) mem[3]) & 0xff) |
-+- ((((uint32) mem[2]) & 0xff) << 8) |
-+- ((((uint32) mem[1]) & 0xff) << 16) |
-+- ((((uint32) mem[0]) & 0xff) << 24);
-++ switch (sz) {
-++ case 0:
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 3;
-++#endif
-++ mem[waddr] = *data & 0x0ff;
-++ *ws = mem_ramw_ws + 3;
-+ break;
-+ case 1:
-+- data[0] = (((uint32) mem[1]) & 0xff) |
-+- ((((uint32) mem[0]) & 0xff) << 8);
-+- break;
-+- case 0:
-+- data[0] = mem[0] & 0xff;
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 2;
-++#endif
-++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
-++ *ws = mem_ramw_ws + 3;
-+ break;
-+-
-+- }
-+- } else {
-+- switch (sz) {
-+- case 3:
-+- data[1] = ((((uint32) mem[7]) & 0xff) << 24) |
-+- ((((uint32) mem[6]) & 0xff) << 16) |
-+- ((((uint32) mem[5]) & 0xff) << 8) |
-+- (((uint32) mem[4]) & 0xff);
-+- /* Fall through to 4 */
-+ case 2:
-+- data[0] = ((((uint32) mem[3]) & 0xff) << 24) |
-+- ((((uint32) mem[2]) & 0xff) << 16) |
-+- ((((uint32) mem[1]) & 0xff) << 8) |
-+- (((uint32) mem[0]) & 0xff);
-+- break;
-+- case 1:
-+- data[0] = ((((uint32) mem[1]) & 0xff) << 8) |
-+- (((uint32) mem[0]) & 0xff);
-++ *((uint32 *) &(mem[waddr])) = *data;
-++ *ws = mem_ramw_ws;
-+ break;
-+- case 0:
-+- data[0] = mem[0] & 0xff;
-++ case 3:
-++ *((uint32 *) &(mem[waddr])) = data[0];
-++ *((uint32 *) &(mem[waddr + 4])) = data[1];
-++ *ws = 2 * mem_ramw_ws + STD_WS;
-+ break;
-+- }
-+ }
-+ }
-+
-+
-+-/* Store data in target byte order. MEM points to location to store data;
-+- DATA points to words in host byte order to be stored. SZ contains log(2)
-+- of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
-+- 2 (one word), or 3 (two words). */
-++/* Memory emulation */
-+
-+-static void
-+-store_bytes (mem, data, sz)
-+- unsigned char *mem;
-+- uint32 *data;
-+- int sz;
-++static int
-++memory_iread(addr, data, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 *ws;
-+ {
-+- if (CURRENT_TARGET_BYTE_ORDER == LITTLE_ENDIAN) {
-+- switch (sz) {
-+- case 3:
-+- mem[7] = (data[1] >> 24) & 0xff;
-+- mem[6] = (data[1] >> 16) & 0xff;
-+- mem[5] = (data[1] >> 8) & 0xff;
-+- mem[4] = data[1] & 0xff;
-+- /* Fall through to 2 */
-+- case 2:
-+- mem[3] = (data[0] >> 24) & 0xff;
-+- mem[2] = (data[0] >> 16) & 0xff;
-+- /* Fall through to 1 */
-+- case 1:
-+- mem[1] = (data[0] >> 8) & 0xff;
-+- /* Fall through to 0 */
-+- case 0:
-+- mem[0] = data[0] & 0xff;
-+- break;
-+- }
-+- } else {
-+- switch (sz) {
-+- case 3:
-+- mem[7] = data[1] & 0xff;
-+- mem[6] = (data[1] >> 8) & 0xff;
-+- mem[5] = (data[1] >> 16) & 0xff;
-+- mem[4] = (data[1] >> 24) & 0xff;
-+- /* Fall through to 2 */
-+- case 2:
-+- mem[3] = data[0] & 0xff;
-+- mem[2] = (data[0] >> 8) & 0xff;
-+- mem[1] = (data[0] >> 16) & 0xff;
-+- mem[0] = (data[0] >> 24) & 0xff;
-+- break;
-+- case 1:
-+- mem[1] = data[0] & 0xff;
-+- mem[0] = (data[0] >> 8) & 0xff;
-+- break;
-+- case 0:
-+- mem[0] = data[0] & 0xff;
-+- break;
-+-
-+- }
-++ uint32 asi;
-++ if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
-++ *data = *((uint32 *) & (ramb[addr & mem_rammask & ~3]));
-++ *ws = mem_ramr_ws;
-++ return (0);
-++ } else if (addr < mem_romsz) {
-++ *data = *((uint32 *) & (romb[addr & ~3]));
-++ *ws = mem_romr_ws;
-++ return (0);
-+ }
-+-}
-+-
-+
-+-/* Memory emulation */
-++ printf("Memory exception at %x (illegal address)\n", addr);
-++ if (sregs.psr & 0x080) asi = 9; else asi = 8;
-++ set_sfsr(UIMP_ACC, addr, asi, 1);
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-+
-+-int
-+-memory_read(asi, addr, data, sz, ws)
-+- int32 asi;
-++static int
-++memory_read(addr, data, sz, ws)
-+ uint32 addr;
-+ uint32 *data;
-+ int32 sz;
-+ int32 *ws;
-+ {
-+ int32 mexc;
-++ int32 asi;
-+
-+ #ifdef ERRINJ
-+ if (errmec) {
-+ if (sis_verbose)
-+ printf("Inserted MEC error %d\n",errmec);
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ set_sfsr(errmec, addr, asi, 1);
-+ if (errmec == 5) mecparerror();
-+ if (errmec == 6) iucomperr();
-+@@ -1663,10 +1659,11 @@ memory_read(asi, addr, data, sz, ws)
-+ #endif
-+
-+ if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
-+- fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz);
-++ *data = *((uint32 *) & (ramb[addr & mem_rammask & ~3]));
-+ *ws = mem_ramr_ws;
-+ return (0);
-+ } else if ((addr >= MEC_START) && (addr < MEC_END)) {
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ mexc = mec_read(addr, asi, data);
-+ if (mexc) {
-+ set_sfsr(MEC_ACC, addr, asi, 1);
-+@@ -1681,7 +1678,7 @@ memory_read(asi, addr, data, sz, ws)
-+ } else if (era) {
-+ if ((addr < 0x100000) ||
-+ ((addr>= 0x80000000) && (addr < 0x80100000))) {
-+- fetch_bytes (asi, &romb[addr & ROM_MASK], data, sz);
-++ *data = *((uint32 *) & (romb[addr & ROM_MASK & ~3]));
-+ *ws = 4;
-+ return (0);
-+ } else if ((addr >= 0x10000000) &&
-+@@ -1692,13 +1689,13 @@ memory_read(asi, addr, data, sz, ws)
-+ }
-+
-+ } else if (addr < mem_romsz) {
-+- fetch_bytes (asi, &romb[addr], data, sz);
-++ *data = *((uint32 *) & (romb[addr & ~3]));
-+ *ws = mem_romr_ws;
-+ return (0);
-+
-+ #else
-+ } else if (addr < mem_romsz) {
-+- fetch_bytes (asi, &romb[addr], data, sz);
-++ *data = *((uint32 *) & (romb[addr & ~3]));
-+ *ws = mem_romr_ws;
-+ return (0);
-+ #endif
-+@@ -1706,19 +1703,30 @@ memory_read(asi, addr, data, sz, ws)
-+ }
-+
-+ printf("Memory exception at %x (illegal address)\n", addr);
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ set_sfsr(UIMP_ACC, addr, asi, 1);
-+ *ws = MEM_EX_WS;
-+ return (1);
-+ }
-+
-+-int
-+-memory_write(asi, addr, data, sz, ws)
-++static int
-++memory_read_asi(asi, addr, data, sz, ws)
-+ int32 asi;
-+ uint32 addr;
-+ uint32 *data;
-+ int32 sz;
-+ int32 *ws;
-+ {
-++ return(memory_read(addr, data, sz, ws));
-++}
-++
-++static int
-++memory_write(addr, data, sz, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-+ uint32 byte_addr;
-+ uint32 byte_mask;
-+ uint32 waddr;
-+@@ -1726,11 +1734,13 @@ memory_write(asi, addr, data, sz, ws)
-+ int32 mexc;
-+ int i;
-+ int wphit[2];
-++ int32 asi;
-+
-+ #ifdef ERRINJ
-+ if (errmec) {
-+ if (sis_verbose)
-+ printf("Inserted MEC error %d\n",errmec);
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ set_sfsr(errmec, addr, asi, 0);
-+ if (errmec == 5) mecparerror();
-+ if (errmec == 6) iucomperr();
-+@@ -1743,6 +1753,7 @@ memory_write(asi, addr, data, sz, ws)
-+ if (mem_accprot) {
-+
-+ waddr = (addr & 0x7fffff) >> 2;
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ for (i = 0; i < 2; i++)
-+ wphit[i] =
-+ (((asi == 0xa) && (mec_wpr[i] & 1)) ||
-+@@ -1761,22 +1772,12 @@ memory_write(asi, addr, data, sz, ws)
-+ }
-+ }
-+
-+- store_bytes (&ramb[addr & mem_rammask], data, sz);
-+-
-+- switch (sz) {
-+- case 0:
-+- case 1:
-+- *ws = mem_ramw_ws + 3;
-+- break;
-+- case 2:
-+- *ws = mem_ramw_ws;
-+- break;
-+- case 3:
-+- *ws = 2 * mem_ramw_ws + STD_WS;
-+- break;
-+- }
-++ waddr = addr & mem_rammask;
-++ store_bytes (ramb, waddr, data, sz, ws);
-+ return (0);
-++
-+ } else if ((addr >= MEC_START) && (addr < MEC_END)) {
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ if ((sz != 2) || (asi != 0xb)) {
-+ set_sfsr(MEC_ACC, addr, asi, 0);
-+ *ws = MEM_EX_WS;
-+@@ -1798,7 +1799,7 @@ memory_write(asi, addr, data, sz, ws)
-+ ((addr < 0x100000) || ((addr >= 0x80000000) && (addr < 0x80100000)))) {
-+ addr &= ROM_MASK;
-+ *ws = sz == 3 ? 8 : 4;
-+- store_bytes (&romb[addr], data, sz);
-++ store_bytes (romb, addr, data, sz, ws);
-+ return (0);
-+ } else if ((addr >= 0x10000000) &&
-+ (addr < (0x10000000 + (512 << (mec_iocr & 0x0f)))) &&
-+@@ -1814,7 +1815,7 @@ memory_write(asi, addr, data, sz, ws)
-+ *ws = mem_romw_ws + 1;
-+ if (sz == 3)
-+ *ws += mem_romw_ws + STD_WS;
-+- store_bytes (&romb[addr], data, sz);
-++ store_bytes (romb, addr, data, sz, ws);
-+ return (0);
-+
-+ #else
-+@@ -1825,7 +1826,7 @@ memory_write(asi, addr, data, sz, ws)
-+ *ws = mem_romw_ws + 1;
-+ if (sz == 3)
-+ *ws += mem_romw_ws + STD_WS;
-+- store_bytes (&romb[addr], data, sz);
-++ store_bytes (romb, addr, data, sz, ws);
-+ return (0);
-+
-+ #endif
-+@@ -1833,10 +1834,22 @@ memory_write(asi, addr, data, sz, ws)
-+ }
-+
-+ *ws = MEM_EX_WS;
-++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
-+ set_sfsr(UIMP_ACC, addr, asi, 0);
-+ return (1);
-+ }
-+
-++static int
-++memory_write_asi(asi, addr, data, sz, ws)
-++ int32 asi;
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ return(memory_write(addr, data, sz, ws));
-++}
-++
-+ static unsigned char *
-+ get_mem_ptr(addr, size)
-+ uint32 addr;
-+@@ -1858,7 +1871,7 @@ get_mem_ptr(addr, size)
-+ return ((char *) -1);
-+ }
-+
-+-int
-++static int
-+ sis_memory_write(addr, data, length)
-+ uint32 addr;
-+ const unsigned char *data;
-+@@ -1873,13 +1886,19 @@ sis_memory_write(addr, data, length)
-+ return (length);
-+ }
-+
-+-int
-++static int
-+ sis_memory_read(addr, data, length)
-+ uint32 addr;
-+ char *data;
-+ uint32 length;
-+ {
-+ char *mem;
-++ int ws;
-++
-++ if (length == 4) {
-++ memory_read(addr, data, length, &ws);
-++ return(4);
-++ }
-+
-+ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
-+ return (0);
-+@@ -1887,3 +1906,35 @@ sis_memory_read(addr, data, length)
-+ memcpy(data, mem, length);
-+ return (length);
-+ }
-++
-++static void
-++boot_init ()
-++{
-++ mec_write(MEC_WCR, 0); /* zero waitstates */
-++ mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
-++ mec_write(MEC_RTC_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
-++ mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
-++ sregs.wim = 2;
-++ sregs.psr = 0x110010e0;
-++ sregs.r[30] = RAM_END;
-++ sregs.r[14] = sregs.r[30] - 96*4;
-++ mec_mcr |= 1; /* power-down enabled */
-++}
-++
-++struct memsys erc32sys = {
-++ init_sim,
-++ reset,
-++ error_mode,
-++ sim_halt,
-++ exit_sim,
-++ init_stdio,
-++ restore_stdio,
-++ memory_iread,
-++ memory_read,
-++ memory_read_asi,
-++ memory_write,
-++ memory_write_asi,
-++ sis_memory_write,
-++ sis_memory_read,
-++ boot_init
-++};
-+diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c
-+index dc86ba3..f812ad9 100644
-+--- a/sim/erc32/exec.c
-++++ b/sim/erc32/exec.c
-+@@ -21,11 +21,9 @@
-+
-+ #include "config.h"
-+ #include "sis.h"
-+-#include "end.h"
-+ #include <math.h>
-+ #include <stdio.h>
-+
-+-extern int32 sis_verbose, sparclite;
-+ int ext_irl = 0;
-+
-+ /* Load/store interlock delay */
-+@@ -229,10 +227,6 @@ static int fpexec (uint32 op3, uint32 rd, uint32 rs1, uint32 rs2,
-+ struct pstate *sregs);
-+ static int chk_asi (struct pstate *sregs, uint32 *asi, uint32 op3);
-+
-+-
-+-extern struct estate ebase;
-+-extern int32 nfp,ift;
-+-
-+ #ifdef ERRINJ
-+ extern uint32 errtt, errftt;
-+ #endif
-+@@ -371,6 +365,36 @@ div64 (uint32 n1_hi, uint32 n1_low, uint32 n2, uint32 *result, int msigned)
-+ }
-+
-+
-++static int
-++extract_short(uint32 data, uint32 address)
-++{
-++ return((data>>((2 - (address & 2))*8)) & 0xffff);
-++}
-++
-++static int
-++extract_short_signed(uint32 data, uint32 address)
-++{
-++ uint32 tmp;
-++ tmp = ((data>>((2 - (address & 2))*8)) & 0xffff);
-++ if (tmp & 0x8000) tmp |= 0xffff0000;
-++ return(tmp);
-++}
-++
-++static int
-++extract_byte(uint32 data, uint32 address)
-++{
-++ return((data>>((3 - (address & 3))*8)) & 0xff);
-++}
-++
-++static int
-++extract_byte_signed(uint32 data, uint32 address)
-++{
-++ uint32 tmp;
-++ tmp = ((data>>((3 - (address & 3))*8)) & 0xff);
-++ if (tmp & 0x80) tmp |= 0xffffff00;
-++ return(tmp);
-++}
-++
-+ int
-+ dispatch_instruction(sregs)
-+ struct pstate *sregs;
-+@@ -1041,17 +1065,17 @@ dispatch_instruction(sregs)
-+ *rdd = sregs->psr;
-+ break;
-+ case RDY:
-+- if (!sparclite)
-++ if ((!sparclite) && (cputype != CPU_LEON3))
-+ *rdd = sregs->y;
-+ else {
-+ int rs1_is_asr = (sregs->inst >> 14) & 0x1f;
-+ if ( 0 == rs1_is_asr )
-+ *rdd = sregs->y;
-+- else if ( 17 == rs1_is_asr )
-++ else if ( 17 == rs1_is_asr ) {
-+ *rdd = sregs->asr17;
-++ }
-+ else {
-+ sregs->trap = TRAP_UNIMP;
-+- break;
-+ }
-+ }
-+ break;
-+@@ -1078,7 +1102,8 @@ dispatch_instruction(sregs)
-+ sregs->trap = TRAP_PRIVI;
-+ break;
-+ }
-+- sregs->psr = (rs1 ^ operand2) & 0x00f03fff;
-++ sregs->psr = (sregs->psr & 0xff000000) |
-++ (rs1 ^ operand2) & 0x00f03fff;
-+ break;
-+ case WRWIM:
-+ if (!(sregs->psr & PSR_S)) {
-+@@ -1096,13 +1121,19 @@ dispatch_instruction(sregs)
-+ ((rs1 ^ operand2) & 0xfffff000);
-+ break;
-+ case WRY:
-+- if (!sparclite)
-++ if ((!sparclite) && (cputype != CPU_LEON3))
-+ sregs->y = (rs1 ^ operand2);
-+ else {
-+ if ( 0 == rd )
-+ sregs->y = (rs1 ^ operand2);
-+- else if ( 17 == rd )
-+- sregs->asr17 = (rs1 ^ operand2);
-++ else if ( 17 == rd ) {
-++ if (sparclite)
-++ sregs->asr17 = (rs1 ^ operand2);
-++ }
-++ else if ( 19 == rd ) {
-++ if (cputype == CPU_LEON3)
-++ wait_for_irq();
-++ }
-+ else {
-+ sregs->trap = TRAP_UNIMP;
-+ break;
-+@@ -1202,6 +1233,32 @@ dispatch_instruction(sregs)
-+ switch (op3) {
-+ case LDDA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x7) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ if (rd & 1) {
-++ rd &= 0x1e;
-++ if (rd > 7)
-++ rdd = &(sregs->r[(cwp + rd) & 0x7f]);
-++ else
-++ rdd = &(sregs->g[rd]);
-++ }
-++ mexc = ms->memory_read_asi(asi, address, ddata, 2, &ws);
-++ sregs->hold += ws;
-++ mexc |= ms->memory_read_asi(asi, address+4, &ddata[1], 2, &ws);
-++ sregs->hold += ws;
-++ sregs->icnt = T_LDD;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ } else {
-++ rdd[0] = ddata[0];
-++ rdd[1] = ddata[1];
-++#ifdef STAT
-++ sregs->nload++; /* Double load counts twice */
-++#endif
-++ }
-++ break;
-+ case LDD:
-+ if (address & 0x7) {
-+ sregs->trap = TRAP_UNALI;
-+@@ -1214,8 +1271,10 @@ dispatch_instruction(sregs)
-+ else
-+ rdd = &(sregs->g[rd]);
-+ }
-+- mexc = memory_read(asi, address, ddata, 3, &ws);
-+- sregs->hold += ws * 2;
-++ mexc = ms->memory_read(address, ddata, 2, &ws);
-++ sregs->hold += ws;
-++ mexc |= ms->memory_read(address+4, &ddata[1], 2, &ws);
-++ sregs->hold += ws;
-+ sregs->icnt = T_LDD;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1230,12 +1289,24 @@ dispatch_instruction(sregs)
-+
-+ case LDA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x3) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ mexc = ms->memory_read_asi(asi, address, &data, 2, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ } else {
-++ *rdd = data;
-++ }
-++ break;
-+ case LD:
-+ if (address & 0x3) {
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_read(asi, address, &data, 2, &ws);
-++ mexc = ms->memory_read(address, &data, 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1245,17 +1316,37 @@ dispatch_instruction(sregs)
-+ break;
-+ case LDSTUBA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ mexc = ms->memory_read_asi(asi, address, &data, 0, &ws);
-++ sregs->hold += ws;
-++ sregs->icnt = T_LDST;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ }
-++ data = extract_byte(data, address);
-++ *rdd = data;
-++ data = 0x0ff;
-++ mexc = ms->memory_write_asi(asi, address, &data, 0, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ }
-++#ifdef STAT
-++ sregs->nload++;
-++#endif
-++ break;
-+ case LDSTUB:
-+- mexc = memory_read(asi, address, &data, 0, &ws);
-++ mexc = ms->memory_read(address, &data, 0, &ws);
-+ sregs->hold += ws;
-+ sregs->icnt = T_LDST;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+ break;
-+ }
-++ data = extract_byte(data, address);
-+ *rdd = data;
-+ data = 0x0ff;
-+- mexc = memory_write(asi, address, &data, 0, &ws);
-++ mexc = ms->memory_write(address, &data, 0, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1267,35 +1358,67 @@ dispatch_instruction(sregs)
-+ case LDSBA:
-+ case LDUBA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ mexc = ms->memory_read_asi(asi, address, &data, 0, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ }
-++ if (op3 == LDSB)
-++ data = extract_byte_signed(data, address);
-++ else
-++ data = extract_byte(data, address);
-++ *rdd = data;
-++ break;
-+ case LDSB:
-+ case LDUB:
-+- mexc = memory_read(asi, address, &data, 0, &ws);
-++ mexc = ms->memory_read(address, &data, 0, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+ break;
-+ }
-+- if ((op3 == LDSB) && (data & 0x80))
-+- data |= 0xffffff00;
-++ if (op3 == LDSB)
-++ data = extract_byte_signed(data, address);
-++ else
-++ data = extract_byte(data, address);
-+ *rdd = data;
-+ break;
-+ case LDSHA:
-+ case LDUHA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x1) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ mexc = ms->memory_read_asi(asi, address, &data, 1, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ }
-++ if (op3 == LDSH)
-++ data = extract_short_signed(data, address);
-++ else
-++ data = extract_short(data, address);
-++ *rdd = data;
-++ break;
-+ case LDSH:
-+ case LDUH:
-+ if (address & 0x1) {
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_read(asi, address, &data, 1, &ws);
-++ mexc = ms->memory_read(address, &data, 1, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+ break;
-+ }
-+- if ((op3 == LDSH) && (data & 0x8000))
-+- data |= 0xffff0000;
-++ if (op3 == LDSH)
-++ data = extract_short_signed(data, address);
-++ else
-++ data = extract_short(data, address);
-+ *rdd = data;
-+ break;
-+ case LDF:
-+@@ -1312,7 +1435,7 @@ dispatch_instruction(sregs)
-+ (sregs->frs2 == rd))
-+ sregs->fhold += (sregs->ftime - ebase.simtime);
-+ }
-+- mexc = memory_read(asi, address, &data, 2, &ws);
-++ mexc = ms->memory_read(address, &data, 2, &ws);
-+ sregs->hold += ws;
-+ sregs->flrd = rd;
-+ sregs->ltime = ebase.simtime + sregs->icnt + FLSTHOLD +
-+@@ -1338,8 +1461,10 @@ dispatch_instruction(sregs)
-+ ((sregs->frs2 >> 1) == (rd >> 1)))
-+ sregs->fhold += (sregs->ftime - ebase.simtime);
-+ }
-+- mexc = memory_read(asi, address, ddata, 3, &ws);
-+- sregs->hold += ws * 2;
-++ mexc = ms->memory_read(address, ddata, 2, &ws);
-++ sregs->hold += ws;
-++ mexc |= ms->memory_read(address+4, &ddata[1], 2, &ws);
-++ sregs->hold += ws;
-+ sregs->icnt = T_LDD;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1367,7 +1492,7 @@ dispatch_instruction(sregs)
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_read(asi, address, &data, 2, &ws);
-++ mexc = ms->memory_read(address, &data, 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1389,7 +1514,7 @@ dispatch_instruction(sregs)
-+ if (ebase.simtime < sregs->ftime) {
-+ sregs->fhold += (sregs->ftime - ebase.simtime);
-+ }
-+- mexc = memory_write(asi, address, &sregs->fsr, 2, &ws);
-++ mexc = ms->memory_write(address, &sregs->fsr, 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1398,12 +1523,22 @@ dispatch_instruction(sregs)
-+
-+ case STA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x3) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ mexc = ms->memory_write_asi(asi, address, rdd, 2, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ }
-++ break;
-+ case ST:
-+ if (address & 0x3) {
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_write(asi, address, rdd, 2, &ws);
-++ mexc = ms->memory_write(address, rdd, 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1411,8 +1546,14 @@ dispatch_instruction(sregs)
-+ break;
-+ case STBA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ mexc = ms->memory_write_asi(asi, address, rdd, 0, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ }
-++ break;
-+ case STB:
-+- mexc = memory_write(asi, address, rdd, 0, &ws);
-++ mexc = ms->memory_write(address, rdd, 0, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1420,6 +1561,28 @@ dispatch_instruction(sregs)
-+ break;
-+ case STDA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x7) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ if (rd & 1) {
-++ rd &= 0x1e;
-++ if (rd > 7)
-++ rdd = &(sregs->r[(cwp + rd) & 0x7f]);
-++ else
-++ rdd = &(sregs->g[rd]);
-++ }
-++ mexc = ms->memory_write_asi(asi, address, rdd, 3, &ws);
-++ sregs->hold += ws;
-++ sregs->icnt = T_STD;
-++#ifdef STAT
-++ sregs->nstore++; /* Double store counts twice */
-++#endif
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ }
-++ break;
-+ case STD:
-+ if (address & 0x7) {
-+ sregs->trap = TRAP_UNALI;
-+@@ -1432,7 +1595,7 @@ dispatch_instruction(sregs)
-+ else
-+ rdd = &(sregs->g[rd]);
-+ }
-+- mexc = memory_write(asi, address, rdd, 3, &ws);
-++ mexc = ms->memory_write(address, rdd, 3, &ws);
-+ sregs->hold += ws;
-+ sregs->icnt = T_STD;
-+ #ifdef STAT
-+@@ -1461,7 +1624,7 @@ dispatch_instruction(sregs)
-+ break;
-+ }
-+ rdd = &(sregs->fpq[0]);
-+- mexc = memory_write(asi, address, rdd, 3, &ws);
-++ mexc = ms->memory_write(address, rdd, 3, &ws);
-+ sregs->hold += ws;
-+ sregs->icnt = T_STD;
-+ #ifdef STAT
-+@@ -1477,12 +1640,22 @@ dispatch_instruction(sregs)
-+ break;
-+ case STHA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x1) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ mexc = ms->memory_write_asi(asi, address, rdd, 1, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ }
-++ break;
-+ case STH:
-+ if (address & 0x1) {
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_write(asi, address, rdd, 1, &ws);
-++ mexc = ms->memory_write(address, rdd, 1, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1501,7 +1674,7 @@ dispatch_instruction(sregs)
-+ if (sregs->frd == rd)
-+ sregs->fhold += (sregs->ftime - ebase.simtime);
-+ }
-+- mexc = memory_write(asi, address, &sregs->fsi[rd], 2, &ws);
-++ mexc = ms->memory_write(address, &sregs->fsi[rd], 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+@@ -1521,7 +1694,7 @@ dispatch_instruction(sregs)
-+ if ((sregs->frd == rd) || (sregs->frd + 1 == rd))
-+ sregs->fhold += (sregs->ftime - ebase.simtime);
-+ }
-+- mexc = memory_write(asi, address, &sregs->fsi[rd], 3, &ws);
-++ mexc = ms->memory_write(address, &sregs->fsi[rd], 3, &ws);
-+ sregs->hold += ws;
-+ sregs->icnt = T_STD;
-+ #ifdef STAT
-+@@ -1533,18 +1706,40 @@ dispatch_instruction(sregs)
-+ break;
-+ case SWAPA:
-+ if (!chk_asi(sregs, &asi, op3)) break;
-++ if (address & 0x3) {
-++ sregs->trap = TRAP_UNALI;
-++ break;
-++ }
-++ mexc = ms->memory_read_asi(asi, address, &data, 2, &ws);
-++ sregs->hold += ws;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ }
-++ mexc = ms->memory_write_asi(asi, address, rdd, 2, &ws);
-++ sregs->hold += ws;
-++ sregs->icnt = T_LDST;
-++ if (mexc) {
-++ sregs->trap = TRAP_DEXC;
-++ break;
-++ } else
-++ *rdd = data;
-++#ifdef STAT
-++ sregs->nload++;
-++#endif
-++ break;
-+ case SWAP:
-+ if (address & 0x3) {
-+ sregs->trap = TRAP_UNALI;
-+ break;
-+ }
-+- mexc = memory_read(asi, address, &data, 2, &ws);
-++ mexc = ms->memory_read(address, &data, 2, &ws);
-+ sregs->hold += ws;
-+ if (mexc) {
-+ sregs->trap = TRAP_DEXC;
-+ break;
-+ }
-+- mexc = memory_write(asi, address, rdd, 2, &ws);
-++ mexc = ms->memory_write(address, rdd, 2, &ws);
-+ sregs->hold += ws;
-+ sregs->icnt = T_LDST;
-+ if (mexc) {
-+@@ -1696,7 +1891,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
-+ but what about machines where float values are different endianness
-+ from integer values? */
-+
-+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
-++#ifdef HOST_LITTLE_ENDIAN
-+ rs1 &= 0x1f;
-+ switch (opf) {
-+ case FADDd:
-+@@ -1780,7 +1975,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
-+ sregs->ftime += T_FDIVd;
-+ break;
-+ case FMOVs:
-+- sregs->fs[rd] = sregs->fs[rs2];
-++ sregs->fsi[rd] = sregs->fsi[rs2];
-+ sregs->ftime += T_FMOVs;
-+ sregs->frs1 = 32; /* rs1 ignored */
-+ break;
-+@@ -1874,7 +2069,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
-+
-+ accex = get_accex();
-+
-+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
-++#ifdef HOST_LITTLE_ENDIAN
-+ switch (opf) {
-+ case FADDd:
-+ case FDIVd:
-+@@ -1962,7 +2157,7 @@ execute_trap(sregs)
-+ sregs->pc = sregs->tbr;
-+ sregs->npc = sregs->tbr + 4;
-+
-+- if ( 0 != (1 & sregs->asr17) ) {
-++ if ( 0 != (1 & (sregs->asr17 >> 13)) ) {
-+ /* single vector trapping! */
-+ sregs->pc = sregs->tbr & 0xfffff000;
-+ sregs->npc = sregs->pc + 4;
-+@@ -1978,8 +2173,6 @@ execute_trap(sregs)
-+
-+ }
-+
-+-extern struct irqcell irqarr[16];
-+-
-+ int
-+ check_interrupts(sregs)
-+ struct pstate *sregs;
-+@@ -2011,7 +2204,13 @@ init_regs(sregs)
-+ sregs->npc = 4;
-+ sregs->trap = 0;
-+ sregs->psr &= 0x00f03fdf;
-+- sregs->psr |= 0x080; /* Set supervisor bit */
-++ if (cputype == CPU_LEON3)
-++ sregs->psr |= 0xF3000080; /* Set supervisor bit */
-++ else
-++ if (cputype == CPU_LEON2)
-++ sregs->psr |= 0x00000080; /* Set supervisor bit */
-++ else
-++ sregs->psr |= 0x11000080; /* Set supervisor bit */
-+ sregs->breakpoint = 0;
-+ sregs->annul = 0;
-+ sregs->fpstate = FP_EXE_MODE;
-+@@ -2021,7 +2220,7 @@ init_regs(sregs)
-+ sregs->err_mode = 0;
-+ ext_irl = 0;
-+ sregs->g[0] = 0;
-+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
-++#ifdef HOST_LITTLE_ENDIAN
-+ sregs->fdp = (float32 *) sregs->fd;
-+ sregs->fsi = (int32 *) sregs->fs;
-+ #else
-+@@ -2040,4 +2239,8 @@ init_regs(sregs)
-+
-+ sregs->rett_err = 0;
-+ sregs->jmpltime = 0;
-++ if (cputype == CPU_LEON3) {
-++ sregs->asr17 = 0x107;
-++ if (!nfp) sregs->asr17 |= (3 << 10); /* Meiko FPU */
-++ }
-+ }
-+diff --git a/sim/erc32/float.c b/sim/erc32/float.c
-+index 598b7cc..ce92a39 100644
-+--- a/sim/erc32/float.c
-++++ b/sim/erc32/float.c
-+@@ -38,7 +38,6 @@
-+
-+ extern uint32 _get_sw (void);
-+ extern uint32 _get_cw (void);
-+-static void __setfpucw (unsigned short fpu_control);
-+
-+ /* This host dependent routine should return the accrued exceptions */
-+ int
-+@@ -46,7 +45,7 @@ get_accex()
-+ {
-+ #ifdef sparc
-+ return ((_get_fsr_raw() >> 5) & 0x1F);
-+-#elif i386
-++#elif defined(i386) || defined(__x86_64__)
-+ uint32 accx;
-+
-+ accx = _get_sw() & 0x3f;
-+@@ -66,7 +65,7 @@ clear_accex()
-+ {
-+ #ifdef sparc
-+ set_fsr((_get_fsr_raw() & ~0x3e0));
-+-#elif i386
-++#elif defined(i386) || defined(__x86_64__)
-+ asm("\n"
-+ ".text\n"
-+ " fnclex\n"
-+@@ -84,9 +83,8 @@ uint32 fsr;
-+ {
-+ #ifdef sparc
-+ _set_fsr_raw(fsr & ~0x0f800000);
-+-#elif i386
-+- void __setfpucw(unsigned short fpu_control);
-+- uint32 rawfsr;
-++#elif defined(i386) || defined(__x86_64__)
-++ unsigned short rawfsr;
-+
-+ fsr >>= 30;
-+ switch (fsr) {
-+@@ -102,9 +100,8 @@ uint32 fsr;
-+ fsr = 1;
-+ break;
++
+
+ ac_sources="$sim_link_files"
+ ac_dests="$sim_link_links"
+@@ -13110,10 +13374,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ :end' >>confcache
+ if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+- test "x$cache_file" != "x/dev/null" &&
++ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+ $as_echo "$as_me: updating cache $cache_file" >&6;}
+- cat confcache >$cache_file
++ if test ! -f "$cache_file" || test -h "$cache_file"; then
++ cat confcache >"$cache_file"
++ else
++ case $cache_file in #(
++ */* | ?:*)
++ mv -f confcache "$cache_file"$$ &&
++ mv -f "$cache_file"$$ "$cache_file" ;; #(
++ *)
++ mv -f confcache "$cache_file" ;;
++ esac
++ fi
++ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+@@ -13129,6 +13404,7 @@ DEFS=-DHAVE_CONFIG_H
+
+ ac_libobjs=
+ ac_ltlibobjs=
++U=
+ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+@@ -13144,19 +13420,20 @@ LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -z "${GMAKE_TRUE}" && test -z "${GMAKE_FALSE}"; then
+- as_fn_error "conditional \"GMAKE\" was never defined.
++ as_fn_error $? "conditional \"GMAKE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
+ if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+- as_fn_error "conditional \"PLUGINS\" was never defined.
++ as_fn_error $? "conditional \"PLUGINS\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
+ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+- as_fn_error "conditional \"MAINTAINER_MODE\" was never defined.
++ as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
+
+-: ${CONFIG_STATUS=./config.status}
++
++: "${CONFIG_STATUS=./config.status}"
+ ac_write_fail=0
+ ac_clean_files_save=$ac_clean_files
+ ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+@@ -13257,6 +13534,7 @@ fi
+ IFS=" "" $as_nl"
+
+ # Find who we are. Look in the path if we contain no directory separator.
++as_myself=
+ case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+@@ -13302,19 +13580,19 @@ export LANGUAGE
+ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+-# as_fn_error ERROR [LINENO LOG_FD]
+-# ---------------------------------
++# as_fn_error STATUS ERROR [LINENO LOG_FD]
++# ----------------------------------------
+ # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+ # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+-# script with status $?, using 1 if that was 0.
++# script with STATUS, using 1 if that was 0.
+ as_fn_error ()
+ {
+- as_status=$?; test $as_status -eq 0 && as_status=1
+- if test "$3"; then
+- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
++ as_status=$1; test $as_status -eq 0 && as_status=1
++ if test "$4"; then
++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+- $as_echo "$as_me: error: $1" >&2
++ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+ } # as_fn_error
+
+@@ -13452,16 +13730,16 @@ if (echo >conf$$.file) 2>/dev/null; then
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+- # In both cases, we have to default to `cp -p'.
++ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ fi
+ else
+- as_ln_s='cp -p'
++ as_ln_s='cp -pR'
+ fi
+ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+ rmdir conf$$.dir 2>/dev/null
+@@ -13510,7 +13788,7 @@ $as_echo X"$as_dir" |
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+ } # as_fn_mkdir_p
+@@ -13521,28 +13799,16 @@ else
+ as_mkdir_p=false
+ fi
+
+-if test -x / >/dev/null 2>&1; then
+- as_test_x='test -x'
+-else
+- if ls -dL / >/dev/null 2>&1; then
+- as_ls_L_option=L
+- else
+- as_ls_L_option=
+- fi
+- as_test_x='
+- eval sh -c '\''
+- if test -d "$1"; then
+- test -d "$1/.";
+- else
+- case $1 in #(
+- -*)set "./$1";;
+- esac;
+- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+- ???[sx]*):;;*)false;;esac;fi
+- '\'' sh
+- '
+-fi
+-as_executable_p=$as_test_x
++
++# as_fn_executable_p FILE
++# -----------------------
++# Test if FILE is an executable regular file.
++as_fn_executable_p ()
++{
++ test -f "$1" && test -x "$1"
++} # as_fn_executable_p
++as_test_x='test -x'
++as_executable_p=as_fn_executable_p
+
+ # Sed expression to map a string onto a valid CPP name.
+ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+@@ -13564,7 +13830,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ # values after options handling.
+ ac_log="
+ This file was extended by $as_me, which was
+-generated by GNU Autoconf 2.64. Invocation command line was
++generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+@@ -13605,6 +13871,7 @@ Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
++ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+@@ -13630,12 +13897,13 @@ Report bugs to the package provider."
+
+ _ACEOF
+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
++ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ ac_cs_version="\\
+ config.status
+-configured by $0, generated by GNU Autoconf 2.64,
+- with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
++configured by $0, generated by GNU Autoconf 2.69,
++ with options \\"\$ac_cs_config\\"
+
+-Copyright (C) 2009 Free Software Foundation, Inc.
++Copyright (C) 2012 Free Software Foundation, Inc.
+ This config.status script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it."
+
+@@ -13652,11 +13920,16 @@ ac_need_defaults=:
+ while test $# != 0
+ do
+ case $1 in
+- --*=*)
++ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
++ --*=)
++ ac_option=`expr "X$1" : 'X\([^=]*\)='`
++ ac_optarg=
++ ac_shift=:
++ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+@@ -13670,12 +13943,15 @@ do
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
++ --config | --confi | --conf | --con | --co | --c )
++ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
++ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+@@ -13688,7 +13964,7 @@ do
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+- as_fn_error "ambiguous option: \`$1'
++ as_fn_error $? "ambiguous option: \`$1'
+ Try \`$0 --help' for more information.";;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+@@ -13697,7 +13973,7 @@ Try \`$0 --help' for more information.";;
+ ac_cs_silent=: ;;
+
+ # This is an error.
+- -*) as_fn_error "unrecognized option: \`$1'
++ -*) as_fn_error $? "unrecognized option: \`$1'
+ Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+@@ -13717,7 +13993,7 @@ fi
+ _ACEOF
+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ if \$ac_cs_recheck; then
+- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
++ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+@@ -14021,7 +14297,7 @@ do
+ "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+ "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
+
+- *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
++ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+ done
+
+@@ -14045,9 +14321,10 @@ fi
+ # after its creation but before its name has been assigned to `$tmp'.
+ $debug ||
+ {
+- tmp=
++ tmp= ac_tmp=
+ trap 'exit_status=$?
+- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
++ : "${ac_tmp:=$tmp}"
++ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+ ' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+ }
+@@ -14055,12 +14332,13 @@ $debug ||
+
+ {
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+- test -n "$tmp" && test -d "$tmp"
++ test -d "$tmp"
+ } ||
+ {
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
++} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
++ac_tmp=$tmp
+
+ # Set up the scripts for CONFIG_FILES section.
+ # No need to generate them if there are no CONFIG_FILES.
+@@ -14077,12 +14355,12 @@ if test "x$ac_cr" = x; then
+ fi
+ ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+ if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+- ac_cs_awk_cr='\r'
++ ac_cs_awk_cr='\\r'
+ else
+ ac_cs_awk_cr=$ac_cr
+ fi
+
+-echo 'BEGIN {' >"$tmp/subs1.awk" &&
++echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+ _ACEOF
+
+
+@@ -14091,18 +14369,18 @@ _ACEOF
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+ } >conf$$subs.sh ||
+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
++ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ ac_delim='%!_!# '
+ for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+@@ -14110,7 +14388,7 @@ done
+ rm -f conf$$subs.sh
+
+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
++cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+ _ACEOF
+ sed -n '
+ h
+@@ -14124,7 +14402,7 @@ s/'"$ac_delim"'$//
+ t delim
+ :nl
+ h
+-s/\(.\{148\}\).*/\1/
++s/\(.\{148\}\)..*/\1/
+ t more1
+ s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+ p
+@@ -14138,7 +14416,7 @@ s/.\{148\}//
+ t nl
+ :delim
+ h
+-s/\(.\{148\}\).*/\1/
++s/\(.\{148\}\)..*/\1/
+ t more2
+ s/["\\]/\\&/g; s/^/"/; s/$/"/
+ p
+@@ -14158,7 +14436,7 @@ t delim
+ rm -f conf$$subs.awk
+ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ _ACAWK
+-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
++cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+@@ -14190,21 +14468,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+ else
+ cat
+-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+- || as_fn_error "could not setup config files machinery" "$LINENO" 5
++fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
++ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+ _ACEOF
+
+-# VPATH may cause trouble with some makes, so we remove $(srcdir),
+-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
++# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
++# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+ # trailing colons and then remove the whole line if VPATH becomes empty
+ # (actually we leave an empty line to preserve line numbers).
+ if test "x$srcdir" = x.; then
+- ac_vpsub='/^[ ]*VPATH[ ]*=/{
+-s/:*\$(srcdir):*/:/
+-s/:*\${srcdir}:*/:/
+-s/:*@srcdir@:*/:/
+-s/^\([^=]*=[ ]*\):*/\1/
++ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
++h
++s///
++s/^/:/
++s/[ ]*$/:/
++s/:\$(srcdir):/:/g
++s/:\${srcdir}:/:/g
++s/:@srcdir@:/:/g
++s/^:*//
+ s/:*$//
++x
++s/\(=[ ]*\).*/\1/
++G
++s/\n//
+ s/^[^=]*=[ ]*$//
+ }'
+ fi
+@@ -14216,7 +14502,7 @@ fi # test -n "$CONFIG_FILES"
+ # No need to generate them if there are no CONFIG_HEADERS.
+ # This happens for instance with `./config.status Makefile'.
+ if test -n "$CONFIG_HEADERS"; then
+-cat >"$tmp/defines.awk" <<\_ACAWK ||
++cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
+@@ -14228,11 +14514,11 @@ _ACEOF
+ # handling of long lines.
+ ac_delim='%!_!# '
+ for ac_last_try in false false :; do
+- ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+- if test -z "$ac_t"; then
++ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
++ if test -z "$ac_tt"; then
+ break
+ elif $ac_last_try; then
+- as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
++ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+@@ -14317,7 +14603,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ _ACAWK
+ _ACEOF
+ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+- as_fn_error "could not setup config headers machinery" "$LINENO" 5
++ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+ fi # test -n "$CONFIG_HEADERS"
+
+
+@@ -14330,7 +14616,7 @@ do
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+- :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
++ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+@@ -14349,7 +14635,7 @@ do
+ for ac_f
+ do
+ case $ac_f in
+- -) ac_f="$tmp/stdin";;
++ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+@@ -14358,7 +14644,7 @@ do
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+- as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
++ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+@@ -14384,8 +14670,8 @@ $as_echo "$as_me: creating $ac_file" >&6;}
+ esac
+
+ case $ac_tag in
+- *:-:* | *:-) cat >"$tmp/stdin" \
+- || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
++ *:-:* | *:-) cat >"$ac_tmp/stdin" \
++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+@@ -14515,23 +14801,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+ s&@INSTALL@&$ac_INSTALL&;t t
+ $ac_datarootdir_hack
+ "
+-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+- || as_fn_error "could not create $ac_file" "$LINENO" 5
++eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
++ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
++ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
++ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
++ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+-which seems to be undefined. Please make sure it is defined." >&5
++which seems to be undefined. Please make sure it is defined" >&5
+ $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+-which seems to be undefined. Please make sure it is defined." >&2;}
++which seems to be undefined. Please make sure it is defined" >&2;}
+
+- rm -f "$tmp/stdin"
++ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+- -) cat "$tmp/out" && rm -f "$tmp/out";;
+- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
++ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
++ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+- || as_fn_error "could not create $ac_file" "$LINENO" 5
++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+ :H)
+ #
+@@ -14540,21 +14827,21 @@ which seems to be undefined. Please make sure it is defined." >&2;}
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+- } >"$tmp/config.h" \
+- || as_fn_error "could not create $ac_file" "$LINENO" 5
+- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
++ } >"$ac_tmp/config.h" \
++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
++ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+ $as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+- mv "$tmp/config.h" "$ac_file" \
+- || as_fn_error "could not create $ac_file" "$LINENO" 5
++ mv "$ac_tmp/config.h" "$ac_file" \
++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+- || as_fn_error "could not create -" "$LINENO" 5
++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
++ || as_fn_error $? "could not create -" "$LINENO" 5
+ fi
+ ;;
+ :L)
+@@ -14574,19 +14861,19 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;}
+ $as_echo "$as_me: linking $ac_source to $ac_file" >&6;}
+
+ if test ! -r "$ac_source"; then
+- as_fn_error "$ac_source: file not found" "$LINENO" 5
++ as_fn_error $? "$ac_source: file not found" "$LINENO" 5
+ fi
+ rm -f "$ac_file"
+
+ # Try a relative symlink, then a hard link, then a copy.
+- case $srcdir in
++ case $ac_source in
+ [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;;
+ *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
+ esac
+ ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
+ ln "$ac_source" "$ac_file" 2>/dev/null ||
+ cp -p "$ac_source" "$ac_file" ||
+- as_fn_error "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
++ as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
+ fi
+ ;;
+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+@@ -15256,7 +15543,7 @@ _ACEOF
+ ac_clean_files=$ac_clean_files_save
+
+ test $ac_write_fail = 0 ||
+- as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
++ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+ # configure is writing to config.log, and then calls config.status.
+@@ -15277,7 +15564,7 @@ if test "$no_create" != yes; then
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+- $ac_cs_success || as_fn_exit $?
++ $ac_cs_success || as_fn_exit 1
+ fi
+ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+diff --git a/sim/erc32/configure.ac b/sim/erc32/configure.ac
+index bc46091..1646cc5 100644
+--- a/sim/erc32/configure.ac
++++ b/sim/erc32/configure.ac
+@@ -32,4 +32,5 @@ else
+ AC_ERROR([the required "readline" library is missing]), $TERMCAP)
+ fi
+ AC_SUBST(READLINE)
++AC_C_BIGENDIAN
+ SIM_AC_OUTPUT
+diff --git a/sim/erc32/end.c b/sim/erc32/end.c
+deleted file mode 100644
+index 9337198..0000000
+--- a/sim/erc32/end.c
++++ /dev/null
+@@ -1,27 +0,0 @@
+-#include "config.h"
+-#include <stdio.h>
+-
+-int
+-main()
+-{
+-
+- unsigned int u1;
+- char *c;
+- double d1;
+- float *f1;
+-
+- c = (char *) &u1;
+- u1 = 0x0F;
+- if (c[0] == 0x0F)
+- puts("#define HOST_LITTLE_ENDIAN\n");
+- else
+- puts("#define HOST_BIG_ENDIAN\n");
+-
+- d1 = 1.0;
+- f1 = (float *) &d1;
+- if (*((int *) f1) != 0x3ff00000)
+- puts("#define HOST_LITTLE_ENDIAN_FLOAT\n");
+- else
+- puts("#define HOST_BIG_ENDIAN_FLOAT\n");
+- return 0;
+-}
+diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
+index 4d4177e..0846bab 100644
+--- a/sim/erc32/erc32.c
++++ b/sim/erc32/erc32.c
+@@ -22,6 +22,7 @@
+ /* The control space devices */
+
+ #include "config.h"
++#include <errno.h>
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include <string.h>
+@@ -30,16 +31,9 @@
+ #include <sys/file.h>
+ #include <unistd.h>
+ #include "sis.h"
+-#include "end.h"
+ #include "sim-config.h"
+
+-extern int ctrl_c;
+-extern int32 sis_verbose;
+-extern int32 sparclite, sparclite_board;
+-extern int rom8,wrp,uben;
+-extern char uart_dev1[], uart_dev2[];
+-
+-int dumbio = 0; /* normal, smart, terminal oriented IO by default */
++static int tty_setup = 1; /* default setup if not a tty */
+
+ /* MEC registers */
+ #define MEC_START 0x01f80000
+@@ -55,11 +49,6 @@ int dumbio = 0; /* normal, smart, terminal oriented IO by default */
+ extern int errmec;
+ #endif
+
+-/* The target's byte order is big-endian by default until we load a
+- little-endian program. */
+-
+-int current_target_byte_order = BIG_ENDIAN;
+-
+ #define MEC_WS 0 /* Waitstates per MEC access (0 ws) */
+ #define MOK 0
+
+@@ -297,26 +286,24 @@ static void gpt_reload_set (uint32 val);
+ static void timer_ctrl (uint32 val);
+ static unsigned char *
+ get_mem_ptr (uint32 addr, uint32 size);
++static void store_bytes (unsigned char *mem, uint32 waddr,
++ uint32 *data, int sz, int32 *ws);
+
+-static void fetch_bytes (int asi, unsigned char *mem,
+- uint32 *data, int sz);
+-
+-static void store_bytes (unsigned char *mem, uint32 *data, int sz);
+-
+-extern int ext_irl;
++static host_callback *callback;
+
+
+ /* One-time init */
+
+-void
++static void
+ init_sim()
+ {
++ callback = sim_callback;
+ port_init();
+ }
+
+ /* Power-on reset init */
+
+-void
++static void
+ reset()
+ {
+ mec_reset();
+@@ -396,7 +383,7 @@ mecparerror()
+
+ /* IU error mode manager */
+
+-void
++static void
+ error_mode(pc)
+ uint32 pc;
+ {
+@@ -467,7 +454,7 @@ decode_mcr()
+
+ /* Flush ports when simulator stops */
+
+-void
++static void
+ sim_halt()
+ {
+ #ifdef FAST_UART
+@@ -475,13 +462,6 @@ sim_halt()
+ #endif
+ }
+
+-int
+-sim_stop(SIM_DESC sd)
+-{
+- ctrl_c = 1;
+- return 1;
+-}
+-
+ static void
+ close_port()
+ {
+@@ -491,7 +471,7 @@ close_port()
+ fclose(f2in);
+ }
+
+-void
++static void
+ exit_sim()
+ {
+ close_port();
+@@ -743,6 +723,14 @@ mec_read(addr, asi, data)
+ *data = read_uart(addr);
+ break;
+
++ case 0xF4: /* simulator RAM size in bytes */
++ *data = 4096*1024;
++ break;
++
++ case 0xF8: /* simulator ROM size in bytes */
++ *data = 1024*1024;
++ break;
++
+ default:
+ set_sfsr(MEC_ACC, addr, asi, 1);
+ return (1);
+@@ -935,32 +923,38 @@ mec_write(addr, data)
+
+ static int ifd1 = -1, ifd2 = -1, ofd1 = -1, ofd2 = -1;
+
+-void
++static void
+ init_stdio()
+ {
+ if (dumbio)
+ return; /* do nothing */
+- if (!ifd1)
++ if (ifd1 == 0 && f1open) {
+ tcsetattr(0, TCSANOW, &ioc1);
+- if (!ifd2)
++ tcflush(ifd1, TCIFLUSH);
++ }
++ if (ifd2 == 0 && f1open) {
+ tcsetattr(0, TCSANOW, &ioc2);
++ tcflush(ifd2, TCIFLUSH);
++ }
+ }
+
+-void
++static void
+ restore_stdio()
+ {
+ if (dumbio)
+ return; /* do nothing */
+- if (!ifd1)
++ if (ifd1 == 0 && f1open && tty_setup)
+ tcsetattr(0, TCSANOW, &iocold1);
+- if (!ifd2)
++ if (ifd2 == 0 && f2open && tty_setup)
+ tcsetattr(0, TCSANOW, &iocold2);
+ }
+
+ #define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
+- ( dumbio \
++ ( dumbio || nouartrx \
+ ? (0) /* no bytes read, no delay */ \
+- : read( _fd_, _buf_, _len_ ) )
++ : (_fd_) == 1 && callback ? \
++ callback->read_stdin (callback, _buf_, _len_) : \
++ read( _fd_, _buf_, _len_ ) )
+
+
+ static void
+@@ -990,21 +984,26 @@ port_init()
+ }
+ if (f1in) ifd1 = fileno(f1in);
+ if (ifd1 == 0) {
++ if (callback && !callback->isatty(callback, ifd1)) {
++ tty_setup = 0;
++ }
+ if (sis_verbose)
+ printf("serial port A on stdin/stdout\n");
+ if (!dumbio) {
+ tcgetattr(ifd1, &ioc1);
++ if (tty_setup) {
+ iocold1 = ioc1;
+ ioc1.c_lflag &= ~(ICANON | ECHO);
+ ioc1.c_cc[VMIN] = 0;
+ ioc1.c_cc[VTIME] = 0;
+ }
++ }
+ f1open = 1;
+ }
+
+ if (f1out) {
+ ofd1 = fileno(f1out);
+- if (!dumbio && ofd1 == 1) setbuf(f1out, NULL);
++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
+ }
+
+ if (uart_dev2[0] != 0)
+@@ -1023,17 +1022,19 @@ port_init()
+ printf("serial port B on stdin/stdout\n");
+ if (!dumbio) {
+ tcgetattr(ifd2, &ioc2);
++ if (tty_setup) {
+ iocold2 = ioc2;
+ ioc2.c_lflag &= ~(ICANON | ECHO);
+ ioc2.c_cc[VMIN] = 0;
+ ioc2.c_cc[VTIME] = 0;
+ }
++ }
+ f2open = 1;
+ }
+
+ if (f2out) {
+ ofd2 = fileno(f2out);
+- if (!dumbio && ofd2 == 1) setbuf(f2out, NULL);
++ if (!dumbio && tty_setup && ofd2 == 1) setbuf(f2out, NULL);
+ }
+
+ wnuma = wnumb = 0;
+@@ -1062,6 +1063,9 @@ read_uart(addr)
+ if (f1open) {
+ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
+ }
++ else {
++ anum = 0;
++ }
+ if (anum > 0) {
+ aind = 0;
+ if ((aind + 1) < anum)
+@@ -1094,6 +1098,9 @@ read_uart(addr)
+ if (f2open) {
+ bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
+ }
++ else {
++ bnum = 0;
++ }
+ if (bnum > 0) {
+ bind = 0;
+ if ((bind + 1) < bnum)
+@@ -1126,6 +1133,9 @@ read_uart(addr)
+ if (f1open) {
+ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
+ }
++ else {
++ anum = 0;
++ }
+ if (anum > 0) {
+ Ucontrol |= 0x00000001;
+ aind = 0;
+@@ -1138,6 +1148,9 @@ read_uart(addr)
+ if (f2open) {
+ bnum = DO_STDIO_READ(ifd2, bq, UARTBUF);
+ }
++ else {
++ bnum = 0;
++ }
+ if (bnum > 0) {
+ Ucontrol |= 0x00010000;
+ bind = 0;
+@@ -1178,8 +1191,12 @@ write_uart(addr, data)
+ if (wnuma < UARTBUF)
+ wbufa[wnuma++] = c;
+ else {
+- while (wnuma)
++ while (wnuma) {
++ if (ofd1 == 1 && callback)
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ else
+ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
++ }
+ wbufa[wnuma++] = c;
+ }
+ }
+@@ -1202,8 +1219,12 @@ write_uart(addr, data)
+ if (wnumb < UARTBUF)
+ wbufb[wnumb++] = c;
+ else {
+- while (wnumb)
++ while (wnumb) {
++ if (ofd1 == 1 && callback)
++ wnumb -= callback->write_stdout(callback, wbufb, wnumb);
++ else
+ wnumb -= fwrite(wbufb, 1, wnumb, f2out);
++ }
+ wbufb[wnumb++] = c;
+ }
+ }
+@@ -1241,19 +1262,37 @@ write_uart(addr, data)
+ static void
+ flush_uart()
+ {
+- while (wnuma && f1open)
++ while (wnuma && f1open) {
++ if (ofd1 == 1 && callback) {
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ callback->flush_stdout(callback);
++ }
++ else
+ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
+- while (wnumb && f2open)
++ }
++ while (wnumb && f2open) {
++ if (ofd2 == 1 && callback) {
++ wnuma -= callback->write_stdout(callback, wbufb, wnuma);
++ callback->flush_stdout(callback);
++ }
++ else
+ wnumb -= fwrite(wbufb, 1, wnumb, f2out);
+ }
++}
+
+
+
+ static void
+ uarta_tx()
+ {
+-
+- while (f1open && fwrite(&uarta_sreg, 1, 1, f1out) != 1);
++ while (f1open) {
++ if (ofd1 == 1 && callback) {
++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
++ }
++ else {
++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
++ }
++ }
+ if (uart_stat_reg & UARTA_HRE) {
+ uart_stat_reg |= UARTA_SRE;
+ } else {
+@@ -1267,7 +1306,14 @@ uarta_tx()
+ static void
+ uartb_tx()
+ {
+- while (f2open && fwrite(&uartb_sreg, 1, 1, f2out) != 1);
++ while (f2open) {
++ if (ofd2 == 1 && callback) {
++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
++ }
++ else {
++ while (fwrite(&uartb_sreg, 1, 1, f2out) != 1);
++ }
++ }
+ if (uart_stat_reg & UARTB_HRE) {
+ uart_stat_reg |= UARTB_SRE;
+ } else {
+@@ -1289,6 +1335,8 @@ uart_rx(arg)
+ rsize = 0;
+ if (f1open)
+ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
++ else
++ rsize = 0;
+ if (rsize > 0) {
+ uarta_data = UART_DR | rxd;
+ if (uart_stat_reg & UARTA_HRE)
+@@ -1305,6 +1353,8 @@ uart_rx(arg)
+ rsize = 0;
+ if (f2open)
+ rsize = DO_STDIO_READ(ifd2, &rxd, 1);
++ else
++ rsize = 0;
+ if (rsize) {
+ uartb_data = UART_DR | rxd;
+ if (uart_stat_reg & UARTB_HRE)
+@@ -1517,143 +1567,89 @@ timer_ctrl(val)
+ gpt_start();
+ }
+
+-
+-/* Retrieve data from target memory. MEM points to location from which
+- to read the data; DATA points to words where retrieved data will be
+- stored in host byte order. SZ contains log(2) of the number of bytes
+- to retrieve, and can be 0 (1 byte), 1 (one half-word), 2 (one word),
+- or 3 (two words). */
++/* Store data in host byte order. MEM points to the beginning of the
++ emulated memory; WADDR contains the index the emulated memory,
++ DATA points to words in host byte order to be stored. SZ contains log(2)
++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
+
+ static void
+-fetch_bytes (asi, mem, data, sz)
+- int asi;
++store_bytes (mem, waddr, data, sz, ws)
+ unsigned char *mem;
++ uint32 waddr;
+ uint32 *data;
+- int sz;
++ int32 sz;
++ int32 *ws;
+ {
+- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN
+- || asi == 8 || asi == 9) {
+- switch (sz) {
+- case 3:
+- data[1] = (((uint32) mem[7]) & 0xff) |
+- ((((uint32) mem[6]) & 0xff) << 8) |
+- ((((uint32) mem[5]) & 0xff) << 16) |
+- ((((uint32) mem[4]) & 0xff) << 24);
+- /* Fall through to 2 */
+- case 2:
+- data[0] = (((uint32) mem[3]) & 0xff) |
+- ((((uint32) mem[2]) & 0xff) << 8) |
+- ((((uint32) mem[1]) & 0xff) << 16) |
+- ((((uint32) mem[0]) & 0xff) << 24);
++ switch (sz) {
++ case 0:
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 3;
++#endif
++ mem[waddr] = *data & 0x0ff;
++ *ws = mem_ramw_ws + 3;
+ break;
+ case 1:
+- data[0] = (((uint32) mem[1]) & 0xff) |
+- ((((uint32) mem[0]) & 0xff) << 8);
+- break;
+- case 0:
+- data[0] = mem[0] & 0xff;
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 2;
++#endif
++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
++ *ws = mem_ramw_ws + 3;
+ break;
+-
+- }
+- } else {
+- switch (sz) {
+- case 3:
+- data[1] = ((((uint32) mem[7]) & 0xff) << 24) |
+- ((((uint32) mem[6]) & 0xff) << 16) |
+- ((((uint32) mem[5]) & 0xff) << 8) |
+- (((uint32) mem[4]) & 0xff);
+- /* Fall through to 4 */
+ case 2:
+- data[0] = ((((uint32) mem[3]) & 0xff) << 24) |
+- ((((uint32) mem[2]) & 0xff) << 16) |
+- ((((uint32) mem[1]) & 0xff) << 8) |
+- (((uint32) mem[0]) & 0xff);
+- break;
+- case 1:
+- data[0] = ((((uint32) mem[1]) & 0xff) << 8) |
+- (((uint32) mem[0]) & 0xff);
++ *((uint32 *) &(mem[waddr])) = *data;
++ *ws = mem_ramw_ws;
+ break;
+- case 0:
+- data[0] = mem[0] & 0xff;
++ case 3:
++ *((uint32 *) &(mem[waddr])) = data[0];
++ *((uint32 *) &(mem[waddr + 4])) = data[1];
++ *ws = 2 * mem_ramw_ws + STD_WS;
+ break;
+- }
+ }
+ }
+
+
+-/* Store data in target byte order. MEM points to location to store data;
+- DATA points to words in host byte order to be stored. SZ contains log(2)
+- of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
+- 2 (one word), or 3 (two words). */
++/* Memory emulation */
+
+-static void
+-store_bytes (mem, data, sz)
+- unsigned char *mem;
+- uint32 *data;
+- int sz;
++static int
++memory_iread(addr, data, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 *ws;
+ {
+- if (CURRENT_TARGET_BYTE_ORDER == LITTLE_ENDIAN) {
+- switch (sz) {
+- case 3:
+- mem[7] = (data[1] >> 24) & 0xff;
+- mem[6] = (data[1] >> 16) & 0xff;
+- mem[5] = (data[1] >> 8) & 0xff;
+- mem[4] = data[1] & 0xff;
+- /* Fall through to 2 */
+- case 2:
+- mem[3] = (data[0] >> 24) & 0xff;
+- mem[2] = (data[0] >> 16) & 0xff;
+- /* Fall through to 1 */
+- case 1:
+- mem[1] = (data[0] >> 8) & 0xff;
+- /* Fall through to 0 */
+- case 0:
+- mem[0] = data[0] & 0xff;
+- break;
+- }
+- } else {
+- switch (sz) {
+- case 3:
+- mem[7] = data[1] & 0xff;
+- mem[6] = (data[1] >> 8) & 0xff;
+- mem[5] = (data[1] >> 16) & 0xff;
+- mem[4] = (data[1] >> 24) & 0xff;
+- /* Fall through to 2 */
+- case 2:
+- mem[3] = data[0] & 0xff;
+- mem[2] = (data[0] >> 8) & 0xff;
+- mem[1] = (data[0] >> 16) & 0xff;
+- mem[0] = (data[0] >> 24) & 0xff;
+- break;
+- case 1:
+- mem[1] = data[0] & 0xff;
+- mem[0] = (data[0] >> 8) & 0xff;
+- break;
+- case 0:
+- mem[0] = data[0] & 0xff;
+- break;
+-
+- }
++ uint32 asi;
++ if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
++ *data = *((uint32 *) & (ramb[addr & mem_rammask & ~3]));
++ *ws = mem_ramr_ws;
++ return (0);
++ } else if (addr < mem_romsz) {
++ *data = *((uint32 *) & (romb[addr & ~3]));
++ *ws = mem_romr_ws;
++ return (0);
+ }
+-}
+-
+
+-/* Memory emulation */
++ printf("Memory exception at %x (illegal address)\n", addr);
++ if (sregs.psr & 0x080) asi = 9; else asi = 8;
++ set_sfsr(UIMP_ACC, addr, asi, 1);
++ *ws = MEM_EX_WS;
++ return (1);
++}
+
+-int
+-memory_read(asi, addr, data, sz, ws)
+- int32 asi;
++static int
++memory_read(addr, data, sz, ws)
+ uint32 addr;
+ uint32 *data;
+ int32 sz;
+ int32 *ws;
+ {
+ int32 mexc;
++ int32 asi;
+
+ #ifdef ERRINJ
+ if (errmec) {
+ if (sis_verbose)
+ printf("Inserted MEC error %d\n",errmec);
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ set_sfsr(errmec, addr, asi, 1);
+ if (errmec == 5) mecparerror();
+ if (errmec == 6) iucomperr();
+@@ -1663,10 +1659,11 @@ memory_read(asi, addr, data, sz, ws)
+ #endif
+
+ if ((addr >= mem_ramstart) && (addr < (mem_ramstart + mem_ramsz))) {
+- fetch_bytes (asi, &ramb[addr & mem_rammask], data, sz);
++ *data = *((uint32 *) & (ramb[addr & mem_rammask & ~3]));
+ *ws = mem_ramr_ws;
+ return (0);
+ } else if ((addr >= MEC_START) && (addr < MEC_END)) {
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ mexc = mec_read(addr, asi, data);
+ if (mexc) {
+ set_sfsr(MEC_ACC, addr, asi, 1);
+@@ -1681,7 +1678,7 @@ memory_read(asi, addr, data, sz, ws)
+ } else if (era) {
+ if ((addr < 0x100000) ||
+ ((addr>= 0x80000000) && (addr < 0x80100000))) {
+- fetch_bytes (asi, &romb[addr & ROM_MASK], data, sz);
++ *data = *((uint32 *) & (romb[addr & ROM_MASK & ~3]));
+ *ws = 4;
+ return (0);
+ } else if ((addr >= 0x10000000) &&
+@@ -1692,13 +1689,13 @@ memory_read(asi, addr, data, sz, ws)
+ }
+
+ } else if (addr < mem_romsz) {
+- fetch_bytes (asi, &romb[addr], data, sz);
++ *data = *((uint32 *) & (romb[addr & ~3]));
+ *ws = mem_romr_ws;
+ return (0);
+
+ #else
+ } else if (addr < mem_romsz) {
+- fetch_bytes (asi, &romb[addr], data, sz);
++ *data = *((uint32 *) & (romb[addr & ~3]));
+ *ws = mem_romr_ws;
+ return (0);
+ #endif
+@@ -1706,19 +1703,30 @@ memory_read(asi, addr, data, sz, ws)
+ }
+
+ printf("Memory exception at %x (illegal address)\n", addr);
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ set_sfsr(UIMP_ACC, addr, asi, 1);
+ *ws = MEM_EX_WS;
+ return (1);
+ }
+
+-int
+-memory_write(asi, addr, data, sz, ws)
++static int
++memory_read_asi(asi, addr, data, sz, ws)
+ int32 asi;
+ uint32 addr;
+ uint32 *data;
+ int32 sz;
+ int32 *ws;
+ {
++ return(memory_read(addr, data, sz, ws));
++}
++
++static int
++memory_write(addr, data, sz, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
+ uint32 byte_addr;
+ uint32 byte_mask;
+ uint32 waddr;
+@@ -1726,11 +1734,13 @@ memory_write(asi, addr, data, sz, ws)
+ int32 mexc;
+ int i;
+ int wphit[2];
++ int32 asi;
+
+ #ifdef ERRINJ
+ if (errmec) {
+ if (sis_verbose)
+ printf("Inserted MEC error %d\n",errmec);
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ set_sfsr(errmec, addr, asi, 0);
+ if (errmec == 5) mecparerror();
+ if (errmec == 6) iucomperr();
+@@ -1743,6 +1753,7 @@ memory_write(asi, addr, data, sz, ws)
+ if (mem_accprot) {
+
+ waddr = (addr & 0x7fffff) >> 2;
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ for (i = 0; i < 2; i++)
+ wphit[i] =
+ (((asi == 0xa) && (mec_wpr[i] & 1)) ||
+@@ -1761,22 +1772,12 @@ memory_write(asi, addr, data, sz, ws)
+ }
+ }
+
+- store_bytes (&ramb[addr & mem_rammask], data, sz);
+-
+- switch (sz) {
+- case 0:
+- case 1:
+- *ws = mem_ramw_ws + 3;
+- break;
+- case 2:
+- *ws = mem_ramw_ws;
+- break;
+- case 3:
+- *ws = 2 * mem_ramw_ws + STD_WS;
+- break;
+- }
++ waddr = addr & mem_rammask;
++ store_bytes (ramb, waddr, data, sz, ws);
+ return (0);
++
+ } else if ((addr >= MEC_START) && (addr < MEC_END)) {
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ if ((sz != 2) || (asi != 0xb)) {
+ set_sfsr(MEC_ACC, addr, asi, 0);
+ *ws = MEM_EX_WS;
+@@ -1798,7 +1799,7 @@ memory_write(asi, addr, data, sz, ws)
+ ((addr < 0x100000) || ((addr >= 0x80000000) && (addr < 0x80100000)))) {
+ addr &= ROM_MASK;
+ *ws = sz == 3 ? 8 : 4;
+- store_bytes (&romb[addr], data, sz);
++ store_bytes (romb, addr, data, sz, ws);
+ return (0);
+ } else if ((addr >= 0x10000000) &&
+ (addr < (0x10000000 + (512 << (mec_iocr & 0x0f)))) &&
+@@ -1814,7 +1815,7 @@ memory_write(asi, addr, data, sz, ws)
+ *ws = mem_romw_ws + 1;
+ if (sz == 3)
+ *ws += mem_romw_ws + STD_WS;
+- store_bytes (&romb[addr], data, sz);
++ store_bytes (romb, addr, data, sz, ws);
+ return (0);
+
+ #else
+@@ -1825,7 +1826,7 @@ memory_write(asi, addr, data, sz, ws)
+ *ws = mem_romw_ws + 1;
+ if (sz == 3)
+ *ws += mem_romw_ws + STD_WS;
+- store_bytes (&romb[addr], data, sz);
++ store_bytes (romb, addr, data, sz, ws);
+ return (0);
+
+ #endif
+@@ -1833,10 +1834,22 @@ memory_write(asi, addr, data, sz, ws)
+ }
+
+ *ws = MEM_EX_WS;
++ if (sregs.psr & 0x080) asi = 11; else asi = 10;
+ set_sfsr(UIMP_ACC, addr, asi, 0);
+ return (1);
+ }
+
++static int
++memory_write_asi(asi, addr, data, sz, ws)
++ int32 asi;
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ return(memory_write(addr, data, sz, ws));
++}
++
+ static unsigned char *
+ get_mem_ptr(addr, size)
+ uint32 addr;
+@@ -1858,7 +1871,7 @@ get_mem_ptr(addr, size)
+ return ((char *) -1);
+ }
+
+-int
++static int
+ sis_memory_write(addr, data, length)
+ uint32 addr;
+ const unsigned char *data;
+@@ -1873,13 +1886,19 @@ sis_memory_write(addr, data, length)
+ return (length);
+ }
+
+-int
++static int
+ sis_memory_read(addr, data, length)
+ uint32 addr;
+ char *data;
+ uint32 length;
+ {
+ char *mem;
++ int ws;
++
++ if (length == 4) {
++ memory_read(addr, data, length, &ws);
++ return(4);
++ }
+
+ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
+ return (0);
+@@ -1887,3 +1906,35 @@ sis_memory_read(addr, data, length)
+ memcpy(data, mem, length);
+ return (length);
+ }
++
++static void
++boot_init ()
++{
++ mec_write(MEC_WCR, 0); /* zero waitstates */
++ mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
++ mec_write(MEC_RTC_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
++ mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
++ sregs.wim = 2;
++ sregs.psr = 0x110010e0;
++ sregs.r[30] = RAM_END;
++ sregs.r[14] = sregs.r[30] - 96*4;
++ mec_mcr |= 1; /* power-down enabled */
++}
++
++struct memsys erc32sys = {
++ init_sim,
++ reset,
++ error_mode,
++ sim_halt,
++ exit_sim,
++ init_stdio,
++ restore_stdio,
++ memory_iread,
++ memory_read,
++ memory_read_asi,
++ memory_write,
++ memory_write_asi,
++ sis_memory_write,
++ sis_memory_read,
++ boot_init
++};
+diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c
+index dc86ba3..f812ad9 100644
+--- a/sim/erc32/exec.c
++++ b/sim/erc32/exec.c
+@@ -21,11 +21,9 @@
+
+ #include "config.h"
+ #include "sis.h"
+-#include "end.h"
+ #include <math.h>
+ #include <stdio.h>
+
+-extern int32 sis_verbose, sparclite;
+ int ext_irl = 0;
+
+ /* Load/store interlock delay */
+@@ -229,10 +227,6 @@ static int fpexec (uint32 op3, uint32 rd, uint32 rs1, uint32 rs2,
+ struct pstate *sregs);
+ static int chk_asi (struct pstate *sregs, uint32 *asi, uint32 op3);
+
+-
+-extern struct estate ebase;
+-extern int32 nfp,ift;
+-
+ #ifdef ERRINJ
+ extern uint32 errtt, errftt;
+ #endif
+@@ -371,6 +365,36 @@ div64 (uint32 n1_hi, uint32 n1_low, uint32 n2, uint32 *result, int msigned)
+ }
+
+
++static int
++extract_short(uint32 data, uint32 address)
++{
++ return((data>>((2 - (address & 2))*8)) & 0xffff);
++}
++
++static int
++extract_short_signed(uint32 data, uint32 address)
++{
++ uint32 tmp;
++ tmp = ((data>>((2 - (address & 2))*8)) & 0xffff);
++ if (tmp & 0x8000) tmp |= 0xffff0000;
++ return(tmp);
++}
++
++static int
++extract_byte(uint32 data, uint32 address)
++{
++ return((data>>((3 - (address & 3))*8)) & 0xff);
++}
++
++static int
++extract_byte_signed(uint32 data, uint32 address)
++{
++ uint32 tmp;
++ tmp = ((data>>((3 - (address & 3))*8)) & 0xff);
++ if (tmp & 0x80) tmp |= 0xffffff00;
++ return(tmp);
++}
++
+ int
+ dispatch_instruction(sregs)
+ struct pstate *sregs;
+@@ -1041,17 +1065,17 @@ dispatch_instruction(sregs)
+ *rdd = sregs->psr;
+ break;
+ case RDY:
+- if (!sparclite)
++ if ((!sparclite) && (cputype != CPU_LEON3))
+ *rdd = sregs->y;
+ else {
+ int rs1_is_asr = (sregs->inst >> 14) & 0x1f;
+ if ( 0 == rs1_is_asr )
+ *rdd = sregs->y;
+- else if ( 17 == rs1_is_asr )
++ else if ( 17 == rs1_is_asr ) {
+ *rdd = sregs->asr17;
++ }
+ else {
+ sregs->trap = TRAP_UNIMP;
+- break;
+ }
+ }
+ break;
+@@ -1078,7 +1102,8 @@ dispatch_instruction(sregs)
+ sregs->trap = TRAP_PRIVI;
+ break;
+ }
+- sregs->psr = (rs1 ^ operand2) & 0x00f03fff;
++ sregs->psr = (sregs->psr & 0xff000000) |
++ (rs1 ^ operand2) & 0x00f03fff;
+ break;
+ case WRWIM:
+ if (!(sregs->psr & PSR_S)) {
+@@ -1096,13 +1121,19 @@ dispatch_instruction(sregs)
+ ((rs1 ^ operand2) & 0xfffff000);
+ break;
+ case WRY:
+- if (!sparclite)
++ if ((!sparclite) && (cputype != CPU_LEON3))
+ sregs->y = (rs1 ^ operand2);
+ else {
+ if ( 0 == rd )
+ sregs->y = (rs1 ^ operand2);
+- else if ( 17 == rd )
+- sregs->asr17 = (rs1 ^ operand2);
++ else if ( 17 == rd ) {
++ if (sparclite)
++ sregs->asr17 = (rs1 ^ operand2);
++ }
++ else if ( 19 == rd ) {
++ if (cputype == CPU_LEON3)
++ wait_for_irq();
++ }
+ else {
+ sregs->trap = TRAP_UNIMP;
+ break;
+@@ -1202,6 +1233,32 @@ dispatch_instruction(sregs)
+ switch (op3) {
+ case LDDA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x7) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ if (rd & 1) {
++ rd &= 0x1e;
++ if (rd > 7)
++ rdd = &(sregs->r[(cwp + rd) & 0x7f]);
++ else
++ rdd = &(sregs->g[rd]);
++ }
++ mexc = ms->memory_read_asi(asi, address, ddata, 2, &ws);
++ sregs->hold += ws;
++ mexc |= ms->memory_read_asi(asi, address+4, &ddata[1], 2, &ws);
++ sregs->hold += ws;
++ sregs->icnt = T_LDD;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ } else {
++ rdd[0] = ddata[0];
++ rdd[1] = ddata[1];
++#ifdef STAT
++ sregs->nload++; /* Double load counts twice */
++#endif
++ }
++ break;
+ case LDD:
+ if (address & 0x7) {
+ sregs->trap = TRAP_UNALI;
+@@ -1214,8 +1271,10 @@ dispatch_instruction(sregs)
+ else
+ rdd = &(sregs->g[rd]);
+ }
+- mexc = memory_read(asi, address, ddata, 3, &ws);
+- sregs->hold += ws * 2;
++ mexc = ms->memory_read(address, ddata, 2, &ws);
++ sregs->hold += ws;
++ mexc |= ms->memory_read(address+4, &ddata[1], 2, &ws);
++ sregs->hold += ws;
+ sregs->icnt = T_LDD;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1230,12 +1289,24 @@ dispatch_instruction(sregs)
+
+ case LDA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x3) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ mexc = ms->memory_read_asi(asi, address, &data, 2, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ } else {
++ *rdd = data;
++ }
++ break;
+ case LD:
+ if (address & 0x3) {
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_read(asi, address, &data, 2, &ws);
++ mexc = ms->memory_read(address, &data, 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1245,17 +1316,37 @@ dispatch_instruction(sregs)
+ break;
+ case LDSTUBA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ mexc = ms->memory_read_asi(asi, address, &data, 0, &ws);
++ sregs->hold += ws;
++ sregs->icnt = T_LDST;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ }
++ data = extract_byte(data, address);
++ *rdd = data;
++ data = 0x0ff;
++ mexc = ms->memory_write_asi(asi, address, &data, 0, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ }
++#ifdef STAT
++ sregs->nload++;
++#endif
++ break;
+ case LDSTUB:
+- mexc = memory_read(asi, address, &data, 0, &ws);
++ mexc = ms->memory_read(address, &data, 0, &ws);
+ sregs->hold += ws;
+ sregs->icnt = T_LDST;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+ break;
+ }
++ data = extract_byte(data, address);
+ *rdd = data;
+ data = 0x0ff;
+- mexc = memory_write(asi, address, &data, 0, &ws);
++ mexc = ms->memory_write(address, &data, 0, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1267,35 +1358,67 @@ dispatch_instruction(sregs)
+ case LDSBA:
+ case LDUBA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ mexc = ms->memory_read_asi(asi, address, &data, 0, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ }
++ if (op3 == LDSB)
++ data = extract_byte_signed(data, address);
++ else
++ data = extract_byte(data, address);
++ *rdd = data;
++ break;
+ case LDSB:
+ case LDUB:
+- mexc = memory_read(asi, address, &data, 0, &ws);
++ mexc = ms->memory_read(address, &data, 0, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+ break;
+ }
+- if ((op3 == LDSB) && (data & 0x80))
+- data |= 0xffffff00;
++ if (op3 == LDSB)
++ data = extract_byte_signed(data, address);
++ else
++ data = extract_byte(data, address);
+ *rdd = data;
+ break;
+ case LDSHA:
+ case LDUHA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x1) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ mexc = ms->memory_read_asi(asi, address, &data, 1, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ }
++ if (op3 == LDSH)
++ data = extract_short_signed(data, address);
++ else
++ data = extract_short(data, address);
++ *rdd = data;
++ break;
+ case LDSH:
+ case LDUH:
+ if (address & 0x1) {
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_read(asi, address, &data, 1, &ws);
++ mexc = ms->memory_read(address, &data, 1, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+ break;
+ }
+- if ((op3 == LDSH) && (data & 0x8000))
+- data |= 0xffff0000;
++ if (op3 == LDSH)
++ data = extract_short_signed(data, address);
++ else
++ data = extract_short(data, address);
+ *rdd = data;
+ break;
+ case LDF:
+@@ -1312,7 +1435,7 @@ dispatch_instruction(sregs)
+ (sregs->frs2 == rd))
+ sregs->fhold += (sregs->ftime - ebase.simtime);
+ }
+- mexc = memory_read(asi, address, &data, 2, &ws);
++ mexc = ms->memory_read(address, &data, 2, &ws);
+ sregs->hold += ws;
+ sregs->flrd = rd;
+ sregs->ltime = ebase.simtime + sregs->icnt + FLSTHOLD +
+@@ -1338,8 +1461,10 @@ dispatch_instruction(sregs)
+ ((sregs->frs2 >> 1) == (rd >> 1)))
+ sregs->fhold += (sregs->ftime - ebase.simtime);
+ }
+- mexc = memory_read(asi, address, ddata, 3, &ws);
+- sregs->hold += ws * 2;
++ mexc = ms->memory_read(address, ddata, 2, &ws);
++ sregs->hold += ws;
++ mexc |= ms->memory_read(address+4, &ddata[1], 2, &ws);
++ sregs->hold += ws;
+ sregs->icnt = T_LDD;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1367,7 +1492,7 @@ dispatch_instruction(sregs)
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_read(asi, address, &data, 2, &ws);
++ mexc = ms->memory_read(address, &data, 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1389,7 +1514,7 @@ dispatch_instruction(sregs)
+ if (ebase.simtime < sregs->ftime) {
+ sregs->fhold += (sregs->ftime - ebase.simtime);
+ }
+- mexc = memory_write(asi, address, &sregs->fsr, 2, &ws);
++ mexc = ms->memory_write(address, &sregs->fsr, 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1398,12 +1523,22 @@ dispatch_instruction(sregs)
+
+ case STA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x3) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ mexc = ms->memory_write_asi(asi, address, rdd, 2, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ }
++ break;
+ case ST:
+ if (address & 0x3) {
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_write(asi, address, rdd, 2, &ws);
++ mexc = ms->memory_write(address, rdd, 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1411,8 +1546,14 @@ dispatch_instruction(sregs)
+ break;
+ case STBA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ mexc = ms->memory_write_asi(asi, address, rdd, 0, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ }
++ break;
+ case STB:
+- mexc = memory_write(asi, address, rdd, 0, &ws);
++ mexc = ms->memory_write(address, rdd, 0, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1420,6 +1561,28 @@ dispatch_instruction(sregs)
+ break;
+ case STDA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x7) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ if (rd & 1) {
++ rd &= 0x1e;
++ if (rd > 7)
++ rdd = &(sregs->r[(cwp + rd) & 0x7f]);
++ else
++ rdd = &(sregs->g[rd]);
++ }
++ mexc = ms->memory_write_asi(asi, address, rdd, 3, &ws);
++ sregs->hold += ws;
++ sregs->icnt = T_STD;
++#ifdef STAT
++ sregs->nstore++; /* Double store counts twice */
++#endif
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ }
++ break;
+ case STD:
+ if (address & 0x7) {
+ sregs->trap = TRAP_UNALI;
+@@ -1432,7 +1595,7 @@ dispatch_instruction(sregs)
+ else
+ rdd = &(sregs->g[rd]);
+ }
+- mexc = memory_write(asi, address, rdd, 3, &ws);
++ mexc = ms->memory_write(address, rdd, 3, &ws);
+ sregs->hold += ws;
+ sregs->icnt = T_STD;
+ #ifdef STAT
+@@ -1461,7 +1624,7 @@ dispatch_instruction(sregs)
+ break;
+ }
+ rdd = &(sregs->fpq[0]);
+- mexc = memory_write(asi, address, rdd, 3, &ws);
++ mexc = ms->memory_write(address, rdd, 3, &ws);
+ sregs->hold += ws;
+ sregs->icnt = T_STD;
+ #ifdef STAT
+@@ -1477,12 +1640,22 @@ dispatch_instruction(sregs)
+ break;
+ case STHA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x1) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ mexc = ms->memory_write_asi(asi, address, rdd, 1, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ }
++ break;
+ case STH:
+ if (address & 0x1) {
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_write(asi, address, rdd, 1, &ws);
++ mexc = ms->memory_write(address, rdd, 1, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1501,7 +1674,7 @@ dispatch_instruction(sregs)
+ if (sregs->frd == rd)
+ sregs->fhold += (sregs->ftime - ebase.simtime);
+ }
+- mexc = memory_write(asi, address, &sregs->fsi[rd], 2, &ws);
++ mexc = ms->memory_write(address, &sregs->fsi[rd], 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+@@ -1521,7 +1694,7 @@ dispatch_instruction(sregs)
+ if ((sregs->frd == rd) || (sregs->frd + 1 == rd))
+ sregs->fhold += (sregs->ftime - ebase.simtime);
+ }
+- mexc = memory_write(asi, address, &sregs->fsi[rd], 3, &ws);
++ mexc = ms->memory_write(address, &sregs->fsi[rd], 3, &ws);
+ sregs->hold += ws;
+ sregs->icnt = T_STD;
+ #ifdef STAT
+@@ -1533,18 +1706,40 @@ dispatch_instruction(sregs)
+ break;
+ case SWAPA:
+ if (!chk_asi(sregs, &asi, op3)) break;
++ if (address & 0x3) {
++ sregs->trap = TRAP_UNALI;
++ break;
++ }
++ mexc = ms->memory_read_asi(asi, address, &data, 2, &ws);
++ sregs->hold += ws;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ }
++ mexc = ms->memory_write_asi(asi, address, rdd, 2, &ws);
++ sregs->hold += ws;
++ sregs->icnt = T_LDST;
++ if (mexc) {
++ sregs->trap = TRAP_DEXC;
++ break;
++ } else
++ *rdd = data;
++#ifdef STAT
++ sregs->nload++;
++#endif
++ break;
+ case SWAP:
+ if (address & 0x3) {
+ sregs->trap = TRAP_UNALI;
+ break;
+ }
+- mexc = memory_read(asi, address, &data, 2, &ws);
++ mexc = ms->memory_read(address, &data, 2, &ws);
+ sregs->hold += ws;
+ if (mexc) {
+ sregs->trap = TRAP_DEXC;
+ break;
+ }
+- mexc = memory_write(asi, address, rdd, 2, &ws);
++ mexc = ms->memory_write(address, rdd, 2, &ws);
+ sregs->hold += ws;
+ sregs->icnt = T_LDST;
+ if (mexc) {
+@@ -1696,7 +1891,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
+ but what about machines where float values are different endianness
+ from integer values? */
+
+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
++#ifdef HOST_LITTLE_ENDIAN
+ rs1 &= 0x1f;
+ switch (opf) {
+ case FADDd:
+@@ -1780,7 +1975,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
+ sregs->ftime += T_FDIVd;
+ break;
+ case FMOVs:
+- sregs->fs[rd] = sregs->fs[rs2];
++ sregs->fsi[rd] = sregs->fsi[rs2];
+ sregs->ftime += T_FMOVs;
+ sregs->frs1 = 32; /* rs1 ignored */
+ break;
+@@ -1874,7 +2069,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
+
+ accex = get_accex();
+
+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
++#ifdef HOST_LITTLE_ENDIAN
+ switch (opf) {
+ case FADDd:
+ case FDIVd:
+@@ -1962,7 +2157,7 @@ execute_trap(sregs)
+ sregs->pc = sregs->tbr;
+ sregs->npc = sregs->tbr + 4;
+
+- if ( 0 != (1 & sregs->asr17) ) {
++ if ( 0 != (1 & (sregs->asr17 >> 13)) ) {
+ /* single vector trapping! */
+ sregs->pc = sregs->tbr & 0xfffff000;
+ sregs->npc = sregs->pc + 4;
+@@ -1978,8 +2173,6 @@ execute_trap(sregs)
+
+ }
+
+-extern struct irqcell irqarr[16];
+-
+ int
+ check_interrupts(sregs)
+ struct pstate *sregs;
+@@ -2011,7 +2204,13 @@ init_regs(sregs)
+ sregs->npc = 4;
+ sregs->trap = 0;
+ sregs->psr &= 0x00f03fdf;
+- sregs->psr |= 0x080; /* Set supervisor bit */
++ if (cputype == CPU_LEON3)
++ sregs->psr |= 0xF3000080; /* Set supervisor bit */
++ else
++ if (cputype == CPU_LEON2)
++ sregs->psr |= 0x00000080; /* Set supervisor bit */
++ else
++ sregs->psr |= 0x11000080; /* Set supervisor bit */
+ sregs->breakpoint = 0;
+ sregs->annul = 0;
+ sregs->fpstate = FP_EXE_MODE;
+@@ -2021,7 +2220,7 @@ init_regs(sregs)
+ sregs->err_mode = 0;
+ ext_irl = 0;
+ sregs->g[0] = 0;
+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
++#ifdef HOST_LITTLE_ENDIAN
+ sregs->fdp = (float32 *) sregs->fd;
+ sregs->fsi = (int32 *) sregs->fs;
+ #else
+@@ -2040,4 +2239,8 @@ init_regs(sregs)
+
+ sregs->rett_err = 0;
+ sregs->jmpltime = 0;
++ if (cputype == CPU_LEON3) {
++ sregs->asr17 = 0x107;
++ if (!nfp) sregs->asr17 |= (3 << 10); /* Meiko FPU */
++ }
+ }
+diff --git a/sim/erc32/float.c b/sim/erc32/float.c
+index 598b7cc..ce92a39 100644
+--- a/sim/erc32/float.c
++++ b/sim/erc32/float.c
+@@ -38,7 +38,6 @@
+
+ extern uint32 _get_sw (void);
+ extern uint32 _get_cw (void);
+-static void __setfpucw (unsigned short fpu_control);
+
+ /* This host dependent routine should return the accrued exceptions */
+ int
+@@ -46,7 +45,7 @@ get_accex()
+ {
+ #ifdef sparc
+ return ((_get_fsr_raw() >> 5) & 0x1F);
+-#elif i386
++#elif defined(i386) || defined(__x86_64__)
+ uint32 accx;
+
+ accx = _get_sw() & 0x3f;
+@@ -66,7 +65,7 @@ clear_accex()
+ {
+ #ifdef sparc
+ set_fsr((_get_fsr_raw() & ~0x3e0));
+-#elif i386
++#elif defined(i386) || defined(__x86_64__)
+ asm("\n"
+ ".text\n"
+ " fnclex\n"
+@@ -84,9 +83,8 @@ uint32 fsr;
+ {
+ #ifdef sparc
+ _set_fsr_raw(fsr & ~0x0f800000);
+-#elif i386
+- void __setfpucw(unsigned short fpu_control);
+- uint32 rawfsr;
++#elif defined(i386) || defined(__x86_64__)
++ unsigned short rawfsr;
+
+ fsr >>= 30;
+ switch (fsr) {
+@@ -102,9 +100,8 @@ uint32 fsr;
+ fsr = 1;
+ break;
+ }
+- rawfsr = _get_cw();
+- rawfsr |= (fsr << 10) | 0x3ff;
+- __setfpucw(rawfsr);
++ rawfsr = (fsr << 10) | 0x2FF; /* double precision, all traps masked */
++ __asm__ volatile ("fldcw %0" :: "m" (rawfsr));
+ #else
+ #warning no fpu trap support for this target
+ #endif
+@@ -175,45 +172,36 @@ uint32 fsr;
+ "\n"
+ " ");
+
++#elif defined(__x86_64__)
++ asm ("\n"
++"\n"
++".text\n"
++".align 8\n"
++".globl _get_sw, __get_sw\n"
++"__get_sw:\n"
++"_get_sw:\n"
++" pushq %rbp\n"
++" movq %rsp, %rbp\n"
++" movl $0, %eax\n"
++" fnstsw %ax\n"
++" movq %rbp, %rsp\n"
++" popq %rbp\n"
++" ret\n"
++".align 8\n"
++".globl _get_cw, __get_cw\n"
++"__get_cw:\n"
++"_get_cw:\n"
++" pushq %rbp\n"
++" movq %rsp, %rbp\n"
++" subq $2, %rsp\n"
++" fnstcw -2(%rbp)\n"
++" movw -2(%rbp), %ax\n"
++" movq %rbp, %rsp\n"
++" popq %rbp\n"
++" ret\n"
++" ");
+
+ #else
+ #warning no fpu trap support for this target
+ #endif
+
+-#if i386
+-/* #if defined _WIN32 || defined __GO32__ */
+-/* This is so floating exception handling works on NT
+- These definitions are from the linux fpu_control.h, which
+- doesn't exist on NT.
+-
+- default to:
+- - extended precision
+- - rounding to nearest
+- - exceptions on overflow, zero divide and NaN
+-*/
+-#define _FPU_DEFAULT 0x1372
+-#define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */
+-
+-static void
+-__setfpucw(unsigned short fpu_control)
+-{
+- volatile unsigned short cw;
+-
+- /* If user supplied _fpu_control, use it ! */
+- if (!fpu_control)
+- {
+- /* use defaults */
+- fpu_control = _FPU_DEFAULT;
+- }
+- /* Get Control Word */
+- __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
+-
+- /* mask in */
+- cw &= _FPU_RESERVED;
+- cw = cw | (fpu_control & ~_FPU_RESERVED);
+-
+- /* set cw */
+- __asm__ volatile ("fldcw %0" :: "m" (cw));
+-}
+-/* #endif */
+-#endif
+diff --git a/sim/erc32/func.c b/sim/erc32/func.c
+index d001c58..6f985a1 100644
+--- a/sim/erc32/func.c
++++ b/sim/erc32/func.c
+@@ -26,20 +26,26 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include "sis.h"
+-#include "end.h"
+ #include <dis-asm.h>
+ #include "sim-config.h"
+
+
+ #define VAL(x) strtoul(x,(char **)NULL,0)
+
+-extern int current_target_byte_order;
++/* The target's byte order is big-endian by default until we load a
++ little-endian program. */
++int current_target_byte_order = BIG_ENDIAN;
++
++int dumbio = 0; /* normal, smart, terminal oriented IO by default */
+ struct disassemble_info dinfo;
+ struct pstate sregs;
+-extern struct estate ebase;
++struct estate ebase;
++struct evcell evbuf[EVENT_MAX];
++struct irqcell irqarr[16];
++
+ int ctrl_c = 0;
+ int sis_verbose = 0;
+-char *sis_version = "2.7.5";
++char *sis_version = "2.8";
+ int nfp = 0;
+ int ift = 0;
+ int wrp = 0;
+@@ -50,8 +56,11 @@ int sparclite = 0; /* emulating SPARClite instructions? */
+ int sparclite_board = 0; /* emulating SPARClite board RAM? */
+ char uart_dev1[128] = "";
+ char uart_dev2[128] = "";
+-extern int ext_irl;
+ uint32 last_load_addr = 0;
++int nouartrx = 0;
++host_callback *sim_callback;
++struct memsys *ms = &erc32sys;
++int cputype = 0; /* 0 = erc32, 3 = leon3 */
+
+ #ifdef ERRINJ
+ uint32 errcnt = 0;
+@@ -81,6 +90,7 @@ batch(sregs, fname)
+ {
+ FILE *fp;
+ char lbuf[1024];
++ char *tmp;
+
+ if ((fp = fopen(fname, "r")) == NULL) {
+ fprintf(stderr, "couldn't open batch file %s\n", fname);
+@@ -88,7 +98,7 @@ batch(sregs, fname)
+ }
+ while (!feof(fp)) {
+ lbuf[0] = 0;
+- fgets(lbuf, 1023, fp);
++ tmp = fgets(lbuf, 1023, fp);
+ if ((strlen(lbuf) > 0) && (lbuf[strlen(lbuf) - 1] == '\n'))
+ lbuf[strlen(lbuf) - 1] = 0;
+ printf("sis> %s\n", lbuf);
+@@ -382,7 +392,7 @@ exec_cmd(sregs, cmd)
+ {
+ char *cmd1, *cmd2;
+ int32 stat;
+- uint32 len, i, clen, j;
++ uint32 len, i, clen, j, tmp;
+ static uint32 daddr = 0;
+ char *cmdsave;
+
+@@ -426,7 +436,7 @@ exec_cmd(sregs, cmd)
+ stat = run_sim(sregs, VAL(cmd1), 0);
+ }
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "debug", clen) == 0) {
+ if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) {
+ sis_verbose = VAL(cmd1);
+@@ -468,6 +478,7 @@ exec_cmd(sregs, cmd)
+ }
+ sregs->pc = len & ~3;
+ sregs->npc = sregs->pc + 4;
++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
+ printf("resuming at 0x%08x\n",sregs->pc);
+ if ((cmd2 = strtok(NULL, " \t\n\r")) != NULL) {
+ stat = run_sim(sregs, VAL(cmd2), 0);
+@@ -475,7 +486,7 @@ exec_cmd(sregs, cmd)
+ stat = run_sim(sregs, UINT64_MAX, 0);
+ }
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "help", clen) == 0) {
+ gen_help();
+ } else if (strncmp(cmd1, "history", clen) == 0) {
+@@ -543,26 +554,31 @@ exec_cmd(sregs, cmd)
+ ebase.simtime = 0;
+ reset_all();
+ reset_stat(sregs);
++ if (last_load_addr != 0) {
++ sregs->pc = last_load_addr & ~3;
++ sregs->npc = sregs->pc + 4;
++ }
++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
+ if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) {
+ stat = run_sim(sregs, UINT64_MAX, 0);
+ } else {
+ stat = run_sim(sregs, VAL(cmd1), 0);
+ }
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "shell", clen) == 0) {
+ if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) {
+- system(&cmdsave[clen]);
++ tmp = system(&cmdsave[clen]);
+ }
+ } else if (strncmp(cmd1, "step", clen) == 0) {
+ stat = run_sim(sregs, 1, 1);
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "tcont", clen) == 0) {
+ sregs->tlimit = limcalc(sregs->freq);
+ stat = run_sim(sregs, UINT64_MAX, 0);
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "tgo", clen) == 0) {
+ if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) {
+ len = last_load_addr;
+@@ -575,7 +591,7 @@ exec_cmd(sregs, cmd)
+ printf("resuming at 0x%08x\n",sregs->pc);
+ stat = run_sim(sregs, UINT64_MAX, 0);
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "tlimit", clen) == 0) {
+ sregs->tlimit = limcalc(sregs->freq);
+ if (sregs->tlimit != (uint32) -1)
+@@ -589,15 +605,20 @@ exec_cmd(sregs, cmd)
+ }
+ printf("\n");
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else if (strncmp(cmd1, "trun", clen) == 0) {
+ ebase.simtime = 0;
+ reset_all();
+ reset_stat(sregs);
++ if (last_load_addr != 0) {
++ sregs->pc = last_load_addr & ~3;
++ sregs->npc = sregs->pc + 4;
++ }
++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
+ sregs->tlimit = limcalc(sregs->freq);
+ stat = run_sim(sregs, UINT64_MAX, 0);
+ daddr = sregs->pc;
+- sim_halt();
++ ms->sim_halt();
+ } else
+ printf("syntax error\n");
+ }
+@@ -611,7 +632,7 @@ void
+ reset_stat(sregs)
+ struct pstate *sregs;
+ {
+- sregs->tottime = 0;
++ sregs->tottime = 0.0;
+ sregs->pwdtime = 0;
+ sregs->ninst = 0;
+ sregs->fholdt = 0;
+@@ -629,10 +650,10 @@ void
+ show_stat(sregs)
+ struct pstate *sregs;
+ {
+- uint32 iinst;
+- uint32 stime, tottime;
++ uint64 iinst;
++ uint64 stime;
+
+- if (sregs->tottime == 0) tottime = 1; else tottime = sregs->tottime;
++ if (sregs->tottime == 0.0) sregs->tottime +=1E-6;
+ stime = ebase.simtime - sregs->simstart; /* Total simulated time */
+ #ifdef STAT
+
+@@ -640,39 +661,39 @@ show_stat(sregs)
+ sregs->nbranch;
+ #endif
+
+- printf("\n Cycles : %9d\n\r", ebase.simtime - sregs->simstart);
+- printf(" Instructions : %9d\n", sregs->ninst);
++ printf("\n Cycles : %9llu\n\r", ebase.simtime - sregs->simstart);
++ printf(" Instructions : %9llu\n", sregs->ninst);
+
+ #ifdef STAT
+- printf(" integer : %9.2f %%\n", 100.0 * (float) iinst / (float) sregs->ninst);
++ printf(" integer : %9.2f %%\n", 100.0 * (double) iinst / (double) sregs->ninst);
+ printf(" load : %9.2f %%\n",
+- 100.0 * (float) sregs->nload / (float) sregs->ninst);
++ 100.0 * (double) sregs->nload / (double) sregs->ninst);
+ printf(" store : %9.2f %%\n",
+- 100.0 * (float) sregs->nstore / (float) sregs->ninst);
++ 100.0 * (double) sregs->nstore / (double) sregs->ninst);
+ printf(" branch : %9.2f %%\n",
+- 100.0 * (float) sregs->nbranch / (float) sregs->ninst);
++ 100.0 * (double) sregs->nbranch / (double) sregs->ninst);
+ printf(" float : %9.2f %%\n",
+- 100.0 * (float) sregs->finst / (float) sregs->ninst);
++ 100.0 * (double) sregs->finst / (double) sregs->ninst);
+ printf(" Integer CPI : %9.2f\n",
+- ((float) (stime - sregs->pwdtime - sregs->fholdt - sregs->finst))
++ ((double) (stime - sregs->pwdtime - sregs->fholdt - sregs->finst))
+ /
+- (float) (sregs->ninst - sregs->finst));
++ (double) (sregs->ninst - sregs->finst));
+ printf(" Float CPI : %9.2f\n",
+- ((float) sregs->fholdt / (float) sregs->finst) + 1.0);
++ ((double) sregs->fholdt / (double) sregs->finst) + 1.0);
+ #endif
+ printf(" Overall CPI : %9.2f\n",
+- (float) (stime - sregs->pwdtime) / (float) sregs->ninst);
+- printf("\n ERC32 performance (%4.1f MHz): %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n",
+- sregs->freq, sregs->freq * (float) sregs->ninst / (float) (stime - sregs->pwdtime),
+- sregs->freq * (float) (sregs->ninst - sregs->finst) /
+- (float) (stime - sregs->pwdtime),
+- sregs->freq * (float) sregs->finst / (float) (stime - sregs->pwdtime));
+- printf(" Simulated ERC32 time : %5.2f ms\n", (float) (ebase.simtime - sregs->simstart) / 1000.0 / sregs->freq);
+- printf(" Processor utilisation : %5.2f %%\n", 100.0 * (1.0 - ((float) sregs->pwdtime / (float) stime)));
+- printf(" Real-time / simulator-time : 1/%.2f \n",
+- ((float) sregs->tottime) / ((float) (stime) / (sregs->freq * 1.0E6)));
+- printf(" Simulator performance : %d KIPS\n",sregs->ninst/tottime/1000);
+- printf(" Used time (sys + user) : %3d s\n\n", sregs->tottime);
++ (double) (stime - sregs->pwdtime) / (double) sregs->ninst);
++ printf("\n CPU performance (%4.1f MHz) : %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n",
++ sregs->freq, sregs->freq * (double) sregs->ninst / (double) (stime - sregs->pwdtime),
++ sregs->freq * (double) (sregs->ninst - sregs->finst) /
++ (double) (stime - sregs->pwdtime),
++ sregs->freq * (double) sregs->finst / (double) (stime - sregs->pwdtime));
++ printf(" Simulated CPU time : %.2f s\n", (double) (ebase.simtime - sregs->simstart) / 1000000.0 / sregs->freq);
++ printf(" Processor utilisation : %.2f %%\n", 100.0 * (1.0 - ((double) sregs->pwdtime / (double) stime)));
++ printf(" Real-time performance : %.2f %%\n", 100.0/
++ ((sregs->tottime) / ((double) (stime) / (sregs->freq * 1.0E6))));
++ printf(" Simulator performance : %.2f MIPS\n",(double)(sregs->ninst)/sregs->tottime/1E6);
++ printf(" Used time (sys + user) : %.2f s\n\n", sregs->tottime);
+ }
+
+
+@@ -708,12 +729,6 @@ init_signals()
+ }
+
+
+-extern struct disassemble_info dinfo;
+-
+-struct estate ebase;
+-struct evcell evbuf[EVENT_MAX];
+-struct irqcell irqarr[16];
+-
+ static int
+ disp_fpu(sregs)
+ struct pstate *sregs;
+@@ -724,7 +739,7 @@ disp_fpu(sregs)
+
+ printf("\n fsr: %08X\n\n", sregs->fsr);
+
+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
++#ifdef HOST_LITTLE_ENDIAN
+ for (i = 0; i < 32; i++)
+ sregs->fdp[i ^ 1] = sregs->fs[i];
+ #endif
+@@ -759,21 +774,32 @@ disp_regs(sregs,cwp)
+ }
+ }
+
++static void print_insn_sparc_sis(uint32 addr, struct disassemble_info *info)
++{
++ unsigned char i[4];
++
++ ms->sis_memory_read(addr, i, 4);
++ dinfo.buffer_vma = addr;
++ dinfo.buffer_length = 4;
++ dinfo.buffer = i;
++ print_insn_sparc(addr, info);
++}
++
+ static void
+ disp_ctrl(sregs)
+ struct pstate *sregs;
+ {
+
+- unsigned char i[4];
++ uint32 i;
+
+ printf("\n psr: %08X wim: %08X tbr: %08X y: %08X\n",
+ sregs->psr, sregs->wim, sregs->tbr, sregs->y);
+- sis_memory_read(sregs->pc, i, 4);
+- printf("\n pc: %08X = %02X%02X%02X%02X ", sregs->pc,i[0],i[1],i[2],i[3]);
+- print_insn_sparc(sregs->pc, &dinfo);
+- sis_memory_read(sregs->npc, i, 4);
+- printf("\n npc: %08X = %02X%02X%02X%02X ",sregs->npc,i[0],i[1],i[2],i[3]);
+- print_insn_sparc(sregs->npc, &dinfo);
++ ms->sis_memory_read(sregs->pc, (char *) &i, 4);
++ printf("\n pc: %08X = %08X ", sregs->pc, i);
++ print_insn_sparc_sis(sregs->pc, &dinfo);
++ ms->sis_memory_read(sregs->npc, (char *) &i, 4);
++ printf("\n npc: %08X = %08X ", sregs->npc, i);
++ print_insn_sparc_sis(sregs->npc, &dinfo);
+ if (sregs->err_mode)
+ printf("\n IU in error mode");
+ printf("\n\n");
+@@ -787,21 +813,28 @@ disp_mem(addr, len)
+
+ uint32 i;
+ unsigned char data[4];
++ uint32 *wdata = (uint32 *) data;
+ uint32 mem[4], j;
+ char *p;
++ int end;
+
++#ifdef HOST_LITTLE_ENDIAN
++ end = 3;
++#else
++ end = 0;
++#endif
+ for (i = addr & ~3; i < ((addr + len) & ~3); i += 16) {
+ printf("\n %8X ", i);
+ for (j = 0; j < 4; j++) {
+- sis_memory_read((i + (j * 4)), data, 4);
+- printf("%02x%02x%02x%02x ", data[0],data[1],data[2],data[3]);
++ ms->sis_memory_read((i + (j * 4)), data, 4);
++ printf("%08x ", *wdata);
+ mem[j] = *((int *) &data);
+ }
+ printf(" ");
+ p = (char *) mem;
+ for (j = 0; j < 16; j++) {
+- if (isprint(p[j]))
+- putchar(p[j]);
++ if (isprint(p[j^end]))
++ putchar(p[j^end]);
+ else
+ putchar('.');
+ }
+@@ -817,11 +850,12 @@ dis_mem(addr, len, info)
+ {
+ uint32 i;
+ unsigned char data[4];
++ uint32 *wdata = (uint32 *) data;
+
+ for (i = addr & -3; i < ((addr & -3) + (len << 2)); i += 4) {
+- sis_memory_read(i, data, 4);
+- printf(" %08x %02x%02x%02x%02x ", i, data[0],data[1],data[2],data[3]);
+- print_insn_sparc(i, info);
++ ms->sis_memory_read(i, data, 4);
++ printf(" %08x %08x ", i, *wdata);
++ print_insn_sparc_sis(i, info);
+ if (i >= 0xfffffffc) break;
+ printf("\n");
+ }
+@@ -983,7 +1017,7 @@ reset_all()
+ {
+ init_event(); /* Clear event queue */
+ init_regs(&sregs);
+- reset();
++ ms->reset();
+ #ifdef ERRINJ
+ errinjstart();
+ #endif
+@@ -1019,6 +1053,7 @@ bfd_load(fname)
+ asection *section;
+ bfd *pbfd;
+ const bfd_arch_info_type *arch;
++ int i;
+
+ pbfd = bfd_openr(fname, 0);
+
+@@ -1092,14 +1127,18 @@ bfd_load(fname)
+ fptr = 0;
+
+ while (section_size > 0) {
+- char buffer[1024];
+ int count;
++ char buffer[1024];
++ uint32 *wbuffer = (uint32 *) buffer;
+
+ count = min(section_size, 1024);
+
+ bfd_get_section_contents(pbfd, section, buffer, fptr, count);
+
+- sis_memory_write(section_address, buffer, count);
++#ifdef HOST_LITTLE_ENDIAN
++ for (i=0;i<count/4;i++) wbuffer[i] = ntohl(wbuffer[i]); // endian swap
++#endif
++ ms->sis_memory_write(section_address, buffer, count);
+
+ section_address += count;
+ fptr += count;
+@@ -1115,3 +1154,16 @@ bfd_load(fname)
+
+ return(bfd_get_start_address (pbfd));
+ }
++
++
++double get_time (void)
++{
++ double usec;
++
++ struct timeval tm;
++
++ gettimeofday (&tm, NULL);
++ usec = ((double) tm.tv_sec) * 1E6 + ((double) tm.tv_usec);
++ return (usec / 1E6);
++
++}
+diff --git a/sim/erc32/grlib.c b/sim/erc32/grlib.c
+new file mode 100644
+index 0000000..42a3ed0
+--- /dev/null
++++ b/sim/erc32/grlib.c
+@@ -0,0 +1,98 @@
++/*
++ * This file is part of SIS.
++ *
++ * SIS, SPARC instruction simulator. Copyright (C) 2014 Jiri Gaisler
++ *
++ * This program is free software; you can redistribute it and/or modify it under
++ * the terms of the GNU General Public License as published by the Free
++ * Software Foundation; either version 3 of the License, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * 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 "sis.h"
++#include "grlib.h"
++
++
++/* APB PNP */
++
++static uint32 apbppmem[32*2]; /* 32-entry APB PP AREA */
++static int apbppindex;
++
++int grlib_apbpp_add(uint32 id, uint32 addr)
++{
++ apbppmem[apbppindex++] = id;
++ apbppmem[apbppindex++] = addr;
++ if(apbppindex >= (32*2)) apbppindex = 0; /* prevent overflow of area */
++ return(apbppindex);
++}
++
++uint32 grlib_apbpnp_read(uint32 addr)
++{
++ uint32 read_data;
++ addr &= 0xff;
++ read_data = apbppmem[addr>>2];
++
++ return read_data;
++}
++
++/* AHB PNP */
++
++static uint32 ahbppmem[128*8]; /* 128-entry AHB PP AREA */
++static int ahbmppindex;
++static int ahbsppindex = 64*8;
++
++int grlib_ahbmpp_add(uint32 id)
++{
++ ahbppmem[ahbmppindex] = id;
++ ahbmppindex += 8;
++ if(ahbmppindex >= (64*8)) ahbmppindex = 0; /* prevent overflow of area */
++ return(ahbmppindex);
++}
++
++int grlib_ahbspp_add(uint32 id, uint32 addr1, uint32 addr2,
++ uint32 addr3, uint32 addr4)
++{
++ ahbppmem[ahbsppindex] = id;
++ ahbsppindex += 4;
++ ahbppmem[ahbsppindex++] = addr1;
++ ahbppmem[ahbsppindex++] = addr2;
++ ahbppmem[ahbsppindex++] = addr3;
++ ahbppmem[ahbsppindex++] = addr4;
++ if(ahbsppindex >= (128*8)) ahbsppindex = 64*8; /* prevent overflow of area */
++ return(ahbsppindex);
++}
++
++uint32 grlib_ahbpnp_read(uint32 addr)
++{
++ uint32 read_data;
++
++ addr &= 0xfff;
++ read_data = ahbppmem[addr>>2];
++ return read_data;
++
++}
++
++void grlib_init()
++{
++ /* Add PP records for Leon3, APB bridge and interrupt controller
++ as this is not done elsewhere */
++
++ grlib_ahbmpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_LEON3, 0, 0));
++ grlib_ahbspp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_APBMST, 0, 0),
++ GRLIB_PP_AHBADDR(0x80000000, 0xFFF, 0, 0, 2),
++ 0, 0, 0);
++
++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_IRQMP, 2, 0),
++ GRLIB_PP_APBADDR(0x80000200, 0xFFF));
++
++}
+diff --git a/sim/erc32/grlib.h b/sim/erc32/grlib.h
+new file mode 100644
+index 0000000..4d52211
+--- /dev/null
++++ b/sim/erc32/grlib.h
+@@ -0,0 +1,57 @@
++/*
++ * This file is part of SIS.
++ *
++ * SIS, SPARC instruction simulator. Copyright (C) 2014 Jiri Gaisler
++ *
++ * This program is free software; you can redistribute it and/or modify it under
++ * the terms of the GNU General Public License as published by the Free
++ * Software Foundation; either version 3 of the License, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, see <http://www.gnu.org/licenses/>.
++ *
++ */
++
++
++/* Definitions for AMBA PNP in Gaisler Research GRLIB SOC */
++
++/* Vendors */
++#define VENDOR_GAISLER 1
++#define VENDOR_PENDER 2
++#define VENDOR_ESA 4
++#define VENDOR_DLR 10
++
++/* Devices */
++#define GAISLER_LEON3 0x003
++#define GAISLER_APBMST 0x006
++#define GAISLER_SRCTRL 0x008
++#define GAISLER_APBUART 0x00C
++#define GAISLER_IRQMP 0x00D
++#define GAISLER_GPTIMER 0x011
++#define ESA_MCTRL 0x00F
++
++/* How to build entries in the plug&play area */
++#define GRLIB_PP_ID(v, d, x, i) ((v & 0xff) << 24) | ((d & 0x3ff) << 12) |\
++ ((x & 0x1f) << 5) | (i & 0x1f)
++#define GRLIB_PP_AHBADDR(a, m, p, c, t) (a & 0xfff00000) | ((m & 0xfff) << 4) |\
++ ((p & 1) << 17) | ((c & 1) << 16) | (t & 0x3)
++#define GRLIB_PP_APBADDR(a, m) ((a & 0xfff00)<< 12) | ((m & 0xfff) << 4) | 1
++
++#define AHBPP_START 0xFFFFF000
++#define AHBPP_END 0xFFFFFFFF
++#define APBPP_START 0x800FF000
++#define APBPP_END 0x800FFFFF
++
++int grlib_apbpp_add(uint32 id, uint32 addr);
++int grlib_ahbmpp_add(uint32 id);
++int grlib_ahbspp_add(uint32 id, uint32 addr1, uint32 addr2,
++ uint32 addr3, uint32 addr4);
++uint32 grlib_ahbpnp_read(uint32 addr);
++uint32 grlib_apbpnp_read(uint32 addr);
++void grlib_init();
+diff --git a/sim/erc32/help.c b/sim/erc32/help.c
+index 21c2a77..6d74e79 100644
+--- a/sim/erc32/help.c
++++ b/sim/erc32/help.c
+@@ -7,8 +7,8 @@ usage()
+ {
+
+ printf("usage: sis [-uart1 uart_device1] [-uart2 uart_device2]\n");
++ printf("[-sparclite] [-dumbio] [-v] [-vv]\n");
+ printf("[-nfp] [-freq frequency] [-c batch_file] [files]\n");
+- printf("[-sparclite] [-dumbio]\n");
+ }
+
+ void
+diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
+index e2db44e..259c8f3 100644
+--- a/sim/erc32/interf.c
++++ b/sim/erc32/interf.c
+@@ -24,7 +24,6 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+-#include <time.h>
+ #include <sys/fcntl.h>
+ #include "sis.h"
+ #include "libiberty.h"
+@@ -36,34 +35,10 @@
+ #include "gdb/signals.h"
+
+ #define PSR_CWP 0x7
+-
+-extern struct disassemble_info dinfo;
+-extern struct pstate sregs;
+-extern struct estate ebase;
+-
+-extern int current_target_byte_order;
+-extern int ctrl_c;
+-extern int nfp;
+-extern int ift;
+-extern int rom8;
+-extern int wrp;
+-extern int uben;
+-extern int sis_verbose;
+-extern char *sis_version;
+-extern struct estate ebase;
+-extern struct evcell evbuf[];
+-extern struct irqcell irqarr[];
+-extern int irqpend, ext_irl;
+-extern int sparclite;
+-extern int dumbio;
+-extern int sparclite_board;
+-extern int termsave;
+-extern char uart_dev1[], uart_dev2[];
++#define SOFT_BREAK 0x91d02001
+
+ int sis_gdb_break = 1;
+
+-host_callback *sim_callback;
+-
+ int
+ run_sim(sregs, icount, dis)
+ struct pstate *sregs;
+@@ -75,9 +50,10 @@ run_sim(sregs, icount, dis)
+ if (sis_verbose)
+ (*sim_callback->printf_filtered) (sim_callback, "resuming at %x\n",
+ sregs->pc);
+- init_stdio();
+- sregs->starttime = time(NULL);
++ ms->init_stdio();
++ sregs->starttime = get_time();
+ irq = 0;
++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
+ while (!sregs->err_mode & (icount > 0)) {
+
+ sregs->fhold = 0;
+@@ -94,9 +70,8 @@ run_sim(sregs, icount, dis)
+ if (sregs->pc == 0 || sregs->npc == 0)
+ printf ("bogus pc or npc\n");
+ #endif
+- mexc = memory_read(sregs->asi, sregs->pc, &sregs->inst,
+- 2, &sregs->hold);
+-#if 1 /* DELETE ME! for debugging purposes only */
++ mexc = ms->memory_iread(sregs->pc, &sregs->inst, &sregs->hold);
++#if 0 /* DELETE ME! for debugging purposes only */
+ if (sis_verbose > 2)
+ printf("pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n",
+ sregs->pc, sregs->npc,
+@@ -117,12 +92,12 @@ run_sim(sregs, icount, dis)
+ if (mexc) {
+ sregs->trap = I_ACC_EXC;
+ } else {
+- if ((sis_gdb_break) && (sregs->inst == 0x91d02001)) {
++ if ((sis_gdb_break) && (sregs->inst == SOFT_BREAK)) {
+ if (sis_verbose)
+ (*sim_callback->printf_filtered) (sim_callback,
+ "SW BP hit at %x\n", sregs->pc);
+- sim_halt();
+- restore_stdio();
++ ms->sim_halt();
++ ms->restore_stdio();
+ clearerr(stdin);
+ return (BPT_HIT);
+ } else
+@@ -140,12 +115,12 @@ run_sim(sregs, icount, dis)
+ icount = 0;
+ }
+ }
+- sim_halt();
+- sregs->tottime += time(NULL) - sregs->starttime;
+- restore_stdio();
++ ms->sim_halt();
++ sregs->tottime += get_time() - sregs->starttime;
++ ms->restore_stdio();
+ clearerr(stdin);
+ if (sregs->err_mode)
+- error_mode(sregs->pc);
++ ms->error_mode(sregs->pc);
+ if (sregs->err_mode)
+ return (ERROR);
+ if (sregs->bphit) {
+@@ -210,6 +185,17 @@ sim_open (kind, callback, abfd, argv)
+ if (strcmp(argv[stat], "-dumbio") == 0) {
+ dumbio = 1;
+ } else
++ if (strcmp(argv[stat], "-nouartrx") == 0) {
++ nouartrx = 1;
++ } else
++ if (strcmp(argv[stat], "-leon2") == 0) {
++ ms = &leon2;
++ cputype = CPU_LEON2;
++ } else
++ if (strcmp(argv[stat], "-leon3") == 0) {
++ ms = &leon3;
++ cputype = CPU_LEON3;
++ } else
+ if (strcmp(argv[stat], "-wrp") == 0) {
+ wrp = 1;
+ } else
+@@ -247,9 +233,24 @@ sim_open (kind, callback, abfd, argv)
+ stat++;
+ }
+
++ if ((cputype == CPU_LEON3) || (cputype == CPU_LEON2))
++ sregs.freq = freq ? freq : 50;
++ else
++ sregs.freq = freq ? freq : 14;
++
+ if (sis_verbose) {
+ (*sim_callback->printf_filtered) (sim_callback, "\n SIS - SPARC instruction simulator %s\n", sis_version);
+- (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler ESA/ESTEC (jgais at wd.estec.esa.nl)\n");
++ (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler (jiri at gaisler.se)\n\n");
++ switch (cputype) {
++ case CPU_LEON2:
++ (*sim_callback->printf_filtered) (sim_callback, "LEON2 emulation enabled\n");
++ break;
++ case CPU_LEON3:
++ (*sim_callback->printf_filtered) (sim_callback, "LEON3 emulation enabled\n");
++ break;
++ default:
++ (*sim_callback->printf_filtered) (sim_callback, "ERC32 emulation enabled\n");
++ }
+ if (nfp)
+ (*sim_callback->printf_filtered) (sim_callback, "no FPU\n");
+ if (sparclite)
+@@ -258,17 +259,19 @@ sim_open (kind, callback, abfd, argv)
+ (*sim_callback->printf_filtered) (sim_callback, "dumb IO (no input, dumb output)\n");
+ if (sis_gdb_break == 0)
+ (*sim_callback->printf_filtered) (sim_callback, "disabling GDB trap handling for breakpoints\n");
+- if (freq)
+- (*sim_callback->printf_filtered) (sim_callback, " ERC32 freq %d Mhz\n", freq);
++ (*sim_callback->printf_filtered) (sim_callback, "CPU freq %3.1f MHz\n", sregs.freq);
+ }
+
+- sregs.freq = freq ? freq : 15;
+ termsave = fcntl(0, F_GETFL, 0);
+ INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
++#ifdef HOST_LITTLE_ENDIAN
++ dinfo.endian = BFD_ENDIAN_LITTLE;
++#else
+ dinfo.endian = BFD_ENDIAN_BIG;
++#endif
+ reset_all();
+ ebase.simtime = 0;
+- init_sim();
++ ms->init_sim();
+ init_bpt(&sregs);
+ reset_stat(&sregs);
+
+@@ -282,7 +285,7 @@ sim_close(sd, quitting)
+ int quitting;
+ {
+
+- exit_sim();
++ ms->exit_sim();
+ fcntl(0, F_SETFL, termsave);
+
+ };
+@@ -355,7 +358,19 @@ sim_write(sd, mem, buf, length)
+ const unsigned char *buf;
+ int length;
+ {
+- return (sis_memory_write(mem, buf, length));
++#ifdef HOST_LITTLE_ENDIAN
++ int *ibufp = (int *) buf;
++ int ibuf[8192];
++ int i, len;
++
++ if (length >= 4)
++ for (i=0; i<length; i+=4) {
++ ibuf[i] = ntohl(ibufp[i]);
++ }
++ return (ms->sis_memory_write(mem, (char *) ibuf, length));
++#else
++ return (ms->sis_memory_write(mem, buf, length));
++#endif
+ }
+
+ int
+@@ -365,7 +380,20 @@ sim_read(sd, mem, buf, length)
+ unsigned char *buf;
+ int length;
+ {
+- return (sis_memory_read(mem, buf, length));
++#ifdef HOST_LITTLE_ENDIAN
++ int *ibuf = (int *) buf;
++ int i, len;
++
++ len = ms->sis_memory_read(mem, buf, length);
++ if (length >= 4)
++ for (i=0; i<length; i+=4) {
++ *ibuf = htonl(*ibuf);
++ ibuf++;
++ }
++ return (len);
++#else
++ return (ms->sis_memory_read(mem, buf, length));
++#endif
+ }
+
+ void
+@@ -451,7 +479,7 @@ flush_windows ()
+ #endif
+
+ for (i = 0; i < 16; i++)
+- memory_write (11, sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
++ ms->memory_write (sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
+ &ws);
+
+ if (win == cwp)
+@@ -481,7 +509,7 @@ sim_do_command(sd, cmd)
+ SIM_DESC sd;
+ char *cmd;
+ {
+- exec_cmd(&sregs, cmd);
++ exec_cmd(&sregs, (char *) cmd);
+ }
+
+ char **
+@@ -490,6 +518,13 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
+ return NULL;
+ }
+
++int
++sim_stop(SIM_DESC sd)
++{
++ ctrl_c = 1;
++ return 1;
++}
++
+ #if 0 /* FIXME: These shouldn't exist. */
+
+ int
+diff --git a/sim/erc32/leon2.c b/sim/erc32/leon2.c
+new file mode 100644
+index 0000000..5ab3f79
+--- /dev/null
++++ b/sim/erc32/leon2.c
+@@ -0,0 +1,1041 @@
++/*
++ * This file is part of SIS.
++ *
++ * SIS, SPARC instruction simulator V2.5 Copyright (C) 1995 Jiri Gaisler,
++ * European Space Agency
++ *
++ * This program is free software; you can redistribute it and/or modify it under
++ * the terms of the GNU General Public License as published by the Free
++ * Software Foundation; either version 3 of the License, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, see <http://www.gnu.org/licenses/>.
++ *
++ * Leon2 emulation, based on leon3.c .
++ */
++
++/* The control space devices */
++
++#include "config.h"
++#include <errno.h>
++#include <sys/types.h>
++#include <stdio.h>
++#include <string.h>
++#include <termios.h>
++#include <sys/fcntl.h>
++#include <sys/file.h>
++#include <unistd.h>
++#include "sis.h"
++#include "sim-config.h"
++
++static int tty_setup = 1; /* default setup if not a tty */
++
++/* APB registers */
++#define APBSTART 0x80000000
++#define APBEND 0x80000100
++
++/* Memory exception waitstates */
++#define MEM_EX_WS 1
++
++#define MOK 0
++
++/* LEON2 APB register addresses */
++
++#define IRQCTRL_IPR 0x094
++#define IRQCTRL_IMR 0x090
++#define IRQCTRL_ICR 0x09C
++#define IRQCTRL_IFR 0x098
++#define TIMER_SCALER 0x060
++#define TIMER_SCLOAD 0x064
++#define LEON2_CONFIG 0x024
++#define TIMER_TIMER1 0x040
++#define TIMER_RELOAD1 0x044
++#define TIMER_CTRL1 0x048
++#define TIMER_TIMER2 0x050
++#define TIMER_RELOAD2 0x054
++#define TIMER_CTRL2 0x058
++#define CACHE_CTRL 0x014
++#define POWER_DOWN 0x018
++
++#define APBUART_RXTX 0x070
++#define APBUART_STATUS 0x074
++
++/* Size of UART buffers (bytes) */
++#define UARTBUF 1024
++
++/* Number of simulator ticks between flushing the UARTS. */
++/* For good performance, keep above 1000 */
++#define UART_FLUSH_TIME 3000
++
++
++/* New uart defines */
++#define UART_TX_TIME 1000
++#define UART_RX_TIME 1000
++#define UARTA_DR 0x1
++#define UARTA_SRE 0x2
++#define UARTA_HRE 0x4
++#define UARTA_OR 0x10
++
++/* IRQCTRL registers */
++
++static uint32 irqctrl_ipr;
++static uint32 irqctrl_imr;
++static uint32 irqctrl_ifr;
++
++/* TIMER registers */
++
++#define NTIMERS 2
++#define TIMER_IRQ 8
++
++static uint32 gpt_scaler;
++static uint32 gpt_scaler_start;
++static uint32 gpt_counter[NTIMERS];
++static uint32 gpt_reload[NTIMERS];
++static uint32 gpt_ctrl[NTIMERS];
++
++/* ROM size 16 Mbyte */
++#define ROM_START 0x00000000
++#define ROM_MASK 0x00ffffff
++#define ROM_END (ROM_START + ROM_MASK + 1)
++
++/* RAM size 16 Mbyte */
++#define RAM_START 0x40000000
++#define RAM_MASK 0x00ffffff
++#define RAM_END (RAM_START + RAM_MASK + 1)
++
++/* Memory */
++
++static unsigned char romb[ROM_END - ROM_START];
++static unsigned char ramb[RAM_END - RAM_START];
++static uint32 cache_ctrl;
++
++
++/* UART support variables */
++
++static int32 fd1, fd2; /* file descriptor for input file */
++static int32 Ucontrol; /* UART status register */
++static unsigned char aq[UARTBUF], bq[UARTBUF];
++static int32 anum, aind = 0;
++static int32 bnum, bind = 0;
++static char wbufa[UARTBUF], wbufb[UARTBUF];
++static unsigned wnuma;
++static unsigned wnumb;
++static FILE *f1in, *f1out;
++static struct termios ioc1, ioc2, iocold1, iocold2;
++static int f1open = 0;
++
++static char uarta_sreg, uarta_hreg;
++static uint32 uart_stat_reg;
++static uint32 uarta_data;
++
++/* Forward declarations */
++
++static void mem_init (void);
++static void close_port (void);
++static void leon2_reset (void);
++static void irqctrl_intack (int32 level);
++static void chk_irq (void);
++static void set_irq (int32 level);
++static int32 apb_read (uint32 addr, uint32 *data);
++static int apb_write (uint32 addr, uint32 data);
++static void port_init (void);
++static uint32 grlib_read_uart (uint32 addr);
++static void grlib_write_uart (uint32 addr, uint32 data);
++static void flush_uart (void);
++static void uarta_tx (void);
++static void uart_rx (caddr_t arg);
++static void uart_intr (caddr_t arg);
++static void uart_irq_start (void);
++static void gpt_intr (caddr_t arg);
++static void gpt_init (void);
++static void gpt_reset (void);
++static void gpt_scaler_set (uint32 val);
++static void timer_ctrl (uint32 val, int i);
++static unsigned char *
++ get_mem_ptr (uint32 addr, uint32 size);
++static void store_bytes (unsigned char *mem, uint32 waddr,
++ uint32 *data, int sz, int32 *ws);
++
++static host_callback *callback;
++
++
++/* One-time init */
++
++static void
++init_sim()
++{
++ callback = sim_callback;
++ grlib_init();
++ mem_init();
++ port_init();
++ gpt_init();
++}
++
++/* Power-on reset init */
++
++static void
++reset()
++{
++ leon2_reset();
++ uart_irq_start();
++ gpt_reset();
++}
++
++/* IU error mode manager */
++
++static void
++error_mode(pc)
++ uint32 pc;
++{
++
++}
++
++
++/* Memory init */
++
++static void
++mem_init()
++{
++
++ if (sis_verbose)
++ printf("RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n",
++ RAM_START, (RAM_MASK+1)/1024, (ROM_MASK+1)/1024);
++}
++
++/* Flush ports when simulator stops */
++
++static void
++sim_halt()
++{
++#ifdef FAST_UART
++ flush_uart();
++#endif
++}
++
++static void
++close_port()
++{
++ if (f1open && f1in != stdin)
++ fclose(f1in);
++}
++
++static void
++exit_sim()
++{
++ close_port();
++}
++
++static void
++leon2_reset()
++{
++ int i;
++
++ irqctrl_ipr = 0;
++ irqctrl_imr = 0;
++ irqctrl_ifr = 0;
++
++ wnuma = wnumb = 0;
++ anum = aind = bnum = bind = 0;
++
++ uart_stat_reg = UARTA_SRE | UARTA_HRE;
++
++ gpt_counter[0] = 0xffffffff;
++ gpt_reload[0] = 0xffffffff;
++ gpt_scaler = 0xffff;
++ gpt_ctrl[0] = 0;
++ gpt_ctrl[1] = 0;
++
++}
++
++
++
++static void
++irqctrl_intack(level)
++ int32 level;
++{
++ int irq_test;
++
++ if (sis_verbose > 2)
++ printf("interrupt %d acknowledged\n", level);
++ if (irqctrl_ifr & (1 << level))
++ irqctrl_ifr &= ~(1 << level);
++ else
++ irqctrl_ipr &= ~(1 << level);
++ chk_irq();
++}
++
++static void
++chk_irq()
++{
++ int32 i;
++ uint32 itmp;
++ int old_irl;
++
++ old_irl = ext_irl;
++ itmp = ((irqctrl_ipr | irqctrl_ifr) & irqctrl_imr) & 0x0fffe;
++ ext_irl = 0;
++ if (itmp != 0) {
++ for (i = 15; i > 0; i--) {
++ if (((itmp >> i) & 1) != 0) {
++ if ((sis_verbose > 2) && (i > old_irl))
++ printf("IU irl: %d\n", i);
++ ext_irl = i;
++ set_int(i, irqctrl_intack, i);
++ break;
++ }
++ }
++ }
++}
++
++static void
++set_irq(level)
++ int32 level;
++{
++ irqctrl_ipr |= (1 << level);
++ chk_irq();
++}
++
++static int32
++apb_read(addr, data)
++ uint32 addr;
++ uint32 *data;
++{
++
++ switch (addr & 0xfff) {
++
++ case APBUART_RXTX: /* 0x100 */
++ case APBUART_STATUS: /* 0x104 */
++ *data = grlib_read_uart(addr);
++ break;
++
++ case IRQCTRL_IPR: /* 0x204 */
++ *data = irqctrl_ipr;
++ break;
++
++ case IRQCTRL_IFR: /* 0x208 */
++ *data = irqctrl_ifr;
++ break;
++
++ case IRQCTRL_IMR: /* 0x240 */
++ *data = irqctrl_imr;
++ break;
++
++ case TIMER_SCALER: /* 0x300 */
++ *data = gpt_scaler - (now() - gpt_scaler_start);
++ break;
++
++ case TIMER_SCLOAD: /* 0x304 */
++ *data = gpt_scaler;
++ break;
++
++ case LEON2_CONFIG: /* 0x308 */
++ *data = 0x700310;
++ break;
++
++ case TIMER_TIMER1: /* 0x310 */
++ *data = gpt_counter[0];
++ break;
++
++ case TIMER_RELOAD1: /* 0x314 */
++ *data = gpt_reload[0];
++ break;
++
++ case TIMER_CTRL1: /* 0x318 */
++ *data = gpt_ctrl[0];
++ break;
++
++ case TIMER_TIMER2: /* 0x320 */
++ *data = gpt_counter[1];
++ break;
++
++ case TIMER_RELOAD2: /* 0x324 */
++ *data = gpt_reload[1];
++ break;
++
++ case TIMER_CTRL2: /* 0x328 */
++ *data = gpt_ctrl[1];
++ break;
++
++ case CACHE_CTRL: /* 0x328 */
++ *data = cache_ctrl;
++ break;
++
++ default:
++ *data = 0;
++ break;
++ }
++
++ if (sis_verbose > 1)
++ printf("APB read a: %08x, d: %08x\n", addr, *data);
++
++ return (MOK);
++}
++
++static int
++apb_write(addr, data)
++ uint32 addr;
++ uint32 data;
++{
++ if (sis_verbose > 1)
++ printf("APB write a: %08x, d: %08x\n",addr,data);
++ switch (addr & 0xff) {
++
++ case APBUART_RXTX: /* 0x100 */
++ case APBUART_STATUS: /* 0x104 */
++ grlib_write_uart(addr, data);
++ break;
++
++ case IRQCTRL_IFR: /* 0x208 */
++ irqctrl_ifr = data & 0xfffe;
++ chk_irq();
++ break;
++
++ case IRQCTRL_ICR: /* 0x20C */
++ irqctrl_ipr &= ~data & 0x0fffe;
++ chk_irq();
++ break;
++
++ case IRQCTRL_IMR: /* 0x240 */
++ irqctrl_imr = data & 0x7ffe;
++ chk_irq();
++ break;
++
++ case TIMER_SCLOAD: /* 0x304 */
++ gpt_scaler_set(data);
++ break;
++
++ case TIMER_TIMER1: /* 0x310 */
++ gpt_counter[0] = data;
++ break;
++
++ case TIMER_RELOAD1: /* 0x314 */
++ gpt_reload[0] = data;
++ break;
++
++ case TIMER_CTRL1: /* 0x318 */
++ timer_ctrl(data, 0);
++ break;
++
++ case TIMER_TIMER2: /* 0x320 */
++ gpt_counter[1] = data;
++ break;
++
++ case TIMER_RELOAD2: /* 0x324 */
++ gpt_reload[1] = data;
++ break;
++
++ case TIMER_CTRL2: /* 0x328 */
++ timer_ctrl(data, 1);
++ break;
++
++ case POWER_DOWN: /* 0x328 */
++ wait_for_irq();
++ break;
++
++ case CACHE_CTRL: /* 0x328 */
++ cache_ctrl = data & 0x1000f;
++ break;
++
++ default:
++ break;
++ }
++ return (MOK);
++}
++
++
++/* APBUART */
++
++static int ifd1 = -1, ofd1 = -1;
++
++static void
++init_stdio()
++{
++ if (dumbio)
++ return; /* do nothing */
++ if (ifd1 == 0 && f1open) {
++ tcsetattr(0, TCSANOW, &ioc1);
++ tcflush(ifd1, TCIFLUSH);
++ }
++}
++
++static void
++restore_stdio()
++{
++ if (dumbio)
++ return; /* do nothing */
++ if (ifd1 == 0 && f1open && tty_setup)
++ tcsetattr(0, TCSANOW, &iocold1);
++}
++
++#define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
++ ( dumbio || nouartrx \
++ ? (0) /* no bytes read, no delay */ \
++ : (_fd_) == 1 && callback ? \
++ callback->read_stdin (callback, _buf_, _len_) : \
++ read( _fd_, _buf_, _len_ ) )
++
++
++static void
++port_init()
++{
++
++ f1in = stdin;
++ f1out = stdout;
++ if (uart_dev1[0] != 0)
++ if ((fd1 = open(uart_dev1, O_RDWR | O_NONBLOCK)) < 0) {
++ printf("Warning, couldn't open output device %s\n", uart_dev1);
++ } else {
++ if (sis_verbose)
++ printf("serial port A on %s\n", uart_dev1);
++ f1in = f1out = fdopen(fd1, "r+");
++ setbuf(f1out, NULL);
++ f1open = 1;
++ }
++ if (f1in) ifd1 = fileno(f1in);
++ if (ifd1 == 0) {
++ if (callback && !callback->isatty(callback, ifd1)) {
++ tty_setup = 0;
++ }
++ if (sis_verbose)
++ printf("serial port A on stdin/stdout\n");
++ if (!dumbio) {
++ tcgetattr(ifd1, &ioc1);
++ if (tty_setup) {
++ iocold1 = ioc1;
++ ioc1.c_lflag &= ~(ICANON | ECHO);
++ ioc1.c_cc[VMIN] = 0;
++ ioc1.c_cc[VTIME] = 0;
++ }
++ }
++ f1open = 1;
++ }
++
++ if (f1out) {
++ ofd1 = fileno(f1out);
++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
++ }
++
++ wnuma = 0;
++
++}
++
++static uint32
++grlib_read_uart(addr)
++ uint32 addr;
++{
++
++ unsigned tmp;
++
++ tmp = 0;
++ switch (addr & 0xfff) {
++
++ case 0x070: /* UART 1 RX/TX */
++#ifndef _WIN32
++#ifdef FAST_UART
++
++ if (aind < anum) {
++ if ((aind + 1) < anum)
++ set_irq(3);
++ return ((uint32) aq[aind++]);
++ } else {
++ if (f1open) {
++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
++ }
++ else {
++ anum = 0;
++ }
++ if (anum > 0) {
++ aind = 0;
++ if ((aind + 1) < anum)
++ set_irq(3);
++ return ((uint32) aq[aind++]);
++ } else {
++ return ((uint32) aq[aind]);
++ }
++
++ }
++#else
++ tmp = uarta_data;
++ uarta_data &= ~UART_DR;
++ uart_stat_reg &= ~UARTA_DR;
++ return tmp;
++#endif
++#else
++ return(0);
++#endif
++ break;
++
++ case 0x074: /* UART status register */
++#ifndef _WIN32
++#ifdef FAST_UART
++
++ Ucontrol = 0;
++ if (aind < anum) {
++ Ucontrol |= 0x00000001;
++ } else {
++ if (f1open) {
++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
++ }
++ else {
++ anum = 0;
++ }
++ if (anum > 0) {
++ Ucontrol |= 0x00000001;
++ aind = 0;
++ set_irq(3);
++ }
++ }
++ Ucontrol |= 0x00000006;
++ return (Ucontrol);
++#else
++ return (uart_stat_reg);
++#endif
++#else
++ return(0x00060006);
++#endif
++ break;
++ default:
++ if (sis_verbose)
++ printf("Read from unimplemented LEON2 register (%x)\n", addr);
++
++ }
++ return (0);
++}
++
++static void
++grlib_write_uart(addr, data)
++ uint32 addr;
++ uint32 data;
++{
++ unsigned char c;
++
++ c = (unsigned char) data;
++ switch (addr & 0xfff) {
++
++ case 0x070: /* UART A */
++#ifdef FAST_UART
++ if (f1open) {
++ if (wnuma < UARTBUF)
++ wbufa[wnuma++] = c;
++ else {
++ while (wnuma) {
++ if (ofd1 == 1 && callback)
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ else
++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
++ }
++ wbufa[wnuma++] = c;
++ }
++ }
++ set_irq(3);
++#else
++ if (uart_stat_reg & UARTA_SRE) {
++ uarta_sreg = c;
++ uart_stat_reg &= ~UARTA_SRE;
++ event(uarta_tx, 0, UART_TX_TIME);
++ } else {
++ uarta_hreg = c;
++ uart_stat_reg &= ~UARTA_HRE;
++ }
++#endif
++ break;
++
++ case 0x074: /* UART status register */
++#ifndef FAST_UART
++ uart_stat_reg &= 1;
++#endif
++ break;
++ default:
++ if (sis_verbose)
++ printf("Write to unimplemented APB register (%x)\n", addr);
++
++ }
++}
++
++static void
++flush_uart()
++{
++ while (wnuma && f1open) {
++ if (ofd1 == 1 && callback) {
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ callback->flush_stdout(callback);
++ }
++ else
++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
++ }
++}
++
++
++
++static void
++uarta_tx()
++{
++ while (f1open) {
++ if (ofd1 == 1 && callback) {
++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
++ }
++ else {
++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
++ }
++ }
++ if (uart_stat_reg & UARTA_HRE) {
++ uart_stat_reg |= UARTA_SRE;
++ } else {
++ uarta_sreg = uarta_hreg;
++ uart_stat_reg |= UARTA_HRE;
++ event(uarta_tx, 0, UART_TX_TIME);
++ }
++ set_irq(3);
++}
++
++static void
++uart_rx(arg)
++ caddr_t arg;
++{
++ int32 rsize;
++ char rxd;
++
++
++ rsize = 0;
++ if (f1open)
++ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
++ else
++ rsize = 0;
++ if (rsize > 0) {
++ uarta_data = rxd;
++ if (uart_stat_reg & UARTA_DR) {
++ uart_stat_reg |= UARTA_OR;
++ }
++ uart_stat_reg |= UARTA_DR;
++ set_irq(3);
++ }
++ event(uart_rx, 0, UART_RX_TIME);
++}
++
++static void
++uart_intr(arg)
++ caddr_t arg;
++{
++ grlib_read_uart(APBUART_STATUS); /* Check for UART interrupts every 1000 clk */
++ flush_uart(); /* Flush UART ports */
++ event(uart_intr, 0, UART_FLUSH_TIME);
++}
++
++
++static void
++uart_irq_start()
++{
++#ifdef FAST_UART
++ event(uart_intr, 0, UART_FLUSH_TIME);
++#else
++#ifndef _WIN32
++ event(uart_rx, 0, UART_RX_TIME);
++#endif
++#endif
++}
++
++/* TIMER */
++
++static void
++gpt_intr(arg)
++ caddr_t arg;
++{
++ int i;
++
++ for (i=0; i<NTIMERS; i++) {
++ if (gpt_ctrl[i] & 1) {
++ gpt_counter[i] -= 1;
++ if (gpt_counter[i] == -1) {
++ set_irq(TIMER_IRQ + i);
++ if (gpt_ctrl[i] & 2)
++ gpt_counter[i] = gpt_reload[i];
++ }
++ }
++ }
++ event(gpt_intr, 0, gpt_scaler + 1);
++ gpt_scaler_start = now();
++}
++
++static void
++gpt_init()
++{
++ if (sis_verbose)
++ printf("GPT started (period %d)\n\r", gpt_scaler + 1);
++}
++
++static void
++gpt_reset()
++{
++ event(gpt_intr, 0, gpt_scaler + 1);
++ gpt_scaler_start = now();
++}
++
++static void
++gpt_scaler_set(val)
++ uint32 val;
++{
++ gpt_scaler = val & 0x0ffff; /* 16-bit scaler */
++}
++
++static void
++timer_ctrl(val, i)
++ uint32 val;
++ int i;
++{
++ if (val & 4) { /* reload */
++ gpt_counter[i] = gpt_reload[i];
++ }
++ gpt_ctrl[i] = val & 0xb;
++}
++
++/* Store data in host byte order. MEM points to the beginning of the
++ emulated memory; WADDR contains the index the emulated memory,
++ DATA points to words in host byte order to be stored. SZ contains log(2)
++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
++
++static void
++store_bytes (mem, waddr, data, sz, ws)
++ unsigned char *mem;
++ uint32 waddr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ switch (sz) {
++ case 0:
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 3;
++#endif
++ mem[waddr] = *data & 0x0ff;
++ *ws = 0;
++ break;
++ case 1:
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 2;
++#endif
++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
++ *ws = 0;
++ break;
++ case 2:
++ *((uint32 *) &(mem[waddr])) = *data;
++ *ws = 0;
++ break;
++ case 3:
++ *((uint32 *) &(mem[waddr])) = data[0];
++ *((uint32 *) &(mem[waddr + 4])) = data[1];
++ *ws = 0;
++ break;
++ }
++}
++
++
++/* Memory emulation */
++
++static int
++memory_iread(addr, data, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 *ws;
++{
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ *data = *((uint32 *) & (ramb[addr & RAM_MASK]));
++ *ws = 0;
++ return (0);
++ } else if (addr < ROM_END) {
++ *data = *((uint32 *) & (romb[addr]));
++ *ws = 0;
++ return (0);
++ }
++
++ printf("Memory exception at %x (illegal address)\n", addr);
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_read(addr, data, sz, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ int32 mexc;
++
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ *data = *((uint32 *) & (ramb[addr & RAM_MASK & ~3]));
++ *ws = 0;
++ return (0);
++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
++ mexc = apb_read(addr, data);
++ if (mexc) {
++ *ws = MEM_EX_WS;
++ } else {
++ *ws = 0;
++ }
++ return (mexc);
++ } else if (addr < ROM_END) {
++ *data = *((uint32 *) & (romb[addr & ~3]));
++ *ws = 0;
++ return (0);
++ }
++
++ printf("Memory exception at %x (illegal address)\n", addr);
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_read_asi(asi, addr, data, sz, ws)
++ int32 asi;
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ return(memory_read(addr, data, sz, ws));
++}
++
++static int
++memory_write(addr, data, sz, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ uint32 byte_addr;
++ uint32 byte_mask;
++ uint32 waddr;
++ uint32 *ram;
++ int32 mexc;
++ int i;
++ int wphit[2];
++
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ waddr = addr & RAM_MASK;
++ store_bytes (ramb, waddr, data, sz, ws);
++ return (0);
++
++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
++ if (sz != 2) {
++ *ws = MEM_EX_WS;
++ return (1);
++ }
++ apb_write(addr, *data);
++ *ws = 0;
++ return (0);
++
++ } else if (addr < ROM_END) {
++// return (1);
++ *ws = 0;
++ store_bytes (romb, addr, data, sz, ws);
++ return (0);
++ }
++
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_write_asi(asi, addr, data, sz, ws)
++ int32 asi;
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ return(memory_write(addr, data, sz, ws));
++}
++
++static unsigned char *
++get_mem_ptr(addr, size)
++ uint32 addr;
++ uint32 size;
++{
++ if ((addr + size) < ROM_END) {
++ return (&romb[addr]);
++ } else if ((addr >= RAM_START) && ((addr + size) < RAM_END)) {
++ return (&ramb[addr & RAM_MASK]);
++ }
++
++ return ((char *) -1);
++}
++
++static int
++sis_memory_write(addr, data, length)
++ uint32 addr;
++ const unsigned char *data;
++ uint32 length;
++{
++ char *mem;
++
++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
++ return (0);
++
++ memcpy(mem, data, length);
++ return (length);
++}
++
++static int
++sis_memory_read(addr, data, length)
++ uint32 addr;
++ char *data;
++ uint32 length;
++{
++ char *mem;
++ int ws;
++
++ if (length == 4) {
++ memory_read(addr, data, length, &ws);
++ return(4);
++ }
++
++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
++ return (0);
++
++ memcpy(data, mem, length);
++ return (length);
++}
++
++static void
++boot_init ()
++{
++// mec_write(MEC_WCR, 0); /* zero waitstates */
++// mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
++ apb_write(TIMER_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
++ apb_write(TIMER_SCLOAD, sregs.freq-1);
++ apb_write(TIMER_TIMER1, -1);
++ apb_write(TIMER_RELOAD1, -1);
++ apb_write(TIMER_CTRL1, 0x7);
++// mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
++ sregs.wim = 2;
++ sregs.psr = 0x000010e0;
++ sregs.r[30] = RAM_END;
++ sregs.r[14] = sregs.r[30] - 96*4;
++ cache_ctrl = 0x01000f;
++
++}
++
++struct memsys leon2 = {
++ init_sim,
++ reset,
++ error_mode,
++ sim_halt,
++ exit_sim,
++ init_stdio,
++ restore_stdio,
++ memory_iread,
++ memory_read,
++ memory_read_asi,
++ memory_write,
++ memory_write_asi,
++ sis_memory_write,
++ sis_memory_read,
++ boot_init
++};
+diff --git a/sim/erc32/leon3.c b/sim/erc32/leon3.c
+new file mode 100644
+index 0000000..e79169e
+--- /dev/null
++++ b/sim/erc32/leon3.c
+@@ -0,0 +1,1066 @@
++/*
++ * This file is part of SIS.
++ *
++ * SIS, SPARC instruction simulator V2.5 Copyright (C) 1995 Jiri Gaisler,
++ * European Space Agency
++ *
++ * This program is free software; you can redistribute it and/or modify it under
++ * the terms of the GNU General Public License as published by the Free
++ * Software Foundation; either version 3 of the License, or (at your option)
++ * any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
++ * more details.
++ *
++ * You should have received a copy of the GNU General Public License along with
++ * this program; if not, see <http://www.gnu.org/licenses/>.
++ *
++ * Leon3 emulation, loosely based on erc32.c .
++ */
++
++/* The control space devices */
++
++#include "config.h"
++#include <errno.h>
++#include <sys/types.h>
++#include <stdio.h>
++#include <string.h>
++#include <termios.h>
++#include <sys/fcntl.h>
++#include <sys/file.h>
++#include <unistd.h>
++#include "sis.h"
++#include "grlib.h"
++#include "sim-config.h"
++
++static int tty_setup = 1; /* default setup if not a tty */
++
++/* APB registers */
++#define APBSTART 0x80000000
++#define APBEND 0x80100000
++
++/* Memory exception waitstates */
++#define MEM_EX_WS 1
++
++#define MOK 0
++
++/* LEON3 APB register addresses */
++
++#define IRQMP_IPR 0x204
++#define IRQMP_IMR 0x240
++#define IRQMP_ICR 0x20C
++#define IRQMP_IFR 0x208
++#define GPTIMER_SCALER 0x300
++#define GPTIMER_SCLOAD 0x304
++#define GPTIMER_CONFIG 0x308
++#define GPTIMER_TIMER1 0x310
++#define GPTIMER_RELOAD1 0x314
++#define GPTIMER_CTRL1 0x318
++#define GPTIMER_TIMER2 0x320
++#define GPTIMER_RELOAD2 0x324
++#define GPTIMER_CTRL2 0x328
++
++#define APBUART_RXTX 0x100
++#define APBUART_STATUS 0x104
++
++/* Size of UART buffers (bytes) */
++#define UARTBUF 1024
++
++/* Number of simulator ticks between flushing the UARTS. */
++/* For good performance, keep above 1000 */
++#define UART_FLUSH_TIME 3000
++
++
++/* New uart defines */
++#define UART_TX_TIME 1000
++#define UART_RX_TIME 1000
++#define UARTA_DR 0x1
++#define UARTA_SRE 0x2
++#define UARTA_HRE 0x4
++#define UARTA_OR 0x10
++
++/* IRQMP registers */
++
++static uint32 irqmp_ipr;
++static uint32 irqmp_imr;
++static uint32 irqmp_ifr;
++
++/* GPTIMER registers */
++
++#define NGPTIMERS 2
++#define GPTIMER_IRQ 8
++
++static uint32 gpt_scaler;
++static uint32 gpt_scaler_start;
++static uint32 gpt_counter[NGPTIMERS];
++static uint32 gpt_reload[NGPTIMERS];
++static uint32 gpt_ctrl[NGPTIMERS];
++
++/* ROM size 16 Mbyte */
++#define ROM_START 0x00000000
++#define ROM_MASK 0x00ffffff
++#define ROM_END (ROM_START + ROM_MASK + 1)
++
++/* RAM size 16 Mbyte */
++#define RAM_START 0x40000000
++#define RAM_MASK 0x00ffffff
++#define RAM_END (RAM_START + RAM_MASK + 1)
++
++/* Memory */
++
++static unsigned char romb[ROM_END - ROM_START];
++static unsigned char ramb[RAM_END - RAM_START];
++static uint32 cache_ctrl;
++
++
++/* UART support variables */
++
++static int32 fd1, fd2; /* file descriptor for input file */
++static int32 Ucontrol; /* UART status register */
++static unsigned char aq[UARTBUF], bq[UARTBUF];
++static int32 anum, aind = 0;
++static int32 bnum, bind = 0;
++static char wbufa[UARTBUF], wbufb[UARTBUF];
++static unsigned wnuma;
++static unsigned wnumb;
++static FILE *f1in, *f1out;
++static struct termios ioc1, ioc2, iocold1, iocold2;
++static int f1open = 0;
++
++static char uarta_sreg, uarta_hreg;
++static uint32 uart_stat_reg;
++static uint32 uarta_data;
++
++/* Forward declarations */
++
++static void mem_init (void);
++static void close_port (void);
++static void leon3_reset (void);
++static void irqmp_intack (int32 level);
++static void chk_irq (void);
++static void set_irq (int32 level);
++static int32 apb_read (uint32 addr, uint32 *data);
++static int apb_write (uint32 addr, uint32 data);
++static void port_init (void);
++static uint32 grlib_read_uart (uint32 addr);
++static void grlib_write_uart (uint32 addr, uint32 data);
++static void flush_uart (void);
++static void uarta_tx (void);
++static void uart_rx (caddr_t arg);
++static void uart_intr (caddr_t arg);
++static void uart_irq_start (void);
++static void gpt_intr (caddr_t arg);
++static void gpt_init (void);
++static void gpt_reset (void);
++static void gpt_scaler_set (uint32 val);
++static void timer_ctrl (uint32 val, int i);
++static unsigned char *
++ get_mem_ptr (uint32 addr, uint32 size);
++static void store_bytes (unsigned char *mem, uint32 waddr,
++ uint32 *data, int sz, int32 *ws);
++
++static host_callback *callback;
++
++
++/* One-time init */
++
++static void
++init_sim()
++{
++ callback = sim_callback;
++ grlib_init();
++ mem_init();
++ port_init();
++ gpt_init();
++}
++
++/* Power-on reset init */
++
++static void
++reset()
++{
++ leon3_reset();
++ uart_irq_start();
++ gpt_reset();
++}
++
++/* IU error mode manager */
++
++static void
++error_mode(pc)
++ uint32 pc;
++{
++
++}
++
++
++/* Memory init */
++
++static void
++mem_init()
++{
++
++/* Add AMBA P&P record for SRCTRL memory controller */
++
++ grlib_ahbspp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_SRCTRL, 0, 0),
++ GRLIB_PP_AHBADDR(0x00000000, 0xE00, 1, 1, 2),
++ GRLIB_PP_AHBADDR(0x40000000, 0xC00, 1, 1, 2),
++ GRLIB_PP_AHBADDR(0x20000000, 0xE00, 0, 0, 2),
++ 0);
++ if (sis_verbose)
++ printf("RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n",
++ RAM_START, (RAM_MASK+1)/1024, (ROM_MASK+1)/1024);
++}
++
++/* Flush ports when simulator stops */
++
++static void
++sim_halt()
++{
++#ifdef FAST_UART
++ flush_uart();
++#endif
++}
++
++static void
++close_port()
++{
++ if (f1open && f1in != stdin)
++ fclose(f1in);
++}
++
++static void
++exit_sim()
++{
++ close_port();
++}
++
++static void
++leon3_reset()
++{
++ int i;
++
++ irqmp_ipr = 0;
++ irqmp_imr = 0;
++ irqmp_ifr = 0;
++
++ wnuma = wnumb = 0;
++ anum = aind = bnum = bind = 0;
++
++ uart_stat_reg = UARTA_SRE | UARTA_HRE;
++
++ gpt_counter[0] = 0xffffffff;
++ gpt_reload[0] = 0xffffffff;
++ gpt_scaler = 0xffff;
++ gpt_ctrl[0] = 0;
++ gpt_ctrl[1] = 0;
++
++}
++
++
++
++static void
++irqmp_intack(level)
++ int32 level;
++{
++ int irq_test;
++
++ if (sis_verbose > 2)
++ printf("interrupt %d acknowledged\n", level);
++ if (irqmp_ifr & (1 << level))
++ irqmp_ifr &= ~(1 << level);
++ else
++ irqmp_ipr &= ~(1 << level);
++ chk_irq();
++}
++
++static void
++chk_irq()
++{
++ int32 i;
++ uint32 itmp;
++ int old_irl;
++
++ old_irl = ext_irl;
++ itmp = ((irqmp_ipr | irqmp_ifr) & irqmp_imr) & 0x0fffe;
++ ext_irl = 0;
++ if (itmp != 0) {
++ for (i = 15; i > 0; i--) {
++ if (((itmp >> i) & 1) != 0) {
++ if ((sis_verbose > 2) && (i > old_irl))
++ printf("IU irl: %d\n", i);
++ ext_irl = i;
++ set_int(i, irqmp_intack, i);
++ break;
++ }
++ }
++ }
++}
++
++static void
++set_irq(level)
++ int32 level;
++{
++ irqmp_ipr |= (1 << level);
++ chk_irq();
++}
++
++static int32
++apb_read(addr, data)
++ uint32 addr;
++ uint32 *data;
++{
++
++ switch (addr & 0xfff) {
++
++ case APBUART_RXTX: /* 0x100 */
++ case APBUART_STATUS: /* 0x104 */
++ *data = grlib_read_uart(addr);
++ break;
++
++ case IRQMP_IPR: /* 0x204 */
++ *data = irqmp_ipr;
++ break;
++
++ case IRQMP_IFR: /* 0x208 */
++ *data = irqmp_ifr;
++ break;
++
++ case IRQMP_IMR: /* 0x240 */
++ *data = irqmp_imr;
++ break;
++
++ case GPTIMER_SCALER: /* 0x300 */
++ *data = gpt_scaler - (now() - gpt_scaler_start);
++ break;
++
++ case GPTIMER_SCLOAD: /* 0x304 */
++ *data = gpt_scaler;
++ break;
++
++ case GPTIMER_CONFIG: /* 0x308 */
++ *data = 0x100 | (GPTIMER_IRQ << 3) | NGPTIMERS;
++ break;
++
++ case GPTIMER_TIMER1: /* 0x310 */
++ *data = gpt_counter[0];
++ break;
++
++ case GPTIMER_RELOAD1: /* 0x314 */
++ *data = gpt_reload[0];
++ break;
++
++ case GPTIMER_CTRL1: /* 0x318 */
++ *data = gpt_ctrl[0];
++ break;
++
++ case GPTIMER_TIMER2: /* 0x320 */
++ *data = gpt_counter[1];
++ break;
++
++ case GPTIMER_RELOAD2: /* 0x324 */
++ *data = gpt_reload[1];
++ break;
++
++ case GPTIMER_CTRL2: /* 0x328 */
++ *data = gpt_ctrl[1];
++ break;
++
++ default:
++ *data = 0;
++ break;
++ }
++
++ if (sis_verbose > 1)
++ printf("APB read a: %08x, d: %08x\n", addr, *data);
++
++ return (MOK);
++}
++
++static int
++apb_write(addr, data)
++ uint32 addr;
++ uint32 data;
++{
++ if (sis_verbose > 1)
++ printf("APB write a: %08x, d: %08x\n",addr,data);
++ switch (addr & 0xfff) {
++
++ case APBUART_RXTX: /* 0x100 */
++ case APBUART_STATUS: /* 0x104 */
++ grlib_write_uart(addr, data);
++ break;
++
++ case IRQMP_IFR: /* 0x208 */
++ irqmp_ifr = data & 0xfffe;
++ chk_irq();
++ break;
++
++ case IRQMP_ICR: /* 0x20C */
++ irqmp_ipr &= ~data & 0x0fffe;
++ chk_irq();
++ break;
++
++ case IRQMP_IMR: /* 0x240 */
++ irqmp_imr = data & 0x7ffe;
++ chk_irq();
++ break;
++
++ case GPTIMER_SCLOAD: /* 0x304 */
++ gpt_scaler_set(data);
++ break;
++
++ case GPTIMER_TIMER1: /* 0x310 */
++ gpt_counter[0] = data;
++ break;
++
++ case GPTIMER_RELOAD1: /* 0x314 */
++ gpt_reload[0] = data;
++ break;
++
++ case GPTIMER_CTRL1: /* 0x318 */
++ timer_ctrl(data, 0);
++ break;
++
++ case GPTIMER_TIMER2: /* 0x320 */
++ gpt_counter[1] = data;
++ break;
++
++ case GPTIMER_RELOAD2: /* 0x324 */
++ gpt_reload[1] = data;
++ break;
++
++ case GPTIMER_CTRL2: /* 0x328 */
++ timer_ctrl(data, 1);
++ break;
++
++ default:
++ break;
++ }
++ return (MOK);
++}
++
++
++/* APBUART */
++
++static int ifd1 = -1, ofd1 = -1;
++
++static void
++init_stdio()
++{
++ if (dumbio)
++ return; /* do nothing */
++ if (ifd1 == 0 && f1open) {
++ tcsetattr(0, TCSANOW, &ioc1);
++ tcflush(ifd1, TCIFLUSH);
++ }
++}
++
++static void
++restore_stdio()
++{
++ if (dumbio)
++ return; /* do nothing */
++ if (ifd1 == 0 && f1open && tty_setup)
++ tcsetattr(0, TCSANOW, &iocold1);
++}
++
++#define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
++ ( dumbio || nouartrx \
++ ? (0) /* no bytes read, no delay */ \
++ : (_fd_) == 1 && callback ? \
++ callback->read_stdin (callback, _buf_, _len_) : \
++ read( _fd_, _buf_, _len_ ) )
++
++
++static void
++port_init()
++{
++
++ f1in = stdin;
++ f1out = stdout;
++ if (uart_dev1[0] != 0)
++ if ((fd1 = open(uart_dev1, O_RDWR | O_NONBLOCK)) < 0) {
++ printf("Warning, couldn't open output device %s\n", uart_dev1);
++ } else {
++ if (sis_verbose)
++ printf("serial port A on %s\n", uart_dev1);
++ f1in = f1out = fdopen(fd1, "r+");
++ setbuf(f1out, NULL);
++ f1open = 1;
++ }
++ if (f1in) ifd1 = fileno(f1in);
++ if (ifd1 == 0) {
++ if (callback && !callback->isatty(callback, ifd1)) {
++ tty_setup = 0;
++ }
++ if (sis_verbose)
++ printf("serial port A on stdin/stdout\n");
++ if (!dumbio) {
++ tcgetattr(ifd1, &ioc1);
++ if (tty_setup) {
++ iocold1 = ioc1;
++ ioc1.c_lflag &= ~(ICANON | ECHO);
++ ioc1.c_cc[VMIN] = 0;
++ ioc1.c_cc[VTIME] = 0;
++ }
++ }
++ f1open = 1;
++ }
++
++ if (f1out) {
++ ofd1 = fileno(f1out);
++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
++ }
++
++ wnuma = 0;
++
++
++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_APBUART, 1, 3),
++ GRLIB_PP_APBADDR(0x80000100, 0xFFF));
++}
++
++static uint32
++grlib_read_uart(addr)
++ uint32 addr;
++{
++
++ unsigned tmp;
++
++ tmp = 0;
++ switch (addr & 0xff) {
++
++ case 0x00: /* UART 1 RX/TX */
++#ifndef _WIN32
++#ifdef FAST_UART
++
++ if (aind < anum) {
++ if ((aind + 1) < anum)
++ set_irq(3);
++ return ((uint32) aq[aind++]);
++ } else {
++ if (f1open) {
++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
++ }
++ else {
++ anum = 0;
+ }
-+- rawfsr = _get_cw();
-+- rawfsr |= (fsr << 10) | 0x3ff;
-+- __setfpucw(rawfsr);
-++ rawfsr = (fsr << 10) | 0x2FF; /* double precision, all traps masked */
-++ __asm__ volatile ("fldcw %0" :: "m" (rawfsr));
-+ #else
-+ #warning no fpu trap support for this target
-+ #endif
-+@@ -175,45 +172,36 @@ uint32 fsr;
-+ "\n"
-+ " ");
-+
-++#elif defined(__x86_64__)
-++ asm ("\n"
-++"\n"
-++".text\n"
-++".align 8\n"
-++".globl _get_sw, __get_sw\n"
-++"__get_sw:\n"
-++"_get_sw:\n"
-++" pushq %rbp\n"
-++" movq %rsp, %rbp\n"
-++" movl $0, %eax\n"
-++" fnstsw %ax\n"
-++" movq %rbp, %rsp\n"
-++" popq %rbp\n"
-++" ret\n"
-++".align 8\n"
-++".globl _get_cw, __get_cw\n"
-++"__get_cw:\n"
-++"_get_cw:\n"
-++" pushq %rbp\n"
-++" movq %rsp, %rbp\n"
-++" subq $2, %rsp\n"
-++" fnstcw -2(%rbp)\n"
-++" movw -2(%rbp), %ax\n"
-++" movq %rbp, %rsp\n"
-++" popq %rbp\n"
-++" ret\n"
-++" ");
-+
-+ #else
-+ #warning no fpu trap support for this target
-+ #endif
-+
-+-#if i386
-+-/* #if defined _WIN32 || defined __GO32__ */
-+-/* This is so floating exception handling works on NT
-+- These definitions are from the linux fpu_control.h, which
-+- doesn't exist on NT.
-+-
-+- default to:
-+- - extended precision
-+- - rounding to nearest
-+- - exceptions on overflow, zero divide and NaN
-+-*/
-+-#define _FPU_DEFAULT 0x1372
-+-#define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */
-+-
-+-static void
-+-__setfpucw(unsigned short fpu_control)
-+-{
-+- volatile unsigned short cw;
-+-
-+- /* If user supplied _fpu_control, use it ! */
-+- if (!fpu_control)
-+- {
-+- /* use defaults */
-+- fpu_control = _FPU_DEFAULT;
-+- }
-+- /* Get Control Word */
-+- __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
-+-
-+- /* mask in */
-+- cw &= _FPU_RESERVED;
-+- cw = cw | (fpu_control & ~_FPU_RESERVED);
-+-
-+- /* set cw */
-+- __asm__ volatile ("fldcw %0" :: "m" (cw));
-+-}
-+-/* #endif */
-+-#endif
-+diff --git a/sim/erc32/func.c b/sim/erc32/func.c
-+index d001c58..6f985a1 100644
-+--- a/sim/erc32/func.c
-++++ b/sim/erc32/func.c
-+@@ -26,20 +26,26 @@
-+ #include <stdlib.h>
-+ #include <ctype.h>
-+ #include "sis.h"
-+-#include "end.h"
-+ #include <dis-asm.h>
-+ #include "sim-config.h"
-+
-+
-+ #define VAL(x) strtoul(x,(char **)NULL,0)
-+
-+-extern int current_target_byte_order;
-++/* The target's byte order is big-endian by default until we load a
-++ little-endian program. */
-++int current_target_byte_order = BIG_ENDIAN;
-++
-++int dumbio = 0; /* normal, smart, terminal oriented IO by default */
-+ struct disassemble_info dinfo;
-+ struct pstate sregs;
-+-extern struct estate ebase;
-++struct estate ebase;
-++struct evcell evbuf[EVENT_MAX];
-++struct irqcell irqarr[16];
-++
-+ int ctrl_c = 0;
-+ int sis_verbose = 0;
-+-char *sis_version = "2.7.5";
-++char *sis_version = "2.8";
-+ int nfp = 0;
-+ int ift = 0;
-+ int wrp = 0;
-+@@ -50,8 +56,11 @@ int sparclite = 0; /* emulating SPARClite instructions? */
-+ int sparclite_board = 0; /* emulating SPARClite board RAM? */
-+ char uart_dev1[128] = "";
-+ char uart_dev2[128] = "";
-+-extern int ext_irl;
-+ uint32 last_load_addr = 0;
-++int nouartrx = 0;
-++host_callback *sim_callback;
-++struct memsys *ms = &erc32sys;
-++int cputype = 0; /* 0 = erc32, 3 = leon3 */
-+
-+ #ifdef ERRINJ
-+ uint32 errcnt = 0;
-+@@ -81,6 +90,7 @@ batch(sregs, fname)
-+ {
-+ FILE *fp;
-+ char lbuf[1024];
-++ char *tmp;
-+
-+ if ((fp = fopen(fname, "r")) == NULL) {
-+ fprintf(stderr, "couldn't open batch file %s\n", fname);
-+@@ -88,7 +98,7 @@ batch(sregs, fname)
-+ }
-+ while (!feof(fp)) {
-+ lbuf[0] = 0;
-+- fgets(lbuf, 1023, fp);
-++ tmp = fgets(lbuf, 1023, fp);
-+ if ((strlen(lbuf) > 0) && (lbuf[strlen(lbuf) - 1] == '\n'))
-+ lbuf[strlen(lbuf) - 1] = 0;
-+ printf("sis> %s\n", lbuf);
-+@@ -382,7 +392,7 @@ exec_cmd(sregs, cmd)
-+ {
-+ char *cmd1, *cmd2;
-+ int32 stat;
-+- uint32 len, i, clen, j;
-++ uint32 len, i, clen, j, tmp;
-+ static uint32 daddr = 0;
-+ char *cmdsave;
-+
-+@@ -426,7 +436,7 @@ exec_cmd(sregs, cmd)
-+ stat = run_sim(sregs, VAL(cmd1), 0);
-+ }
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "debug", clen) == 0) {
-+ if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) {
-+ sis_verbose = VAL(cmd1);
-+@@ -468,6 +478,7 @@ exec_cmd(sregs, cmd)
-+ }
-+ sregs->pc = len & ~3;
-+ sregs->npc = sregs->pc + 4;
-++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
-+ printf("resuming at 0x%08x\n",sregs->pc);
-+ if ((cmd2 = strtok(NULL, " \t\n\r")) != NULL) {
-+ stat = run_sim(sregs, VAL(cmd2), 0);
-+@@ -475,7 +486,7 @@ exec_cmd(sregs, cmd)
-+ stat = run_sim(sregs, UINT64_MAX, 0);
-+ }
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "help", clen) == 0) {
-+ gen_help();
-+ } else if (strncmp(cmd1, "history", clen) == 0) {
-+@@ -543,26 +554,31 @@ exec_cmd(sregs, cmd)
-+ ebase.simtime = 0;
-+ reset_all();
-+ reset_stat(sregs);
-++ if (last_load_addr != 0) {
-++ sregs->pc = last_load_addr & ~3;
-++ sregs->npc = sregs->pc + 4;
-++ }
-++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
-+ if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) {
-+ stat = run_sim(sregs, UINT64_MAX, 0);
-+ } else {
-+ stat = run_sim(sregs, VAL(cmd1), 0);
-+ }
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "shell", clen) == 0) {
-+ if ((cmd1 = strtok(NULL, " \t\n\r")) != NULL) {
-+- system(&cmdsave[clen]);
-++ tmp = system(&cmdsave[clen]);
-+ }
-+ } else if (strncmp(cmd1, "step", clen) == 0) {
-+ stat = run_sim(sregs, 1, 1);
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "tcont", clen) == 0) {
-+ sregs->tlimit = limcalc(sregs->freq);
-+ stat = run_sim(sregs, UINT64_MAX, 0);
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "tgo", clen) == 0) {
-+ if ((cmd1 = strtok(NULL, " \t\n\r")) == NULL) {
-+ len = last_load_addr;
-+@@ -575,7 +591,7 @@ exec_cmd(sregs, cmd)
-+ printf("resuming at 0x%08x\n",sregs->pc);
-+ stat = run_sim(sregs, UINT64_MAX, 0);
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "tlimit", clen) == 0) {
-+ sregs->tlimit = limcalc(sregs->freq);
-+ if (sregs->tlimit != (uint32) -1)
-+@@ -589,15 +605,20 @@ exec_cmd(sregs, cmd)
-+ }
-+ printf("\n");
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else if (strncmp(cmd1, "trun", clen) == 0) {
-+ ebase.simtime = 0;
-+ reset_all();
-+ reset_stat(sregs);
-++ if (last_load_addr != 0) {
-++ sregs->pc = last_load_addr & ~3;
-++ sregs->npc = sregs->pc + 4;
-++ }
-++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
-+ sregs->tlimit = limcalc(sregs->freq);
-+ stat = run_sim(sregs, UINT64_MAX, 0);
-+ daddr = sregs->pc;
-+- sim_halt();
-++ ms->sim_halt();
-+ } else
-+ printf("syntax error\n");
-+ }
-+@@ -611,7 +632,7 @@ void
-+ reset_stat(sregs)
-+ struct pstate *sregs;
-+ {
-+- sregs->tottime = 0;
-++ sregs->tottime = 0.0;
-+ sregs->pwdtime = 0;
-+ sregs->ninst = 0;
-+ sregs->fholdt = 0;
-+@@ -629,10 +650,10 @@ void
-+ show_stat(sregs)
-+ struct pstate *sregs;
-+ {
-+- uint32 iinst;
-+- uint32 stime, tottime;
-++ uint64 iinst;
-++ uint64 stime;
-+
-+- if (sregs->tottime == 0) tottime = 1; else tottime = sregs->tottime;
-++ if (sregs->tottime == 0.0) sregs->tottime +=1E-6;
-+ stime = ebase.simtime - sregs->simstart; /* Total simulated time */
-+ #ifdef STAT
-+
-+@@ -640,39 +661,39 @@ show_stat(sregs)
-+ sregs->nbranch;
-+ #endif
-+
-+- printf("\n Cycles : %9d\n\r", ebase.simtime - sregs->simstart);
-+- printf(" Instructions : %9d\n", sregs->ninst);
-++ printf("\n Cycles : %9llu\n\r", ebase.simtime - sregs->simstart);
-++ printf(" Instructions : %9llu\n", sregs->ninst);
-+
-+ #ifdef STAT
-+- printf(" integer : %9.2f %%\n", 100.0 * (float) iinst / (float) sregs->ninst);
-++ printf(" integer : %9.2f %%\n", 100.0 * (double) iinst / (double) sregs->ninst);
-+ printf(" load : %9.2f %%\n",
-+- 100.0 * (float) sregs->nload / (float) sregs->ninst);
-++ 100.0 * (double) sregs->nload / (double) sregs->ninst);
-+ printf(" store : %9.2f %%\n",
-+- 100.0 * (float) sregs->nstore / (float) sregs->ninst);
-++ 100.0 * (double) sregs->nstore / (double) sregs->ninst);
-+ printf(" branch : %9.2f %%\n",
-+- 100.0 * (float) sregs->nbranch / (float) sregs->ninst);
-++ 100.0 * (double) sregs->nbranch / (double) sregs->ninst);
-+ printf(" float : %9.2f %%\n",
-+- 100.0 * (float) sregs->finst / (float) sregs->ninst);
-++ 100.0 * (double) sregs->finst / (double) sregs->ninst);
-+ printf(" Integer CPI : %9.2f\n",
-+- ((float) (stime - sregs->pwdtime - sregs->fholdt - sregs->finst))
-++ ((double) (stime - sregs->pwdtime - sregs->fholdt - sregs->finst))
-+ /
-+- (float) (sregs->ninst - sregs->finst));
-++ (double) (sregs->ninst - sregs->finst));
-+ printf(" Float CPI : %9.2f\n",
-+- ((float) sregs->fholdt / (float) sregs->finst) + 1.0);
-++ ((double) sregs->fholdt / (double) sregs->finst) + 1.0);
-+ #endif
-+ printf(" Overall CPI : %9.2f\n",
-+- (float) (stime - sregs->pwdtime) / (float) sregs->ninst);
-+- printf("\n ERC32 performance (%4.1f MHz): %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n",
-+- sregs->freq, sregs->freq * (float) sregs->ninst / (float) (stime - sregs->pwdtime),
-+- sregs->freq * (float) (sregs->ninst - sregs->finst) /
-+- (float) (stime - sregs->pwdtime),
-+- sregs->freq * (float) sregs->finst / (float) (stime - sregs->pwdtime));
-+- printf(" Simulated ERC32 time : %5.2f ms\n", (float) (ebase.simtime - sregs->simstart) / 1000.0 / sregs->freq);
-+- printf(" Processor utilisation : %5.2f %%\n", 100.0 * (1.0 - ((float) sregs->pwdtime / (float) stime)));
-+- printf(" Real-time / simulator-time : 1/%.2f \n",
-+- ((float) sregs->tottime) / ((float) (stime) / (sregs->freq * 1.0E6)));
-+- printf(" Simulator performance : %d KIPS\n",sregs->ninst/tottime/1000);
-+- printf(" Used time (sys + user) : %3d s\n\n", sregs->tottime);
-++ (double) (stime - sregs->pwdtime) / (double) sregs->ninst);
-++ printf("\n CPU performance (%4.1f MHz) : %5.2f MOPS (%5.2f MIPS, %5.2f MFLOPS)\n",
-++ sregs->freq, sregs->freq * (double) sregs->ninst / (double) (stime - sregs->pwdtime),
-++ sregs->freq * (double) (sregs->ninst - sregs->finst) /
-++ (double) (stime - sregs->pwdtime),
-++ sregs->freq * (double) sregs->finst / (double) (stime - sregs->pwdtime));
-++ printf(" Simulated CPU time : %.2f s\n", (double) (ebase.simtime - sregs->simstart) / 1000000.0 / sregs->freq);
-++ printf(" Processor utilisation : %.2f %%\n", 100.0 * (1.0 - ((double) sregs->pwdtime / (double) stime)));
-++ printf(" Real-time performance : %.2f %%\n", 100.0/
-++ ((sregs->tottime) / ((double) (stime) / (sregs->freq * 1.0E6))));
-++ printf(" Simulator performance : %.2f MIPS\n",(double)(sregs->ninst)/sregs->tottime/1E6);
-++ printf(" Used time (sys + user) : %.2f s\n\n", sregs->tottime);
-+ }
-+
-+
-+@@ -708,12 +729,6 @@ init_signals()
-+ }
-+
-+
-+-extern struct disassemble_info dinfo;
-+-
-+-struct estate ebase;
-+-struct evcell evbuf[EVENT_MAX];
-+-struct irqcell irqarr[16];
-+-
-+ static int
-+ disp_fpu(sregs)
-+ struct pstate *sregs;
-+@@ -724,7 +739,7 @@ disp_fpu(sregs)
-+
-+ printf("\n fsr: %08X\n\n", sregs->fsr);
-+
-+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
-++#ifdef HOST_LITTLE_ENDIAN
-+ for (i = 0; i < 32; i++)
-+ sregs->fdp[i ^ 1] = sregs->fs[i];
-+ #endif
-+@@ -759,21 +774,32 @@ disp_regs(sregs,cwp)
-+ }
-+ }
-+
-++static void print_insn_sparc_sis(uint32 addr, struct disassemble_info *info)
-++{
-++ unsigned char i[4];
-++
-++ ms->sis_memory_read(addr, i, 4);
-++ dinfo.buffer_vma = addr;
-++ dinfo.buffer_length = 4;
-++ dinfo.buffer = i;
-++ print_insn_sparc(addr, info);
-++}
-++
-+ static void
-+ disp_ctrl(sregs)
-+ struct pstate *sregs;
-+ {
-+
-+- unsigned char i[4];
-++ uint32 i;
-+
-+ printf("\n psr: %08X wim: %08X tbr: %08X y: %08X\n",
-+ sregs->psr, sregs->wim, sregs->tbr, sregs->y);
-+- sis_memory_read(sregs->pc, i, 4);
-+- printf("\n pc: %08X = %02X%02X%02X%02X ", sregs->pc,i[0],i[1],i[2],i[3]);
-+- print_insn_sparc(sregs->pc, &dinfo);
-+- sis_memory_read(sregs->npc, i, 4);
-+- printf("\n npc: %08X = %02X%02X%02X%02X ",sregs->npc,i[0],i[1],i[2],i[3]);
-+- print_insn_sparc(sregs->npc, &dinfo);
-++ ms->sis_memory_read(sregs->pc, (char *) &i, 4);
-++ printf("\n pc: %08X = %08X ", sregs->pc, i);
-++ print_insn_sparc_sis(sregs->pc, &dinfo);
-++ ms->sis_memory_read(sregs->npc, (char *) &i, 4);
-++ printf("\n npc: %08X = %08X ", sregs->npc, i);
-++ print_insn_sparc_sis(sregs->npc, &dinfo);
-+ if (sregs->err_mode)
-+ printf("\n IU in error mode");
-+ printf("\n\n");
-+@@ -787,21 +813,28 @@ disp_mem(addr, len)
-+
-+ uint32 i;
-+ unsigned char data[4];
-++ uint32 *wdata = (uint32 *) data;
-+ uint32 mem[4], j;
-+ char *p;
-++ int end;
-+
-++#ifdef HOST_LITTLE_ENDIAN
-++ end = 3;
-++#else
-++ end = 0;
-++#endif
-+ for (i = addr & ~3; i < ((addr + len) & ~3); i += 16) {
-+ printf("\n %8X ", i);
-+ for (j = 0; j < 4; j++) {
-+- sis_memory_read((i + (j * 4)), data, 4);
-+- printf("%02x%02x%02x%02x ", data[0],data[1],data[2],data[3]);
-++ ms->sis_memory_read((i + (j * 4)), data, 4);
-++ printf("%08x ", *wdata);
-+ mem[j] = *((int *) &data);
-+ }
-+ printf(" ");
-+ p = (char *) mem;
-+ for (j = 0; j < 16; j++) {
-+- if (isprint(p[j]))
-+- putchar(p[j]);
-++ if (isprint(p[j^end]))
-++ putchar(p[j^end]);
-+ else
-+ putchar('.');
-+ }
-+@@ -817,11 +850,12 @@ dis_mem(addr, len, info)
-+ {
-+ uint32 i;
-+ unsigned char data[4];
-++ uint32 *wdata = (uint32 *) data;
-+
-+ for (i = addr & -3; i < ((addr & -3) + (len << 2)); i += 4) {
-+- sis_memory_read(i, data, 4);
-+- printf(" %08x %02x%02x%02x%02x ", i, data[0],data[1],data[2],data[3]);
-+- print_insn_sparc(i, info);
-++ ms->sis_memory_read(i, data, 4);
-++ printf(" %08x %08x ", i, *wdata);
-++ print_insn_sparc_sis(i, info);
-+ if (i >= 0xfffffffc) break;
-+ printf("\n");
-+ }
-+@@ -983,7 +1017,7 @@ reset_all()
-+ {
-+ init_event(); /* Clear event queue */
-+ init_regs(&sregs);
-+- reset();
-++ ms->reset();
-+ #ifdef ERRINJ
-+ errinjstart();
-+ #endif
-+@@ -1019,6 +1053,7 @@ bfd_load(fname)
-+ asection *section;
-+ bfd *pbfd;
-+ const bfd_arch_info_type *arch;
-++ int i;
-+
-+ pbfd = bfd_openr(fname, 0);
-+
-+@@ -1092,14 +1127,18 @@ bfd_load(fname)
-+ fptr = 0;
-+
-+ while (section_size > 0) {
-+- char buffer[1024];
-+ int count;
-++ char buffer[1024];
-++ uint32 *wbuffer = (uint32 *) buffer;
-+
-+ count = min(section_size, 1024);
-+
-+ bfd_get_section_contents(pbfd, section, buffer, fptr, count);
-+
-+- sis_memory_write(section_address, buffer, count);
-++#ifdef HOST_LITTLE_ENDIAN
-++ for (i=0;i<count/4;i++) wbuffer[i] = ntohl(wbuffer[i]); // endian swap
-++#endif
-++ ms->sis_memory_write(section_address, buffer, count);
-+
-+ section_address += count;
-+ fptr += count;
-+@@ -1115,3 +1154,16 @@ bfd_load(fname)
-+
-+ return(bfd_get_start_address (pbfd));
-+ }
-++
-++
-++double get_time (void)
-++{
-++ double usec;
-++
-++ struct timeval tm;
-++
-++ gettimeofday (&tm, NULL);
-++ usec = ((double) tm.tv_sec) * 1E6 + ((double) tm.tv_usec);
-++ return (usec / 1E6);
-++
-++}
-+diff --git a/sim/erc32/grlib.c b/sim/erc32/grlib.c
-+new file mode 100644
-+index 0000000..42a3ed0
-+--- /dev/null
-++++ b/sim/erc32/grlib.c
-+@@ -0,0 +1,98 @@
-++/*
-++ * This file is part of SIS.
-++ *
-++ * SIS, SPARC instruction simulator. Copyright (C) 2014 Jiri Gaisler
-++ *
-++ * This program is free software; you can redistribute it and/or modify it under
-++ * the terms of the GNU General Public License as published by the Free
-++ * Software Foundation; either version 3 of the License, or (at your option)
-++ * any later version.
-++ *
-++ * This program is distributed in the hope that it will be useful, but WITHOUT
-++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-++ * more details.
-++ *
-++ * 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 "sis.h"
-++#include "grlib.h"
-++
-++
-++/* APB PNP */
-++
-++static uint32 apbppmem[32*2]; /* 32-entry APB PP AREA */
-++static int apbppindex;
-++
-++int grlib_apbpp_add(uint32 id, uint32 addr)
-++{
-++ apbppmem[apbppindex++] = id;
-++ apbppmem[apbppindex++] = addr;
-++ if(apbppindex >= (32*2)) apbppindex = 0; /* prevent overflow of area */
-++ return(apbppindex);
-++}
-++
-++uint32 grlib_apbpnp_read(uint32 addr)
-++{
-++ uint32 read_data;
-++ addr &= 0xff;
-++ read_data = apbppmem[addr>>2];
-++
-++ return read_data;
-++}
-++
-++/* AHB PNP */
-++
-++static uint32 ahbppmem[128*8]; /* 128-entry AHB PP AREA */
-++static int ahbmppindex;
-++static int ahbsppindex = 64*8;
-++
-++int grlib_ahbmpp_add(uint32 id)
-++{
-++ ahbppmem[ahbmppindex] = id;
-++ ahbmppindex += 8;
-++ if(ahbmppindex >= (64*8)) ahbmppindex = 0; /* prevent overflow of area */
-++ return(ahbmppindex);
-++}
-++
-++int grlib_ahbspp_add(uint32 id, uint32 addr1, uint32 addr2,
-++ uint32 addr3, uint32 addr4)
-++{
-++ ahbppmem[ahbsppindex] = id;
-++ ahbsppindex += 4;
-++ ahbppmem[ahbsppindex++] = addr1;
-++ ahbppmem[ahbsppindex++] = addr2;
-++ ahbppmem[ahbsppindex++] = addr3;
-++ ahbppmem[ahbsppindex++] = addr4;
-++ if(ahbsppindex >= (128*8)) ahbsppindex = 64*8; /* prevent overflow of area */
-++ return(ahbsppindex);
-++}
-++
-++uint32 grlib_ahbpnp_read(uint32 addr)
-++{
-++ uint32 read_data;
-++
-++ addr &= 0xfff;
-++ read_data = ahbppmem[addr>>2];
-++ return read_data;
-++
-++}
-++
-++void grlib_init()
-++{
-++ /* Add PP records for Leon3, APB bridge and interrupt controller
-++ as this is not done elsewhere */
-++
-++ grlib_ahbmpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_LEON3, 0, 0));
-++ grlib_ahbspp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_APBMST, 0, 0),
-++ GRLIB_PP_AHBADDR(0x80000000, 0xFFF, 0, 0, 2),
-++ 0, 0, 0);
-++
-++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_IRQMP, 2, 0),
-++ GRLIB_PP_APBADDR(0x80000200, 0xFFF));
-++
-++}
-+diff --git a/sim/erc32/grlib.h b/sim/erc32/grlib.h
-+new file mode 100644
-+index 0000000..4d52211
-+--- /dev/null
-++++ b/sim/erc32/grlib.h
-+@@ -0,0 +1,57 @@
-++/*
-++ * This file is part of SIS.
-++ *
-++ * SIS, SPARC instruction simulator. Copyright (C) 2014 Jiri Gaisler
-++ *
-++ * This program is free software; you can redistribute it and/or modify it under
-++ * the terms of the GNU General Public License as published by the Free
-++ * Software Foundation; either version 3 of the License, or (at your option)
-++ * any later version.
-++ *
-++ * This program is distributed in the hope that it will be useful, but WITHOUT
-++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-++ * more details.
-++ *
-++ * You should have received a copy of the GNU General Public License along with
-++ * this program; if not, see <http://www.gnu.org/licenses/>.
-++ *
-++ */
-++
-++
-++/* Definitions for AMBA PNP in Gaisler Research GRLIB SOC */
-++
-++/* Vendors */
-++#define VENDOR_GAISLER 1
-++#define VENDOR_PENDER 2
-++#define VENDOR_ESA 4
-++#define VENDOR_DLR 10
-++
-++/* Devices */
-++#define GAISLER_LEON3 0x003
-++#define GAISLER_APBMST 0x006
-++#define GAISLER_SRCTRL 0x008
-++#define GAISLER_APBUART 0x00C
-++#define GAISLER_IRQMP 0x00D
-++#define GAISLER_GPTIMER 0x011
-++#define ESA_MCTRL 0x00F
-++
-++/* How to build entries in the plug&play area */
-++#define GRLIB_PP_ID(v, d, x, i) ((v & 0xff) << 24) | ((d & 0x3ff) << 12) |\
-++ ((x & 0x1f) << 5) | (i & 0x1f)
-++#define GRLIB_PP_AHBADDR(a, m, p, c, t) (a & 0xfff00000) | ((m & 0xfff) << 4) |\
-++ ((p & 1) << 17) | ((c & 1) << 16) | (t & 0x3)
-++#define GRLIB_PP_APBADDR(a, m) ((a & 0xfff00)<< 12) | ((m & 0xfff) << 4) | 1
-++
-++#define AHBPP_START 0xFFFFF000
-++#define AHBPP_END 0xFFFFFFFF
-++#define APBPP_START 0x800FF000
-++#define APBPP_END 0x800FFFFF
-++
-++int grlib_apbpp_add(uint32 id, uint32 addr);
-++int grlib_ahbmpp_add(uint32 id);
-++int grlib_ahbspp_add(uint32 id, uint32 addr1, uint32 addr2,
-++ uint32 addr3, uint32 addr4);
-++uint32 grlib_ahbpnp_read(uint32 addr);
-++uint32 grlib_apbpnp_read(uint32 addr);
-++void grlib_init();
-+diff --git a/sim/erc32/help.c b/sim/erc32/help.c
-+index 21c2a77..6d74e79 100644
-+--- a/sim/erc32/help.c
-++++ b/sim/erc32/help.c
-+@@ -7,8 +7,8 @@ usage()
-+ {
-+
-+ printf("usage: sis [-uart1 uart_device1] [-uart2 uart_device2]\n");
-++ printf("[-sparclite] [-dumbio] [-v] [-vv]\n");
-+ printf("[-nfp] [-freq frequency] [-c batch_file] [files]\n");
-+- printf("[-sparclite] [-dumbio]\n");
-+ }
-+
-+ void
-+diff --git a/sim/erc32/interf.c b/sim/erc32/interf.c
-+index e2db44e..259c8f3 100644
-+--- a/sim/erc32/interf.c
-++++ b/sim/erc32/interf.c
-+@@ -24,7 +24,6 @@
-+ #include <string.h>
-+ #include <stdio.h>
-+ #include <stdlib.h>
-+-#include <time.h>
-+ #include <sys/fcntl.h>
-+ #include "sis.h"
-+ #include "libiberty.h"
-+@@ -36,34 +35,10 @@
-+ #include "gdb/signals.h"
-+
-+ #define PSR_CWP 0x7
-+-
-+-extern struct disassemble_info dinfo;
-+-extern struct pstate sregs;
-+-extern struct estate ebase;
-+-
-+-extern int current_target_byte_order;
-+-extern int ctrl_c;
-+-extern int nfp;
-+-extern int ift;
-+-extern int rom8;
-+-extern int wrp;
-+-extern int uben;
-+-extern int sis_verbose;
-+-extern char *sis_version;
-+-extern struct estate ebase;
-+-extern struct evcell evbuf[];
-+-extern struct irqcell irqarr[];
-+-extern int irqpend, ext_irl;
-+-extern int sparclite;
-+-extern int dumbio;
-+-extern int sparclite_board;
-+-extern int termsave;
-+-extern char uart_dev1[], uart_dev2[];
-++#define SOFT_BREAK 0x91d02001
-+
-+ int sis_gdb_break = 1;
-+
-+-host_callback *sim_callback;
-+-
-+ int
-+ run_sim(sregs, icount, dis)
-+ struct pstate *sregs;
-+@@ -75,9 +50,10 @@ run_sim(sregs, icount, dis)
-+ if (sis_verbose)
-+ (*sim_callback->printf_filtered) (sim_callback, "resuming at %x\n",
-+ sregs->pc);
-+- init_stdio();
-+- sregs->starttime = time(NULL);
-++ ms->init_stdio();
-++ sregs->starttime = get_time();
-+ irq = 0;
-++ if ((sregs->pc != 0) && (ebase.simtime == 0)) ms->boot_init();
-+ while (!sregs->err_mode & (icount > 0)) {
-+
-+ sregs->fhold = 0;
-+@@ -94,9 +70,8 @@ run_sim(sregs, icount, dis)
-+ if (sregs->pc == 0 || sregs->npc == 0)
-+ printf ("bogus pc or npc\n");
-+ #endif
-+- mexc = memory_read(sregs->asi, sregs->pc, &sregs->inst,
-+- 2, &sregs->hold);
-+-#if 1 /* DELETE ME! for debugging purposes only */
-++ mexc = ms->memory_iread(sregs->pc, &sregs->inst, &sregs->hold);
-++#if 0 /* DELETE ME! for debugging purposes only */
-+ if (sis_verbose > 2)
-+ printf("pc %x, np %x, sp %x, fp %x, wm %x, cw %x, i %08x\n",
-+ sregs->pc, sregs->npc,
-+@@ -117,12 +92,12 @@ run_sim(sregs, icount, dis)
-+ if (mexc) {
-+ sregs->trap = I_ACC_EXC;
-+ } else {
-+- if ((sis_gdb_break) && (sregs->inst == 0x91d02001)) {
-++ if ((sis_gdb_break) && (sregs->inst == SOFT_BREAK)) {
-+ if (sis_verbose)
-+ (*sim_callback->printf_filtered) (sim_callback,
-+ "SW BP hit at %x\n", sregs->pc);
-+- sim_halt();
-+- restore_stdio();
-++ ms->sim_halt();
-++ ms->restore_stdio();
-+ clearerr(stdin);
-+ return (BPT_HIT);
-+ } else
-+@@ -140,12 +115,12 @@ run_sim(sregs, icount, dis)
-+ icount = 0;
-+ }
-+ }
-+- sim_halt();
-+- sregs->tottime += time(NULL) - sregs->starttime;
-+- restore_stdio();
-++ ms->sim_halt();
-++ sregs->tottime += get_time() - sregs->starttime;
-++ ms->restore_stdio();
-+ clearerr(stdin);
-+ if (sregs->err_mode)
-+- error_mode(sregs->pc);
-++ ms->error_mode(sregs->pc);
-+ if (sregs->err_mode)
-+ return (ERROR);
-+ if (sregs->bphit) {
-+@@ -210,6 +185,17 @@ sim_open (kind, callback, abfd, argv)
-+ if (strcmp(argv[stat], "-dumbio") == 0) {
-+ dumbio = 1;
-+ } else
-++ if (strcmp(argv[stat], "-nouartrx") == 0) {
-++ nouartrx = 1;
-++ } else
-++ if (strcmp(argv[stat], "-leon2") == 0) {
-++ ms = &leon2;
-++ cputype = CPU_LEON2;
-++ } else
-++ if (strcmp(argv[stat], "-leon3") == 0) {
-++ ms = &leon3;
-++ cputype = CPU_LEON3;
-++ } else
-+ if (strcmp(argv[stat], "-wrp") == 0) {
-+ wrp = 1;
-+ } else
-+@@ -247,9 +233,24 @@ sim_open (kind, callback, abfd, argv)
-+ stat++;
-+ }
-+
-++ if ((cputype == CPU_LEON3) || (cputype == CPU_LEON2))
-++ sregs.freq = freq ? freq : 50;
-++ else
-++ sregs.freq = freq ? freq : 14;
-++
-+ if (sis_verbose) {
-+ (*sim_callback->printf_filtered) (sim_callback, "\n SIS - SPARC instruction simulator %s\n", sis_version);
-+- (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler ESA/ESTEC (jgais at wd.estec.esa.nl)\n");
-++ (*sim_callback->printf_filtered) (sim_callback, " Bug-reports to Jiri Gaisler (jiri at gaisler.se)\n\n");
-++ switch (cputype) {
-++ case CPU_LEON2:
-++ (*sim_callback->printf_filtered) (sim_callback, "LEON2 emulation enabled\n");
-++ break;
-++ case CPU_LEON3:
-++ (*sim_callback->printf_filtered) (sim_callback, "LEON3 emulation enabled\n");
-++ break;
-++ default:
-++ (*sim_callback->printf_filtered) (sim_callback, "ERC32 emulation enabled\n");
-++ }
-+ if (nfp)
-+ (*sim_callback->printf_filtered) (sim_callback, "no FPU\n");
-+ if (sparclite)
-+@@ -258,17 +259,19 @@ sim_open (kind, callback, abfd, argv)
-+ (*sim_callback->printf_filtered) (sim_callback, "dumb IO (no input, dumb output)\n");
-+ if (sis_gdb_break == 0)
-+ (*sim_callback->printf_filtered) (sim_callback, "disabling GDB trap handling for breakpoints\n");
-+- if (freq)
-+- (*sim_callback->printf_filtered) (sim_callback, " ERC32 freq %d Mhz\n", freq);
-++ (*sim_callback->printf_filtered) (sim_callback, "CPU freq %3.1f MHz\n", sregs.freq);
-+ }
-+
-+- sregs.freq = freq ? freq : 15;
-+ termsave = fcntl(0, F_GETFL, 0);
-+ INIT_DISASSEMBLE_INFO(dinfo, stdout,(fprintf_ftype)fprintf);
-++#ifdef HOST_LITTLE_ENDIAN
-++ dinfo.endian = BFD_ENDIAN_LITTLE;
-++#else
-+ dinfo.endian = BFD_ENDIAN_BIG;
-++#endif
-+ reset_all();
-+ ebase.simtime = 0;
-+- init_sim();
-++ ms->init_sim();
-+ init_bpt(&sregs);
-+ reset_stat(&sregs);
-+
-+@@ -282,7 +285,7 @@ sim_close(sd, quitting)
-+ int quitting;
-+ {
-+
-+- exit_sim();
-++ ms->exit_sim();
-+ fcntl(0, F_SETFL, termsave);
-+
-+ };
-+@@ -355,7 +358,19 @@ sim_write(sd, mem, buf, length)
-+ const unsigned char *buf;
-+ int length;
-+ {
-+- return (sis_memory_write(mem, buf, length));
-++#ifdef HOST_LITTLE_ENDIAN
-++ int *ibufp = (int *) buf;
-++ int ibuf[8192];
-++ int i, len;
-++
-++ if (length >= 4)
-++ for (i=0; i<length; i+=4) {
-++ ibuf[i] = ntohl(ibufp[i]);
-++ }
-++ return (ms->sis_memory_write(mem, (char *) ibuf, length));
-++#else
-++ return (ms->sis_memory_write(mem, buf, length));
-++#endif
-+ }
-+
-+ int
-+@@ -365,7 +380,20 @@ sim_read(sd, mem, buf, length)
-+ unsigned char *buf;
-+ int length;
-+ {
-+- return (sis_memory_read(mem, buf, length));
-++#ifdef HOST_LITTLE_ENDIAN
-++ int *ibuf = (int *) buf;
-++ int i, len;
-++
-++ len = ms->sis_memory_read(mem, buf, length);
-++ if (length >= 4)
-++ for (i=0; i<length; i+=4) {
-++ *ibuf = htonl(*ibuf);
-++ ibuf++;
-++ }
-++ return (len);
-++#else
-++ return (ms->sis_memory_read(mem, buf, length));
-++#endif
-+ }
-+
-+ void
-+@@ -451,7 +479,7 @@ flush_windows ()
-+ #endif
-+
-+ for (i = 0; i < 16; i++)
-+- memory_write (11, sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
-++ ms->memory_write (sp + 4 * i, &sregs.r[(win * 16 + 16 + i) & 0x7f], 2,
-+ &ws);
-+
-+ if (win == cwp)
-+@@ -481,7 +509,7 @@ sim_do_command(sd, cmd)
-+ SIM_DESC sd;
-+ char *cmd;
-+ {
-+- exec_cmd(&sregs, cmd);
-++ exec_cmd(&sregs, (char *) cmd);
-+ }
-+
-+ char **
-+@@ -490,6 +518,13 @@ sim_complete_command (SIM_DESC sd, const char *text, const char *word)
-+ return NULL;
-+ }
-+
-++int
-++sim_stop(SIM_DESC sd)
-++{
-++ ctrl_c = 1;
-++ return 1;
-++}
-++
-+ #if 0 /* FIXME: These shouldn't exist. */
-+
-+ int
-+diff --git a/sim/erc32/leon2.c b/sim/erc32/leon2.c
-+new file mode 100644
-+index 0000000..5ab3f79
-+--- /dev/null
-++++ b/sim/erc32/leon2.c
-+@@ -0,0 +1,1041 @@
-++/*
-++ * This file is part of SIS.
-++ *
-++ * SIS, SPARC instruction simulator V2.5 Copyright (C) 1995 Jiri Gaisler,
-++ * European Space Agency
-++ *
-++ * This program is free software; you can redistribute it and/or modify it under
-++ * the terms of the GNU General Public License as published by the Free
-++ * Software Foundation; either version 3 of the License, or (at your option)
-++ * any later version.
-++ *
-++ * This program is distributed in the hope that it will be useful, but WITHOUT
-++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-++ * more details.
-++ *
-++ * You should have received a copy of the GNU General Public License along with
-++ * this program; if not, see <http://www.gnu.org/licenses/>.
-++ *
-++ * Leon2 emulation, based on leon3.c .
-++ */
-++
-++/* The control space devices */
-++
-++#include "config.h"
-++#include <errno.h>
-++#include <sys/types.h>
-++#include <stdio.h>
-++#include <string.h>
-++#include <termios.h>
-++#include <sys/fcntl.h>
-++#include <sys/file.h>
-++#include <unistd.h>
-++#include "sis.h"
-++#include "sim-config.h"
-++
-++static int tty_setup = 1; /* default setup if not a tty */
-++
-++/* APB registers */
-++#define APBSTART 0x80000000
-++#define APBEND 0x80000100
-++
-++/* Memory exception waitstates */
-++#define MEM_EX_WS 1
-++
-++#define MOK 0
-++
-++/* LEON2 APB register addresses */
-++
-++#define IRQCTRL_IPR 0x094
-++#define IRQCTRL_IMR 0x090
-++#define IRQCTRL_ICR 0x09C
-++#define IRQCTRL_IFR 0x098
-++#define TIMER_SCALER 0x060
-++#define TIMER_SCLOAD 0x064
-++#define LEON2_CONFIG 0x024
-++#define TIMER_TIMER1 0x040
-++#define TIMER_RELOAD1 0x044
-++#define TIMER_CTRL1 0x048
-++#define TIMER_TIMER2 0x050
-++#define TIMER_RELOAD2 0x054
-++#define TIMER_CTRL2 0x058
-++#define CACHE_CTRL 0x014
-++#define POWER_DOWN 0x018
-++
-++#define APBUART_RXTX 0x070
-++#define APBUART_STATUS 0x074
-++
-++/* Size of UART buffers (bytes) */
-++#define UARTBUF 1024
-++
-++/* Number of simulator ticks between flushing the UARTS. */
-++/* For good performance, keep above 1000 */
-++#define UART_FLUSH_TIME 3000
-++
-++
-++/* New uart defines */
-++#define UART_TX_TIME 1000
-++#define UART_RX_TIME 1000
-++#define UARTA_DR 0x1
-++#define UARTA_SRE 0x2
-++#define UARTA_HRE 0x4
-++#define UARTA_OR 0x10
-++
-++/* IRQCTRL registers */
-++
-++static uint32 irqctrl_ipr;
-++static uint32 irqctrl_imr;
-++static uint32 irqctrl_ifr;
-++
-++/* TIMER registers */
-++
-++#define NTIMERS 2
-++#define TIMER_IRQ 8
-++
-++static uint32 gpt_scaler;
-++static uint32 gpt_scaler_start;
-++static uint32 gpt_counter[NTIMERS];
-++static uint32 gpt_reload[NTIMERS];
-++static uint32 gpt_ctrl[NTIMERS];
-++
-++/* ROM size 16 Mbyte */
-++#define ROM_START 0x00000000
-++#define ROM_MASK 0x00ffffff
-++#define ROM_END (ROM_START + ROM_MASK + 1)
-++
-++/* RAM size 16 Mbyte */
-++#define RAM_START 0x40000000
-++#define RAM_MASK 0x00ffffff
-++#define RAM_END (RAM_START + RAM_MASK + 1)
-++
-++/* Memory */
-++
-++static unsigned char romb[ROM_END - ROM_START];
-++static unsigned char ramb[RAM_END - RAM_START];
-++static uint32 cache_ctrl;
-++
-++
-++/* UART support variables */
-++
-++static int32 fd1, fd2; /* file descriptor for input file */
-++static int32 Ucontrol; /* UART status register */
-++static unsigned char aq[UARTBUF], bq[UARTBUF];
-++static int32 anum, aind = 0;
-++static int32 bnum, bind = 0;
-++static char wbufa[UARTBUF], wbufb[UARTBUF];
-++static unsigned wnuma;
-++static unsigned wnumb;
-++static FILE *f1in, *f1out;
-++static struct termios ioc1, ioc2, iocold1, iocold2;
-++static int f1open = 0;
-++
-++static char uarta_sreg, uarta_hreg;
-++static uint32 uart_stat_reg;
-++static uint32 uarta_data;
-++
-++/* Forward declarations */
-++
-++static void mem_init (void);
-++static void close_port (void);
-++static void leon2_reset (void);
-++static void irqctrl_intack (int32 level);
-++static void chk_irq (void);
-++static void set_irq (int32 level);
-++static int32 apb_read (uint32 addr, uint32 *data);
-++static int apb_write (uint32 addr, uint32 data);
-++static void port_init (void);
-++static uint32 grlib_read_uart (uint32 addr);
-++static void grlib_write_uart (uint32 addr, uint32 data);
-++static void flush_uart (void);
-++static void uarta_tx (void);
-++static void uart_rx (caddr_t arg);
-++static void uart_intr (caddr_t arg);
-++static void uart_irq_start (void);
-++static void gpt_intr (caddr_t arg);
-++static void gpt_init (void);
-++static void gpt_reset (void);
-++static void gpt_scaler_set (uint32 val);
-++static void timer_ctrl (uint32 val, int i);
-++static unsigned char *
-++ get_mem_ptr (uint32 addr, uint32 size);
-++static void store_bytes (unsigned char *mem, uint32 waddr,
-++ uint32 *data, int sz, int32 *ws);
-++
-++static host_callback *callback;
-++
-++
-++/* One-time init */
-++
-++static void
-++init_sim()
-++{
-++ callback = sim_callback;
-++ grlib_init();
-++ mem_init();
-++ port_init();
-++ gpt_init();
-++}
-++
-++/* Power-on reset init */
-++
-++static void
-++reset()
-++{
-++ leon2_reset();
-++ uart_irq_start();
-++ gpt_reset();
-++}
-++
-++/* IU error mode manager */
-++
-++static void
-++error_mode(pc)
-++ uint32 pc;
-++{
-++
-++}
-++
-++
-++/* Memory init */
-++
-++static void
-++mem_init()
-++{
-++
-++ if (sis_verbose)
-++ printf("RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n",
-++ RAM_START, (RAM_MASK+1)/1024, (ROM_MASK+1)/1024);
-++}
-++
-++/* Flush ports when simulator stops */
-++
-++static void
-++sim_halt()
-++{
-++#ifdef FAST_UART
-++ flush_uart();
-++#endif
-++}
-++
-++static void
-++close_port()
-++{
-++ if (f1open && f1in != stdin)
-++ fclose(f1in);
-++}
-++
-++static void
-++exit_sim()
-++{
-++ close_port();
-++}
-++
-++static void
-++leon2_reset()
-++{
-++ int i;
-++
-++ irqctrl_ipr = 0;
-++ irqctrl_imr = 0;
-++ irqctrl_ifr = 0;
-++
-++ wnuma = wnumb = 0;
-++ anum = aind = bnum = bind = 0;
-++
-++ uart_stat_reg = UARTA_SRE | UARTA_HRE;
-++
-++ gpt_counter[0] = 0xffffffff;
-++ gpt_reload[0] = 0xffffffff;
-++ gpt_scaler = 0xffff;
-++ gpt_ctrl[0] = 0;
-++ gpt_ctrl[1] = 0;
-++
-++}
-++
-++
-++
-++static void
-++irqctrl_intack(level)
-++ int32 level;
-++{
-++ int irq_test;
-++
-++ if (sis_verbose > 2)
-++ printf("interrupt %d acknowledged\n", level);
-++ if (irqctrl_ifr & (1 << level))
-++ irqctrl_ifr &= ~(1 << level);
-++ else
-++ irqctrl_ipr &= ~(1 << level);
-++ chk_irq();
-++}
-++
-++static void
-++chk_irq()
-++{
-++ int32 i;
-++ uint32 itmp;
-++ int old_irl;
-++
-++ old_irl = ext_irl;
-++ itmp = ((irqctrl_ipr | irqctrl_ifr) & irqctrl_imr) & 0x0fffe;
-++ ext_irl = 0;
-++ if (itmp != 0) {
-++ for (i = 15; i > 0; i--) {
-++ if (((itmp >> i) & 1) != 0) {
-++ if ((sis_verbose > 2) && (i > old_irl))
-++ printf("IU irl: %d\n", i);
-++ ext_irl = i;
-++ set_int(i, irqctrl_intack, i);
-++ break;
-++ }
-++ }
-++ }
-++}
-++
-++static void
-++set_irq(level)
-++ int32 level;
-++{
-++ irqctrl_ipr |= (1 << level);
-++ chk_irq();
-++}
-++
-++static int32
-++apb_read(addr, data)
-++ uint32 addr;
-++ uint32 *data;
-++{
-++
-++ switch (addr & 0xfff) {
-++
-++ case APBUART_RXTX: /* 0x100 */
-++ case APBUART_STATUS: /* 0x104 */
-++ *data = grlib_read_uart(addr);
-++ break;
-++
-++ case IRQCTRL_IPR: /* 0x204 */
-++ *data = irqctrl_ipr;
-++ break;
-++
-++ case IRQCTRL_IFR: /* 0x208 */
-++ *data = irqctrl_ifr;
-++ break;
-++
-++ case IRQCTRL_IMR: /* 0x240 */
-++ *data = irqctrl_imr;
-++ break;
-++
-++ case TIMER_SCALER: /* 0x300 */
-++ *data = gpt_scaler - (now() - gpt_scaler_start);
-++ break;
-++
-++ case TIMER_SCLOAD: /* 0x304 */
-++ *data = gpt_scaler;
-++ break;
-++
-++ case LEON2_CONFIG: /* 0x308 */
-++ *data = 0x700310;
-++ break;
-++
-++ case TIMER_TIMER1: /* 0x310 */
-++ *data = gpt_counter[0];
-++ break;
-++
-++ case TIMER_RELOAD1: /* 0x314 */
-++ *data = gpt_reload[0];
-++ break;
-++
-++ case TIMER_CTRL1: /* 0x318 */
-++ *data = gpt_ctrl[0];
-++ break;
-++
-++ case TIMER_TIMER2: /* 0x320 */
-++ *data = gpt_counter[1];
-++ break;
-++
-++ case TIMER_RELOAD2: /* 0x324 */
-++ *data = gpt_reload[1];
-++ break;
-++
-++ case TIMER_CTRL2: /* 0x328 */
-++ *data = gpt_ctrl[1];
-++ break;
-++
-++ case CACHE_CTRL: /* 0x328 */
-++ *data = cache_ctrl;
-++ break;
-++
-++ default:
-++ *data = 0;
-++ break;
-++ }
-++
-++ if (sis_verbose > 1)
-++ printf("APB read a: %08x, d: %08x\n", addr, *data);
-++
-++ return (MOK);
-++}
-++
-++static int
-++apb_write(addr, data)
-++ uint32 addr;
-++ uint32 data;
-++{
-++ if (sis_verbose > 1)
-++ printf("APB write a: %08x, d: %08x\n",addr,data);
-++ switch (addr & 0xff) {
-++
-++ case APBUART_RXTX: /* 0x100 */
-++ case APBUART_STATUS: /* 0x104 */
-++ grlib_write_uart(addr, data);
-++ break;
-++
-++ case IRQCTRL_IFR: /* 0x208 */
-++ irqctrl_ifr = data & 0xfffe;
-++ chk_irq();
-++ break;
-++
-++ case IRQCTRL_ICR: /* 0x20C */
-++ irqctrl_ipr &= ~data & 0x0fffe;
-++ chk_irq();
-++ break;
-++
-++ case IRQCTRL_IMR: /* 0x240 */
-++ irqctrl_imr = data & 0x7ffe;
-++ chk_irq();
-++ break;
-++
-++ case TIMER_SCLOAD: /* 0x304 */
-++ gpt_scaler_set(data);
-++ break;
-++
-++ case TIMER_TIMER1: /* 0x310 */
-++ gpt_counter[0] = data;
-++ break;
-++
-++ case TIMER_RELOAD1: /* 0x314 */
-++ gpt_reload[0] = data;
-++ break;
-++
-++ case TIMER_CTRL1: /* 0x318 */
-++ timer_ctrl(data, 0);
-++ break;
-++
-++ case TIMER_TIMER2: /* 0x320 */
-++ gpt_counter[1] = data;
-++ break;
-++
-++ case TIMER_RELOAD2: /* 0x324 */
-++ gpt_reload[1] = data;
-++ break;
-++
-++ case TIMER_CTRL2: /* 0x328 */
-++ timer_ctrl(data, 1);
-++ break;
-++
-++ case POWER_DOWN: /* 0x328 */
-++ wait_for_irq();
-++ break;
-++
-++ case CACHE_CTRL: /* 0x328 */
-++ cache_ctrl = data & 0x1000f;
-++ break;
-++
-++ default:
-++ break;
-++ }
-++ return (MOK);
-++}
-++
-++
-++/* APBUART */
-++
-++static int ifd1 = -1, ofd1 = -1;
-++
-++static void
-++init_stdio()
-++{
-++ if (dumbio)
-++ return; /* do nothing */
-++ if (ifd1 == 0 && f1open) {
-++ tcsetattr(0, TCSANOW, &ioc1);
-++ tcflush(ifd1, TCIFLUSH);
-++ }
-++}
-++
-++static void
-++restore_stdio()
-++{
-++ if (dumbio)
-++ return; /* do nothing */
-++ if (ifd1 == 0 && f1open && tty_setup)
-++ tcsetattr(0, TCSANOW, &iocold1);
-++}
-++
-++#define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
-++ ( dumbio || nouartrx \
-++ ? (0) /* no bytes read, no delay */ \
-++ : (_fd_) == 1 && callback ? \
-++ callback->read_stdin (callback, _buf_, _len_) : \
-++ read( _fd_, _buf_, _len_ ) )
-++
-++
-++static void
-++port_init()
-++{
-++
-++ f1in = stdin;
-++ f1out = stdout;
-++ if (uart_dev1[0] != 0)
-++ if ((fd1 = open(uart_dev1, O_RDWR | O_NONBLOCK)) < 0) {
-++ printf("Warning, couldn't open output device %s\n", uart_dev1);
-++ } else {
-++ if (sis_verbose)
-++ printf("serial port A on %s\n", uart_dev1);
-++ f1in = f1out = fdopen(fd1, "r+");
-++ setbuf(f1out, NULL);
-++ f1open = 1;
-++ }
-++ if (f1in) ifd1 = fileno(f1in);
-++ if (ifd1 == 0) {
-++ if (callback && !callback->isatty(callback, ifd1)) {
-++ tty_setup = 0;
-++ }
-++ if (sis_verbose)
-++ printf("serial port A on stdin/stdout\n");
-++ if (!dumbio) {
-++ tcgetattr(ifd1, &ioc1);
-++ if (tty_setup) {
-++ iocold1 = ioc1;
-++ ioc1.c_lflag &= ~(ICANON | ECHO);
-++ ioc1.c_cc[VMIN] = 0;
-++ ioc1.c_cc[VTIME] = 0;
-++ }
-++ }
-++ f1open = 1;
-++ }
-++
-++ if (f1out) {
-++ ofd1 = fileno(f1out);
-++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
-++ }
-++
-++ wnuma = 0;
-++
-++}
-++
-++static uint32
-++grlib_read_uart(addr)
-++ uint32 addr;
-++{
-++
-++ unsigned tmp;
-++
-++ tmp = 0;
-++ switch (addr & 0xfff) {
-++
-++ case 0x070: /* UART 1 RX/TX */
-++#ifndef _WIN32
-++#ifdef FAST_UART
-++
-++ if (aind < anum) {
-++ if ((aind + 1) < anum)
-++ set_irq(3);
-++ return ((uint32) aq[aind++]);
-++ } else {
-++ if (f1open) {
-++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-++ }
-++ else {
-++ anum = 0;
-++ }
-++ if (anum > 0) {
-++ aind = 0;
-++ if ((aind + 1) < anum)
-++ set_irq(3);
-++ return ((uint32) aq[aind++]);
-++ } else {
-++ return ((uint32) aq[aind]);
-++ }
-++
-++ }
-++#else
-++ tmp = uarta_data;
-++ uarta_data &= ~UART_DR;
-++ uart_stat_reg &= ~UARTA_DR;
-++ return tmp;
-++#endif
-++#else
-++ return(0);
-++#endif
-++ break;
-++
-++ case 0x074: /* UART status register */
-++#ifndef _WIN32
-++#ifdef FAST_UART
-++
-++ Ucontrol = 0;
-++ if (aind < anum) {
-++ Ucontrol |= 0x00000001;
-++ } else {
-++ if (f1open) {
-++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-++ }
-++ else {
-++ anum = 0;
-++ }
-++ if (anum > 0) {
-++ Ucontrol |= 0x00000001;
-++ aind = 0;
-++ set_irq(3);
-++ }
-++ }
-++ Ucontrol |= 0x00000006;
-++ return (Ucontrol);
-++#else
-++ return (uart_stat_reg);
-++#endif
-++#else
-++ return(0x00060006);
-++#endif
-++ break;
-++ default:
-++ if (sis_verbose)
-++ printf("Read from unimplemented LEON2 register (%x)\n", addr);
-++
-++ }
-++ return (0);
-++}
-++
-++static void
-++grlib_write_uart(addr, data)
-++ uint32 addr;
-++ uint32 data;
-++{
-++ unsigned char c;
-++
-++ c = (unsigned char) data;
-++ switch (addr & 0xfff) {
-++
-++ case 0x070: /* UART A */
-++#ifdef FAST_UART
-++ if (f1open) {
-++ if (wnuma < UARTBUF)
-++ wbufa[wnuma++] = c;
-++ else {
-++ while (wnuma) {
-++ if (ofd1 == 1 && callback)
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ else
-++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-++ }
-++ wbufa[wnuma++] = c;
-++ }
-++ }
-++ set_irq(3);
-++#else
-++ if (uart_stat_reg & UARTA_SRE) {
-++ uarta_sreg = c;
-++ uart_stat_reg &= ~UARTA_SRE;
-++ event(uarta_tx, 0, UART_TX_TIME);
-++ } else {
-++ uarta_hreg = c;
-++ uart_stat_reg &= ~UARTA_HRE;
-++ }
-++#endif
-++ break;
-++
-++ case 0x074: /* UART status register */
-++#ifndef FAST_UART
-++ uart_stat_reg &= 1;
-++#endif
-++ break;
-++ default:
-++ if (sis_verbose)
-++ printf("Write to unimplemented APB register (%x)\n", addr);
-++
-++ }
-++}
-++
-++static void
-++flush_uart()
-++{
-++ while (wnuma && f1open) {
-++ if (ofd1 == 1 && callback) {
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ callback->flush_stdout(callback);
-++ }
-++ else
-++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-++ }
-++}
-++
-++
-++
-++static void
-++uarta_tx()
-++{
-++ while (f1open) {
-++ if (ofd1 == 1 && callback) {
-++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
-++ }
-++ else {
-++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
-++ }
-++ }
-++ if (uart_stat_reg & UARTA_HRE) {
-++ uart_stat_reg |= UARTA_SRE;
-++ } else {
-++ uarta_sreg = uarta_hreg;
-++ uart_stat_reg |= UARTA_HRE;
-++ event(uarta_tx, 0, UART_TX_TIME);
-++ }
-++ set_irq(3);
-++}
-++
-++static void
-++uart_rx(arg)
-++ caddr_t arg;
-++{
-++ int32 rsize;
-++ char rxd;
-++
-++
-++ rsize = 0;
-++ if (f1open)
-++ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
-++ else
-++ rsize = 0;
-++ if (rsize > 0) {
-++ uarta_data = rxd;
-++ if (uart_stat_reg & UARTA_DR) {
-++ uart_stat_reg |= UARTA_OR;
-++ }
-++ uart_stat_reg |= UARTA_DR;
-++ set_irq(3);
-++ }
-++ event(uart_rx, 0, UART_RX_TIME);
-++}
-++
-++static void
-++uart_intr(arg)
-++ caddr_t arg;
-++{
-++ grlib_read_uart(APBUART_STATUS); /* Check for UART interrupts every 1000 clk */
-++ flush_uart(); /* Flush UART ports */
-++ event(uart_intr, 0, UART_FLUSH_TIME);
-++}
-++
-++
-++static void
-++uart_irq_start()
-++{
-++#ifdef FAST_UART
-++ event(uart_intr, 0, UART_FLUSH_TIME);
-++#else
-++#ifndef _WIN32
-++ event(uart_rx, 0, UART_RX_TIME);
-++#endif
-++#endif
-++}
-++
-++/* TIMER */
-++
-++static void
-++gpt_intr(arg)
-++ caddr_t arg;
-++{
-++ int i;
-++
-++ for (i=0; i<NTIMERS; i++) {
-++ if (gpt_ctrl[i] & 1) {
-++ gpt_counter[i] -= 1;
-++ if (gpt_counter[i] == -1) {
-++ set_irq(TIMER_IRQ + i);
-++ if (gpt_ctrl[i] & 2)
-++ gpt_counter[i] = gpt_reload[i];
-++ }
-++ }
-++ }
-++ event(gpt_intr, 0, gpt_scaler + 1);
-++ gpt_scaler_start = now();
-++}
-++
-++static void
-++gpt_init()
-++{
-++ if (sis_verbose)
-++ printf("GPT started (period %d)\n\r", gpt_scaler + 1);
-++}
-++
-++static void
-++gpt_reset()
-++{
-++ event(gpt_intr, 0, gpt_scaler + 1);
-++ gpt_scaler_start = now();
-++}
-++
-++static void
-++gpt_scaler_set(val)
-++ uint32 val;
-++{
-++ gpt_scaler = val & 0x0ffff; /* 16-bit scaler */
-++}
-++
-++static void
-++timer_ctrl(val, i)
-++ uint32 val;
-++ int i;
-++{
-++ if (val & 4) { /* reload */
-++ gpt_counter[i] = gpt_reload[i];
-++ }
-++ gpt_ctrl[i] = val & 0xb;
-++}
-++
-++/* Store data in host byte order. MEM points to the beginning of the
-++ emulated memory; WADDR contains the index the emulated memory,
-++ DATA points to words in host byte order to be stored. SZ contains log(2)
-++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
-++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
-++
-++static void
-++store_bytes (mem, waddr, data, sz, ws)
-++ unsigned char *mem;
-++ uint32 waddr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ switch (sz) {
-++ case 0:
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 3;
-++#endif
-++ mem[waddr] = *data & 0x0ff;
-++ *ws = 0;
-++ break;
-++ case 1:
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 2;
-++#endif
-++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
-++ *ws = 0;
-++ break;
-++ case 2:
-++ *((uint32 *) &(mem[waddr])) = *data;
-++ *ws = 0;
-++ break;
-++ case 3:
-++ *((uint32 *) &(mem[waddr])) = data[0];
-++ *((uint32 *) &(mem[waddr + 4])) = data[1];
-++ *ws = 0;
-++ break;
-++ }
-++}
-++
-++
-++/* Memory emulation */
-++
-++static int
-++memory_iread(addr, data, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 *ws;
-++{
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ *data = *((uint32 *) & (ramb[addr & RAM_MASK]));
-++ *ws = 0;
-++ return (0);
-++ } else if (addr < ROM_END) {
-++ *data = *((uint32 *) & (romb[addr]));
-++ *ws = 0;
-++ return (0);
-++ }
-++
-++ printf("Memory exception at %x (illegal address)\n", addr);
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_read(addr, data, sz, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ int32 mexc;
-++
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ *data = *((uint32 *) & (ramb[addr & RAM_MASK & ~3]));
-++ *ws = 0;
-++ return (0);
-++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
-++ mexc = apb_read(addr, data);
-++ if (mexc) {
-++ *ws = MEM_EX_WS;
-++ } else {
-++ *ws = 0;
-++ }
-++ return (mexc);
-++ } else if (addr < ROM_END) {
-++ *data = *((uint32 *) & (romb[addr & ~3]));
-++ *ws = 0;
-++ return (0);
-++ }
-++
-++ printf("Memory exception at %x (illegal address)\n", addr);
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_read_asi(asi, addr, data, sz, ws)
-++ int32 asi;
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ return(memory_read(addr, data, sz, ws));
-++}
-++
-++static int
-++memory_write(addr, data, sz, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ uint32 byte_addr;
-++ uint32 byte_mask;
-++ uint32 waddr;
-++ uint32 *ram;
-++ int32 mexc;
-++ int i;
-++ int wphit[2];
-++
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ waddr = addr & RAM_MASK;
-++ store_bytes (ramb, waddr, data, sz, ws);
-++ return (0);
-++
-++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
-++ if (sz != 2) {
-++ *ws = MEM_EX_WS;
-++ return (1);
-++ }
-++ apb_write(addr, *data);
-++ *ws = 0;
-++ return (0);
-++
-++ } else if (addr < ROM_END) {
-++// return (1);
-++ *ws = 0;
-++ store_bytes (romb, addr, data, sz, ws);
-++ return (0);
-++ }
-++
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_write_asi(asi, addr, data, sz, ws)
-++ int32 asi;
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ return(memory_write(addr, data, sz, ws));
-++}
-++
-++static unsigned char *
-++get_mem_ptr(addr, size)
-++ uint32 addr;
-++ uint32 size;
-++{
-++ if ((addr + size) < ROM_END) {
-++ return (&romb[addr]);
-++ } else if ((addr >= RAM_START) && ((addr + size) < RAM_END)) {
-++ return (&ramb[addr & RAM_MASK]);
-++ }
-++
-++ return ((char *) -1);
-++}
-++
-++static int
-++sis_memory_write(addr, data, length)
-++ uint32 addr;
-++ const unsigned char *data;
-++ uint32 length;
-++{
-++ char *mem;
-++
-++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
-++ return (0);
-++
-++ memcpy(mem, data, length);
-++ return (length);
-++}
-++
-++static int
-++sis_memory_read(addr, data, length)
-++ uint32 addr;
-++ char *data;
-++ uint32 length;
-++{
-++ char *mem;
-++ int ws;
-++
-++ if (length == 4) {
-++ memory_read(addr, data, length, &ws);
-++ return(4);
-++ }
-++
-++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
-++ return (0);
-++
-++ memcpy(data, mem, length);
-++ return (length);
-++}
-++
-++static void
-++boot_init ()
-++{
-++// mec_write(MEC_WCR, 0); /* zero waitstates */
-++// mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
-++ apb_write(TIMER_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
-++ apb_write(TIMER_SCLOAD, sregs.freq-1);
-++ apb_write(TIMER_TIMER1, -1);
-++ apb_write(TIMER_RELOAD1, -1);
-++ apb_write(TIMER_CTRL1, 0x7);
-++// mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
-++ sregs.wim = 2;
-++ sregs.psr = 0x000010e0;
-++ sregs.r[30] = RAM_END;
-++ sregs.r[14] = sregs.r[30] - 96*4;
-++ cache_ctrl = 0x01000f;
-++
-++}
-++
-++struct memsys leon2 = {
-++ init_sim,
-++ reset,
-++ error_mode,
-++ sim_halt,
-++ exit_sim,
-++ init_stdio,
-++ restore_stdio,
-++ memory_iread,
-++ memory_read,
-++ memory_read_asi,
-++ memory_write,
-++ memory_write_asi,
-++ sis_memory_write,
-++ sis_memory_read,
-++ boot_init
-++};
-+diff --git a/sim/erc32/leon3.c b/sim/erc32/leon3.c
-+new file mode 100644
-+index 0000000..e79169e
-+--- /dev/null
-++++ b/sim/erc32/leon3.c
-+@@ -0,0 +1,1066 @@
-++/*
-++ * This file is part of SIS.
-++ *
-++ * SIS, SPARC instruction simulator V2.5 Copyright (C) 1995 Jiri Gaisler,
-++ * European Space Agency
-++ *
-++ * This program is free software; you can redistribute it and/or modify it under
-++ * the terms of the GNU General Public License as published by the Free
-++ * Software Foundation; either version 3 of the License, or (at your option)
-++ * any later version.
-++ *
-++ * This program is distributed in the hope that it will be useful, but WITHOUT
-++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-++ * more details.
-++ *
-++ * You should have received a copy of the GNU General Public License along with
-++ * this program; if not, see <http://www.gnu.org/licenses/>.
-++ *
-++ * Leon3 emulation, loosely based on erc32.c .
-++ */
-++
-++/* The control space devices */
-++
-++#include "config.h"
-++#include <errno.h>
-++#include <sys/types.h>
-++#include <stdio.h>
-++#include <string.h>
-++#include <termios.h>
-++#include <sys/fcntl.h>
-++#include <sys/file.h>
-++#include <unistd.h>
-++#include "sis.h"
-++#include "grlib.h"
-++#include "sim-config.h"
-++
-++static int tty_setup = 1; /* default setup if not a tty */
-++
-++/* APB registers */
-++#define APBSTART 0x80000000
-++#define APBEND 0x80100000
-++
-++/* Memory exception waitstates */
-++#define MEM_EX_WS 1
-++
-++#define MOK 0
-++
-++/* LEON3 APB register addresses */
-++
-++#define IRQMP_IPR 0x204
-++#define IRQMP_IMR 0x240
-++#define IRQMP_ICR 0x20C
-++#define IRQMP_IFR 0x208
-++#define GPTIMER_SCALER 0x300
-++#define GPTIMER_SCLOAD 0x304
-++#define GPTIMER_CONFIG 0x308
-++#define GPTIMER_TIMER1 0x310
-++#define GPTIMER_RELOAD1 0x314
-++#define GPTIMER_CTRL1 0x318
-++#define GPTIMER_TIMER2 0x320
-++#define GPTIMER_RELOAD2 0x324
-++#define GPTIMER_CTRL2 0x328
-++
-++#define APBUART_RXTX 0x100
-++#define APBUART_STATUS 0x104
-++
-++/* Size of UART buffers (bytes) */
-++#define UARTBUF 1024
-++
-++/* Number of simulator ticks between flushing the UARTS. */
-++/* For good performance, keep above 1000 */
-++#define UART_FLUSH_TIME 3000
-++
-++
-++/* New uart defines */
-++#define UART_TX_TIME 1000
-++#define UART_RX_TIME 1000
-++#define UARTA_DR 0x1
-++#define UARTA_SRE 0x2
-++#define UARTA_HRE 0x4
-++#define UARTA_OR 0x10
-++
-++/* IRQMP registers */
-++
-++static uint32 irqmp_ipr;
-++static uint32 irqmp_imr;
-++static uint32 irqmp_ifr;
-++
-++/* GPTIMER registers */
-++
-++#define NGPTIMERS 2
-++#define GPTIMER_IRQ 8
-++
-++static uint32 gpt_scaler;
-++static uint32 gpt_scaler_start;
-++static uint32 gpt_counter[NGPTIMERS];
-++static uint32 gpt_reload[NGPTIMERS];
-++static uint32 gpt_ctrl[NGPTIMERS];
-++
-++/* ROM size 16 Mbyte */
-++#define ROM_START 0x00000000
-++#define ROM_MASK 0x00ffffff
-++#define ROM_END (ROM_START + ROM_MASK + 1)
-++
-++/* RAM size 16 Mbyte */
-++#define RAM_START 0x40000000
-++#define RAM_MASK 0x00ffffff
-++#define RAM_END (RAM_START + RAM_MASK + 1)
-++
-++/* Memory */
-++
-++static unsigned char romb[ROM_END - ROM_START];
-++static unsigned char ramb[RAM_END - RAM_START];
-++static uint32 cache_ctrl;
-++
-++
-++/* UART support variables */
-++
-++static int32 fd1, fd2; /* file descriptor for input file */
-++static int32 Ucontrol; /* UART status register */
-++static unsigned char aq[UARTBUF], bq[UARTBUF];
-++static int32 anum, aind = 0;
-++static int32 bnum, bind = 0;
-++static char wbufa[UARTBUF], wbufb[UARTBUF];
-++static unsigned wnuma;
-++static unsigned wnumb;
-++static FILE *f1in, *f1out;
-++static struct termios ioc1, ioc2, iocold1, iocold2;
-++static int f1open = 0;
-++
-++static char uarta_sreg, uarta_hreg;
-++static uint32 uart_stat_reg;
-++static uint32 uarta_data;
-++
-++/* Forward declarations */
-++
-++static void mem_init (void);
-++static void close_port (void);
-++static void leon3_reset (void);
-++static void irqmp_intack (int32 level);
-++static void chk_irq (void);
-++static void set_irq (int32 level);
-++static int32 apb_read (uint32 addr, uint32 *data);
-++static int apb_write (uint32 addr, uint32 data);
-++static void port_init (void);
-++static uint32 grlib_read_uart (uint32 addr);
-++static void grlib_write_uart (uint32 addr, uint32 data);
-++static void flush_uart (void);
-++static void uarta_tx (void);
-++static void uart_rx (caddr_t arg);
-++static void uart_intr (caddr_t arg);
-++static void uart_irq_start (void);
-++static void gpt_intr (caddr_t arg);
-++static void gpt_init (void);
-++static void gpt_reset (void);
-++static void gpt_scaler_set (uint32 val);
-++static void timer_ctrl (uint32 val, int i);
-++static unsigned char *
-++ get_mem_ptr (uint32 addr, uint32 size);
-++static void store_bytes (unsigned char *mem, uint32 waddr,
-++ uint32 *data, int sz, int32 *ws);
-++
-++static host_callback *callback;
-++
-++
-++/* One-time init */
-++
-++static void
-++init_sim()
-++{
-++ callback = sim_callback;
-++ grlib_init();
-++ mem_init();
-++ port_init();
-++ gpt_init();
-++}
-++
-++/* Power-on reset init */
-++
-++static void
-++reset()
-++{
-++ leon3_reset();
-++ uart_irq_start();
-++ gpt_reset();
-++}
-++
-++/* IU error mode manager */
-++
-++static void
-++error_mode(pc)
-++ uint32 pc;
-++{
-++
-++}
-++
-++
-++/* Memory init */
-++
-++static void
-++mem_init()
-++{
-++
-++/* Add AMBA P&P record for SRCTRL memory controller */
-++
-++ grlib_ahbspp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_SRCTRL, 0, 0),
-++ GRLIB_PP_AHBADDR(0x00000000, 0xE00, 1, 1, 2),
-++ GRLIB_PP_AHBADDR(0x40000000, 0xC00, 1, 1, 2),
-++ GRLIB_PP_AHBADDR(0x20000000, 0xE00, 0, 0, 2),
-++ 0);
-++ if (sis_verbose)
-++ printf("RAM start: 0x%x, RAM size: %d K, ROM size: %d K\n",
-++ RAM_START, (RAM_MASK+1)/1024, (ROM_MASK+1)/1024);
-++}
-++
-++/* Flush ports when simulator stops */
-++
-++static void
-++sim_halt()
-++{
-++#ifdef FAST_UART
-++ flush_uart();
-++#endif
-++}
-++
-++static void
-++close_port()
-++{
-++ if (f1open && f1in != stdin)
-++ fclose(f1in);
-++}
-++
-++static void
-++exit_sim()
-++{
-++ close_port();
-++}
-++
-++static void
-++leon3_reset()
-++{
-++ int i;
-++
-++ irqmp_ipr = 0;
-++ irqmp_imr = 0;
-++ irqmp_ifr = 0;
-++
-++ wnuma = wnumb = 0;
-++ anum = aind = bnum = bind = 0;
-++
-++ uart_stat_reg = UARTA_SRE | UARTA_HRE;
-++
-++ gpt_counter[0] = 0xffffffff;
-++ gpt_reload[0] = 0xffffffff;
-++ gpt_scaler = 0xffff;
-++ gpt_ctrl[0] = 0;
-++ gpt_ctrl[1] = 0;
-++
-++}
-++
-++
-++
-++static void
-++irqmp_intack(level)
-++ int32 level;
-++{
-++ int irq_test;
-++
-++ if (sis_verbose > 2)
-++ printf("interrupt %d acknowledged\n", level);
-++ if (irqmp_ifr & (1 << level))
-++ irqmp_ifr &= ~(1 << level);
-++ else
-++ irqmp_ipr &= ~(1 << level);
-++ chk_irq();
-++}
-++
-++static void
-++chk_irq()
-++{
-++ int32 i;
-++ uint32 itmp;
-++ int old_irl;
-++
-++ old_irl = ext_irl;
-++ itmp = ((irqmp_ipr | irqmp_ifr) & irqmp_imr) & 0x0fffe;
-++ ext_irl = 0;
-++ if (itmp != 0) {
-++ for (i = 15; i > 0; i--) {
-++ if (((itmp >> i) & 1) != 0) {
-++ if ((sis_verbose > 2) && (i > old_irl))
-++ printf("IU irl: %d\n", i);
-++ ext_irl = i;
-++ set_int(i, irqmp_intack, i);
-++ break;
-++ }
-++ }
-++ }
-++}
-++
-++static void
-++set_irq(level)
-++ int32 level;
-++{
-++ irqmp_ipr |= (1 << level);
-++ chk_irq();
-++}
-++
-++static int32
-++apb_read(addr, data)
-++ uint32 addr;
-++ uint32 *data;
-++{
-++
-++ switch (addr & 0xfff) {
-++
-++ case APBUART_RXTX: /* 0x100 */
-++ case APBUART_STATUS: /* 0x104 */
-++ *data = grlib_read_uart(addr);
-++ break;
-++
-++ case IRQMP_IPR: /* 0x204 */
-++ *data = irqmp_ipr;
-++ break;
-++
-++ case IRQMP_IFR: /* 0x208 */
-++ *data = irqmp_ifr;
-++ break;
-++
-++ case IRQMP_IMR: /* 0x240 */
-++ *data = irqmp_imr;
-++ break;
-++
-++ case GPTIMER_SCALER: /* 0x300 */
-++ *data = gpt_scaler - (now() - gpt_scaler_start);
-++ break;
-++
-++ case GPTIMER_SCLOAD: /* 0x304 */
-++ *data = gpt_scaler;
-++ break;
-++
-++ case GPTIMER_CONFIG: /* 0x308 */
-++ *data = 0x100 | (GPTIMER_IRQ << 3) | NGPTIMERS;
-++ break;
-++
-++ case GPTIMER_TIMER1: /* 0x310 */
-++ *data = gpt_counter[0];
-++ break;
-++
-++ case GPTIMER_RELOAD1: /* 0x314 */
-++ *data = gpt_reload[0];
-++ break;
-++
-++ case GPTIMER_CTRL1: /* 0x318 */
-++ *data = gpt_ctrl[0];
-++ break;
-++
-++ case GPTIMER_TIMER2: /* 0x320 */
-++ *data = gpt_counter[1];
-++ break;
-++
-++ case GPTIMER_RELOAD2: /* 0x324 */
-++ *data = gpt_reload[1];
-++ break;
-++
-++ case GPTIMER_CTRL2: /* 0x328 */
-++ *data = gpt_ctrl[1];
-++ break;
-++
-++ default:
-++ *data = 0;
-++ break;
-++ }
-++
-++ if (sis_verbose > 1)
-++ printf("APB read a: %08x, d: %08x\n", addr, *data);
-++
-++ return (MOK);
-++}
-++
-++static int
-++apb_write(addr, data)
-++ uint32 addr;
-++ uint32 data;
-++{
-++ if (sis_verbose > 1)
-++ printf("APB write a: %08x, d: %08x\n",addr,data);
-++ switch (addr & 0xfff) {
-++
-++ case APBUART_RXTX: /* 0x100 */
-++ case APBUART_STATUS: /* 0x104 */
-++ grlib_write_uart(addr, data);
-++ break;
-++
-++ case IRQMP_IFR: /* 0x208 */
-++ irqmp_ifr = data & 0xfffe;
-++ chk_irq();
-++ break;
-++
-++ case IRQMP_ICR: /* 0x20C */
-++ irqmp_ipr &= ~data & 0x0fffe;
-++ chk_irq();
-++ break;
-++
-++ case IRQMP_IMR: /* 0x240 */
-++ irqmp_imr = data & 0x7ffe;
-++ chk_irq();
-++ break;
-++
-++ case GPTIMER_SCLOAD: /* 0x304 */
-++ gpt_scaler_set(data);
-++ break;
-++
-++ case GPTIMER_TIMER1: /* 0x310 */
-++ gpt_counter[0] = data;
-++ break;
-++
-++ case GPTIMER_RELOAD1: /* 0x314 */
-++ gpt_reload[0] = data;
-++ break;
-++
-++ case GPTIMER_CTRL1: /* 0x318 */
-++ timer_ctrl(data, 0);
-++ break;
-++
-++ case GPTIMER_TIMER2: /* 0x320 */
-++ gpt_counter[1] = data;
-++ break;
-++
-++ case GPTIMER_RELOAD2: /* 0x324 */
-++ gpt_reload[1] = data;
-++ break;
-++
-++ case GPTIMER_CTRL2: /* 0x328 */
-++ timer_ctrl(data, 1);
-++ break;
-++
-++ default:
-++ break;
-++ }
-++ return (MOK);
-++}
-++
-++
-++/* APBUART */
-++
-++static int ifd1 = -1, ofd1 = -1;
-++
-++static void
-++init_stdio()
-++{
-++ if (dumbio)
-++ return; /* do nothing */
-++ if (ifd1 == 0 && f1open) {
-++ tcsetattr(0, TCSANOW, &ioc1);
-++ tcflush(ifd1, TCIFLUSH);
-++ }
-++}
-++
-++static void
-++restore_stdio()
-++{
-++ if (dumbio)
-++ return; /* do nothing */
-++ if (ifd1 == 0 && f1open && tty_setup)
-++ tcsetattr(0, TCSANOW, &iocold1);
-++}
-++
-++#define DO_STDIO_READ( _fd_, _buf_, _len_ ) \
-++ ( dumbio || nouartrx \
-++ ? (0) /* no bytes read, no delay */ \
-++ : (_fd_) == 1 && callback ? \
-++ callback->read_stdin (callback, _buf_, _len_) : \
-++ read( _fd_, _buf_, _len_ ) )
-++
-++
-++static void
-++port_init()
-++{
-++
-++ f1in = stdin;
-++ f1out = stdout;
-++ if (uart_dev1[0] != 0)
-++ if ((fd1 = open(uart_dev1, O_RDWR | O_NONBLOCK)) < 0) {
-++ printf("Warning, couldn't open output device %s\n", uart_dev1);
-++ } else {
-++ if (sis_verbose)
-++ printf("serial port A on %s\n", uart_dev1);
-++ f1in = f1out = fdopen(fd1, "r+");
-++ setbuf(f1out, NULL);
-++ f1open = 1;
-++ }
-++ if (f1in) ifd1 = fileno(f1in);
-++ if (ifd1 == 0) {
-++ if (callback && !callback->isatty(callback, ifd1)) {
-++ tty_setup = 0;
-++ }
-++ if (sis_verbose)
-++ printf("serial port A on stdin/stdout\n");
-++ if (!dumbio) {
-++ tcgetattr(ifd1, &ioc1);
-++ if (tty_setup) {
-++ iocold1 = ioc1;
-++ ioc1.c_lflag &= ~(ICANON | ECHO);
-++ ioc1.c_cc[VMIN] = 0;
-++ ioc1.c_cc[VTIME] = 0;
-++ }
-++ }
-++ f1open = 1;
-++ }
-++
-++ if (f1out) {
-++ ofd1 = fileno(f1out);
-++ if (!dumbio && tty_setup && ofd1 == 1) setbuf(f1out, NULL);
-++ }
-++
-++ wnuma = 0;
-++
-++
-++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_APBUART, 1, 3),
-++ GRLIB_PP_APBADDR(0x80000100, 0xFFF));
-++}
-++
-++static uint32
-++grlib_read_uart(addr)
-++ uint32 addr;
-++{
-++
-++ unsigned tmp;
-++
-++ tmp = 0;
-++ switch (addr & 0xff) {
-++
-++ case 0x00: /* UART 1 RX/TX */
-++#ifndef _WIN32
-++#ifdef FAST_UART
-++
-++ if (aind < anum) {
-++ if ((aind + 1) < anum)
-++ set_irq(3);
-++ return ((uint32) aq[aind++]);
-++ } else {
-++ if (f1open) {
-++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-++ }
-++ else {
-++ anum = 0;
-++ }
-++ if (anum > 0) {
-++ aind = 0;
-++ if ((aind + 1) < anum)
-++ set_irq(3);
-++ return ((uint32) aq[aind++]);
-++ } else {
-++ return ((uint32) aq[aind]);
-++ }
-++
-++ }
-++#else
-++ tmp = uarta_data;
-++ uarta_data &= ~UART_DR;
-++ uart_stat_reg &= ~UARTA_DR;
-++ return tmp;
-++#endif
-++#else
-++ return(0);
-++#endif
-++ break;
-++
-++ case 0x04: /* UART status register */
-++#ifndef _WIN32
-++#ifdef FAST_UART
-++
-++ Ucontrol = 0;
-++ if (aind < anum) {
-++ Ucontrol |= 0x00000001;
-++ } else {
-++ if (f1open) {
-++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
-++ }
-++ else {
-++ anum = 0;
-++ }
-++ if (anum > 0) {
-++ Ucontrol |= 0x00000001;
-++ aind = 0;
-++ set_irq(3);
-++ }
-++ }
-++ Ucontrol |= 0x00000006;
-++ return (Ucontrol);
-++#else
-++ return (uart_stat_reg);
-++#endif
-++#else
-++ return(0x00060006);
-++#endif
-++ break;
-++ default:
-++ if (sis_verbose)
-++ printf("Read from unimplemented MEC register (%x)\n", addr);
-++
-++ }
-++ return (0);
-++}
-++
-++static void
-++grlib_write_uart(addr, data)
-++ uint32 addr;
-++ uint32 data;
-++{
-++ unsigned char c;
-++
-++ c = (unsigned char) data;
-++ switch (addr & 0xff) {
-++
-++ case 0x00: /* UART A */
-++#ifdef FAST_UART
-++ if (f1open) {
-++ if (wnuma < UARTBUF)
-++ wbufa[wnuma++] = c;
-++ else {
-++ while (wnuma) {
-++ if (ofd1 == 1 && callback)
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ else
-++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-++ }
-++ wbufa[wnuma++] = c;
-++ }
-++ }
-++ set_irq(3);
-++#else
-++ if (uart_stat_reg & UARTA_SRE) {
-++ uarta_sreg = c;
-++ uart_stat_reg &= ~UARTA_SRE;
-++ event(uarta_tx, 0, UART_TX_TIME);
-++ } else {
-++ uarta_hreg = c;
-++ uart_stat_reg &= ~UARTA_HRE;
-++ }
-++#endif
-++ break;
-++
-++ case 0x04: /* UART status register */
-++#ifndef FAST_UART
-++ uart_stat_reg &= 1;
-++#endif
-++ break;
-++ default:
-++ if (sis_verbose)
-++ printf("Write to unimplemented APB register (%x)\n", addr);
-++
-++ }
-++}
-++
-++static void
-++flush_uart()
-++{
-++ while (wnuma && f1open) {
-++ if (ofd1 == 1 && callback) {
-++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
-++ callback->flush_stdout(callback);
-++ }
-++ else
-++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
-++ }
-++}
-++
-++
-++
-++static void
-++uarta_tx()
-++{
-++ while (f1open) {
-++ if (ofd1 == 1 && callback) {
-++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
-++ }
-++ else {
-++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
-++ }
-++ }
-++ if (uart_stat_reg & UARTA_HRE) {
-++ uart_stat_reg |= UARTA_SRE;
-++ } else {
-++ uarta_sreg = uarta_hreg;
-++ uart_stat_reg |= UARTA_HRE;
-++ event(uarta_tx, 0, UART_TX_TIME);
-++ }
-++ set_irq(3);
-++}
-++
-++static void
-++uart_rx(arg)
-++ caddr_t arg;
-++{
-++ int32 rsize;
-++ char rxd;
-++
-++
-++ rsize = 0;
-++ if (f1open)
-++ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
-++ else
-++ rsize = 0;
-++ if (rsize > 0) {
-++ uarta_data = rxd;
-++ if (uart_stat_reg & UARTA_DR) {
-++ uart_stat_reg |= UARTA_OR;
-++ }
-++ uart_stat_reg |= UARTA_DR;
-++ set_irq(3);
-++ }
-++ event(uart_rx, 0, UART_RX_TIME);
-++}
-++
-++static void
-++uart_intr(arg)
-++ caddr_t arg;
-++{
-++ grlib_read_uart(APBUART_STATUS); /* Check for UART interrupts every 1000 clk */
-++ flush_uart(); /* Flush UART ports */
-++ event(uart_intr, 0, UART_FLUSH_TIME);
-++}
-++
-++
-++static void
-++uart_irq_start()
-++{
-++#ifdef FAST_UART
-++ event(uart_intr, 0, UART_FLUSH_TIME);
-++#else
-++#ifndef _WIN32
-++ event(uart_rx, 0, UART_RX_TIME);
-++#endif
-++#endif
-++}
-++
-++/* GPTIMER */
-++
-++static void
-++gpt_intr(arg)
-++ caddr_t arg;
-++{
-++ int i;
-++
-++ for (i=0; i<NGPTIMERS; i++) {
-++ if (gpt_ctrl[i] & 1) {
-++ gpt_counter[i] -= 1;
-++ if (gpt_counter[i] == -1) {
-++ if (gpt_ctrl[i] & 8)
-++ set_irq(GPTIMER_IRQ + i);
-++ if (gpt_ctrl[i] & 2)
-++ gpt_counter[i] = gpt_reload[i];
-++ }
-++ }
-++ }
-++ event(gpt_intr, 0, gpt_scaler + 1);
-++ gpt_scaler_start = now();
-++}
-++
-++static void
-++gpt_init()
-++{
-++ if (sis_verbose)
-++ printf("GPT started (period %d)\n\r", gpt_scaler + 1);
-++
-++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_GPTIMER, 0, 8),
-++ GRLIB_PP_APBADDR(0x80000300, 0xFFF));
-++}
-++
-++static void
-++gpt_reset()
-++{
-++ event(gpt_intr, 0, gpt_scaler + 1);
-++ gpt_scaler_start = now();
-++}
-++
-++static void
-++gpt_scaler_set(val)
-++ uint32 val;
-++{
-++ gpt_scaler = val & 0x0ffff; /* 16-bit scaler */
-++}
-++
-++static void
-++timer_ctrl(val, i)
-++ uint32 val;
-++ int i;
-++{
-++ if (val & 4) { /* reload */
-++ gpt_counter[i] = gpt_reload[i];
-++ }
-++ gpt_ctrl[i] = val & 0xb;
-++}
-++
-++/* Store data in host byte order. MEM points to the beginning of the
-++ emulated memory; WADDR contains the index the emulated memory,
-++ DATA points to words in host byte order to be stored. SZ contains log(2)
-++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
-++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
-++
-++static void
-++store_bytes (mem, waddr, data, sz, ws)
-++ unsigned char *mem;
-++ uint32 waddr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ switch (sz) {
-++ case 0:
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 3;
-++#endif
-++ mem[waddr] = *data & 0x0ff;
-++ *ws = 0;
-++ break;
-++ case 1:
-++#ifdef HOST_LITTLE_ENDIAN
-++ waddr ^= 2;
-++#endif
-++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
-++ *ws = 0;
-++ break;
-++ case 2:
-++ *((uint32 *) &(mem[waddr])) = *data;
-++ *ws = 0;
-++ break;
-++ case 3:
-++ *((uint32 *) &(mem[waddr])) = data[0];
-++ *((uint32 *) &(mem[waddr + 4])) = data[1];
-++ *ws = 0;
-++ break;
-++ }
-++}
-++
-++
-++/* Memory emulation */
-++
-++static int
-++memory_iread(addr, data, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 *ws;
-++{
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ *data = *((uint32 *) & (ramb[addr & RAM_MASK]));
-++ *ws = 0;
-++ return (0);
-++ } else if (addr < ROM_END) {
-++ *data = *((uint32 *) & (romb[addr]));
-++ *ws = 0;
-++ return (0);
-++ }
-++
-++ printf("Memory exception at %x (illegal address)\n", addr);
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_read(addr, data, sz, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ int32 mexc;
-++
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ *data = *((uint32 *) & (ramb[addr & RAM_MASK & ~3]));
-++ *ws = 0;
-++ return (0);
-++ } else if ((addr >= APBPP_START) && (addr <= APBPP_END)) {
-++ *data = grlib_apbpnp_read(addr);
-++ if (sis_verbose > 1)
-++ printf("APB PP read a: %08x, d: %08x\n",addr, *data);
-++ *ws = 4;
-++ return (0);
-++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
-++ mexc = apb_read(addr, data);
-++ if (mexc) {
-++ *ws = MEM_EX_WS;
-++ } else {
-++ *ws = 0;
-++ }
-++ return (mexc);
-++ } else if ((addr >= AHBPP_START) && (addr <= AHBPP_END)) {
-++ if (sis_verbose > 1)
-++ printf("AHB PP read a: %08x, d: %08x\n",addr, *data);
-++ *data = grlib_ahbpnp_read(addr);
-++ *ws = 4;
-++ return (0);
-++ } else if (addr < ROM_END) {
-++ *data = *((uint32 *) & (romb[addr & ~3]));
-++ *ws = 0;
-++ return (0);
-++ }
-++
-++ printf("Memory exception at %x (illegal address)\n", addr);
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_read_asi(asi, addr, data, sz, ws)
-++ int32 asi;
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ if (asi == 2) {
-++ if (addr == 0)
-++ *data = cache_ctrl;
-++ else
-++ *data = 0;
-++ return MOK;
-++ } else
-++ return(memory_read(addr, data, sz, ws));
-++}
-++
-++static int
-++memory_write(addr, data, sz, ws)
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ uint32 byte_addr;
-++ uint32 byte_mask;
-++ uint32 waddr;
-++ uint32 *ram;
-++ int32 mexc;
-++ int i;
-++ int wphit[2];
-++
-++ if ((addr >= RAM_START) && (addr < RAM_END)) {
-++ waddr = addr & RAM_MASK;
-++ store_bytes (ramb, waddr, data, sz, ws);
-++ return (0);
-++
-++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
-++ if (sz != 2) {
-++ *ws = MEM_EX_WS;
-++ return (1);
-++ }
-++ apb_write(addr, *data);
-++ *ws = 0;
-++ return (0);
-++
-++ } else if (addr < ROM_END) {
-++// return (1);
-++ *ws = 0;
-++ store_bytes (romb, addr, data, sz, ws);
-++ return (0);
-++ }
-++
-++ *ws = MEM_EX_WS;
-++ return (1);
-++}
-++
-++static int
-++memory_write_asi(asi, addr, data, sz, ws)
-++ int32 asi;
-++ uint32 addr;
-++ uint32 *data;
-++ int32 sz;
-++ int32 *ws;
-++{
-++ if (asi == 2) {
-++ cache_ctrl = *data & 0x81000f;
-++ if (sis_verbose)
-++ printf("cache ctrl reg : 0x%08x\n", cache_ctrl);
-++ return MOK;
-++ } else
-++ return(memory_write(addr, data, sz, ws));
-++}
-++
-++static unsigned char *
-++get_mem_ptr(addr, size)
-++ uint32 addr;
-++ uint32 size;
-++{
-++ if ((addr + size) < ROM_END) {
-++ return (&romb[addr]);
-++ } else if ((addr >= RAM_START) && ((addr + size) < RAM_END)) {
-++ return (&ramb[addr & RAM_MASK]);
-++ }
-++
-++ return ((char *) -1);
-++}
-++
-++static int
-++sis_memory_write(addr, data, length)
-++ uint32 addr;
-++ const unsigned char *data;
-++ uint32 length;
-++{
-++ char *mem;
-++
-++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
-++ return (0);
-++
-++ memcpy(mem, data, length);
-++ return (length);
-++}
-++
-++static int
-++sis_memory_read(addr, data, length)
-++ uint32 addr;
-++ char *data;
-++ uint32 length;
-++{
-++ char *mem;
-++ int ws;
-++
-++ if (length == 4) {
-++ memory_read(addr, data, length, &ws);
-++ return(4);
-++ }
-++
-++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
-++ return (0);
-++
-++ memcpy(data, mem, length);
-++ return (length);
-++}
-++
-++static void
-++boot_init ()
-++{
-++// mec_write(MEC_WCR, 0); /* zero waitstates */
-++// mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
-++ apb_write(GPTIMER_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
-++ apb_write(GPTIMER_SCLOAD, sregs.freq-1);
-++ apb_write(GPTIMER_TIMER1, -1);
-++ apb_write(GPTIMER_RELOAD1, -1);
-++ apb_write(GPTIMER_CTRL1, 0x7);
-++// mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
-++ sregs.wim = 2;
-++ sregs.psr = 0xF30010e0;
-++ sregs.r[30] = RAM_END;
-++ sregs.r[14] = sregs.r[30] - 96*4;
-++ cache_ctrl = 0x81000f;
-++}
-++
-++struct memsys leon3 = {
-++ init_sim,
-++ reset,
-++ error_mode,
-++ sim_halt,
-++ exit_sim,
-++ init_stdio,
-++ restore_stdio,
-++ memory_iread,
-++ memory_read,
-++ memory_read_asi,
-++ memory_write,
-++ memory_write_asi,
-++ sis_memory_write,
-++ sis_memory_read,
-++ boot_init
-++};
-+diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
-+index 89e6f02..f21ddde 100644
-+--- a/sim/erc32/sis.c
-++++ b/sim/erc32/sis.c
-+@@ -26,7 +26,6 @@
-+ #include <stdlib.h>
-+ #endif
-+ #include <stdio.h>
-+-#include <time.h>
-+ #include <sys/fcntl.h>
-+ #include "sis.h"
-+ #include <dis-asm.h>
-+@@ -36,44 +35,12 @@
-+
-+ /* Structures and functions from readline library */
-+
-+-typedef struct {
-+- char *line;
-+- char *data;
-+-} HIST_ENTRY;
-+-
-+-extern char * readline (char *prompt);
-+-extern void using_history (void);
-+-extern void add_history (char *string);
-+-extern HIST_ENTRY *remove_history (int which);
-+-
-+-
-++#include "readline/readline.h"
-++#include "readline/history.h"
-+
-+ /* Command history buffer length - MUST be binary */
-+ #define HIST_LEN 64
-+
-+-extern struct disassemble_info dinfo;
-+-extern struct pstate sregs;
-+-extern struct estate ebase;
-+-
-+-extern int ctrl_c;
-+-extern int nfp;
-+-extern int ift;
-+-extern int wrp;
-+-extern int rom8;
-+-extern int uben;
-+-extern int sis_verbose;
-+-extern char *sis_version;
-+-extern struct estate ebase;
-+-extern struct evcell evbuf[];
-+-extern struct irqcell irqarr[];
-+-extern int irqpend, ext_irl;
-+-extern int termsave;
-+-extern int sparclite;
-+-extern int dumbio;
-+-extern char uart_dev1[];
-+-extern char uart_dev2[];
-+-extern uint32 last_load_addr;
-+-
-+ #ifdef ERA
-+ extern int era;
-+ #endif
-+@@ -84,20 +51,16 @@ run_sim(sregs, icount, dis)
-+ uint64 icount;
-+ int dis;
-+ {
-+- int irq, mexc, deb, asi;
-++ int irq, mexc, deb;
-+
-+- sregs->starttime = time(NULL);
-+- init_stdio();
-++ sregs->starttime = get_time();
-++ ms->init_stdio();
-+ if (sregs->err_mode) icount = 0;
-+ deb = dis || sregs->histlen || sregs->bptnum;
-+ irq = 0;
-+ while (icount > 0) {
-+
-+- if (sregs->psr & 0x080)
-+- asi = 9;
-+- else
-+- asi = 8;
-+- mexc = memory_read(asi, sregs->pc, &sregs->inst, 2, &sregs->hold);
-++ mexc = ms->memory_iread(sregs->pc, &sregs->inst, &sregs->hold);
-+ sregs->icnt = 1;
-+ if (sregs->annul) {
-+ sregs->annul = 0;
-+@@ -112,7 +75,7 @@ run_sim(sregs, icount, dis)
-+ } else {
-+ if (deb) {
-+ if ((sregs->bphit = check_bpt(sregs)) != 0) {
-+- restore_stdio();
-++ ms->restore_stdio();
-+ return (BPT_HIT);
-+ }
-+ if (sregs->histlen) {
-+@@ -123,7 +86,7 @@ run_sim(sregs, icount, dis)
-+ sregs->histind = 0;
-+ }
-+ if (dis) {
-+- printf(" %8u ", ebase.simtime);
-++ printf(" %8llu ", ebase.simtime);
-+ dis_mem(sregs->pc, 1, &dinfo);
-+ }
-+ }
-+@@ -135,7 +98,7 @@ run_sim(sregs, icount, dis)
-+ irq = 0;
-+ sregs->err_mode = execute_trap(sregs);
-+ if (sregs->err_mode) {
-+- error_mode(sregs->pc);
-++ ms->error_mode(sregs->pc);
-+ icount = 0;
-+ }
-+ }
-+@@ -146,8 +109,8 @@ run_sim(sregs, icount, dis)
-+ if (sregs->tlimit <= ebase.simtime) sregs->tlimit = -1;
-+ }
-+ }
-+- sregs->tottime += time(NULL) - sregs->starttime;
-+- restore_stdio();
-++ sregs->tottime += get_time() - sregs->starttime;
-++ ms->restore_stdio();
-+ if (sregs->err_mode)
-+ return (ERROR);
-+ if (ctrl_c) {
-+@@ -172,12 +135,13 @@ main(argc, argv)
-+ char *cmdq[HIST_LEN];
-+ int cmdi = 0;
-+ int i;
-++ int lfile = 0;
-+
-+ cfile = 0;
-+ for (i = 0; i < 64; i++)
-+ cmdq[i] = 0;
-+ printf("\n SIS - SPARC instruction simulator %s, copyright Jiri Gaisler 1995\n", sis_version);
-+- printf(" Bug-reports to jgais at wd.estec.esa.nl\n\n");
-++ printf(" Bug-reports to jiri at gaisler.se\n\n");
-+ while (stat < argc) {
-+ if (argv[stat][0] == '-') {
-+ if (strcmp(argv[stat], "-v") == 0) {
-+@@ -214,26 +178,53 @@ main(argc, argv)
-+ #endif
-+ } else if (strcmp(argv[stat], "-dumbio") == 0) {
-+ dumbio = 1;
-++ } else if (strcmp(argv[stat], "-nouartrx") == 0) {
-++ nouartrx = 1;
-++ } else if (strcmp(argv[stat], "-leon2") == 0) {
-++ ms = &leon2;
-++ if (freq == 14) freq = 50;
-++ cputype = CPU_LEON2;
-++ } else if (strcmp(argv[stat], "-leon3") == 0) {
-++ ms = &leon3;
-++ if (freq == 14) freq = 50;
-++ cputype = CPU_LEON3;
-++ } else if (strcmp(argv[stat], "-v") == 0) {
-++ sis_verbose = 1;
-++ } else if (strcmp(argv[stat], "-vv") == 0) {
-++ sis_verbose = 2;
-+ } else {
-+ printf("unknown option %s\n", argv[stat]);
-+ usage();
-+ exit(1);
-+ }
-+ } else {
-+- last_load_addr = bfd_load(argv[stat]);
-++ lfile = stat;
-+ }
-+ stat++;
-+ }
-++
-++ switch (cputype) {
-++ case CPU_LEON2:
-++ printf(" LEON2 emulation enabled\n");
-++ break;
-++ case CPU_LEON3:
-++ printf(" LEON3 emulation enabled\n");
-++ break;
-++ default:
-++ printf(" ERC32 emulation enabled\n");
-++ }
-++
-+ if (nfp)
-+- printf("FPU disabled\n");
-+-#ifdef ERA
-+- if (era)
-+- printf("ERA ECC emulation enabled\n");
-+-#endif
-++ printf(" FPU disabled\n");
-+ sregs.freq = freq;
-++ printf("\n");
-+
-+ INIT_DISASSEMBLE_INFO(dinfo, stdout, (fprintf_ftype) fprintf);
-++#ifdef HOST_LITTLE_ENDIAN
-++ dinfo.endian = BFD_ENDIAN_LITTLE;
-++#else
-+ dinfo.endian = BFD_ENDIAN_BIG;
-++#endif
-+
-+ termsave = fcntl(0, F_GETFL, 0);
-+ using_history();
-+@@ -241,7 +232,8 @@ main(argc, argv)
-+ ebase.simtime = 0;
-+ reset_all();
-+ init_bpt(&sregs);
-+- init_sim();
-++ ms->init_sim();
-++ if (lfile) last_load_addr = bfd_load(argv[lfile]);
-+ #ifdef STAT
-+ reset_stat(&sregs);
-+ #endif
-+@@ -278,7 +270,7 @@ main(argc, argv)
-+ case CTRL_C:
-+ printf("\b\bInterrupt!\n");
-+ case TIME_OUT:
-+- printf(" Stopped at time %d (%.3f ms)\n", ebase.simtime,
-++ printf(" Stopped at time %llu (%.3f ms)\n", ebase.simtime,
-+ ((double) ebase.simtime / (double) sregs.freq) / 1000.0);
-+ break;
-+ case BPT_HIT:
-+@@ -288,7 +280,7 @@ main(argc, argv)
-+ case ERROR:
-+ printf("IU in error mode (%d)\n", sregs.trap);
-+ stat = 0;
-+- printf(" %8d ", ebase.simtime);
-++ printf(" %8llu ", ebase.simtime);
-+ dis_mem(sregs.pc, 1, &dinfo);
-+ break;
-+ default:
-+diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h
-+index f49d45d..637549a 100644
-+--- a/sim/erc32/sis.h
-++++ b/sim/erc32/sis.h
-+@@ -24,7 +24,11 @@
-+ #include "gdb/callback.h"
-+ #include "gdb/remote-sim.h"
-+
-+-#include "end.h"
-++#ifdef WORDS_BIGENDIAN
-++#define HOST_BIG_ENDIAN
-++#else
-++#define HOST_LITTLE_ENDIAN
-++#endif
-+
-+ #define I_ACC_EXC 1
-+
-+@@ -60,7 +64,7 @@ typedef long long int64; /* 64-bit signed int */
-+ struct pstate {
-+
-+ float64 fd[16]; /* FPU registers */
-+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
-++#ifdef HOST_LITTLE_ENDIAN
-+ float32 fs[32];
-+ float32 *fdp;
-+ #else
-+@@ -110,14 +114,14 @@ struct pstate {
-+ float32 freq; /* Simulated processor frequency */
-+
-+
-+- uint64 tottime;
-++ double tottime;
-+ uint64 ninst;
-+ uint64 fholdt;
-+ uint64 holdt;
-+ uint64 icntt;
-+ uint64 finst;
-+ uint64 simstart;
-+- uint64 starttime;
-++ double starttime;
-+ uint64 tlimit; /* Simulation time limit */
-+ uint64 pwdtime; /* Cycles in power-down mode */
-+ uint64 nstore; /* Number of load instructions */
-+@@ -149,6 +153,30 @@ struct irqcell {
-+ int32 arg;
-+ };
-+
-++struct memsys {
-++ void (*init_sim) ();
-++ void (*reset) (void);
-++ void (*error_mode) (uint32 pc);
-++ void (*sim_halt) (void);
-++ void (*exit_sim) (void);
-++ void (*init_stdio) (void);
-++ void (*restore_stdio) (void);
-++ int (*memory_iread) (uint32 addr, uint32 *data, int32 *ws);
-++ int (*memory_read) (uint32 addr, uint32 *data,
-++ int32 sz, int32 *ws);
-++ int (*memory_read_asi) (int32 asi, uint32 addr, uint32 *data,
-++ int32 sz, int32 *ws);
-++ int (*memory_write) (uint32 addr, uint32 *data,
-++ int32 sz, int32 *ws);
-++ int (*memory_write_asi) (int32 asi, uint32 addr, uint32 *data,
-++ int32 sz, int32 *ws);
-++ int (*sis_memory_write) (uint32 addr,
-++ const unsigned char *data, uint32 length);
-++ int (*sis_memory_read) (uint32 addr, char *data,
-++ uint32 length);
-++ void (*boot_init) (void);
-++};
-++
-+
-+ #define OK 0
-+ #define TIME_OUT 1
-+@@ -156,26 +184,37 @@ struct irqcell {
-+ #define ERROR 3
-+ #define CTRL_C 4
-+
-++#define CPU_LEON2 2
-++#define CPU_LEON3 3
-++
-+ /* Prototypes */
-+
-+ /* erc32.c */
-+-extern void init_sim (void);
-+-extern void reset (void);
-+-extern void error_mode (uint32 pc);
-+-extern void sim_halt (void);
-+-extern void exit_sim (void);
-+-extern void init_stdio (void);
-+-extern void restore_stdio (void);
-+-extern int memory_read (int32 asi, uint32 addr, uint32 *data,
-+- int32 sz, int32 *ws);
-+-extern int memory_write (int32 asi, uint32 addr, uint32 *data,
-+- int32 sz, int32 *ws);
-+-extern int sis_memory_write (uint32 addr,
-+- const unsigned char *data, uint32 length);
-+-extern int sis_memory_read (uint32 addr, char *data,
-+- uint32 length);
-++extern struct memsys erc32sys;
-+
-+ /* func.c */
-++extern struct pstate sregs;
-++extern struct estate ebase;
-++extern struct evcell evbuf[];
-++extern struct irqcell irqarr[];
-++extern int nfp;
-++extern int ift;
-++extern int ctrl_c;
-++extern int sis_verbose;
-++extern char *sis_version;
-++extern int sparclite;
-++extern int sparclite_board;
-++extern uint32 last_load_addr;
-++extern int wrp;
-++extern int rom8;
-++extern int uben;
-++extern int irqpend;
-++extern int ext_irl;
-++extern int termsave;
-++extern int dumbio;
-++extern char uart_dev1[];
-++extern char uart_dev2[];
-++
-+ extern void set_regi (struct pstate *sregs, int32 reg,
-+ uint32 rval);
-+ extern void get_regi (struct pstate *sregs, int32 reg, char *buf);
-+@@ -186,6 +225,7 @@ extern void init_bpt (struct pstate *sregs);
-+ extern void init_signals (void);
-+
-+ struct disassemble_info;
-++extern struct disassemble_info dinfo;
-+ extern void dis_mem (uint32 addr, uint32 len,
-+ struct disassemble_info *info);
-+ extern void event (void (*cfunc) (), int32 arg, uint64 delta);
-+@@ -197,7 +237,12 @@ extern int check_bpt (struct pstate *sregs);
-+ extern void reset_all (void);
-+ extern void sys_reset (void);
-+ extern void sys_halt (void);
-+-extern int bfd_load (char *fname);
-++extern double get_time (void);
-++extern int nouartrx;
-++extern host_callback *sim_callback;
-++extern int current_target_byte_order;
-++extern int dumbio;
-++extern int cputype;
-+
-+ /* exec.c */
-+ extern int dispatch_instruction (struct pstate *sregs);
-+@@ -217,3 +262,11 @@ extern void set_fsr (uint32 fsr);
-+ /* help.c */
-+ extern void usage (void);
-+ extern void gen_help (void);
-++
-++extern struct memsys *ms;
-++
-++/* leon2.c */
-++extern struct memsys leon2;
-++
-++/* leon3.c */
-++extern struct memsys leon3;
-+diff --git a/sim/erc32/startsim b/sim/erc32/startsim
-+deleted file mode 100644
-+index 1b9b41c..0000000
-+--- a/sim/erc32/startsim
-++++ /dev/null
-+@@ -1,4 +0,0 @@
-+-#
-+-xterm -e sis $* &
-+-xterm -e tip /dev/ttypc &
-+-
---
-1.9.1
-
++ if (anum > 0) {
++ aind = 0;
++ if ((aind + 1) < anum)
++ set_irq(3);
++ return ((uint32) aq[aind++]);
++ } else {
++ return ((uint32) aq[aind]);
++ }
++
++ }
++#else
++ tmp = uarta_data;
++ uarta_data &= ~UART_DR;
++ uart_stat_reg &= ~UARTA_DR;
++ return tmp;
++#endif
++#else
++ return(0);
++#endif
++ break;
++
++ case 0x04: /* UART status register */
++#ifndef _WIN32
++#ifdef FAST_UART
++
++ Ucontrol = 0;
++ if (aind < anum) {
++ Ucontrol |= 0x00000001;
++ } else {
++ if (f1open) {
++ anum = DO_STDIO_READ(ifd1, aq, UARTBUF);
++ }
++ else {
++ anum = 0;
++ }
++ if (anum > 0) {
++ Ucontrol |= 0x00000001;
++ aind = 0;
++ set_irq(3);
++ }
++ }
++ Ucontrol |= 0x00000006;
++ return (Ucontrol);
++#else
++ return (uart_stat_reg);
++#endif
++#else
++ return(0x00060006);
++#endif
++ break;
++ default:
++ if (sis_verbose)
++ printf("Read from unimplemented MEC register (%x)\n", addr);
++
++ }
++ return (0);
++}
++
++static void
++grlib_write_uart(addr, data)
++ uint32 addr;
++ uint32 data;
++{
++ unsigned char c;
++
++ c = (unsigned char) data;
++ switch (addr & 0xff) {
++
++ case 0x00: /* UART A */
++#ifdef FAST_UART
++ if (f1open) {
++ if (wnuma < UARTBUF)
++ wbufa[wnuma++] = c;
++ else {
++ while (wnuma) {
++ if (ofd1 == 1 && callback)
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ else
++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
++ }
++ wbufa[wnuma++] = c;
++ }
++ }
++ set_irq(3);
++#else
++ if (uart_stat_reg & UARTA_SRE) {
++ uarta_sreg = c;
++ uart_stat_reg &= ~UARTA_SRE;
++ event(uarta_tx, 0, UART_TX_TIME);
++ } else {
++ uarta_hreg = c;
++ uart_stat_reg &= ~UARTA_HRE;
++ }
++#endif
++ break;
++
++ case 0x04: /* UART status register */
++#ifndef FAST_UART
++ uart_stat_reg &= 1;
++#endif
++ break;
++ default:
++ if (sis_verbose)
++ printf("Write to unimplemented APB register (%x)\n", addr);
++
++ }
++}
++
++static void
++flush_uart()
++{
++ while (wnuma && f1open) {
++ if (ofd1 == 1 && callback) {
++ wnuma -= callback->write_stdout(callback, wbufa, wnuma);
++ callback->flush_stdout(callback);
++ }
++ else
++ wnuma -= fwrite(wbufa, 1, wnuma, f1out);
++ }
++}
++
++
++
++static void
++uarta_tx()
++{
++ while (f1open) {
++ if (ofd1 == 1 && callback) {
++ while (callback->write_stdout(callback, &uarta_sreg, 1) != 1);
++ }
++ else {
++ while (fwrite(&uarta_sreg, 1, 1, f1out) != 1);
++ }
++ }
++ if (uart_stat_reg & UARTA_HRE) {
++ uart_stat_reg |= UARTA_SRE;
++ } else {
++ uarta_sreg = uarta_hreg;
++ uart_stat_reg |= UARTA_HRE;
++ event(uarta_tx, 0, UART_TX_TIME);
++ }
++ set_irq(3);
++}
++
++static void
++uart_rx(arg)
++ caddr_t arg;
++{
++ int32 rsize;
++ char rxd;
++
++
++ rsize = 0;
++ if (f1open)
++ rsize = DO_STDIO_READ(ifd1, &rxd, 1);
++ else
++ rsize = 0;
++ if (rsize > 0) {
++ uarta_data = rxd;
++ if (uart_stat_reg & UARTA_DR) {
++ uart_stat_reg |= UARTA_OR;
++ }
++ uart_stat_reg |= UARTA_DR;
++ set_irq(3);
++ }
++ event(uart_rx, 0, UART_RX_TIME);
++}
++
++static void
++uart_intr(arg)
++ caddr_t arg;
++{
++ grlib_read_uart(APBUART_STATUS); /* Check for UART interrupts every 1000 clk */
++ flush_uart(); /* Flush UART ports */
++ event(uart_intr, 0, UART_FLUSH_TIME);
++}
++
++
++static void
++uart_irq_start()
++{
++#ifdef FAST_UART
++ event(uart_intr, 0, UART_FLUSH_TIME);
++#else
++#ifndef _WIN32
++ event(uart_rx, 0, UART_RX_TIME);
++#endif
++#endif
++}
++
++/* GPTIMER */
++
++static void
++gpt_intr(arg)
++ caddr_t arg;
++{
++ int i;
++
++ for (i=0; i<NGPTIMERS; i++) {
++ if (gpt_ctrl[i] & 1) {
++ gpt_counter[i] -= 1;
++ if (gpt_counter[i] == -1) {
++ if (gpt_ctrl[i] & 8)
++ set_irq(GPTIMER_IRQ + i);
++ if (gpt_ctrl[i] & 2)
++ gpt_counter[i] = gpt_reload[i];
++ }
++ }
++ }
++ event(gpt_intr, 0, gpt_scaler + 1);
++ gpt_scaler_start = now();
++}
++
++static void
++gpt_init()
++{
++ if (sis_verbose)
++ printf("GPT started (period %d)\n\r", gpt_scaler + 1);
++
++ grlib_apbpp_add(GRLIB_PP_ID(VENDOR_GAISLER, GAISLER_GPTIMER, 0, 8),
++ GRLIB_PP_APBADDR(0x80000300, 0xFFF));
++}
++
++static void
++gpt_reset()
++{
++ event(gpt_intr, 0, gpt_scaler + 1);
++ gpt_scaler_start = now();
++}
++
++static void
++gpt_scaler_set(val)
++ uint32 val;
++{
++ gpt_scaler = val & 0x0ffff; /* 16-bit scaler */
++}
++
++static void
++timer_ctrl(val, i)
++ uint32 val;
++ int i;
++{
++ if (val & 4) { /* reload */
++ gpt_counter[i] = gpt_reload[i];
++ }
++ gpt_ctrl[i] = val & 0xb;
++}
++
++/* Store data in host byte order. MEM points to the beginning of the
++ emulated memory; WADDR contains the index the emulated memory,
++ DATA points to words in host byte order to be stored. SZ contains log(2)
++ of the number of bytes to retrieve, and can be 0 (1 byte), 1 (one half-word),
++ 2 (one word), or 3 (two words); WS should return the number of wait-states. */
++
++static void
++store_bytes (mem, waddr, data, sz, ws)
++ unsigned char *mem;
++ uint32 waddr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ switch (sz) {
++ case 0:
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 3;
++#endif
++ mem[waddr] = *data & 0x0ff;
++ *ws = 0;
++ break;
++ case 1:
++#ifdef HOST_LITTLE_ENDIAN
++ waddr ^= 2;
++#endif
++ *((unsigned short *) &(mem[waddr])) = *data & 0x0ffff;
++ *ws = 0;
++ break;
++ case 2:
++ *((uint32 *) &(mem[waddr])) = *data;
++ *ws = 0;
++ break;
++ case 3:
++ *((uint32 *) &(mem[waddr])) = data[0];
++ *((uint32 *) &(mem[waddr + 4])) = data[1];
++ *ws = 0;
++ break;
++ }
++}
++
++
++/* Memory emulation */
++
++static int
++memory_iread(addr, data, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 *ws;
++{
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ *data = *((uint32 *) & (ramb[addr & RAM_MASK]));
++ *ws = 0;
++ return (0);
++ } else if (addr < ROM_END) {
++ *data = *((uint32 *) & (romb[addr]));
++ *ws = 0;
++ return (0);
++ }
++
++ printf("Memory exception at %x (illegal address)\n", addr);
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_read(addr, data, sz, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ int32 mexc;
++
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ *data = *((uint32 *) & (ramb[addr & RAM_MASK & ~3]));
++ *ws = 0;
++ return (0);
++ } else if ((addr >= APBPP_START) && (addr <= APBPP_END)) {
++ *data = grlib_apbpnp_read(addr);
++ if (sis_verbose > 1)
++ printf("APB PP read a: %08x, d: %08x\n",addr, *data);
++ *ws = 4;
++ return (0);
++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
++ mexc = apb_read(addr, data);
++ if (mexc) {
++ *ws = MEM_EX_WS;
++ } else {
++ *ws = 0;
++ }
++ return (mexc);
++ } else if ((addr >= AHBPP_START) && (addr <= AHBPP_END)) {
++ if (sis_verbose > 1)
++ printf("AHB PP read a: %08x, d: %08x\n",addr, *data);
++ *data = grlib_ahbpnp_read(addr);
++ *ws = 4;
++ return (0);
++ } else if (addr < ROM_END) {
++ *data = *((uint32 *) & (romb[addr & ~3]));
++ *ws = 0;
++ return (0);
++ }
++
++ printf("Memory exception at %x (illegal address)\n", addr);
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_read_asi(asi, addr, data, sz, ws)
++ int32 asi;
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ if (asi == 2) {
++ if (addr == 0)
++ *data = cache_ctrl;
++ else
++ *data = 0;
++ return MOK;
++ } else
++ return(memory_read(addr, data, sz, ws));
++}
++
++static int
++memory_write(addr, data, sz, ws)
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ uint32 byte_addr;
++ uint32 byte_mask;
++ uint32 waddr;
++ uint32 *ram;
++ int32 mexc;
++ int i;
++ int wphit[2];
++
++ if ((addr >= RAM_START) && (addr < RAM_END)) {
++ waddr = addr & RAM_MASK;
++ store_bytes (ramb, waddr, data, sz, ws);
++ return (0);
++
++ } else if ((addr >= APBSTART) && (addr < APBEND)) {
++ if (sz != 2) {
++ *ws = MEM_EX_WS;
++ return (1);
++ }
++ apb_write(addr, *data);
++ *ws = 0;
++ return (0);
++
++ } else if (addr < ROM_END) {
++// return (1);
++ *ws = 0;
++ store_bytes (romb, addr, data, sz, ws);
++ return (0);
++ }
++
++ *ws = MEM_EX_WS;
++ return (1);
++}
++
++static int
++memory_write_asi(asi, addr, data, sz, ws)
++ int32 asi;
++ uint32 addr;
++ uint32 *data;
++ int32 sz;
++ int32 *ws;
++{
++ if (asi == 2) {
++ cache_ctrl = *data & 0x81000f;
++ if (sis_verbose)
++ printf("cache ctrl reg : 0x%08x\n", cache_ctrl);
++ return MOK;
++ } else
++ return(memory_write(addr, data, sz, ws));
++}
++
++static unsigned char *
++get_mem_ptr(addr, size)
++ uint32 addr;
++ uint32 size;
++{
++ if ((addr + size) < ROM_END) {
++ return (&romb[addr]);
++ } else if ((addr >= RAM_START) && ((addr + size) < RAM_END)) {
++ return (&ramb[addr & RAM_MASK]);
++ }
++
++ return ((char *) -1);
++}
++
++static int
++sis_memory_write(addr, data, length)
++ uint32 addr;
++ const unsigned char *data;
++ uint32 length;
++{
++ char *mem;
++
++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
++ return (0);
++
++ memcpy(mem, data, length);
++ return (length);
++}
++
++static int
++sis_memory_read(addr, data, length)
++ uint32 addr;
++ char *data;
++ uint32 length;
++{
++ char *mem;
++ int ws;
++
++ if (length == 4) {
++ memory_read(addr, data, length, &ws);
++ return(4);
++ }
++
++ if ((mem = get_mem_ptr(addr, length)) == ((char *) -1))
++ return (0);
++
++ memcpy(data, mem, length);
++ return (length);
++}
++
++static void
++boot_init ()
++{
++// mec_write(MEC_WCR, 0); /* zero waitstates */
++// mec_write(MEC_TRAPD, 0); /* turn off watch-dog */
++ apb_write(GPTIMER_SCALER, sregs.freq-1); /* generate 1 MHz RTC tick */
++ apb_write(GPTIMER_SCLOAD, sregs.freq-1);
++ apb_write(GPTIMER_TIMER1, -1);
++ apb_write(GPTIMER_RELOAD1, -1);
++ apb_write(GPTIMER_CTRL1, 0x7);
++// mec_write(MEC_MEMCFG, (3 << 18) | (4 << 10)); /* 1 MB ROM, 4 MB RAM */
++ sregs.wim = 2;
++ sregs.psr = 0xF30010e0;
++ sregs.r[30] = RAM_END;
++ sregs.r[14] = sregs.r[30] - 96*4;
++ cache_ctrl = 0x81000f;
++}
++
++struct memsys leon3 = {
++ init_sim,
++ reset,
++ error_mode,
++ sim_halt,
++ exit_sim,
++ init_stdio,
++ restore_stdio,
++ memory_iread,
++ memory_read,
++ memory_read_asi,
++ memory_write,
++ memory_write_asi,
++ sis_memory_write,
++ sis_memory_read,
++ boot_init
++};
+diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
+index 89e6f02..f21ddde 100644
+--- a/sim/erc32/sis.c
++++ b/sim/erc32/sis.c
+@@ -26,7 +26,6 @@
+ #include <stdlib.h>
+ #endif
+ #include <stdio.h>
+-#include <time.h>
+ #include <sys/fcntl.h>
+ #include "sis.h"
+ #include <dis-asm.h>
+@@ -36,44 +35,12 @@
+
+ /* Structures and functions from readline library */
+
+-typedef struct {
+- char *line;
+- char *data;
+-} HIST_ENTRY;
+-
+-extern char * readline (char *prompt);
+-extern void using_history (void);
+-extern void add_history (char *string);
+-extern HIST_ENTRY *remove_history (int which);
+-
+-
++#include "readline/readline.h"
++#include "readline/history.h"
+
+ /* Command history buffer length - MUST be binary */
+ #define HIST_LEN 64
+
+-extern struct disassemble_info dinfo;
+-extern struct pstate sregs;
+-extern struct estate ebase;
+-
+-extern int ctrl_c;
+-extern int nfp;
+-extern int ift;
+-extern int wrp;
+-extern int rom8;
+-extern int uben;
+-extern int sis_verbose;
+-extern char *sis_version;
+-extern struct estate ebase;
+-extern struct evcell evbuf[];
+-extern struct irqcell irqarr[];
+-extern int irqpend, ext_irl;
+-extern int termsave;
+-extern int sparclite;
+-extern int dumbio;
+-extern char uart_dev1[];
+-extern char uart_dev2[];
+-extern uint32 last_load_addr;
+-
+ #ifdef ERA
+ extern int era;
+ #endif
+@@ -84,20 +51,16 @@ run_sim(sregs, icount, dis)
+ uint64 icount;
+ int dis;
+ {
+- int irq, mexc, deb, asi;
++ int irq, mexc, deb;
+
+- sregs->starttime = time(NULL);
+- init_stdio();
++ sregs->starttime = get_time();
++ ms->init_stdio();
+ if (sregs->err_mode) icount = 0;
+ deb = dis || sregs->histlen || sregs->bptnum;
+ irq = 0;
+ while (icount > 0) {
+
+- if (sregs->psr & 0x080)
+- asi = 9;
+- else
+- asi = 8;
+- mexc = memory_read(asi, sregs->pc, &sregs->inst, 2, &sregs->hold);
++ mexc = ms->memory_iread(sregs->pc, &sregs->inst, &sregs->hold);
+ sregs->icnt = 1;
+ if (sregs->annul) {
+ sregs->annul = 0;
+@@ -112,7 +75,7 @@ run_sim(sregs, icount, dis)
+ } else {
+ if (deb) {
+ if ((sregs->bphit = check_bpt(sregs)) != 0) {
+- restore_stdio();
++ ms->restore_stdio();
+ return (BPT_HIT);
+ }
+ if (sregs->histlen) {
+@@ -123,7 +86,7 @@ run_sim(sregs, icount, dis)
+ sregs->histind = 0;
+ }
+ if (dis) {
+- printf(" %8u ", ebase.simtime);
++ printf(" %8llu ", ebase.simtime);
+ dis_mem(sregs->pc, 1, &dinfo);
+ }
+ }
+@@ -135,7 +98,7 @@ run_sim(sregs, icount, dis)
+ irq = 0;
+ sregs->err_mode = execute_trap(sregs);
+ if (sregs->err_mode) {
+- error_mode(sregs->pc);
++ ms->error_mode(sregs->pc);
+ icount = 0;
+ }
+ }
+@@ -146,8 +109,8 @@ run_sim(sregs, icount, dis)
+ if (sregs->tlimit <= ebase.simtime) sregs->tlimit = -1;
+ }
+ }
+- sregs->tottime += time(NULL) - sregs->starttime;
+- restore_stdio();
++ sregs->tottime += get_time() - sregs->starttime;
++ ms->restore_stdio();
+ if (sregs->err_mode)
+ return (ERROR);
+ if (ctrl_c) {
+@@ -172,12 +135,13 @@ main(argc, argv)
+ char *cmdq[HIST_LEN];
+ int cmdi = 0;
+ int i;
++ int lfile = 0;
+
+ cfile = 0;
+ for (i = 0; i < 64; i++)
+ cmdq[i] = 0;
+ printf("\n SIS - SPARC instruction simulator %s, copyright Jiri Gaisler 1995\n", sis_version);
+- printf(" Bug-reports to jgais at wd.estec.esa.nl\n\n");
++ printf(" Bug-reports to jiri at gaisler.se\n\n");
+ while (stat < argc) {
+ if (argv[stat][0] == '-') {
+ if (strcmp(argv[stat], "-v") == 0) {
+@@ -214,26 +178,53 @@ main(argc, argv)
+ #endif
+ } else if (strcmp(argv[stat], "-dumbio") == 0) {
+ dumbio = 1;
++ } else if (strcmp(argv[stat], "-nouartrx") == 0) {
++ nouartrx = 1;
++ } else if (strcmp(argv[stat], "-leon2") == 0) {
++ ms = &leon2;
++ if (freq == 14) freq = 50;
++ cputype = CPU_LEON2;
++ } else if (strcmp(argv[stat], "-leon3") == 0) {
++ ms = &leon3;
++ if (freq == 14) freq = 50;
++ cputype = CPU_LEON3;
++ } else if (strcmp(argv[stat], "-v") == 0) {
++ sis_verbose = 1;
++ } else if (strcmp(argv[stat], "-vv") == 0) {
++ sis_verbose = 2;
+ } else {
+ printf("unknown option %s\n", argv[stat]);
+ usage();
+ exit(1);
+ }
+ } else {
+- last_load_addr = bfd_load(argv[stat]);
++ lfile = stat;
+ }
+ stat++;
+ }
++
++ switch (cputype) {
++ case CPU_LEON2:
++ printf(" LEON2 emulation enabled\n");
++ break;
++ case CPU_LEON3:
++ printf(" LEON3 emulation enabled\n");
++ break;
++ default:
++ printf(" ERC32 emulation enabled\n");
++ }
++
+ if (nfp)
+- printf("FPU disabled\n");
+-#ifdef ERA
+- if (era)
+- printf("ERA ECC emulation enabled\n");
+-#endif
++ printf(" FPU disabled\n");
+ sregs.freq = freq;
++ printf("\n");
+
+ INIT_DISASSEMBLE_INFO(dinfo, stdout, (fprintf_ftype) fprintf);
++#ifdef HOST_LITTLE_ENDIAN
++ dinfo.endian = BFD_ENDIAN_LITTLE;
++#else
+ dinfo.endian = BFD_ENDIAN_BIG;
++#endif
+
+ termsave = fcntl(0, F_GETFL, 0);
+ using_history();
+@@ -241,7 +232,8 @@ main(argc, argv)
+ ebase.simtime = 0;
+ reset_all();
+ init_bpt(&sregs);
+- init_sim();
++ ms->init_sim();
++ if (lfile) last_load_addr = bfd_load(argv[lfile]);
+ #ifdef STAT
+ reset_stat(&sregs);
+ #endif
+@@ -278,7 +270,7 @@ main(argc, argv)
+ case CTRL_C:
+ printf("\b\bInterrupt!\n");
+ case TIME_OUT:
+- printf(" Stopped at time %d (%.3f ms)\n", ebase.simtime,
++ printf(" Stopped at time %llu (%.3f ms)\n", ebase.simtime,
+ ((double) ebase.simtime / (double) sregs.freq) / 1000.0);
+ break;
+ case BPT_HIT:
+@@ -288,7 +280,7 @@ main(argc, argv)
+ case ERROR:
+ printf("IU in error mode (%d)\n", sregs.trap);
+ stat = 0;
+- printf(" %8d ", ebase.simtime);
++ printf(" %8llu ", ebase.simtime);
+ dis_mem(sregs.pc, 1, &dinfo);
+ break;
+ default:
+diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h
+index f49d45d..637549a 100644
+--- a/sim/erc32/sis.h
++++ b/sim/erc32/sis.h
+@@ -24,7 +24,11 @@
+ #include "gdb/callback.h"
+ #include "gdb/remote-sim.h"
+
+-#include "end.h"
++#ifdef WORDS_BIGENDIAN
++#define HOST_BIG_ENDIAN
++#else
++#define HOST_LITTLE_ENDIAN
++#endif
+
+ #define I_ACC_EXC 1
+
+@@ -60,7 +64,7 @@ typedef long long int64; /* 64-bit signed int */
+ struct pstate {
+
+ float64 fd[16]; /* FPU registers */
+-#ifdef HOST_LITTLE_ENDIAN_FLOAT
++#ifdef HOST_LITTLE_ENDIAN
+ float32 fs[32];
+ float32 *fdp;
+ #else
+@@ -110,14 +114,14 @@ struct pstate {
+ float32 freq; /* Simulated processor frequency */
+
+
+- uint64 tottime;
++ double tottime;
+ uint64 ninst;
+ uint64 fholdt;
+ uint64 holdt;
+ uint64 icntt;
+ uint64 finst;
+ uint64 simstart;
+- uint64 starttime;
++ double starttime;
+ uint64 tlimit; /* Simulation time limit */
+ uint64 pwdtime; /* Cycles in power-down mode */
+ uint64 nstore; /* Number of load instructions */
+@@ -149,6 +153,30 @@ struct irqcell {
+ int32 arg;
+ };
+
++struct memsys {
++ void (*init_sim) ();
++ void (*reset) (void);
++ void (*error_mode) (uint32 pc);
++ void (*sim_halt) (void);
++ void (*exit_sim) (void);
++ void (*init_stdio) (void);
++ void (*restore_stdio) (void);
++ int (*memory_iread) (uint32 addr, uint32 *data, int32 *ws);
++ int (*memory_read) (uint32 addr, uint32 *data,
++ int32 sz, int32 *ws);
++ int (*memory_read_asi) (int32 asi, uint32 addr, uint32 *data,
++ int32 sz, int32 *ws);
++ int (*memory_write) (uint32 addr, uint32 *data,
++ int32 sz, int32 *ws);
++ int (*memory_write_asi) (int32 asi, uint32 addr, uint32 *data,
++ int32 sz, int32 *ws);
++ int (*sis_memory_write) (uint32 addr,
++ const unsigned char *data, uint32 length);
++ int (*sis_memory_read) (uint32 addr, char *data,
++ uint32 length);
++ void (*boot_init) (void);
++};
++
+
+ #define OK 0
+ #define TIME_OUT 1
+@@ -156,26 +184,37 @@ struct irqcell {
+ #define ERROR 3
+ #define CTRL_C 4
+
++#define CPU_LEON2 2
++#define CPU_LEON3 3
++
+ /* Prototypes */
+
+ /* erc32.c */
+-extern void init_sim (void);
+-extern void reset (void);
+-extern void error_mode (uint32 pc);
+-extern void sim_halt (void);
+-extern void exit_sim (void);
+-extern void init_stdio (void);
+-extern void restore_stdio (void);
+-extern int memory_read (int32 asi, uint32 addr, uint32 *data,
+- int32 sz, int32 *ws);
+-extern int memory_write (int32 asi, uint32 addr, uint32 *data,
+- int32 sz, int32 *ws);
+-extern int sis_memory_write (uint32 addr,
+- const unsigned char *data, uint32 length);
+-extern int sis_memory_read (uint32 addr, char *data,
+- uint32 length);
++extern struct memsys erc32sys;
+
+ /* func.c */
++extern struct pstate sregs;
++extern struct estate ebase;
++extern struct evcell evbuf[];
++extern struct irqcell irqarr[];
++extern int nfp;
++extern int ift;
++extern int ctrl_c;
++extern int sis_verbose;
++extern char *sis_version;
++extern int sparclite;
++extern int sparclite_board;
++extern uint32 last_load_addr;
++extern int wrp;
++extern int rom8;
++extern int uben;
++extern int irqpend;
++extern int ext_irl;
++extern int termsave;
++extern int dumbio;
++extern char uart_dev1[];
++extern char uart_dev2[];
++
+ extern void set_regi (struct pstate *sregs, int32 reg,
+ uint32 rval);
+ extern void get_regi (struct pstate *sregs, int32 reg, char *buf);
+@@ -186,6 +225,7 @@ extern void init_bpt (struct pstate *sregs);
+ extern void init_signals (void);
+
+ struct disassemble_info;
++extern struct disassemble_info dinfo;
+ extern void dis_mem (uint32 addr, uint32 len,
+ struct disassemble_info *info);
+ extern void event (void (*cfunc) (), int32 arg, uint64 delta);
+@@ -197,7 +237,12 @@ extern int check_bpt (struct pstate *sregs);
+ extern void reset_all (void);
+ extern void sys_reset (void);
+ extern void sys_halt (void);
+-extern int bfd_load (char *fname);
++extern double get_time (void);
++extern int nouartrx;
++extern host_callback *sim_callback;
++extern int current_target_byte_order;
++extern int dumbio;
++extern int cputype;
+
+ /* exec.c */
+ extern int dispatch_instruction (struct pstate *sregs);
+@@ -217,3 +262,11 @@ extern void set_fsr (uint32 fsr);
+ /* help.c */
+ extern void usage (void);
+ extern void gen_help (void);
++
++extern struct memsys *ms;
++
++/* leon2.c */
++extern struct memsys leon2;
++
++/* leon3.c */
++extern struct memsys leon3;
+diff --git a/sim/erc32/startsim b/sim/erc32/startsim
+deleted file mode 100644
+index 1b9b41c..0000000
+--- a/sim/erc32/startsim
++++ /dev/null
+@@ -1,4 +0,0 @@
+-#
+-xterm -e sis $* &
+-xterm -e tip /dev/ttypc &
+-
More information about the vc
mailing list