diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2006-06-13 20:51:08 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2006-06-13 20:51:08 +0000 |
commit | 73c20c325dfd933c29eaea17140611d72fd48d9d (patch) | |
tree | 97ce98c1693a2c420036bafaacd84382151ae404 | |
parent | c4cac45fe99126014c922a1c5f20dfc30cc04523 (diff) | |
download | newlib-73c20c325dfd933c29eaea17140611d72fd48d9d.zip newlib-73c20c325dfd933c29eaea17140611d72fd48d9d.tar.gz newlib-73c20c325dfd933c29eaea17140611d72fd48d9d.tar.bz2 |
2006-06-13 Sandra Loosemore <sandra@codesourcery.com>
* arm/syscalls.c (_unlink, isatty, _system, _rename):
Make them do something useful in the ARM_RDI_MONITOR case.
-rw-r--r-- | libgloss/ChangeLog | 5 | ||||
-rw-r--r-- | libgloss/arm/syscalls.c | 46 |
2 files changed, 44 insertions, 7 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index f381e4c..3091f1c 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,8 @@ +2006-06-13 Sandra Loosemore <sandra@codesourcery.com> + + * arm/syscalls.c (_unlink, isatty, _system, _rename): + Make them do something useful in the ARM_RDI_MONITOR case. + 2006-06-08 Fred Fish <fnf@specifix.com> * mips/idt.ld, mips/idt32.ld, mips/idt64.ld, mips/nullmon.ld, diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index 855a374..2168b88 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -15,6 +15,7 @@ #include <reent.h> #include <signal.h> #include <unistd.h> +#include <sys/wait.h> #include "swi.h" /* Forward prototypes. */ @@ -567,7 +568,10 @@ int _unlink (const char *path) { #ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_Remove, &path); + int block[2]; + block[0] = path; + block[1] = strlen(path); + return wrap (do_AngelSWI (AngelSWI_Reason_Remove, block)) ? -1 : 0; #else (void)path; asm ("swi %a0" :: "i" (SWI_Remove)); @@ -638,11 +642,14 @@ _times (struct tms * tp) int _isatty (int fd) { + int fh = remap_handle (fd); #ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_IsTTY, &fd); + return wrap (do_AngelSWI (AngelSWI_Reason_IsTTY, &fh)); #else - (void)fd; - asm ("swi %a0" :: "i" (SWI_IsTTY)); + asm ("mov r0, %1; swi %a0" + : /* No outputs */ + : "i" (SWI_IsTTY), "r"(fh) + : "r0"); #endif } @@ -650,7 +657,28 @@ int _system (const char *s) { #ifdef ARM_RDI_MONITOR - return do_AngelSWI (AngelSWI_Reason_System, &s); + int block[2]; + int e; + + /* Hmmm. The ARM debug interface specification doesn't say whether + SYS_SYSTEM does the right thing with a null argument, or assign any + meaning to its return value. Try to do something reasonable.... */ + if (!s) + return 1; /* maybe there is a shell available? we can hope. :-P */ + block[0] = s; + block[1] = strlen (s); + e = wrap (do_AngelSWI (AngelSWI_Reason_System, block)); + if ((e >= 0) && (e < 256)) + { + /* We have to convert e, an exit status to the encoded status of + the command. To avoid hard coding the exit status, we simply + loop until we find the right position. */ + int exit_code; + + for (exit_code = e; e && WEXITSTATUS (e) != exit_code; e <<= 1) + continue; + } + return e; #else (void)s; asm ("swi %a0" :: "i" (SWI_CLI)); @@ -661,8 +689,12 @@ int _rename (const char * oldpath, const char * newpath) { #ifdef ARM_RDI_MONITOR - const char *block[2] = {oldpath, newpath}; - return do_AngelSWI (AngelSWI_Reason_Rename, block); + int block[4]; + block[0] = oldpath; + block[1] = strlen(oldpath); + block[2] = newpath; + block[3] = strlen(newpath); + return wrap (do_AngelSWI (AngelSWI_Reason_Rename, block)) ? -1 : 0; #else (void)oldpath; (void)newpath; asm ("swi %a0" :: "i" (SWI_Rename)); |