Add basic tasking support for environment variables

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@291 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-06-30 17:05:44 +00:00
parent 445da7f795
commit 09a3864fd5
22 changed files with 810 additions and 5 deletions
+17 -1
View File
@@ -147,6 +147,19 @@ typedef void (*exitfunc_t)(void);
typedef struct msgq_s msgq_t;
/* The structure used to maintain environment variables */
#ifndef CONFIG_DISABLE_ENVIRON
struct environ_s
{
unsigned int ev_crefs; /* Reference count used when environment
* is shared by threads */
size_t ev_alloc; /* Number of bytes allocated in environment */
ubyte ev_env[1]; /* Environment strings */
};
typedef struct environ_s environ_t;
# define SIZEOF_ENVIRON_T(alloc) (sizeof(environ_t) + alloc - 1)
#endif
/* This is the task control block (TCB) */
struct _TCB
@@ -175,11 +188,14 @@ struct _TCB
ubyte init_priority; /* Initial priority of the task */
char *argv[CONFIG_MAX_TASK_ARGS+1]; /* Name+start-up parameters */
#ifndef CONFIG_DISABLE_ENVIRON
FAR environ_t *envp; /* Environment variables */
#endif
/* Stack-Related Fields *******************************************************/
#ifndef CONFIG_CUSTOM_STACK
size_t adj_stack_size; /* Stack size after adjustment */
size_t adj_stack_size; /* Stack size after adjustment */
/* for hardware, processor, etc. */
/* (for debug purposes only) */
FAR void *stack_alloc_ptr; /* Pointer to allocated stack */
+22 -1
View File
@@ -40,6 +40,7 @@
* Included Files
************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
/************************************************************
@@ -54,6 +55,15 @@
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
/* The environ variable, normally 'extern char **environ;' is
* not implemented as a function call. However, get_environ_ptr()
* can be used in its place.
*/
#ifndef CONFIG_DISABLE_ENIVRON
# define environ get_environ_ptr()
#endif
/************************************************************
* Global Type Definitions
************************************************************/
@@ -70,6 +80,10 @@ struct mallinfo
* by free (not in use) chunks.*/
};
/************************************************************
* Global Function Prototypes
************************************************************/
/************************************************************
* Global Function Prototypes
************************************************************/
@@ -89,7 +103,14 @@ EXTERN int rand(void);
/* Environment variable support */
EXTERN char *getenv(const char *name);
#ifndef CONFIG_DISABLE_ENIVRON
EXTERN FAR char **get_environ_ptr( void );
EXTERN FAR char *getenv(const char *name);
EXTERN int putenv(char *string);
EXTERN int clearenv(void);
EXTERN int setenv(const char *name, const char *value, int overwrite);
EXTERN int unsetenv(const char *name);
#endif
/* Process exit functions */