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/libc/sys/sh | |
parent | 67997034e8216dba39c4eee626c9c123fcae42ed (diff) | |
download | cygnal-b5139f598bf64bdb3212375a6ee6907dfbeacea0.tar.gz cygnal-b5139f598bf64bdb3212375a6ee6907dfbeacea0.tar.bz2 cygnal-b5139f598bf64bdb3212375a6ee6907dfbeacea0.zip |
* 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/libc/sys/sh')
-rw-r--r-- | newlib/libc/sys/sh/sys/syscall.h | 4 | ||||
-rw-r--r-- | newlib/libc/sys/sh/syscalls.c | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/newlib/libc/sys/sh/sys/syscall.h b/newlib/libc/sys/sh/sys/syscall.h index f141df764..fd9ee7c51 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 8380c7017..f0e924297 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); +} |