This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SH: argc/argv initialization


Alexandre Oliva wrote:
> 
> This introduces support for argument list handling, as soon as the
> corresponding SIM patch is installed and GCC's crt1.asm is modified so
> as to use the new function introduced in this patch.  Ok to install?
>

Yes, go ahead.

-- Jeff J.
 
>   ----------------------------------------------------------------------------------------------------
> Index: newlib/ChangeLog
> from  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-25  Alexandre Oliva  <aoliva@redhat.com>
> 
> Index: newlib/libc/sys/sh/syscalls.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/sys/sh/syscalls.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 syscalls.c
> --- newlib/libc/sys/sh/syscalls.c 2001/01/25 21:40:28 1.3
> +++ newlib/libc/sys/sh/syscalls.c 2001/01/25 23:06:27
> @@ -183,3 +183,31 @@ _gettimeofday (struct timeval *tv, struc
>    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);
> +}
> Index: newlib/libc/sys/sh/sys/syscall.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/sys/sh/sys/syscall.h,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 syscall.h
> --- newlib/libc/sys/sh/sys/syscall.h 2000/02/17 19:39:50 1.1.1.1
> +++ newlib/libc/sys/sh/sys/syscall.h 2001/01/25 23:06:27
> @@ -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 */
> 
>   ----------------------------------------------------------------------------------------------------
> 
> --
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]