changeset 8:ece80412419a ecos-sw-1999-05-21

Merge from eCos master repository on 1999-05-21-22:05:54-BST
author jlarmour
date Fri, 21 May 1999 15:09:30 +0000
parents e55593b6dcea
children 95cc44ea0068
files packages/compat/uitron/current/ChangeLog packages/compat/uitron/current/include/uit_func.inl packages/compat/uitron/current/tests/testcx7.cxx packages/hal/arm/aeb/current/ChangeLog packages/hal/arm/aeb/current/include/pkgconf/hal_arm_aeb.h packages/hal/arm/arch/current/ChangeLog packages/hal/arm/arch/current/include/hal_intr.h packages/hal/arm/arch/current/src/arm.ld packages/hal/arm/arch/current/src/vectors.S packages/hal/arm/pid/current/ChangeLog packages/hal/arm/pid/current/include/pkgconf/hal_arm_pid.h packages/hal/common/current/ChangeLog packages/hal/common/current/src/hal_stub.c packages/hal/common/current/tests/intr.c packages/hal/i386/linux/current/ChangeLog packages/hal/i386/linux/current/include/pkgconf/hal_i386_linux.h packages/hal/mips/arch/current/ChangeLog packages/hal/mips/arch/current/include/arch.inc packages/hal/mips/arch/current/include/hal_intr.h packages/hal/mips/arch/current/src/context.S packages/hal/mips/arch/current/src/mips-stub.c packages/hal/mips/arch/current/src/vectors.S packages/hal/mips/jmr3904/current/ChangeLog packages/hal/mips/jmr3904/current/include/pkgconf/hal_mips_tx39_jmr3904.h packages/hal/mips/sim/current/ChangeLog packages/hal/mips/sim/current/include/pkgconf/hal_mips_sim.h packages/hal/mn10300/arch/current/ChangeLog packages/hal/mn10300/arch/current/include/hal_intr.h packages/hal/mn10300/arch/current/src/vectors.S packages/hal/mn10300/sim/current/ChangeLog packages/hal/mn10300/sim/current/include/pkgconf/hal_mn10300_sim.h packages/hal/mn10300/stdeval1/current/ChangeLog packages/hal/mn10300/stdeval1/current/include/pkgconf/hal_mn10300_stdeval1.h packages/hal/powerpc/arch/current/ChangeLog packages/hal/powerpc/arch/current/include/hal_intr.h packages/hal/powerpc/arch/current/src/vectors.S packages/hal/powerpc/cogent/current/ChangeLog packages/hal/powerpc/cogent/current/include/pkgconf/hal_powerpc_cogent.h packages/hal/powerpc/fads/current/ChangeLog packages/hal/powerpc/fads/current/include/pkgconf/hal_powerpc_fads.h packages/hal/powerpc/sim/current/ChangeLog packages/hal/powerpc/sim/current/include/pkgconf/hal_powerpc_sim.h packages/hal/sparclite/arch/current/ChangeLog packages/hal/sparclite/arch/current/include/hal_intr.h packages/hal/sparclite/arch/current/src/context.S packages/hal/sparclite/arch/current/src/icontext.c packages/hal/sparclite/arch/current/src/vec_ivsr.S packages/hal/sparclite/arch/current/src/vectors.S packages/io/serial/current/ChangeLog packages/io/serial/current/src/sparclite/sleb_sdtr.c packages/kernel/current/ChangeLog packages/kernel/current/include/intr.hxx packages/kernel/current/include/kapi.h packages/kernel/current/include/pkgconf/kernel.h packages/kernel/current/include/stackmon.hxx packages/kernel/current/src/common/kapi.cxx packages/kernel/current/src/common/thread.cxx packages/kernel/current/src/intr/intr.cxx packages/kernel/current/tests/stress_threads.c packages/kernel/current/tests/tm_basic.cxx packages/language/c/libm/current/ChangeLog packages/language/c/libm/current/src/PKGconf.mak packages/packages packages/targets
diffstat 64 files changed, 1048 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- a/packages/compat/uitron/current/ChangeLog
+++ b/packages/compat/uitron/current/ChangeLog
@@ -1,3 +1,18 @@
+1999-05-20  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* tests/testcx7.cxx (task1): Add some statistics dumping about
+	stack usage; since this is quite a long and arduous test.  This
+	just helps en passant with testing the interrupt stack work that's
+	been happening recently.  C++ only, so not for test7.
+
+1999-05-17  Hugo Tyson  <hmt@masala.cygnus.co.uk>
+
+	* include/uit_func.inl (ter_tsk): Only up the priority of the
+	killee if priorities are not unique or we are not already
+	elevated.  This is to prevent asserts with the bitmap scheduler.
+	(chg_pri): Support a level X feature, pri zero => reset to the
+	thread's initial priority.
+
 1999-05-14  Hugo Tyson  <hmt@masala.cygnus.co.uk>
 
 	* include/uit_objs.hxx: object array declaration macro now
--- a/packages/compat/uitron/current/include/uit_func.inl
+++ b/packages/compat/uitron/current/include/uit_func.inl
@@ -317,8 +317,10 @@ cre_tsk ( ID tskid, T_CTSK *pk_ctsk )
         // but ensure the task state is dormant:
         // (it is not constructed dormant, but suspended)
         p->kill();
+#ifdef CYGIMP_THREAD_PRIORITY
         // and record the initial priority outside the task too.
         CYG_UITRON_TASK_INITIAL_PRIORITY( tskid ) = pk_ctsk->itskpri;
+#endif
     }
     Cyg_Scheduler::unlock();
     return ret;
@@ -425,16 +427,25 @@ ter_tsk ( ID tskid )
         p->force_resume(); // let it run
         p->kill(); // and set prio high so it runs RIGHT NOW!!
 #ifdef CYGIMP_THREAD_PRIORITY
-        p->set_priority( (cyg_priority) 0 );
+#if CYG_SCHED_UNIQUE_PRIORITIES != 0
+        // see if we are already at prio 0:
+        if ( 0 == cyg_uitron_dis_dsp_old_priority )
+            // then dispatch is enabled, we are not at prio 0
+#endif
+            p->set_priority( (cyg_priority) 0 );
+        // if we do not do this, then we are not running a strictly
+        // uITRON compatible scheduler - so just hope for the best.
 #endif
     }
     Cyg_Scheduler::unlock();
 #ifdef CYGIMP_THREAD_PRIORITY
+#if CYG_SCHED_UNIQUE_PRIORITIES == 0
     if ( (E_OK == ret) && (0 != cyg_uitron_dis_dsp_old_priority) ) {
         // then dispatching is disabled, so our prio is 0 too
         Cyg_Thread::yield(); // so let the dying thread run;
         Cyg_Thread::yield(); // no cost here of making sure.
-    }        
+    }
+#endif
 #endif
     return ret;
 }
@@ -497,6 +508,11 @@ chg_pri ( ID tskid, PRI tskpri )
     else
         CYG_UITRON_CHECK_AND_GETP_TASKS( tskid, p );
 
+#ifdef CYGIMP_THREAD_PRIORITY
+    if ( 0 == tskpri )
+        // then use the initial priority [Level X]
+        tskpri = CYG_UITRON_TASK_INITIAL_PRIORITY( tskid );
+#endif
     CYG_UIT_PARAMCHECK( 0 < tskpri, E_PAR );
 #ifdef CYGIMP_THREAD_PRIORITY
 #if CYG_THREAD_MAX_PRIORITY < CYG_THREAD_MIN_PRIORITY
--- a/packages/compat/uitron/current/tests/testcx7.cxx
+++ b/packages/compat/uitron/current/tests/testcx7.cxx
@@ -105,7 +105,7 @@
 
 // ============================ END ============================
 
-
+#include <cyg/kernel/stackmon.hxx>      // stack analysis tools
 
 #include <cyg/compat/uitron/uit_func.h> // uITRON
 
@@ -705,6 +705,17 @@ void task1( unsigned int arg )
 
     CYG_TEST_INFO( "Task 1 running" );
 
+    {
+        extern Cyg_Thread cyg_uitron_TASKS[];
+        cyg_test_dump_thread_stack_stats(
+            "Startup, task1", &cyg_uitron_TASKS[ 0 ] );
+        cyg_test_dump_thread_stack_stats(
+            "Startup, task2", &cyg_uitron_TASKS[ 1 ] );
+        cyg_test_dump_interrupt_stack_stats( "Startup" );
+        cyg_test_dump_idlethread_stack_stats( "Startup" );
+        cyg_test_clear_interrupt_stack();
+    }
+
     ercd = chg_pri( 1, 8 );
     CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
 
@@ -964,6 +975,15 @@ void task1( unsigned int arg )
     }
     CYG_TEST_PASS("synchronization interaction tests");
 
+    {
+        extern Cyg_Thread cyg_uitron_TASKS[];
+        cyg_test_dump_thread_stack_stats(
+            "All done, task1", &cyg_uitron_TASKS[ 0 ] );
+        cyg_test_dump_thread_stack_stats(
+            "All done, task2", &cyg_uitron_TASKS[ 1 ] );
+        cyg_test_dump_interrupt_stack_stats( "All done" );
+        cyg_test_dump_idlethread_stack_stats( "All done" );
+    }
     // all done
     CYG_TEST_EXIT( "All done" );
     ext_tsk();
--- a/packages/hal/arm/aeb/current/ChangeLog
+++ b/packages/hal/arm/aeb/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_arm_aeb.h: Move RTC setup here.
+
 1999-04-13  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* src/aeb_misc.c: Add some testing code using a second timer.
--- a/packages/hal/arm/aeb/current/include/pkgconf/hal_arm_aeb.h
+++ b/packages/hal/arm/aeb/current/include/pkgconf/hal_arm_aeb.h
@@ -76,6 +76,12 @@
 
 #define CYGHWR_HAL_ARM_AEB_STARTUP       ram
 
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        (240000/16)
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_ARM_AEB_H */
 /* EOF hal_arm_aeb.h */
--- a/packages/hal/arm/arch/current/ChangeLog
+++ b/packages/hal/arm/arch/current/ChangeLog
@@ -1,3 +1,23 @@
+1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
+	HAL_INTERRUPT_STACK_TOP so that stack usage macros in
+	kernel/.../stackmon.hxx can work.
+
+	* src/vectors.S (cyg_interrupt_stack_base): Define this symbol for
+	the interrupt stack and its friend for the stack top so that we
+	can publish them with nice names.
+
+1999-05-19  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* src/arm.ld: Change symbols to match new no-underscore ABI.
+
+1999-05-16  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/hal_intr.h (HAL_INTERRUPT_STACK_CALL_PENDING_DSRS): 
+	Add macro for new DSR handling mechanism (was override of a
+	"weak" symbol in kernel).	
+
 1999-05-13  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_arch.h (HAL_THREAD_INIT_CONTEXT): Align stack
--- a/packages/hal/arm/arch/current/include/hal_intr.h
+++ b/packages/hal/arm/arch/current/include/hal_intr.h
@@ -158,6 +158,24 @@ typedef cyg_uint32 CYG_INTERRUPT_STATE;
         );
 
 //--------------------------------------------------------------------------
+// Routine to execute DSRs using separate interrupt stack
+
+#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+externC void hal_interrupt_stack_call_pending_DSRs(void);
+#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
+    hal_interrupt_stack_call_pending_DSRs()
+
+// these are offered solely for stack usage testing
+// if they are not defined, then there is no interrupt stack.
+#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
+#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
+// use them to declare these extern however you want:
+//       extern char HAL_INTERRUPT_STACK_BASE[];
+//       extern char HAL_INTERRUPT_STACK_TOP[];
+// is recommended
+#endif
+
+//--------------------------------------------------------------------------
 // Vector translation.
 
 #ifndef HAL_TRANSLATE_VECTOR
--- a/packages/hal/arm/arch/current/src/arm.ld
+++ b/packages/hal/arm/arch/current/src/arm.ld
@@ -59,11 +59,11 @@ GROUP(libtarget.a libgcc.a)
 
 #define SECTION_text(_region_, _vma_, _lma_) \
     .text _vma_ : _lma_ \
-    { _stext = ABSOLUTE(.); \
+    { stext = ABSOLUTE(.); \
     PROVIDE (__stext = ABSOLUTE(.)); \
     *(.text*) *(.gnu.warning) *(.gnu.linkonce*) *(.init) } \
     > _region_ \
-    __etext = .; PROVIDE (__etext = .);
+    etext = .; PROVIDE (__etext = .);
 
 #define SECTION_fini(_region_, _vma_, _lma_) \
     .fini _vma_ : _lma_ \
--- a/packages/hal/arm/arch/current/src/vectors.S
+++ b/packages/hal/arm/arch/current/src/vectors.S
@@ -730,11 +730,15 @@ hal_interrupt_objects:
 #endif
 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
 	.balign 16
+	.global cyg_interrupt_stack_base
+cyg_interrupt_stack_base:
 __interrupt_stack_base:
         .rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
         .byte 0
         .endr
 	.balign 16
+	.global cyg_interrupt_stack
+cyg_interrupt_stack:
 __interrupt_stack:
 irq_level:
 	.long	0
--- a/packages/hal/arm/pid/current/ChangeLog
+++ b/packages/hal/arm/pid/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_arm_pid.h: Move RTC setup here.
+
 1999-04-13  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* include/hal_platform_setup.h: New file
--- a/packages/hal/arm/pid/current/include/pkgconf/hal_arm_pid.h
+++ b/packages/hal/arm/pid/current/include/pkgconf/hal_arm_pid.h
@@ -138,6 +138,12 @@
    }}CFG_DATA */
 #define CYGHWR_HAL_ARM_PID_GDB_BAUD     38400
 
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        12500
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_ARM_PID_H */
 /* EOF hal_arm_pid.h */
--- a/packages/hal/common/current/ChangeLog
+++ b/packages/hal/common/current/ChangeLog
@@ -1,3 +1,20 @@
+1999-05-21  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* src/hal_stub.c (__install_traps): Set exit vector to __reset.
+
+	
+1999-05-21  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/intr.c: Get RTC values from CYGBLD_HAL_PLATFORM_H.
+	Ensure there are fallback definitions.
+
+	* src/hal_stub.c (handle_exception_cleanup): Added optional call
+	of HAL_STUB_PLATFORM_STUBS_FIXUP macro.
+
+1999-05-18  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* src/hal_stub.c (hal_output_gdb_string): Added missing ;
+
 1999-05-13  Nick Garnett  <nickg@cygnus.co.uk>
 
 	The following changes were all made on a branch and imported into
--- a/packages/hal/common/current/src/hal_stub.c
+++ b/packages/hal/common/current/src/hal_stub.c
@@ -200,6 +200,17 @@ handle_exception_cleanup( void )
     HAL_GET_GDB_REGISTERS(&registers[0], _hal_registers);
     _registers = &registers[0];
 
+#ifdef HAL_STUB_PLATFORM_STUBS_FIXUP
+    // Some architectures may need to fix the PC in case of a partial
+    // or fully executed trap instruction. GDB only takes correct action
+    // when the PC is pointing to the breakpoint instruction it set.
+    // 
+    // Most architectures would leave PC pointing at the trap
+    // instruction itself though, and so do not need to do anything
+    // special.
+    HAL_STUB_PLATFORM_STUBS_FIXUP();
+#endif
+
 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
     // FIXME: (there may be a better way to do this)
     // If we hit a breakpoint set by the gdb interrupt stub, make it
@@ -239,6 +250,9 @@ void
 {
     // Set signal handling vector so we can treat 'C<signum>' as 'c'.
     __process_signal_vec = &cyg_hal_process_signal;
+    // Set exit vector to reset vector. This will allow automatic reset on
+    // some platforms.
+    __process_exit_vec = &__reset;
 
     __cleanup_vec = &handle_exception_cleanup;
     __init_vec    = &handle_exception_init;
@@ -517,7 +531,7 @@ void
 hal_output_gdb_string(target_register_t str, int string_len)
 {
     unsigned long __state;
-    HAL_DISABLE_INTERRUPTS(__state)
+    HAL_DISABLE_INTERRUPTS(__state);
     __output_gdb_string(str, string_len);
     HAL_RESTORE_INTERRUPTS(__state);
 }
--- a/packages/hal/common/current/tests/intr.c
+++ b/packages/hal/common/current/tests/intr.c
@@ -41,65 +41,18 @@
 
 #include <cyg/hal/hal_intr.h>
 
+// Include HAL/Platform specifics
+#include CYGBLD_HAL_PLATFORM_H
+
 #ifdef CYGPKG_KERNEL
 #include <pkgconf/kernel.h>             // Need to look for the RTC config.
-
-// These are redefined below.
-#undef CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION
-#undef CYGNUM_KERNEL_COUNTERS_RTC_PERIOD
-#endif
-
-// -------------------------------------------------------------------------
-
-#if defined(CYG_HAL_MN10300_STDEVAL1)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       150000
-
-#endif
-#if defined(CYG_HAL_MN10300_SIM)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       9999
-
 #endif
 
-#if defined(CYG_HAL_MIPS_JMR3904)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       15625
-
-#endif
-#if defined(CYG_HAL_MIPS_SIM)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 1000}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       999
-
-#endif
-
-#if defined(CYG_HAL_POWERPC_COGENT)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       20625
-
-#endif
-#if defined(CYGPKG_HAL_POWERPC_SIM)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       999
-
-#endif
-
-#if defined(CYG_HAL_I386_LINUX)
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       10000
-#endif
-
-#ifndef CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       9999
-
+// Fallback defaults (in case HAL didn't define these)
+#ifndef CYGNUM_HAL_RTC_NUMERATOR       
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        9999
 #endif
 
 // -------------------------------------------------------------------------
--- a/packages/hal/i386/linux/current/ChangeLog
+++ b/packages/hal/i386/linux/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_i386_linux.h: Move RTC setup here.
+
 1999-05-14  Jesper Skov  <jskov@cygnus.co.uk>
         PR 18956
 	* include/pkgconf/mlt_i386_linux_ram.mlt: 
--- a/packages/hal/i386/linux/current/include/pkgconf/hal_i386_linux.h
+++ b/packages/hal/i386/linux/current/include/pkgconf/hal_i386_linux.h
@@ -73,6 +73,12 @@
 #define CYGHWR_HAL_I386_LINUX_STARTUP       ram
 #undef  CYGSEM_HAL_I386_LINUX_REAL_TIME
 
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        10000
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_I386_LINUX_H */
 /* EOF hal_i386_linux.h */
--- a/packages/hal/mips/arch/current/ChangeLog
+++ b/packages/hal/mips/arch/current/ChangeLog
@@ -1,8 +1,41 @@
-1999-05-12  Nick Garnett  <nickg@cygnus.co.uk>
+1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
+	HAL_INTERRUPT_STACK_TOP so that stack usage macros in
+	kernel/.../stackmon.hxx can work.
+
+	* src/vectors.S (cyg_interrupt_stack_base): Define this symbol for
+	the interrupt stack and its friend for the stack top so that we
+	can publish them with nice names.
+
+1999-05-21  Nick Garnett  <nickg@cygnus.co.uk>
 
+	* src/vectors.S: 
+	Rationalized use of "at" and "noat" setting.
+	Made use of "lar" where necessary.
+	
+	* src/mips-stub.c (__install_breakpoints): Added cache flushes to
+	ensure that the just-set breakpoint is migrated to main memory and
+	will be fetched by the instruction cache.
+
+	* src/context.S:
+	Rationalized use of "at" and "noat" setting.
+
+	* include/arch.inc:
+	Added initial value for the config0 register and added code to set
+	it to hal_cpu_init.
+	Added default "lar" macro.
+
+1999-05-16  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/hal_intr.h (HAL_INTERRUPT_STACK_CALL_PENDING_DSRS): 
+	Add macro for new DSR handling mechanism (was override of a
+	"weak" symbol in kernel).	
+
+1999-05-13  Nick Garnett  <nickg@cygnus.co.uk>
 	The following have been merged from a branch:
 	
-	(1999-05-11  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-05-11  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* include/hal_arch.h: 
 	* include/hal_intr.h: 
@@ -16,7 +49,7 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 	Removed or disabled some development/debug code.
 	Same imp->var changes as above.
 	
-	(1999-05-06  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-05-06  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/vectors.S: Added call to hal_cpu_except_enable in
 	__default_exception_vsr to re-enable nested exceptions.
@@ -31,7 +64,7 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 	necessary if we are to allow nested exceptions (like breakpoints
 	in exception handlers).
 
-	(1999-04-29  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-04-29  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/vectors.S: Reenable interrupts while processing exceptions.
 	Several temporary kludges to permit us to test ROM code from RAM
@@ -47,17 +80,17 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 	operations to 0x80000000, zero caused MMU exceptions.
 	Fixed looping bugs in all macros that use them.
 
-	(1999-04-28  Gary Thomas  <gthomas@cygnus.co.uk>)
+    1999-04-28  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	[v1_2_2_beta branch]
 	* src/vectors.S: Add dummy "__gccmain()"
 
-	(1999-04-27  Gary Thomas  <gthomas@cygnus.co.uk>)
+    1999-04-27  Gary Thomas  <gthomas@cygnus.co.uk>
 
 	* include/hal_arch.h: Make minimum stack sizes more realistic.
 	Also fix size of interrupt stack frame when FPU present.
 
-	(1999-04-23  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-04-23  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/vectors.S: Added support for floating point register save
 	and restore. Fixed hal_interrupt_stack_call_pending_DSRs to use
@@ -78,7 +111,7 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 	and restore. Moved assembler version of saved state layout here
 	from mips.inc.
 
-	(1999-04-22  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-04-22  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/context.S (hal_thread_load_context): Substituted explicit
 	code to reload the interrupt enable state with a macro.
@@ -97,7 +130,7 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 	Use hal_cpu_int_ensable macro in place of explicit code in
 	hal_interrupt_stack_call_pending_DSRs().
 
-	(1999-04-21  Nick Garnett  <nickg@cygnus.co.uk>)
+    1999-04-21  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* include/arch.inc: Ifdeffed definition of hal_intc_init macro to
 	allow it to be defined elsewhere. Added default versions of diag
@@ -131,7 +164,7 @@ 1999-05-12  Nick Garnett  <nickg@cygnus.
 
 	* include/arch.inc: Added some nops to eret macros.
 
-	(1999-04-13  John Dallaway  <jld@cygnus.co.uk>)
+    1999-04-13  John Dallaway  <jld@cygnus.co.uk>
 
 	* src/mips.ld: Migrate global MIPS linker script to individual
 	MIPS variant directories
--- a/packages/hal/mips/arch/current/include/arch.inc
+++ b/packages/hal/mips/arch/current/include/arch.inc
@@ -68,6 +68,15 @@
 #endif
 
 ##-----------------------------------------------------------------------------
+## Setup the initial value for the config0 register
+
+#ifndef INITIAL_CONFIG0
+
+#define	INITIAL_CONFIG0	0x00000002
+
+#endif
+
+##-----------------------------------------------------------------------------
 ## MIPS thread and interrupt saved state. This must match the layout of the
 ## HAL_SavedRegisters in hal_arch.h. Do not change this without changing the
 ## layout there, or viceversa.	
@@ -116,7 +125,22 @@
 	
 #define mips_stack_frame_size		32	// 4 (64 bit) args worth
 
-	
+##-----------------------------------------------------------------------------
+## Load Address and Relocate. This macro is used in code that may be linked
+## to execute out of RAM but is actually executed from ROM. If that is the
+## case a suitable version of this macro will have been defined elsewhere.
+## This is just a default version for use when that does not happen.
+
+#ifndef CYGPKG_HAL_MIPS_LAR_DEFINED
+
+	.macro	lar	reg,addr
+	la	\reg,\addr
+	.endm
+
+#define CYGPKG_HAL_MIPS_LAR_DEFINED
+
+#endif
+
 ##-----------------------------------------------------------------------------
 ## CPU specific macros. These provide a common assembler interface to
 ## operations that may have CPU specific implementations on different
@@ -131,7 +155,11 @@
 	nop
 	nop
 	nop
-	
+	la	v0,INITIAL_CONFIG0
+	mtc0	v0,config0
+	nop
+	nop
+	nop
 	.endm
 
 	# Enable interrupts
--- a/packages/hal/mips/arch/current/include/hal_intr.h
+++ b/packages/hal/mips/arch/current/include/hal_intr.h
@@ -236,6 +236,24 @@ typedef cyg_uint32 CYG_INTERRUPT_STATE;
 }
 
 //--------------------------------------------------------------------------
+// Routine to execute DSRs using separate interrupt stack
+
+#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+externC void hal_interrupt_stack_call_pending_DSRs(void);
+#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
+    hal_interrupt_stack_call_pending_DSRs()
+
+// these are offered solely for stack usage testing
+// if they are not defined, then there is no interrupt stack.
+#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
+#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
+// use them to declare these extern however you want:
+//       extern char HAL_INTERRUPT_STACK_BASE[];
+//       extern char HAL_INTERRUPT_STACK_TOP[];
+// is recommended
+#endif
+
+//--------------------------------------------------------------------------
 // Vector translation.
 // For chained interrupts we only have a single vector though which all
 // are passed. For unchained interrupts we have a vector per interrupt.
--- a/packages/hal/mips/arch/current/src/context.S
+++ b/packages/hal/mips/arch/current/src/context.S
@@ -44,8 +44,6 @@
 
 #include <cyg/hal/arch.inc>
 
-	.set noat
-	
 #------------------------------------------------------------------------------
 # hal_thread_switch_context
 # Switch thread contexts
@@ -58,6 +56,7 @@ hal_thread_switch_context:
 	addi	sp,sp,-mipsreg_size	# space for registers
 
 	# store GPRs
+	.set	noat
 #ifndef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
 	sw	$0,(mipsreg_regs+0*mips_regsize)(sp)
 	sw	$1,(mipsreg_regs+1*mips_regsize)(sp)
@@ -93,7 +92,8 @@ hal_thread_switch_context:
 	sw	$30,(mipsreg_regs+30*mips_regsize)(sp)	# == FP
 	sw	$31,(mipsreg_regs+31*mips_regsize)(sp)	# == RA
 	sw	$31,(mipsreg_pc)(sp)		# == PC (to help with debugging)
-
+	.set	at
+	
 #ifndef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
 
 	mflo	t0				# save LO and HI regs
@@ -152,6 +152,7 @@ hal_thread_load_context:
 #endif
 
 	# load GPRs
+	.set	noat
 #	lw	$0,(mipsreg_regs+0*mips_regsize)(sp)
 	lw	$4,(mipsreg_regs+4*mips_regsize)(sp)	# A0, must load for thread startup
 #ifndef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
@@ -186,7 +187,8 @@ hal_thread_load_context:
 #	lw	$29,(mipsreg_regs+29*mips_regsize)(sp)	# == SP
 	lw	$30,(mipsreg_regs+30*mips_regsize)(sp)	# == FP
 	lw	$31,(mipsreg_regs+31*mips_regsize)(sp)	# == RA
-
+	.set	at
+	
 	lw	a2,mipsreg_sr(sp)		# A2 = saved SR
 	lw	sp,(mipsreg_regs+29*mips_regsize)(sp)	# SP = saved SP
 
--- a/packages/hal/mips/arch/current/src/mips-stub.c
+++ b/packages/hal/mips/arch/current/src/mips-stub.c
@@ -260,6 +260,12 @@ void __install_breakpoints ()
       *instrBuffer.targetAddr = __break_opcode ();
 //diag_printf("ta %08x si %08x *ta %08x\n",
 //            instrBuffer.targetAddr,instrBuffer.savedInstr,*instrBuffer.targetAddr);
+
+      /* Ensure that the planted breakpoint makes it out to memory and
+         is subsequently loaded into the instruction cache.
+      */
+      __data_cache (CACHE_FLUSH) ;
+      __instruction_cache (CACHE_FLUSH) ;
     }
 }
 
--- a/packages/hal/mips/arch/current/src/vectors.S
+++ b/packages/hal/mips/arch/current/src/vectors.S
@@ -57,16 +57,17 @@
 ## Hardware supplied vectors
 	
 	.set	noreorder
-	.set	noat
  
 	.section ".reset_vector","ax"
 
 	# Reset vector at 0xBFC00000
 	
 FUNC_START(reset_vector)
-	la	v0,_start		# jump to start
+
+	lar	v0,_start		# jump to start
 	jr	v0
 	nop				# (delay slot)
+
 FUNC_END(reset_vector)
 	
 	.section ".debug_vector","ax"
@@ -108,20 +109,19 @@ FUNC_END(utlb_vector)
 
 ##-----------------------------------------------------------------------------
 ## Startup code
-	
+
 	.text
 	
 FUNC_START(_start)
 
 	# Initialize hardware
-
 	hal_cpu_init
+	hal_diag_init
 	hal_mmu_init
 	hal_fpu_init
 	hal_memc_init
 	hal_intc_init
 	hal_cache_init
-	hal_diag_init
 	hal_timer_init
 		
 	# Load Global Pointer register.
@@ -141,14 +141,14 @@ FUNC_START(_start)
 	nop
 
 #endif
-		
+
 	# Zero BSS
 
 	.extern hal_zero_bss
 	jal	hal_zero_bss
 	nop
 
-	# Cal variant and platform HAL
+	# Call variant and platform HAL
 	# initialization routines.
 
 	.extern	hal_variant_init
@@ -158,13 +158,13 @@ FUNC_START(_start)
 	.extern	hal_platform_init
 	jal	hal_platform_init
 	nop
-	
+
 	# Call constructors
 	.extern cyg_hal_invoke_constructors
 	jal     cyg_hal_invoke_constructors
 	nop
 
-#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && !defined(CYG_HAL_STARTUP_STUBS)
         .extern initialize_stub
         jal     initialize_stub
         nop
@@ -176,7 +176,7 @@ FUNC_START(_start)
 	jal	cyg_start
 	nop
 
-9:	j	9b		# Loop if we return
+9:	b	9b		# Loop if we return
 	nop			# (delay slot)
 	
 FUNC_END(_start	)
@@ -207,8 +207,8 @@ FUNC_START(__default_exception_vsr)
 	andi	k0,k0,0x7F		# isolate exception code	
 	sw	k0,mipsreg_vector(sp)	# store vector
 
+	# store GPRs
 	.set	noat
-	# store GPRs
 	sw	$0,(mipsreg_regs+0*4)(sp)
 	sw	$1,(mipsreg_regs+1*4)(sp)
 	sw	$2,(mipsreg_regs+2*4)(sp)
@@ -241,7 +241,8 @@ FUNC_START(__default_exception_vsr)
 #	sw	$29,(mipsreg_regs+29*4)(sp)	# == SP
 	sw	$30,(mipsreg_regs+30*4)(sp)	# == FP
 	sw	$31,(mipsreg_regs+31*4)(sp)	# == RA
-
+	.set	at
+	
 	mfhi	a0
 	mflo	a1
 	sw	a0,mipsreg_hi(sp)
@@ -316,6 +317,7 @@ FUNC_START(__default_interrupt_vsr)
 	sw	k0,mipsreg_vector(sp)	# store vector
 
 	# store GPRs
+	.set	noat
 	sw	$0,(mipsreg_regs+0*4)(sp)
 	sw	$1,(mipsreg_regs+1*4)(sp)
 	sw	$2,(mipsreg_regs+2*4)(sp)
@@ -348,7 +350,8 @@ FUNC_START(__default_interrupt_vsr)
 #	sw	$29,(mipsreg_regs+29*4)(sp)	# == SP
 	sw	$30,(mipsreg_regs+30*4)(sp)	# == FP
 	sw	$31,(mipsreg_regs+31*4)(sp)	# == RA
-
+	.set	at
+	
 	mfhi	a0
 	mflo	a1
 	sw	a0,mipsreg_hi(sp)
@@ -509,7 +512,8 @@ restore_state:
 	mthi	t1
 	mtlo	t2
 
-		# load GPRs
+	# load GPRs
+	.set	noat
 #	lw	$0,(mipsreg_regs+0*4)(sp)
 	lw	$1,(mipsreg_regs+1*4)(sp)
 	lw	$2,(mipsreg_regs+2*4)(sp)
@@ -542,7 +546,8 @@ restore_state:
 #	lw	$29,(mipsreg_regs+29*4)(sp)	# == SP
 	lw	$30,(mipsreg_regs+30*4)(sp)	# == FP
 	lw	$31,(mipsreg_regs+31*4)(sp)	# == RA
-
+	.set	at
+	
 	lw	k0,mipsreg_pc(sp)		# K0 = return PC
 	lw	k1,mipsreg_sr(sp)		# K1 = saved SR
 	lw	sp,(mipsreg_regs+29*4)(sp)	# load SP
@@ -605,11 +610,15 @@ FUNC_END(__gccmain)
 	.bss
 
 	.balign 16
+	.global cyg_interrupt_stack_base
+cyg_interrupt_stack_base:
 __interrupt_stack_base:
 	.rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
 	.byte 0
 	.endr
 	.balign 16
+	.global cyg_interrupt_stack
+cyg_interrupt_stack:
 __interrupt_stack:
 
 	.long	0,0,0,0,0,0,0,0	
@@ -676,7 +685,7 @@ hal_interrupt_objects:
 	.endr
 
 #endif	
-	
+
 ##-----------------------------------------------------------------------------
 ## end of vectors.S
 
--- a/packages/hal/mips/jmr3904/current/ChangeLog
+++ b/packages/hal/mips/jmr3904/current/ChangeLog
@@ -1,3 +1,11 @@
+1999-05-21  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/hal_diag.c: Delete - this has been moved to hal/mips/tx39
+
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_mips_tx39_jmr3904.h: Move RTC setup here.
+
 1999-05-14  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/platform.S: Moved ISR tables out to variant directory.
--- a/packages/hal/mips/jmr3904/current/include/pkgconf/hal_mips_tx39_jmr3904.h
+++ b/packages/hal/mips/jmr3904/current/include/pkgconf/hal_mips_tx39_jmr3904.h
@@ -103,6 +103,20 @@
 
 // #define CYGHWR_HAL_MIPS_TX39_JMR3904_ENABLE_TOE
 
+#include <pkgconf/hal_mips.h>  // Make sure clock frequency is defined
+
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#if (CYGHWR_HAL_MIPS_CPU_FREQ == 50)
+# define CYGNUM_HAL_RTC_PERIOD       15360
+#elif (CYGHWR_HAL_MIPS_CPU_FREQ == 66)
+# define CYGNUM_HAL_RTC_PERIOD       20736
+#else
+#error Unsupported clock frequency
+#endif
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_TX39_JMR3904_H */
 /* EOF hal_tx39_jmr3904.h */
--- a/packages/hal/mips/sim/current/ChangeLog
+++ b/packages/hal/mips/sim/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_mips_sim.h: Move RTC setup here.
+
 1999-05-14  Nick Garnett  <nickg@cygnus.co.uk>
 
 	* src/plf_misc.c:
--- a/packages/hal/mips/sim/current/include/pkgconf/hal_mips_sim.h
+++ b/packages/hal/mips/sim/current/include/pkgconf/hal_mips_sim.h
@@ -63,5 +63,12 @@
    }}CFG_DATA */
 
 /* -------------------------------------------------------------------*/
+
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        999
+
 #endif  /* CYGONCE_PKGCONF_HAL_MIPS_SIM_H */
 /* EOF hal_mips_sim.h */
--- a/packages/hal/mn10300/arch/current/ChangeLog
+++ b/packages/hal/mn10300/arch/current/ChangeLog
@@ -1,3 +1,13 @@
+1999-05-21  Hugo Tyson  <hmt@masala.cygnus.co.uk>
+
+	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
+	HAL_INTERRUPT_STACK_TOP so that stack usage macros in
+	kernel/.../stackmon.hxx can work.
+
+	* src/vectors.S (cyg_interrupt_stack_base): Define this symbol for
+	the interrupt stack and its friend for the stack top so that we
+	can publish them with nice names.
+
 1999-05-13  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_arch.h (HAL_THREAD_INIT_CONTEXT): Align stack
--- a/packages/hal/mn10300/arch/current/include/hal_intr.h
+++ b/packages/hal/mn10300/arch/current/include/hal_intr.h
@@ -486,6 +486,19 @@ externC volatile cyg_uint16     mn10300_
 typedef cyg_uint32 CYG_INTERRUPT_STATE;
 
 //--------------------------------------------------------------------------
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
+// these are offered solely for stack usage testing
+// if they are not defined, then there is no interrupt stack.
+#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
+#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
+// use them to declare these extern however you want:
+//       extern char HAL_INTERRUPT_STACK_BASE[];
+//       extern char HAL_INTERRUPT_STACK_TOP[];
+// is recommended
+#endif
+
+//--------------------------------------------------------------------------
 // Interrupt control macros
 
 #define HAL_DISABLE_INTERRUPTS(_old_)   \
--- a/packages/hal/mn10300/arch/current/src/vectors.S
+++ b/packages/hal/mn10300/arch/current/src/vectors.S
@@ -751,11 +751,15 @@ 1:
 	.section ".bss"
 
 	.balign 16
+	.global _cyg_interrupt_stack_base
+_cyg_interrupt_stack_base:
 __interrupt_stack_base:
 	.rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
 	.byte 0
 	.endr
 	.balign 16
+	.global _cyg_interrupt_stack
+_cyg_interrupt_stack:
 __interrupt_stack:
 	
 	.long	0,0,0,0,0,0,0,0	
--- a/packages/hal/mn10300/sim/current/ChangeLog
+++ b/packages/hal/mn10300/sim/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_mn10300_sim.h: Move RTC setup here.
+
 1999-04-08  John Dallaway  <jld@cygnus.co.uk>
 
 	* include/pkgconf/*.ldi: Revised SECTION_* macro arguments to
--- a/packages/hal/mn10300/sim/current/include/pkgconf/hal_mn10300_sim.h
+++ b/packages/hal/mn10300/sim/current/include/pkgconf/hal_mn10300_sim.h
@@ -61,5 +61,13 @@
    }}CFG_DATA */
 
 /* -------------------------------------------------------------------*/
+
+
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        9999
+
 #endif  /* CYGONCE_PKGCONF_HAL_MN10300_SIM_H */
 /* EOF hal_mn10300_sim.h */
--- a/packages/hal/mn10300/stdeval1/current/ChangeLog
+++ b/packages/hal/mn10300/stdeval1/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_mn10300_stdeval1.h: Move RTC setup here.
+
 1999-04-08  John Dallaway  <jld@cygnus.co.uk>
 
 	* include/pkgconf/*.ldi: Revised SECTION_* macro arguments to
--- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/hal_mn10300_stdeval1.h
+++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/hal_mn10300_stdeval1.h
@@ -79,6 +79,13 @@
    }}CFG_DATA */
 #define CYGHWR_HAL_MN10300_STDEVAL1_STARTUP     ram
 
+// Real-time clock/counter specifics
+
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        150000
+
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_MN10300_STDEVAL1_H */
 /* EOF hal_mn10300_stdeval1.h */
--- a/packages/hal/powerpc/arch/current/ChangeLog
+++ b/packages/hal/powerpc/arch/current/ChangeLog
@@ -1,3 +1,13 @@
+1999-05-21  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* include/hal_intr.h: Define HAL_INTERRUPT_STACK_BASE and
+	HAL_INTERRUPT_STACK_TOP so that stack usage macros in
+	kernel/.../stackmon.hxx can work.
+
+	* src/vectors.S (cyg_interrupt_stack_base): Define this symbol for
+	the interrupt stack and its friend for the stack top so that we
+	can publish them with nice names.
+
 1999-05-13  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_arch.h (HAL_THREAD_INIT_CONTEXT): Align stack
--- a/packages/hal/powerpc/arch/current/include/hal_intr.h
+++ b/packages/hal/powerpc/arch/current/include/hal_intr.h
@@ -324,6 +324,21 @@ typedef cyg_uint32 CYG_INTERRUPT_STATE;
 #endif
 
 //--------------------------------------------------------------------------
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
+// Macro/routine to call DSRs on interrupt stack?
+
+// these are offered solely for stack usage testing
+// if they are not defined, then there is no interrupt stack.
+#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
+#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
+// use them to declare these extern however you want:
+//       extern char HAL_INTERRUPT_STACK_BASE[];
+//       extern char HAL_INTERRUPT_STACK_TOP[];
+// is recommended
+#endif
+
+//--------------------------------------------------------------------------
 // Interrupt and VSR attachment macros
 
 #define HAL_INTERRUPT_IN_USE( _vector_, _state_)                          \
--- a/packages/hal/powerpc/arch/current/src/vectors.S
+++ b/packages/hal/powerpc/arch/current/src/vectors.S
@@ -910,11 +910,15 @@ hal_interrupt_objects:
         .section ".bss"
 
 	.balign 16
+	.global cyg_interrupt_stack_base
+cyg_interrupt_stack_base:
 __interrupt_stack_base:
 	.rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
 	.byte 0
 	.endr
 	.balign 16
+	.global cyg_interrupt_stack
+cyg_interrupt_stack:
 __interrupt_stack:
         
         .long   0,0,0,0,0,0,0,0 
--- a/packages/hal/powerpc/cogent/current/ChangeLog
+++ b/packages/hal/powerpc/cogent/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_powerpc_cogent.h: Move RTC setup here.
+
 1999-04-08  John Dallaway  <jld@cygnus.co.uk>
 
 	* include/pkgconf/*.ldi: Revised SECTION_* macro arguments to
--- a/packages/hal/powerpc/cogent/current/include/pkgconf/hal_powerpc_cogent.h
+++ b/packages/hal/powerpc/cogent/current/include/pkgconf/hal_powerpc_cogent.h
@@ -110,6 +110,13 @@
 #define CYGHWR_HAL_POWERPC_COGENT_GDB_PORT      1
 #define CYGHWR_HAL_POWERPC_COGENT_DIAG_PORT     1
 
+// Real-time clock/counter specifics
+
+// Period is busclock/16/100.
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        20833
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_POWERPC_COGENT_H */
 /* EOF hal_powerpc_cogent.h */
--- a/packages/hal/powerpc/fads/current/ChangeLog
+++ b/packages/hal/powerpc/fads/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_powerpc_fads.h: Move RTC setup here.
+
 1999-04-08  John Dallaway  <jld@cygnus.co.uk>
 
 	* include/pkgconf/*.ldi: Revised SECTION_* macro arguments to
--- a/packages/hal/powerpc/fads/current/include/pkgconf/hal_powerpc_fads.h
+++ b/packages/hal/powerpc/fads/current/include/pkgconf/hal_powerpc_fads.h
@@ -91,6 +91,13 @@
 
 #define CYGHWR_HAL_POWERPC_FADS_STARTUP       ram
 
+// Real-time clock/counter specifics
+
+// Period is busclock/16/100.
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        20833
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_POWERPC_FADS_H */
 /* EOF hal_powerpc_FADS.h */
--- a/packages/hal/powerpc/sim/current/ChangeLog
+++ b/packages/hal/powerpc/sim/current/ChangeLog
@@ -1,3 +1,7 @@
+1999-05-20  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* include/pkgconf/hal_powerpc_sim.h: Move RTC setup here.
+
 1999-04-28  Jesper Skov  <jskov@cygnus.co.uk>
 
 	* include/pkgconf/mlt_powerpc_sim_ram.ldi: 
--- a/packages/hal/powerpc/sim/current/include/pkgconf/hal_powerpc_sim.h
+++ b/packages/hal/powerpc/sim/current/include/pkgconf/hal_powerpc_sim.h
@@ -61,6 +61,13 @@
    }}CFG_DATA
 */
 
+// Real-time clock/counter specifics
+
+// Period is busclock/16/100.
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        9999
+
 /* -------------------------------------------------------------------*/
 #endif  /* CYGONCE_PKGCONF_HAL_POWERPC_SIM_H */
 /* EOF hal_powerpc_sim.h */
--- a/packages/hal/sparclite/arch/current/ChangeLog
+++ b/packages/hal/sparclite/arch/current/ChangeLog
@@ -1,3 +1,29 @@
+1999-05-20  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* include/hal_intr.h (HAL_INTERRUPT_STACK_CALL_PENDING_DSRS): 
+	Define this if CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK;
+	ie. we are running a separate interrupt stack.  Also define
+	symbols for it so that we can monitor its usage easily.
+
+	* src/vec_ivsr.S (hal_interrupt_stack_call_pending_DSRs): Add this
+	function to run DSRs on the interrupt stack (if using it).  Switch
+	over to executing on the interrupt stack when needed.
+
+	* src/vectors.S (cyg_interrupt_stack_base): Define the interrupt
+	stack either if we need it as an interrupt stack or if we need it
+	as a bootup stack (simulator); if it's there, use it as a bootup
+	stack anyway.
+
+	* src/context.S (hal_thread_load_context): Install the PSR that
+	was saved in its entirety, including the interrupt and trap enable
+	state.  This is needed for running a separate interrupt stack, but
+	harmless when not so doing.
+
+	* src/icontext.c (hal_thread_init_context): Install an initial PSR
+	which includes ET, S and PS (Enable traps, Supermode, prevSuper)
+	and a PIL (processor interrupt level) of 15 (maximum)
+	so that a context switch which preserves interrupt mode will work.
+
 1999-05-13  Hugo Tyson  <hmt@cygnus.co.uk>
 
 	* include/hal_arch.h (HAL_THREAD_INIT_CONTEXT): Align stack
--- a/packages/hal/sparclite/arch/current/include/hal_intr.h
+++ b/packages/hal/sparclite/arch/current/include/hal_intr.h
@@ -181,6 +181,25 @@
 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) _index_ = (_vector_)
 
 //---------------------------------------------------------------------------
+// Routine to execute DSRs using separate interrupt stack
+
+#ifdef  CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
+externC void hal_interrupt_stack_call_pending_DSRs(void);
+#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS() \
+    hal_interrupt_stack_call_pending_DSRs()
+
+// these are offered solely for stack usage testing
+// if they are not defined, then there is no interrupt stack.
+#define HAL_INTERRUPT_STACK_BASE cyg_interrupt_stack_base
+#define HAL_INTERRUPT_STACK_TOP  cyg_interrupt_stack
+// use them to declare these extern however you want:
+//       extern char HAL_INTERRUPT_STACK_BASE[];
+//       extern char HAL_INTERRUPT_STACK_TOP[];
+// is recommended
+#endif
+
+//---------------------------------------------------------------------------
 // Static data used by HAL
 
 // VSR table
--- a/packages/hal/sparclite/arch/current/src/context.S
+++ b/packages/hal/sparclite/arch/current/src/context.S
@@ -136,13 +136,12 @@ hal_thread_load_context:
 	! sequence itself gets interrupted and recurses too deep.
 	
 	! now select the new window with traps disabled...
-					! preserve ET, clear CWP
-	andn	%g6, __WINBITS_MAXIMAL, %g6
-	andn	%g6, 0x20, %g5		! clear ET also into %g5
 
-	! get new CWP from %g0 save place...
-	ld	[%g7 + 16 * 4], %g4	! %g7 holds the new stack pointer
-	and	%g4, __WINBITS, %g4	! preserve CWP bits
+	! get the new PSR and CWP that we will ultimately restore
+	! from the %g0 save place...
+	ld	[%g7 + 16 * 4], %g6	! %g7 holds the new stack pointer
+	andn	%g6, 0x20, %g5		! clear ET into %g5
+	and	%g6, __WINBITS, %g4	! CWP bits only in %g4
 		
 	! calculate a new WIM...
 	add	%g4, 1, %g3		! required invalid window number
@@ -150,8 +149,8 @@ hal_thread_load_context:
 	mov	1, %g2
 	sll	%g2, %g3, %g2		! converted to a mask for the WIM
 
-	! DISABLE INTERRUPTS
-	wr	%g5, %g4, %psr		! set CWP to new window, disable traps
+	! DISABLE INTERRUPTS (TRAPS)
+	wr	%g5, %psr		! set CWP to new window, disable traps
 	wr	%g2, %wim		! and WIM to new value
 	nop
 	nop
@@ -172,14 +171,15 @@ hal_thread_load_context:
 	ldd	[%sp + 12 * 4], %i4
 	ldd	[%sp + 14 * 4], %i6
 
-	! ENABLE INTERRUPTS
-	wr	%g6, %g4, %psr		! set new CWP and old ET
+	! RESTORE INTERRUPTS to saved state
+	wr	%g6, %psr		! set new CWP and old ET and PIL
 	nop
 	nop
 	nop
 	
-	! now load the rest of the context; we can be interrupted here, but
-	! that is OK, other state will be preserved in that case...
+	! now load the rest of the context; we can be interrupted here
+	! (if the saved context was a voluntary yield or threadstart)
+	! but that is OK, other state will be preserved in that case...
 
 #ifdef CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
 	ld	[%sp + 24 * 4], %o0	! must load the initial argument
--- a/packages/hal/sparclite/arch/current/src/icontext.c
+++ b/packages/hal/sparclite/arch/current/src/icontext.c
@@ -136,10 +136,10 @@ hal_thread_init_context(  CYG_WORD sparg
     // this is the argument that the entry point is called with
     regs->o[0] = thread;
 
-    // this is the initial CWP; quite arbitrary really, the WIM is set up
-    // accordingly in hal_thread_load_context().
+    // this is the initial CWP and interrupt state; CWP is quite arbitrary
+    // really, the WIM is set up accordingly in hal_thread_load_context().
 
-    regs->g[0] = 7;
+    regs->g[0] = 0x0e7; // PIL zero, ET, S, PS and CWP is 7.
 
     return (CYG_ADDRESS)sp;
 }
--- a/packages/hal/sparclite/arch/current/src/vec_ivsr.S
+++ b/packages/hal/sparclite/arch/current/src/vec_ivsr.S
@@ -51,6 +51,9 @@
 
 #ifdef CYGPKG_KERNEL
 # include <pkgconf/kernel.h>
+#else
+# undef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+# undef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
 #endif
 
 !------------------------------------------------------------------------
@@ -60,14 +63,22 @@
 #define DELAYS_AFTER_WRPSR_SAME_WINDOW
 #define DELAYS_AFTER_WRWIM
 
+! Macro to mark the stack as we descend, for debugging, because it is likely
+! that actually running the ISR won~t touch the stack, but the memory needs
+! to be there.  Normally blank.
+//#define	MARKSTACKUSED st %sp, [ %sp ]
+#define MARKSTACKUSED
+
 !------------------------------------------------------------------------
 
 	.text
 
 !---------------------------------------------------------------------------
 ! default interrupt VSR, which calls the appropriate ISR after scheduler
-! lock andinterrupt masking, then interrupt_end().  interrupt_end() must be
-! called with interrupts enabled, on the original thread stack.
+! lock and interrupt masking, then interrupt_end().  interrupt_end() must be
+! called with interrupts enabled, on the original thread stack (no separate
+! interrupt stack) or with interrupts masked, on the original stack (when
+! separate interrupt stack is supported).
 
 	.global hal_default_interrupt_vsr
 hal_default_interrupt_vsr:
@@ -147,6 +158,29 @@ 1:	! now save away the regs we must pres
 
 	sub	%sp, 24 * 4, %sp	! fresh frame including
 					! arg spill area for callees
+	MARKSTACKUSED			! kilroy was here
+
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+	! we will switch to the interrupt stack unless already running on it
+
+	.extern cyg_interrupt_stack
+	.extern cyg_interrupt_stack_base
+	set	cyg_interrupt_stack, %g1
+	set	cyg_interrupt_stack_base, %g2
+
+	cmp	%sp, %g2		! below base?
+	blu	1f			! if so, switch.
+	cmp	%sp, %g1		! below top? (DELAY SLOT)
+	blu	2f			! if so, DON~T switch.
+	nop				! (DELAY SLOT)
+1:	! switch to the interrupt stack
+	st	%sp, [ %g1 ]		! there is spare above stack
+	sub	%g1, 24 * 4, %sp	! fresh frame including
+					! arg spill area for callees
+	MARKSTACKUSED			! kilroy was here
+2:	
+	! continue as before, already in the interrupt stack.
+#endif // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
 
 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
 	! Lock the scheduler
@@ -158,7 +192,7 @@ 1:	! now save away the regs we must pres
 #endif
 
 	! HELP_GDB_WITH_BACKTRACE
-	mov	%i7, %l5		! preserve it JIC
+	mov	%i7, %l5		! preserve it in l5
 	mov	%l1, %i7		! bogus return link here
 
 	! and we must preserve the Y register (multiply/divide auxiliary)
@@ -202,6 +236,29 @@ 1:	! now save away the regs we must pres
 	! We only need to call _interrupt_end() when there is a kernel
 	! present to do any tidying up.
 
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+	! now we switch back to the user stack (if we~re at the top
+	! of the interrupt stack).
+
+	or	%l0, 0xfe0, %l7
+	wr	%l7, %psr		! Interrupts all masked, ET
+#ifdef DELAYS_AFTER_WRPSR_SAME_WINDOW
+	nop
+	nop
+	nop
+#endif
+	
+	.extern cyg_interrupt_stack
+	set	cyg_interrupt_stack - (24 * 4), %g1
+
+	cmp	%sp, %g1		! is SP less?
+	blu	1f			! if so, do not change back
+	nop
+	! switch to the thread stack
+	ld	[ %g1 + (24 * 4) ], %sp		! there is spare above stack
+1:	
+
+#else // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
 	! First restore the processor interrupt level to that interrupted
 	! (otherwise a task-switch runs at the current PIL) on the assumption
 	! that the ISR dealt with the interrupt source per se, so it is safe
@@ -213,6 +270,8 @@ 1:	! now save away the regs we must pres
 	nop
 	nop
 #endif
+#endif // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
 	! then call interrupt_end( isr_retcode, &intr_object, &regsave )
 	! to unlock the scheduler and do any rescheduling that~s needed.
 	! argument 0 (isr_retcode) is already in place in %o0
@@ -304,5 +363,61 @@ 2:	! restore the condition codes, PSR an
 	jmpl	%l1,  %g0
 	rett	%l2
 
+!----------------------------------------------------------------------------
+
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
+! This routine can only be called from a thread stack, maybe
+! with interrupts (but not traps) disabled.
+! It switches to the interrupt stack then calls back to the
+! kernel to execute DSRs.
+
+	.global hal_interrupt_stack_call_pending_DSRs
+hal_interrupt_stack_call_pending_DSRs:
+	save	%sp, -24 * 4, %sp
+
+	MARKSTACKUSED			! kilroy was here
+
+	! be atomic
+	rd	%psr, %l0
+	andn	%l0, 0x20, %l1		! clear ET to disable traps
+	wr	%l1, %psr		! into the PSR
+	nop
+	nop
+	nop
+
+	mov	%sp, %l7		! save calling stack location	
+
+	! now switch stack to the interrupt stack, plus some headroom
+	! for saving a register set if we are interrupted
+	.extern cyg_interrupt_stack
+	set	cyg_interrupt_stack - 4 * 24, %sp
+
+	MARKSTACKUSED			! kilroy was here
+
+	! and enable interrupts unconditionally to call the DSRs
+	or	%l0, 0x0e0, %l2		! set ET, S, PS
+	andn	%l2, 0xf00, %l2		! PIL to zero
+	wr	%l2, %psr		! into the PSR
+	nop
+	nop
+	nop
+		
+	.extern cyg_interrupt_call_pending_DSRs
+	call	cyg_interrupt_call_pending_DSRs
+	nop
+
+	mov	%l7, %sp		! restore calling stack
+
+	wr	%l0, %psr		! restore interrupt status
+	nop
+	nop
+	nop
+
+	ret
+	restore
+#endif // CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+
+!----------------------------------------------------------------------------
 
 ! end of vec_ivsr.S
--- a/packages/hal/sparclite/arch/current/src/vectors.S
+++ b/packages/hal/sparclite/arch/current/src/vectors.S
@@ -52,9 +52,17 @@
 #include <pkgconf/hal.h>
 
 #ifdef CYGPKG_KERNEL
-# include <pkgconf/kernel.h>	
+# include <pkgconf/kernel.h>
+#else
+# undef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+# undef CYGFUN_HAL_COMMON_KERNEL_SUPPORT
 #endif
 			
+#if defined( CYG_HAL_SPARCLITE_SIM ) || \
+    defined( CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK )
+#define BOOTUPSTACK_IS_INTERRUPTSTACK
+#endif
+	
 !------------------------------------------------------------------------
 
 #include <cyg/hal/vectors.h>
@@ -253,6 +261,7 @@ genuine_reset:				! set psr, mask interr
 #include <cyg/hal/halboot.si>
 	
 // halboot.si returns with %sp all set, in sleb versions.
+// (though we override if there is an interrupt stack)
 
 	led	0x80
 		
@@ -262,9 +271,9 @@ genuine_reset:				! set psr, mask interr
 	! saved frame thingy that refers to itself in the stack,
 	! then another which is valid and drop into main from there.
 
-#ifdef CYG_HAL_SPARCLITE_SIM
-	sethi	%hi(cyg_bootup_stack), %i6
-	or	%i6, %lo(cyg_bootup_stack), %i6
+#ifdef BOOTUPSTACK_IS_INTERRUPTSTACK
+	sethi	%hi(cyg_interrupt_stack), %i6
+	or	%i6, %lo(cyg_interrupt_stack), %i6
 #endif	
 	andn	%i6, 7, %i6		! round fp down to double alignment
 	mov	0, %i7			! null return address
@@ -367,17 +376,22 @@ hal_vsr_table:
 !---------------------------------------------------------------------------
 ! Bootup stack (only needed explicitly in sim)
 	
-#ifdef CYG_HAL_SPARCLITE_SIM
+#ifdef BOOTUPSTACK_IS_INTERRUPTSTACK
 	.section ".bss"
 
+#ifndef CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
+#define CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE 4096
+#endif
 	.balign 16
-cyg_bootup_stack_base:
-	.rept 4064
+	.global cyg_interrupt_stack_base
+cyg_interrupt_stack_base:
+	.rept CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
 	.byte 0
 	.endr
 	.balign 16
-cyg_bootup_stack:
-	.long	0,0,0,0,0,0,0,0	
+	.global cyg_interrupt_stack
+cyg_interrupt_stack:
+	.long	0,0,0,0,0,0,0,0		! here be secret state stored
 #endif
 
 ! end of vectors.S
--- a/packages/io/serial/current/ChangeLog
+++ b/packages/io/serial/current/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-18  Jesper Skov  <jskov@cygnus.co.uk>
+        PR 19926
+	* src/sparclite/sleb_sdtr.c (sleb_sdtr_rx_DSR): Only read chan if
+	there is one.
+
 1999-05-14  Jesper Skov  <jskov@cygnus.co.uk>
 
 	* tests/ser_test_protocol.inl: Removed workaround for spurious
--- a/packages/io/serial/current/src/sparclite/sleb_sdtr.c
+++ b/packages/io/serial/current/src/sparclite/sleb_sdtr.c
@@ -362,8 +362,10 @@ sleb_sdtr_rx_DSR(cyg_vector_t vector, cy
     CYG_ADDRWORD port = sdtr_chan->base;
     cyg_uint8 status, c;
     HAL_SPARC_86940_READ(SDTR_STATUS(port), status);
-    HAL_SPARC_86940_READ(SDTR_RXDATA(port), c);
-    (chan->callbacks->rcv_char)(chan, c);
+    if ((status & SDTR_STAT_RxRDY) != 0) {
+        HAL_SPARC_86940_READ(SDTR_RXDATA(port), c);
+        (chan->callbacks->rcv_char)(chan, c);
+    }
     cyg_drv_interrupt_acknowledge(sdtr_chan->rx_int_num);
     cyg_drv_interrupt_unmask(sdtr_chan->rx_int_num);
 }
--- a/packages/kernel/current/ChangeLog
+++ b/packages/kernel/current/ChangeLog
@@ -1,3 +1,55 @@
+1999-05-20  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* tests/tm_basic.cxx (run_all_tests): Added some more stack stats
+	output using stackmon.hxx; also fixed a BUG associated with the
+	definition of stacks in testaux.hxx (within tests dir) that was
+	making the main stack usage bogus.
+
+	* include/stackmon.hxx: new file, to ease printing stuff about
+	stack usage, particularly of interrupt stacks and the idle
+	thread.  It's not HAL specific, and it can apply to tests outside
+	of the kernel, which is why it's in a public include-place.
+	It just contains inline functions which define empty if there's no
+	handle on the symbols available, so should be safe enough.
+
+1999-05-18  Jesper Skov  <jskov@cygnus.co.uk>
+
+	* tests/stress_threads.c (main_program): Changed behavior of
+	cyg_thread_delete caller.
+
+1999-05-18  Hugo Tyson  <hmt@cygnus.co.uk>
+
+	* include/kapi.h (cyg_thread_delete): is now a boolean function to
+	indicate success.  Failure is when the thread needs to run in
+	order to become killed.
+
+	* src/common/kapi.cxx (cyg_thread_delete): Try killing the thread
+	if necessary before deleting; only run the destructor if it was
+	killed, and tell the caller so.
+	(cyg_thread_kill): Back to the simpler version with no priority
+	diddling; it's up to the called to determine that it _has_ died.
+
+	* src/common/thread.cxx (kill): Only perform the state-changes
+	implied by kill if the thread has not already been killed;
+	otherwise two kill()'s will remove a thread unconditionally,
+	whether it's in the middle of a wait that needs tidying up or not.
+	In other words, ensure idempotency.
+	
+1999-05-17  Hugo Tyson  <hmt@masala.cygnus.co.uk>
+
+	* src/common/kapi.cxx (cyg_thread_kill): Up the priority of the
+	killee to make it terminate *now* if we have priorities and they
+	are not unique, otherwise asserts are likely with the bitmap
+	scheduler.  Likewise in thread delete.  Condition out the bodies
+	of the priority ops if the scheduler does not support priorities.
+
+1999-05-16  Gary Thomas  <gthomas@cygnus.co.uk>
+
+	* src/intr/intr.cxx (call_pending_DSRs): 
+	* include/intr.hxx: Change mechanism for defining HAL function
+	to run DSRs.  This was a "weak" symbol with override, but is now
+	a macro in <cyg/hal/hal_intr.h>.
+
 1999-05-13  Nick Garnett  <nickg@cygnus.co.uk>
 
 	The following changes were all made in a branch and are now being
--- a/packages/kernel/current/include/intr.hxx
+++ b/packages/kernel/current/include/intr.hxx
@@ -81,6 +81,11 @@ class Cyg_Interrupt;
 
 #include <cyg/hal/hal_intr.h>
 
+#ifndef HAL_INTERRUPT_STACK_CALL_PENDING_DSRS
+#define HAL_INTERRUPT_STACK_CALL_PENDING_DSRS()    \
+      Cyg_Interrupt::call_pending_DSRs_inner()
+#endif
+
 externC void interrupt_end(
     cyg_uint32          isr_ret,
     Cyg_Interrupt       *intr,
--- a/packages/kernel/current/include/kapi.h
+++ b/packages/kernel/current/include/kapi.h
@@ -144,7 +144,8 @@ void cyg_thread_create(
     
 void cyg_thread_exit(void);
 
-void cyg_thread_delete(cyg_handle_t thread);
+/* It may be necessary to arrange for the victim to run for it to disappear */
+cyg_bool_t cyg_thread_delete(cyg_handle_t thread); /* false if NOT deleted */
 
 void cyg_thread_suspend(cyg_handle_t thread);
 
--- a/packages/kernel/current/include/pkgconf/kernel.h
+++ b/packages/kernel/current/include/pkgconf/kernel.h
@@ -1119,67 +1119,20 @@
 
 #else /* CYGPKG_KERNEL_COUNTERS_CLOCK_OVERRIDE */
 
-#if defined(CYG_HAL_MN10300_STDEVAL1)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       150000
-
-#endif
-#if defined(CYG_HAL_MN10300_SIM)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       9999
+// Include HAL/Platform specifics
+#include CYGBLD_HAL_PLATFORM_H
 
-#endif
-
-#if defined(CYG_HAL_MIPS_TX39_JMR3904)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#if (CYGHWR_HAL_MIPS_CPU_FREQ == 50)
-# define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       15360
-#elif (CYGHWR_HAL_MIPS_CPU_FREQ == 66)
-# define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       20736
-#else
-#error Unsupported clock frequency
-#endif
+// Fallback defaults (in case HAL didn't define these)
+#ifndef CYGNUM_HAL_RTC_NUMERATOR       
+#define CYGNUM_HAL_RTC_NUMERATOR     1000000000
+#define CYGNUM_HAL_RTC_DENOMINATOR   100
+#define CYGNUM_HAL_RTC_PERIOD        9999
 #endif
 
-#if defined(CYG_HAL_MIPS_SIM)
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       999
-
-#endif
-
-
-#if defined(CYG_HAL_POWERPC_MPC860)
-
-// Period is busclock/16/100.
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       20833
-
-#endif
-
-#if defined(CYG_HAL_ARM_PID)
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       12500
-#endif
-#if defined(CYG_HAL_ARM_AEB)
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       (240000/16)
-#endif
-
-#if defined(CYG_HAL_I386_LINUX)
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       10000
-#endif
-
-#ifndef CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION
-
-#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   {1000000000, 100}
-#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       9999
-
-#endif
+#define CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION   \
+   {CYGNUM_HAL_RTC_NUMERATOR, CYGNUM_HAL_RTC_DENOMINATOR}
+#define CYGNUM_KERNEL_COUNTERS_RTC_PERIOD       \
+   CYGNUM_HAL_RTC_PERIOD
 
 #endif /* CYGPKG_KERNEL_COUNTERS_CLOCK_OVERRIDE */
 
new file mode 100644
--- /dev/null
+++ b/packages/kernel/current/include/stackmon.hxx
@@ -0,0 +1,155 @@
+#ifndef CYGONCE_KERNEL_TESTS_STACKMON_H
+#define CYGONCE_KERNEL_TESTS_STACKMON_H
+
+/*=================================================================
+//
+//        stackmon.h
+//
+//        Auxiliary test header file
+//
+//==========================================================================
+//####COPYRIGHTBEGIN####
+//
+// -------------------------------------------
+// The contents of this file are subject to the Cygnus eCos Public License
+// Version 1.0 (the "License"); you may not use this file except in
+// compliance with the License.  You may obtain a copy of the License at
+// http://sourceware.cygnus.com/ecos
+// 
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the
+// License for the specific language governing rights and limitations under
+// the License.
+// 
+// The Original Code is eCos - Embedded Cygnus Operating System, released
+// September 30, 1998.
+// 
+// The Initial Developer of the Original Code is Cygnus.  Portions created
+// by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions.  All Rights Reserved.
+// -------------------------------------------
+//
+//####COPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     hmt
+// Contributors:  hmt
+// Date:          1999-05-20
+// Description:
+//     Defines some convenience functions for stack use output.
+//
+//####DESCRIPTIONEND####
+*/
+
+#include <pkgconf/system.h>
+#include <pkgconf/hal.h>
+#include <cyg/hal/hal_arch.h>
+#include <cyg/hal/hal_intr.h>
+#ifdef CYGPKG_KERNEL
+#include <pkgconf/kernel.h>
+#include <cyg/kernel/sched.hxx>
+#include <cyg/kernel/thread.hxx>
+#include <cyg/kernel/thread.inl>
+#endif
+
+#ifndef STACKMON_PRINTF
+externC void diag_printf(const char *, ...);
+#define STACKMON_PRINTF diag_printf
+#endif
+
+// ------------------------------------------------------------------------
+// Utility function for actually counting a stack
+
+inline void cyg_test_size_a_stack( char *comment, char *format,
+                                   char *base, char *top )
+{
+    register char *p;
+    for ( p = base; p < top; p++ )
+        if ( *p )
+            break;
+    STACKMON_PRINTF( format, comment, top - p, top - base );
+}
+
+// ------------------------------------------------------------------------
+
+inline void cyg_test_dump_stack_stats( char *comment,
+                                       char *base, char *top )
+{
+    cyg_test_size_a_stack( comment, "%31s : stack used %5d size %5d\n",
+                           base, top );
+}
+
+// ------------------------------------------------------------------------
+
+inline void cyg_test_dump_thread_stack_stats( char *comment,
+                                              Cyg_Thread *p )
+{
+    char *base, *top;
+    base = (char *)p->get_stack_base();
+    top =   base + p->get_stack_size();
+    cyg_test_dump_stack_stats( comment, base, top );
+}
+
+// ------------------------------------------------------------------------
+// Print out size of idle thread stack usage since start-of-time.  Only
+// meaningful if there is a scheduler.
+
+inline void cyg_test_dump_idlethread_stack_stats( char *comment )
+{
+#ifdef CYGPKG_KERNEL
+    extern Cyg_Thread idle_thread;
+    // idle thread is not really a plain CygThread; danger.
+    char *ibase  = (char *)idle_thread.get_stack_base();
+    char *istack = ibase + idle_thread.get_stack_size();
+    cyg_test_size_a_stack( comment,
+              "%20s : Idlethread stack used %5d size %5d\n",
+              ibase, istack );
+#endif
+}
+
+// ------------------------------------------------------------------------
+// Print out size of interrupt stack usage since start-of-time or since it
+// was last cleared.  NB on some architectures and configurations, the
+// interrupt stack is the same as the bootup stack, so clear it in the
+// first first thread to execute.  Clearing it before scheduler start would
+// be fatal!
+
+inline void cyg_test_dump_interrupt_stack_stats( char *comment )
+{
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+#ifdef HAL_INTERRUPT_STACK_BASE
+#ifdef HAL_INTERRUPT_STACK_TOP
+    extern char HAL_INTERRUPT_STACK_BASE[];
+    extern char HAL_INTERRUPT_STACK_TOP[];
+    cyg_test_size_a_stack( comment,
+              "%20s :  Interrupt stack used %5d size %5d\n",
+              HAL_INTERRUPT_STACK_BASE, HAL_INTERRUPT_STACK_TOP );
+#endif
+#endif
+#endif
+}
+
+// Clear interrupt stack to reset stats - only after sched has started.
+inline void cyg_test_clear_interrupt_stack( void )
+{
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+#ifdef HAL_INTERRUPT_STACK_BASE
+#ifdef HAL_INTERRUPT_STACK_TOP
+    cyg_uint32  old_intr;
+    extern char HAL_INTERRUPT_STACK_BASE[];
+    extern char HAL_INTERRUPT_STACK_TOP[];
+    register char *p;
+    HAL_DISABLE_INTERRUPTS(old_intr);
+    for ( p = HAL_INTERRUPT_STACK_BASE; p < HAL_INTERRUPT_STACK_TOP; p++ )
+        *p = 0;                         // zero it for checking later
+    HAL_RESTORE_INTERRUPTS(old_intr);
+#endif
+#endif
+#endif
+}
+
+// ------------------------------------------------------------------------
+
+#endif // ifndef CYGONCE_KERNEL_TESTS_STACKMON_H
+
+// EOF stackmon.h
--- a/packages/kernel/current/src/common/kapi.cxx
+++ b/packages/kernel/current/src/common/kapi.cxx
@@ -151,12 +151,15 @@ externC void cyg_thread_exit()
     Cyg_Thread::exit();
 }
 
-externC void cyg_thread_delete( cyg_handle_t thread )
+externC cyg_bool_t cyg_thread_delete( cyg_handle_t thread )
 {
     Cyg_Thread *th = (Cyg_Thread *)thread;
     if( th->get_state() != Cyg_Thread::EXITED )
-        th->kill();
-    th->~Cyg_Thread();    
+        th->kill(); // encourage it to terminate
+    if( th->get_state() != Cyg_Thread::EXITED )
+        return false; // it didn't run yet, leave it up to the app to fix
+    th->~Cyg_Thread();
+    return true;
 }
 
 externC void cyg_thread_suspend(cyg_handle_t thread)
@@ -179,7 +182,7 @@ externC void cyg_thread_resume(cyg_handl
 
 externC void cyg_thread_kill( cyg_handle_t thread)
 {
-    ((Cyg_Thread *)thread)->kill();    
+    ((Cyg_Thread *)thread)->kill();
 }
 
 externC void cyg_thread_release( cyg_handle_t thread)
@@ -201,12 +204,18 @@ externC cyg_handle_t cyg_thread_self()
 externC void cyg_thread_set_priority(
     cyg_handle_t thread, cyg_priority_t priority )
 {
+#ifdef CYGIMP_THREAD_PRIORITY
     ((Cyg_Thread *)thread)->set_priority(priority);
+#endif
 }
 
 externC cyg_priority_t cyg_thread_get_priority(cyg_handle_t thread)
 {
+#ifdef CYGIMP_THREAD_PRIORITY
     return ((Cyg_Thread *)thread)->get_priority();
+#else
+    return 0;
+#endif
 }
 
 /* Deadline scheduling control (optional) */
--- a/packages/kernel/current/src/common/thread.cxx
+++ b/packages/kernel/current/src/common/thread.cxx
@@ -759,8 +759,8 @@ Cyg_Thread::kill()
                                         // does not persist.
 #endif
 
-    switch( sleep_reason )
-    {
+    if ( EXIT != wake_reason ) switch( sleep_reason ) {
+        // Only do any of this if the thread is not in pending death already:
 
     case NONE:
         // The thread is not sleeping for any reason, it must be
--- a/packages/kernel/current/src/intr/intr.cxx
+++ b/packages/kernel/current/src/intr/intr.cxx
@@ -183,16 +183,16 @@ cyg_interrupt_call_pending_DSRs(void)
     Cyg_Interrupt::call_pending_DSRs_inner();
 }
 
-// This function will be provided by HALs that fully implement
-// interrupt stack functionality
-externC void 
-hal_interrupt_stack_call_pending_DSRs(void)
-  __attribute__ ((weak, alias("cyg_interrupt_call_pending_DSRs")));
+//
+// Use HAL supported function to run through the DSRs, but executing using
+// the separate interrupt stack if available.  This function calls back
+// into this module via 'cyg_interrupt_call_pending_DSRs' above, to keep
+// the whole process as general as possible.
 
 void
 Cyg_Interrupt::call_pending_DSRs(void)
 {
-    hal_interrupt_stack_call_pending_DSRs();
+    HAL_INTERRUPT_STACK_CALL_PENDING_DSRS();
 }
 
 
--- a/packages/kernel/current/tests/stress_threads.c
+++ b/packages/kernel/current/tests/stress_threads.c
@@ -298,12 +298,14 @@ void main_program(cyg_addrword_t data)
                            "Handler not in use!");
                 handler_thread_in_use[handler_id]--;
                 priority_in_use[handler_pri]--;
-                // Finally delete the handler thread.
-                {
-                    // workaround for PRs 20054-20058/20065
-                    cyg_thread_kill(handlerH[handler_id]);
+
+                // Finally delete the handler thread. This must be done in a
+                // loop, waiting for the call to return true. If it returns
+                // false, go to sleep for a bit, so the killed thread gets a
+                // chance to run and complete its business.
+                while (!cyg_thread_delete(handlerH[handler_id])) {
+                    cyg_thread_delay(2);
                 }
-                cyg_thread_delete(handlerH[handler_id]);
             } cyg_mutex_unlock(&handler_slot_lock);
         }
 
@@ -417,10 +419,8 @@ void handler_program(cyg_addrword_t data
       } while (!freed);
   }
 
-  // Then wait for the main_program to kill us.
-  for (;;) {
-      cyg_thread_delay(100);
-  }
+  // Then exit.
+  cyg_thread_exit();
 }
 
 /* look for an available handler thread */
--- a/packages/kernel/current/tests/tm_basic.cxx
+++ b/packages/kernel/current/tests/tm_basic.cxx
@@ -49,6 +49,8 @@
 
 #include <cyg/infra/testcase.h>
 
+#include <cyg/kernel/stackmon.hxx>
+
 // Define this to see the statistics with the first sample datum removed.
 // This can expose the effects of caches on the speed of operations.
 #undef STATS_WITHOUT_FIRST_SAMPLE
@@ -1436,6 +1438,12 @@ run_all_tests(CYG_ADDRESS id)
 #endif
 
     disable_clock_latency_measurement();
+
+    cyg_test_dump_thread_stack_stats( "Startup, main stack", thread[0] );
+    cyg_test_dump_interrupt_stack_stats( "Startup" );
+    cyg_test_dump_idlethread_stack_stats( "Startup" );
+    cyg_test_clear_interrupt_stack();
+
     diag_printf("\neCos Kernel Timings\n");
     diag_printf("Notes: all times are in microseconds (.000001) unless otherwise stated\n");
 #ifdef STATS_WITHOUT_FIRST_SAMPLE
@@ -1529,11 +1537,16 @@ run_all_tests(CYG_ADDRESS id)
         total_stack += actual_stack;
     }
     for (j = 0;  j < STACKSIZE;  j++) {
-        if (stack[j]) break;
+        if (((char *)stack[0])[j]) break;
     }
     diag_printf("%5d   %5d   %5d  (main stack: %5d)  Thread stack used (%d total)\n", 
                 total_stack/NTEST_THREADS, min_stack, max_stack, 
                 STACKSIZE - j, STACK_SIZE);
+
+    cyg_test_dump_thread_stack_stats( "All done, main stack", thread[0] );
+    cyg_test_dump_interrupt_stack_stats( "All done" );
+    cyg_test_dump_idlethread_stack_stats( "All done" );
+
     enable_clock_latency_measurement();
 
     ticks = cyg_current_time();
--- a/packages/language/c/libm/current/ChangeLog
+++ b/packages/language/c/libm/current/ChangeLog
@@ -1,3 +1,25 @@
+1999-05-19  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak: Make below workaround be the other way around by
+	using -O1 and adding more explicit -O2 optimizations, just so we
+	don't lose very many optimizations. This is for sparclite
+
+1999-05-19  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak: Make below workaround be the other way around by
+	using -O1 and adding more explicit -O2 optimizations, just so we
+	don't lose very many optimizations. This is for ARM
+
+1999-05-18  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak: For the sparclite, prevent insn scheduling -
+	workaround for PR 19698
+
+1999-05-18  Jonathan Larmour  <jlarmour@cygnus.co.uk>
+
+	* src/PKGconf.mak: For the ARM, change from -O1 to just prevent insn
+	scheduling - workaround for PR 19698
+
 1999-04-15  John Dallaway  <jld@cygnus.co.uk>
 
 	* include/pkgconf/libm.h: Tidy display string capitalization.
--- a/packages/language/c/libm/current/src/PKGconf.mak
+++ b/packages/language/c/libm/current/src/PKGconf.mak
@@ -73,54 +73,110 @@ OTHER_CLEAN   :=
 
 ifdef CYG_HAL_ARM
 # Work-around for PR 19698
-s_atan.c-CFLAGS += -O1
-s_ceil.c-CFLAGS += -O1
-s_copysign.c-CFLAGS += -O1
-s_cos.c-CFLAGS += -O1
-s_expm1.c-CFLAGS += -O1
-s_fabs.c-CFLAGS += -O1
-s_finite.c-CFLAGS += -O1
-s_floor.c-CFLAGS += -O1
-s_frexp.c-CFLAGS += -O1
-s_isnan.c-CFLAGS += -O1
-s_ldexp.c-CFLAGS += -O1
-s_rint.c-CFLAGS += -O1
-s_scalbn.c-CFLAGS += -O1
-s_sin.c-CFLAGS += -O1
-s_tan.c-CFLAGS += -O1
-s_modf.c-CFLAGS += -O1
-s_tanh.c-CFLAGS += -O1
-s_asinh.c-CFLAGS += -O1
-s_cbrt.c-CFLAGS += -O1
-s_erf.c-CFLAGS += -O1
-s_ilogb.c-CFLAGS += -O1
-s_log1p.c-CFLAGS += -O1
-s_logb.c-CFLAGS += -O1
-s_nextafter.c-CFLAGS += -O1
-s_significand.c-CFLAGS += -O1
+s_atan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ceil.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_copysign.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_expm1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_fabs.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_finite.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_floor.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_frexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_isnan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ldexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_rint.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_scalbn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_sin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_modf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_tanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_asinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_cbrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_erf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ilogb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_log1p.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_logb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_nextafter.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_significand.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+
+e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+w_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_acos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_acosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_asin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_atan2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_atanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_cosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_exp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_hypot.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_j0.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_j1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_jn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_lgamma_r.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_log.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_log10.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_pow.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_rem_pio2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_remainder.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_sinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_sqrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+k_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+k_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+endif
 
-e_fmod.c-CFLAGS += -O1
-w_fmod.c-CFLAGS += -O1
-e_acos.c-CFLAGS += -O1
-e_acosh.c-CFLAGS += -O1
-e_asin.c-CFLAGS += -O1
-e_atan2.c-CFLAGS += -O1
-e_atanh.c-CFLAGS += -O1
-e_exp.c-CFLAGS += -O1
-e_fmod.c-CFLAGS += -O1
-e_hypot.c-CFLAGS += -O1
-e_j0.c-CFLAGS += -O1
-e_j1.c-CFLAGS += -O1
-e_jn.c-CFLAGS += -O1
-e_lgamma_r.c-CFLAGS += -O1
-e_log.c-CFLAGS += -O1
-e_log10.c-CFLAGS += -O1
-e_pow.c-CFLAGS += -O1
-e_rem_pio2.c-CFLAGS += -O1
-e_remainder.c-CFLAGS += -O1
-e_sqrt.c-CFLAGS += -O1
-k_cos.c-CFLAGS += -O1
-k_tan.c-CFLAGS += -O1
+ifdef CYG_HAL_SPARCLITE
+# Work-around for PR 19698
+s_atan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ceil.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_copysign.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_expm1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_fabs.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_finite.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_floor.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_frexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_isnan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ldexp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_rint.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_scalbn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_sin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_modf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_tanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_asinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_cbrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_erf.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_ilogb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_log1p.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_logb.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_nextafter.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+s_significand.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+
+e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+w_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_acos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_acosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_asin.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_atan2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_atanh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_cosh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_exp.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_fmod.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_hypot.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_j0.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_j1.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_jn.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_lgamma_r.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_log.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_log10.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_pow.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_rem_pio2.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_remainder.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_sinh.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+e_sqrt.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+k_cos.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
+k_tan.c-CFLAGS += -O1 -fschedule-insns -fschedule-insns2 -fexpensive-optimizations -fstrength-reduce -fdelayed-branch -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop
 endif
 
 include $(COMPONENT_REPOSITORY)/pkgconf/makrules.src
--- a/packages/packages
+++ b/packages/packages
@@ -145,6 +145,7 @@ package CYGPKG_HAL_ARM_AEB {
 }
 
 
+
 package CYGPKG_HAL_I386 {
 	alias		{ "i386 common HAL" hal_i386 i386_hal i386_arch_hal }
 	directory	hal/i386/arch
@@ -222,6 +223,7 @@ package CYGPKG_HAL_POWERPC_SIM {
 	hardware
 }
 
+
 package CYGPKG_HAL_SPARCLITE {
 	alias		{ "SPARClite common HAL" hal_sparclite sparclite_hal sparclite_arch_hal }
 	directory	hal/sparclite/arch
--- a/packages/targets
+++ b/packages/targets
@@ -178,6 +178,7 @@ target powerpc {
     }
 }
 
+
 target i386 {
     alias		{ i386 i486 i586 i86 ix86 }
     command_prefix  	i686-pc-linux-gnu