3 * System.Environment support internal calls
6 * Dick Porter (dick@ximian.com)
7 * Sebastien Pouliot (sebastien@ximian.com)
9 * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
10 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
11 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
17 #include <mono/metadata/appdomain.h>
18 #include <mono/metadata/environment.h>
19 #include <mono/metadata/exception.h>
20 #include <mono/utils/mono-compiler.h>
21 #include <mono/utils/w32api.h>
23 extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
25 #if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
26 #include <sys/utsname.h>
29 static gint32 exitcode=0;
32 * mono_environment_exitcode_get:
35 mono_environment_exitcode_get (void)
41 * mono_environment_exitcode_set:
44 mono_environment_exitcode_set (gint32 value)
49 /* note: we better manipulate the string in managed code (easier and safer) */
51 ves_icall_System_Environment_GetOSVersionString (void)
54 OSVERSIONINFOEX verinfo;
56 verinfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
57 if (GetVersionEx ((OSVERSIONINFO*)&verinfo)) {
59 /* maximum string length is 45 bytes
60 4 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL */
61 sprintf (version, "%ld.%ld.%ld.%d",
62 verinfo.dwMajorVersion,
63 verinfo.dwMinorVersion,
64 verinfo.dwBuildNumber,
65 verinfo.wServicePackMajor << 16);
66 return mono_string_new (mono_domain_get (), version);
68 #elif defined(HAVE_SYS_UTSNAME_H)
71 if (uname (&name) >= 0) {
72 return mono_string_new (mono_domain_get (), name.release);
75 return mono_string_new (mono_domain_get (), "0.0.0.0");