Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2006-06-09 19:52:15 +0400
committerSandra Loosemore <sandra@codesourcery.com>2006-06-09 19:52:15 +0400
commitc4f65466b96fbfcbc51a26bc6013ee20c86f0b6d (patch)
tree04ff57cc5057f9265eb0a7841ed2c74474a852bf
parentbff849823551b6bafd5814540f74bddc2d3b5819 (diff)
Add additional ARM_RDI_MONITOR calls
-rw-r--r--ChangeLog.csl7
-rw-r--r--libgloss/arm/syscalls.c46
-rw-r--r--newlib/libc/sys/arm/syscalls.c54
3 files changed, 96 insertions, 11 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 5e038bd00..3768c4c2b 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,10 @@
+2006-06-09 Sandra Loosemore <sandra@codesourcery.com>
+
+ * newlib/libc/sys/arm/syscalls.c (_unlink, isatty, _system, _rename):
+ Make them do something useful in the ARM_RDI_MONITOR case.
+ * libgloss/arm/syscalls.c (_unlink, isatty, _system, _rename):
+ Likewise.
+
2006-06-08 Nathan Sidwell <nathan@codesourcery.com>
* libgloss/m68k/bdm-system.c (_system): Properly encode non
diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c
index a6d2f747e..827d6ee3a 100644
--- a/libgloss/arm/syscalls.c
+++ b/libgloss/arm/syscalls.c
@@ -14,6 +14,7 @@
#include <errno.h>
#include <reent.h>
#include <unistd.h>
+#include <sys/wait.h>
#include "swi.h"
/* Forward prototypes. */
@@ -560,7 +561,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));
@@ -631,11 +635,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
}
@@ -643,7 +650,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));
@@ -654,8 +682,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));
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index 3150a39b0..ebbd087e4 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -13,6 +13,7 @@
#include <errno.h>
#include <reent.h>
#include <unistd.h>
+#include <sys/wait.h>
#include "swi.h"
/* Forward prototypes. */
@@ -22,7 +23,7 @@ int isatty _PARAMS ((int));
clock_t _times _PARAMS ((struct tms *));
int _gettimeofday _PARAMS ((struct timeval *, struct timezone *));
void _raise _PARAMS ((void));
-int _unlink _PARAMS ((void));
+int _unlink _PARAMS ((const char *));
int _link _PARAMS ((void));
int _stat _PARAMS ((const char *, struct stat *));
int _fstat _PARAMS ((int, struct stat *));
@@ -504,9 +505,16 @@ _link (void)
}
int
-_unlink (void)
+_unlink (const char *path)
{
+#ifdef ARM_RDI_MONITOR
+ int block[2];
+ block[0] = path;
+ block[1] = strlen(path);
+ return wrap (do_AngelSWI (AngelSWI_Reason_Remove, block)) ? -1 : 0;
+#else
return -1;
+#endif
}
void
@@ -571,22 +579,60 @@ _times (struct tms * tp)
int
isatty (int fd)
{
- return 1;
- fd = fd;
+#ifdef ARM_RDI_MONITOR
+ int fh = remap_handle (fd);
+ return wrap (do_AngelSWI (AngelSWI_Reason_IsTTY, &fh));
+#else
+ return (fd <= 2) ? 1 : 0; /* one of stdin, stdout, stderr */
+#endif
}
int
_system (const char *s)
{
+#ifdef ARM_RDI_MONITOR
+ 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
if (s == NULL)
return 0;
errno = ENOSYS;
return -1;
+#endif
}
int
_rename (const char * oldpath, const char * newpath)
{
+#ifdef ARM_RDI_MONITOR
+ 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
errno = ENOSYS;
return -1;
+#endif
}