2 * environment.c: System.Environment support internal calls
5 * Dick Porter (dick@ximian.com)
6 * Sebastien Pouliot (sebastien@ximian.com)
8 * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
9 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
15 #include <mono/metadata/appdomain.h>
16 #include <mono/metadata/environment.h>
17 #include <mono/metadata/exception.h>
18 #include <mono/utils/mono-compiler.h>
19 #include <mono/io-layer/io-layer.h>
21 extern MonoString
* ves_icall_System_Environment_GetOSVersionString (void) MONO_INTERNAL
;
23 #if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
24 #include <sys/utsname.h>
27 static gint32 exitcode
=0;
29 gint32
mono_environment_exitcode_get (void)
34 void mono_environment_exitcode_set (gint32 value
)
39 /* note: we better manipulate the string in managed code (easier and safer) */
41 ves_icall_System_Environment_GetOSVersionString (void)
44 OSVERSIONINFO verinfo
;
48 verinfo
.dwOSVersionInfoSize
= sizeof (OSVERSIONINFO
);
49 if (GetVersionEx (&verinfo
)) {
51 /* maximum string length is 35 bytes
52 3 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL */
53 sprintf (version
, "%ld.%ld.%ld.0",
54 verinfo
.dwMajorVersion
,
55 verinfo
.dwMinorVersion
,
56 verinfo
.dwBuildNumber
);
57 return mono_string_new (mono_domain_get (), version
);
59 #elif defined(HAVE_SYS_UTSNAME_H)
64 if (uname (&name
) >= 0) {
65 return mono_string_new (mono_domain_get (), name
.release
);
68 return mono_string_new (mono_domain_get (), "0.0.0.0");