diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2001-02-01 21:25:56 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2001-02-01 21:25:56 +0000 |
commit | b5139f598bf64bdb3212375a6ee6907dfbeacea0 (patch) | |
tree | 28bd75ebd5ea0703ad1fd2465476aa73e4ce18a1 /newlib | |
parent | 67997034e8216dba39c4eee626c9c123fcae42ed (diff) | |
download | newlib-b5139f598bf64bdb3212375a6ee6907dfbeacea0.zip newlib-b5139f598bf64bdb3212375a6ee6907dfbeacea0.tar.gz newlib-b5139f598bf64bdb3212375a6ee6907dfbeacea0.tar.bz2 |
* libc/sys/sh/sys/syscall.h (SYS_get_argc, SYS_get_argN_len,
SYS_get_argN):
* libc/sys/sh/syscalls.c (__setup_argv_for_main,
__setup_argv_and_call_main): New.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 7 | ||||
-rw-r--r-- | newlib/libc/sys/sh/sys/syscall.h | 4 | ||||
-rw-r--r-- | newlib/libc/sys/sh/syscalls.c | 28 |
3 files changed, 39 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 741fd7b..d626c26 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,10 @@ +2001-02-01 Alexandre Oliva <aoliva@redhat.com> + + * libc/sys/sh/sys/syscall.h (SYS_get_argc, SYS_get_argN_len, + SYS_get_argN): + * libc/sys/sh/syscalls.c (__setup_argv_for_main, + __setup_argv_and_call_main): New. + 2001-01-31 Jeff Johnston <jjohnstn@redhat.com> * libc/include/stdio.h (FILENAME_MAX): Changed to use __FILENAME_MAX__ diff --git a/newlib/libc/sys/sh/sys/syscall.h b/newlib/libc/sys/sh/sys/syscall.h index f141df7..fd9ee7c 100644 --- a/newlib/libc/sys/sh/sys/syscall.h +++ b/newlib/libc/sys/sh/sys/syscall.h @@ -27,5 +27,9 @@ #define SYS_pipe 42 #define SYS_execve 59 +#define SYS_argc 172 /* == 0xAC, for Argument Count :-) */ +#define SYS_argnlen 173 +#define SYS_argn 174 + #define SYS_utime 201 /* not really a system call */ #define SYS_wait 202 /* nor is this */ diff --git a/newlib/libc/sys/sh/syscalls.c b/newlib/libc/sys/sh/syscalls.c index 8380c70..f0e9242 100644 --- a/newlib/libc/sys/sh/syscalls.c +++ b/newlib/libc/sys/sh/syscalls.c @@ -191,3 +191,31 @@ _gettimeofday (struct timeval *tv, struct timezone *tz) tv->tv_sec = __trap34 (SYS_time); return 0; } + +static inline int +__setup_argv_for_main (int argc) +{ + char **argv; + int i = argc; + + argv = __builtin_alloca ((1 + argc) * sizeof (*argv)); + + argv[i] = NULL; + while (i--) { + argv[i] = __builtin_alloca (1 + __trap34 (SYS_argnlen, i)); + __trap34 (SYS_argn, i, argv[i]); + } + + return main (argc, argv); +} + +int +__setup_argv_and_call_main () +{ + int argc = __trap34 (SYS_argc); + + if (argc <= 0) + return main (argc, NULL); + else + return __setup_argv_for_main (argc); +} |