From ce4654708cc111c6eff691d1e564e3fb5b64eb17 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Mon, 18 Jul 2005 16:18:17 +0000 Subject: [PATCH] 2005-07-18 Shaun Jackman * libgloss/arm/libcfunc.c (abort): Call _exit instead of the RDI 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. --- libgloss/ChangeLog | 15 +++++++++ libgloss/arm/libcfunc.c | 21 ++++++++++--- libgloss/arm/syscalls.c | 67 ++++++++++++++++++++++++++--------------- 3 files changed, 73 insertions(+), 30 deletions(-) diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 89c1165bb..c3b708501 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,18 @@ +2005-07-18 Shaun Jackman + + * libgloss/arm/libcfunc.c (abort): Call _exit instead of the RDI 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. + 2005-07-06 Aldy Hernandez * configure.in: Add ms1 case. diff --git a/libgloss/arm/libcfunc.c b/libgloss/arm/libcfunc.c index ddc611f34..f684c2526 100644 --- a/libgloss/arm/libcfunc.c +++ b/libgloss/arm/libcfunc.c @@ -5,10 +5,12 @@ 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" +#include +#include #ifdef ARM_RDI_MONITOR - static inline int do_AngelSWI (int reason, void * arg) { @@ -22,19 +24,28 @@ do_AngelSWI (int reason, void * arg) } #endif /* ARM_RDI_MONITOR */ - void abort (void) { + extern void _exit (int n); #ifdef ARM_RDI_MONITOR do_AngelSWI (AngelSWI_Reason_ReportException, (void *) 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) +{ + errno = ENOSYS; + return -1; } diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index f0e60da8f..f178049d9 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -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 @@ _write (int file, return len - x; } -extern int strlen (const char *); - int _swiopen (const char * path, int flags) @@ -461,7 +460,7 @@ _kill (int n, int m) n = n; m = m; } -int +int __attribute__((weak)) _getpid (int n) { return 1; @@ -501,9 +500,7 @@ _sbrk (int incr) 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 @@ _fstat (int file, struct stat * st) 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,30 @@ int _stat (const char *fname, struct stat *st) return 0; } -int +int __attribute__((weak)) _link (void) { + errno = ENOSYS; return -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; + errno = ENOSYS; + return -1; } int @@ -601,24 +607,35 @@ _times (struct tms * tp) 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 }