libgloss/arm/libcfunc.c: alarm [PATCH]
Shaun Jackman
sjackman@gmail.com
Wed Jul 13 20:44:00 GMT 2005
On 7/13/05, Nick Clifton <nickc@redhat.com> wrote:
> Certainly, I do not see why not. Would you like to have a go at
> creating a patch ? :-)
Sure!
Cheers,
Shaun
2005-07-13 Shaun Jackman <sjackman@gmail.com>
* libgloss/arm/libcfunc.c (abort): Call _exit instead of the swi.
(alarm): Add the weak attribute.
(pause): New function. Return ENOSYS.
* libgloss/arm/syscalls.c (_getpid): Add the weak attribute.
(_fstat): Ditto.
(_stat): Ditto.
(_link): Ditto. Return ENOSYS.
(_unlink): Call the swi instead of returning -1.
(_raise): Add the weak attribute. Return ENOSYS.
(isatty): Rename to _isatty. Call the swi instead of returning 1.
(_system): Call the swi instead of returning ENOSYS.
(_rename): Ditto.
Index: libgloss/arm/libcfunc.c
===================================================================
RCS file: /cvs/src/src/libgloss/arm/libcfunc.c,v
retrieving revision 1.1
diff -u -r1.1 libcfunc.c
--- libgloss/arm/libcfunc.c 9 Jun 2004 19:06:50 -0000 1.1
+++ libgloss/arm/libcfunc.c 13 Jul 2005 20:28:53 -0000
@@ -5,36 +5,31 @@
Note: These functions are in a seperate file so that OS providers can
overrride the system call stubs (defined in syscalls.c) without having
to provide libc funcitons as well. */
-#include "swi.h"
-
-#ifdef ARM_RDI_MONITOR
-
-static inline int
-do_AngelSWI (int reason, void * arg)
-{
- int value;
- asm volatile ("mov r0, %1; mov r1, %2; swi %a3; mov %0, r0"
- : "=r" (value) /* Outputs */
- : "r" (reason), "r" (arg), "i" (AngelSWI) /* Inputs */
- : "r0", "r1", "lr"
- /* Clobbers r0 and r1, and lr if in supervisor mode */);
- return value;
-}
-#endif /* ARM_RDI_MONITOR */
+#include "swi.h"
+#include <errno.h>
+#include <unistd.h>
-void
+void __attribute__((weak))
abort (void)
{
+ extern void _exit (int n);
#ifdef ARM_RDI_MONITOR
- do_AngelSWI (AngelSWI_Reason_ReportException,
- (void *) ADP_Stopped_RunTimeError);
+ _exit(ADP_Stopped_RunTimeError);
#else
- asm ("mov r0,#17\nswi %a0" :: "i" (SWI_Exit));
+ _exit(17);
#endif
}
-void
-alarm (void)
+unsigned __attribute__((weak))
+alarm (unsigned seconds)
+{
+ (void)seconds;
+ return 0;
+}
+
+int __attribute__((weak))
+pause (void)
{
+ return errno = ENOSYS, -1;
}
Index: libgloss/arm/syscalls.c
===================================================================
RCS file: /cvs/src/src/libgloss/arm/syscalls.c,v
retrieving revision 1.4
diff -u -r1.4 syscalls.c
--- libgloss/arm/syscalls.c 5 May 2005 23:15:53 -0000 1.4
+++ libgloss/arm/syscalls.c 13 Jul 2005 20:28:53 -0000
@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <stdio.h>
+#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
@@ -18,11 +19,11 @@
/* Forward prototypes. */
int _system _PARAMS ((const char *));
int _rename _PARAMS ((const char *, const char *));
-int isatty _PARAMS ((int));
+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 _raise _PARAMS ((int));
+int _unlink _PARAMS ((const char *));
int _link _PARAMS ((void));
int _stat _PARAMS ((const char *, struct stat *));
int _fstat _PARAMS ((int, struct stat *));
@@ -345,8 +346,6 @@
return len - x;
}
-extern int strlen (const char *);
-
int
_swiopen (const char * path,
int flags)
@@ -461,7 +460,7 @@
n = n; m = m;
}
-int
+int __attribute__((weak))
_getpid (int n)
{
return 1;
@@ -501,9 +500,7 @@
return (caddr_t) prev_heap_end;
}
-extern void memset (struct stat *, int, unsigned int);
-
-int
+int __attribute__((weak))
_fstat (int file, struct stat * st)
{
memset (st, 0, sizeof (* st));
@@ -513,7 +510,8 @@
file = file;
}
-int _stat (const char *fname, struct stat *st)
+int __attribute__((weak))
+_stat (const char *fname, struct stat *st)
{
int file;
@@ -529,22 +527,28 @@
return 0;
}
-int
+int __attribute__((weak))
_link (void)
{
- return -1;
+ return errno = ENOSYS, -1;
}
int
-_unlink (void)
+_unlink (const char *path)
{
- return -1;
+#ifdef ARM_RDI_MONITOR
+ return do_AngelSWI (AngelSWI_Reason_Remove, &path);
+#else
+ (void)path;
+ asm ("swi %a0" :: "i" (SWI_Remove));
+#endif
}
-void
-_raise (void)
+int __attribute__((weak))
+_raise (int sig)
{
- return;
+ (void)sig;
+ return errno = ENOSYS, -1;
}
int
@@ -601,24 +605,35 @@
int
-isatty (int fd)
+_isatty (int fd)
{
- return 1;
- fd = fd;
+#ifdef ARM_RDI_MONITOR
+ return do_AngelSWI (AngelSWI_Reason_IsTTY, &fd);
+#else
+ (void)fd;
+ asm ("swi %a0" :: "i" (SWI_IsTTY));
+#endif
}
int
_system (const char *s)
{
- if (s == NULL)
- return 0;
- errno = ENOSYS;
- return -1;
+#ifdef ARM_RDI_MONITOR
+ return do_AngelSWI (AngelSWI_Reason_System, &s);
+#else
+ (void)s;
+ asm ("swi %a0" :: "i" (SWI_CLI));
+#endif
}
int
_rename (const char * oldpath, const char * newpath)
{
- errno = ENOSYS;
- return -1;
+#ifdef ARM_RDI_MONITOR
+ const char *block[2] = {oldpath, newpath};
+ return do_AngelSWI (AngelSWI_Reason_Rename, block);
+#else
+ (void)oldpath; (void)newpath;
+ asm ("swi %a0" :: "i" (SWI_Rename));
+#endif
}
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: libgloss-arm-syscalls.diff
URL: <http://sourceware.org/pipermail/newlib/attachments/20050713/23239172/attachment.ksh>
More information about the Newlib
mailing list