From: Doug Rupp Date: Wed, 10 Jul 2019 09:01:13 +0000 (+0000) Subject: [Ada] The environ macro is broken on vxworks7r2 SR0610 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32e0627f99f4212695ec13b6d50ca48d1c29ded3;p=gcc.git [Ada] The environ macro is broken on vxworks7r2 SR0610 In SR0610, the TCB is made private, so the task environ field used by the environ macro is no longer visible. Arguably this is a bug, however a more correct approach is to use accessor functions to retrieve this field and not use the environ macro, thus avoiding the problem. 2019-07-10 Doug Rupp gcc/ada/ * env.c (__gnat_environ): Reformulate to also work for vxworks7r2 SR0610. From-SVN: r273332 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 88c25be6738..e4034e42f6a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-10 Doug Rupp + + * env.c (__gnat_environ): Reformulate to also work for + vxworks7r2 SR0610. + 2019-07-10 Patrick Bernardi * Makefile.rtl: Handle vxworks7r2 ppc target diff --git a/gcc/ada/env.c b/gcc/ada/env.c index cf839f56682..04e861e19e9 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -60,6 +60,9 @@ #endif #if defined (__vxworks) + #include + #include + #if defined (__RTP__) /* On VxWorks 6 Real-Time process mode, environ is defined in unistd.h. */ #include @@ -69,14 +72,18 @@ envLib.h on VxWorks MILS and VxWorks 653. */ #include #include - #else - /* This should work for kernel mode on both VxWorks 5 and VxWorks 6. */ + #elif (_WRS_VXWORKS_MAJOR <= 6) #include - - /* In that mode environ is a macro which reference the following symbol. - As the symbol is not defined in any VxWorks include files we declare - it as extern. */ + /* In that mode the following symbol is not defined in any VxWorks + include files, prior to vxWorks 7, so we declare it as extern. */ extern char** ppGlobalEnviron; + #elif (_WRS_VXWORKS_MAJOR >= 7) + /* This should work for kernel mode on VxWorks 7.x. In 7.2 the tcb + is made private, so accessor functions must be used, in 7.0 it + is optional but there is no way to distinguish between 7.2 + and 7.0 since the version.h header file was never updated. */ + #include + #include #endif #endif @@ -223,7 +230,18 @@ __gnat_environ (void) extern char **environ; return environ; #else - return environ; + #if defined (__RTP__) || defined (VTHREADS) || (_WRS_VXWORKS_MAJOR <= 6) + return environ; + #elif (_WRS_VXWORKS_MAJOR >= 7) + char **task_environ; + + task_environ = envGet (taskIdSelf ()); + + if (task_environ == NULL) + return ppGlobalEnviron; + else + return task_environ; + #endif #endif }