File tree Expand file tree Collapse file tree 6 files changed +65
-8
lines changed
coreclr/nativeaot/Runtime/eventpipe
tests/tracing/eventpipe/processenvironment Expand file tree Collapse file tree 6 files changed +65
-8
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ extends:
248
248
extraStepsTemplate : /eng/pipelines/coreclr/nativeaot-post-build-steps.yml
249
249
extraStepsParameters :
250
250
creator : dotnet-bot
251
- testBuildArgs : ' nativeaot tree ";nativeaot;Loader;Interop;tracing/eventpipe/config;tracing/eventpipe/diagnosticport;tracing/eventpipe/reverse;tracing/eventpipe/simpleruntimeeventvalidation;" test tracing/eventcounter/runtimecounters.csproj /p:BuildNativeAotFrameworkObjects=true'
251
+ testBuildArgs : ' nativeaot tree ";nativeaot;Loader;Interop;tracing/eventpipe/config;tracing/eventpipe/diagnosticport;tracing/eventpipe/reverse;tracing/eventpipe/processenvironment;tracing/eventpipe/ simpleruntimeeventvalidation;" test tracing/eventcounter/runtimecounters.csproj /p:BuildNativeAotFrameworkObjects=true'
252
252
liveLibrariesBuildConfig : Release
253
253
testRunNamePrefixSuffix : NativeAOT_$(_BuildConfig)
254
254
extraVariablesTemplates :
Original file line number Diff line number Diff line change 1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ #ifdef TARGET_WINDOWS
5
+ #include < windows.h>
6
+ #else
7
+ #include < stdlib.h>
8
+ #endif
9
+
4
10
#include < sys/types.h>
5
11
6
12
#ifdef __APPLE__
@@ -227,4 +233,19 @@ ds_rt_aot_transport_get_default_name (
227
233
return true ;
228
234
#endif
229
235
}
236
+
237
+ uint32_t
238
+ ds_rt_aot_set_environment_variable (const ep_char16_t *name, const ep_char16_t *value)
239
+ {
240
+ #ifdef TARGET_UNIX
241
+ ep_char8_t *nameNarrow = ep_rt_utf16le_to_utf8_string (name, ep_rt_utf16_string_len (name));
242
+ ep_char8_t *valueNarrow = ep_rt_utf16le_to_utf8_string (value, ep_rt_utf16_string_len (value));
243
+ int32_t ret_value = setenv (nameNarrow, valueNarrow, 1 );
244
+ free (nameNarrow);
245
+ free (valueNarrow);
246
+ return ret_value;
247
+ #else
248
+ return SetEnvironmentVariableW (reinterpret_cast <LPCWSTR>(name), reinterpret_cast <LPCWSTR>(value)) ? S_OK : HRESULT_FROM_WIN32 (GetLastError ());
249
+ #endif
250
+ }
230
251
#endif /* ENABLE_PERFTRACING */
Original file line number Diff line number Diff line change @@ -266,9 +266,8 @@ static
266
266
uint32_t
267
267
ds_rt_set_environment_variable (const ep_char16_t * name , const ep_char16_t * value )
268
268
{
269
- // return SetEnvironmentVariableW(reinterpret_cast<LPCWSTR>(name), reinterpret_cast<LPCWSTR>(value)) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
270
- // PalDebugBreak();
271
- return 0xffff ;
269
+ extern uint32_t ds_rt_aot_set_environment_variable (const ep_char16_t * name , const ep_char16_t * value );
270
+ return ds_rt_aot_set_environment_variable (name , value );
272
271
}
273
272
274
273
static
Original file line number Diff line number Diff line change @@ -669,6 +669,44 @@ bool ep_rt_aot_spin_lock_release (ep_rt_spin_lock_handle_t *spin_lock)
669
669
return false ;
670
670
}
671
671
672
+ #ifndef HOST_WIN32
673
+ #if defined(__APPLE__)
674
+ #if defined (HOST_OSX)
675
+ extern " C" {char ***_NSGetEnviron (void );}
676
+ #define environ (*_NSGetEnviron ())
677
+ #else
678
+ static char *_ep_rt_aot_environ[1 ] = { NULL };
679
+ #define environ _ep_rt_aot_environ
680
+ #endif /* defined (HOST_OSX) */
681
+ #else
682
+ extern " C" {
683
+ extern char **environ;
684
+ }
685
+ #endif /* defined (__APPLE__) */
686
+ #endif /* !defined (HOST_WIN32) */
687
+
688
+ void ep_rt_aot_os_environment_get_utf16 (dn_vector_ptr_t *env_array)
689
+ {
690
+ STATIC_CONTRACT_NOTHROW;
691
+ EP_ASSERT (env_array != NULL );
692
+
693
+ #ifdef HOST_WIN32
694
+ ep_char16_t * envs = reinterpret_cast <ep_char16_t *>(GetEnvironmentStringsW ());
695
+ if (envs) {
696
+ const ep_char16_t * next = envs;
697
+ while (*next) {
698
+ dn_vector_ptr_push_back (env_array, ep_rt_utf16_string_dup (reinterpret_cast <const ep_char16_t *>(next)));
699
+ next += ep_rt_utf16_string_len (reinterpret_cast <const ep_char16_t *>(next)) + 1 ;
700
+ }
701
+ FreeEnvironmentStringsW (reinterpret_cast <LPWSTR>(envs));
702
+ }
703
+ #else
704
+ ep_char8_t **next = NULL ;
705
+ for (next = environ; *next != NULL ; ++next)
706
+ dn_vector_ptr_push_back (env_array, ep_rt_utf8_to_utf16le_string (*next, -1 ));
707
+ #endif
708
+ }
709
+
672
710
#ifdef EP_CHECKED_BUILD
673
711
674
712
void ep_rt_aot_lock_requires_lock_held (const ep_rt_lock_handle_t *lock)
Original file line number Diff line number Diff line change @@ -1114,10 +1114,8 @@ static
1114
1114
void
1115
1115
ep_rt_os_environment_get_utf16 (dn_vector_ptr_t *env_array)
1116
1116
{
1117
- STATIC_CONTRACT_NOTHROW;
1118
- EP_ASSERT (env_array != NULL );
1119
-
1120
- // PalDebugBreak();
1117
+ extern void ep_rt_aot_os_environment_get_utf16 (dn_vector_ptr_t *env_array);
1118
+ ep_rt_aot_os_environment_get_utf16 (env_array);
1121
1119
}
1122
1120
1123
1121
/*
Original file line number Diff line number Diff line change 8
8
<GCStressIncompatible >true</GCStressIncompatible >
9
9
<JitOptimizationSensitive >true</JitOptimizationSensitive >
10
10
<IlasmRoundTripIncompatible >true</IlasmRoundTripIncompatible >
11
+ <EventSourceSupport Condition =" '$(TestBuildMode)' == 'nativeaot'" >true</EventSourceSupport >
11
12
</PropertyGroup >
12
13
<ItemGroup >
13
14
<Compile Include =" $(MSBuildProjectName).cs" />
You can’t perform that action at this time.
0 commit comments