[Cbe-oss-dev] [PATCH] libspe: elfspe: set argv[argc] = NULL

Arnd Bergmann arnd at arndb.de
Wed May 23 18:55:37 EST 2007


On Wednesday 23 May 2007, Masato Noguchi wrote:
> 
> Programming language-C standard says "argv[argc] shall be a null pointer."
> but, a value of argv[argc] passed from elfspe to spe program is undefined in current implementation.
> This patch fix it.
> 
> is it ok to apply?
> 

The patch looks good to me. However, I wonder if we should fix another related
problem at the same time. The C99 standard also lists a common extension as

| In a hosted environment, the main function receives a third argument, char *envp[],
| that points to a null-terminated array of pointers to char, each of which points to a string
| that provides information about the environment for this execution of the program
| (5.1.2.2.1).

And posix 1003.1 defines an 'extern char **environ;' to point at the environment
variables, http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html

There are many application that depend on environment variables in some way, but
elfspe currently does not pass the environment down to the application at all.
Implementing the third (optional) argument to main should be easy enough, and it
makes it possible to extend the startup code to provide 'environ' later, if
necessary.

	Arnd <><



More information about the cbe-oss-dev mailing list