From e448b01f6b5b69ee7eefa74f0be5176d92a78aac Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 16 Aug 2005 18:05:35 +0000 Subject: [PATCH] 2005-08-16 Shaun Jackman * arm/syscalls.c (initialise_monitor_handles): Set monitor_stderr to the result of SWI_open(":tt", "a") instead of simply duplicating stdout. --- libgloss/ChangeLog | 6 ++++++ libgloss/arm/syscalls.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index f129ae49e..2fc550309 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,9 @@ +2005-08-16 Shaun Jackman + + * arm/syscalls.c (initialise_monitor_handles): Set + monitor_stderr to the result of SWI_open(":tt", "a") + instead of simply duplicating stdout. + 2005-08-10 DJ Delorie * configure.in: Add m32c support. diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index a4f24c62e..2701bb87a 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -133,6 +133,16 @@ initialise_monitor_handles (void) { int i; + /* Open the standard file descriptors by opening the special + * teletype device, ":tt", read-only to obtain a descritpor for + * standard input and write-only to obtain a descriptor for standard + * output. Finally, open ":tt" in append mode to obtain a descriptor + * for standard error. Since this is a write mode, most kernels will + * probably return the same value as for standard output, but the + * kernel can differentiate the two using the mode flag and return a + * different descriptor for standard error. + */ + #ifdef ARM_RDI_MONITOR int volatile block[3]; @@ -144,7 +154,12 @@ initialise_monitor_handles (void) block[0] = (int) ":tt"; block[2] = 3; /* length of filename */ block[1] = 4; /* mode "w" */ - monitor_stdout = monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); + monitor_stdout = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); + + block[0] = (int) ":tt"; + block[2] = 3; /* length of filename */ + block[1] = 8; /* mode "a" */ + monitor_stderr = do_AngelSWI (AngelSWI_Reason_Open, (void *) block); #else int fh; const char * name; @@ -161,7 +176,14 @@ initialise_monitor_handles (void) : "=r"(fh) : "i" (SWI_Open),"r"(name) : "r0","r1"); - monitor_stdout = monitor_stderr = fh; + monitor_stdout = fh; + + name = ":tt"; + asm ("mov r0,%2; mov r1, #8; swi %a1; mov %0, r0" + : "=r"(fh) + : "i" (SWI_Open),"r"(name) + : "r0","r1"); + monitor_stderr = fh; #endif for (i = 0; i < MAX_OPEN_FILES; i ++) @@ -171,6 +193,8 @@ initialise_monitor_handles (void) openfiles[0].pos = 0; openfiles[1].handle = monitor_stdout; openfiles[1].pos = 0; + openfiles[2].handle = monitor_stderr; + openfiles[2].pos = 0; } static int