void
__gnat_setenv (char *name, char *value)
{
-#if (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__)
+#if (defined (__vxworks) && (defined (__RTP__) || _WRS_VXWORKS_MAJOR >= 7)) \
+ || defined (__APPLE__)
setenv (name, value, 1);
#else
sprintf (expression, "%s=%s", name, value);
putenv (expression);
-#if defined (__MINGW32__) || (defined (__vxworks) && ! defined (__RTP__))
- /* On some systems like MacOS X and Windows, putenv is making a copy of the
- expression string so we can free it after the call to putenv */
+#if defined (__MINGW32__) || defined (__vxworks)
+ /* putenv for Windows and VxWorks 6 kernel modules makes a copy of the
+ expression string, so we need to free it after the call to putenv. */
free (expression);
#endif
#endif
#if defined (__RTP__) || defined (VTHREADS)
return environ;
#else
- /* Kernel mode */
- return envGet (NULL);
+ /* For VxWorks kernel modules use envGet to get the task's environment
+ (either the task's private environment if it has one or the global
+ environment otherwise). taskId parameter of 0 refers to the current
+ task (the VxWorks documentation says to use NULL but the compiler
+ complains that taskId is an int rather than a pointer. Internally,
+ VxWorks uses 0 as well). */
+ return envGet (0);
#endif
#endif
}
void __gnat_unsetenv (char *name)
{
#if defined (__hpux__) || defined (__sun__) \
- || (defined (__vxworks) && ! defined (__RTP__)) \
+ || (defined (__vxworks) && ! defined (__RTP__) \
+ && _WRS_VXWORKS_MAJOR <= 6) \
|| defined (_AIX) || defined (__Lynx__)
/* On Solaris and HP-UX there is no function to clear an environment
if (strlen (env[index]) > size) {
if (strstr (env[index], name) == env[index] &&
env[index][size] == '=') {
-#if defined (__vxworks) && ! defined (__RTP__)
+#if defined (__vxworks)
/* on Vxworks we are sure that the string has been allocated using
malloc */
free (env[index]);
void __gnat_clearenv (void)
{
#if defined (__sun__) \
- || (defined (__vxworks) && ! defined (__RTP__)) || defined (__Lynx__) \
+ || (defined (__vxworks) && !defined (__RTP__) && _WRS_VXWORKS_MAJOR <= 6) \
+ || defined (__Lynx__) \
|| defined (__PikeOS__)
- /* On Solaris, VxWorks (not RTPs), and Lynx there is no system
+ /* On Solaris, VxWorks kernel pre 7, and Lynx there is no system
call to unset a variable or to clear the environment so set all
the entries in the environ table to NULL (see comment in
__gnat_unsetenv for more explanation). */
index++;
}
#elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \
- || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \
+ || (defined (__vxworks) && defined (__RTP__) || _WRS_VXWORKS_MAJOR >= 7) \
+ || defined (__CYGWIN__) \
|| defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__) \
|| defined (__DragonFly__) || defined (__DJGPP__)
/* On Windows, FreeBSD and MacOS there is no function to clean all the