The synth HAL diagnostics were not as thread-safe as they are supposed to be. They also involved an unnecessary system call.
Bart 2009-07-16 Bart Veer <[email protected]> * src/synth_diag.c: add locking to the HAL diag code. Remove an unnecessary fdatasync(). Index: arch/current/src/synth_diag.c =================================================================== RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/src/synth_diag.c,v retrieving revision 1.6 diff -u -p -r1.6 synth_diag.c --- arch/current/src/synth_diag.c 29 Jan 2009 17:49:43 -0000 1.6 +++ arch/current/src/synth_diag.c 23 Aug 2009 11:27:30 -0000 @@ -61,6 +61,7 @@ #include <cyg/infra/cyg_type.h> #include <cyg/hal/hal_diag.h> #include <cyg/hal/hal_io.h> +#include <cyg/hal/hal_intr.h> #include <cyg/infra/cyg_ass.h> //----------------------------------------------------------------------------- @@ -102,10 +103,12 @@ void hal_diag_init( void ) void hal_diag_write_char(char c) { - static int diag_index = 0; + static int diag_index = 0; static unsigned char diag_buffer[128]; - + int ints_state; + CYG_ASSERT(diag_index < 128, "Diagnostic buffer overflow"); + HAL_DISABLE_INTERRUPTS(ints_state); diag_buffer[diag_index++] = (unsigned char) c; if (('\n' == c) || (128 == diag_index)) { @@ -129,9 +132,9 @@ void hal_diag_write_char(char c) } CYG_ASSERT(0 == diag_index, "All data should have been written out"); diag_index = 0; - cyg_hal_sys_fdatasync(1); } } + HAL_RESTORE_INTERRUPTS(ints_state); } // Diagnostic input. It is not clear that this is actually useful,
