Index: mono/metadata/environment.c
===================================================================
RCS file: /cvs/public/mono/mono/metadata/environment.c,v
retrieving revision 1.1
diff -u -r1.1 environment.c
--- mono/metadata/environment.c	23 Jan 2003 17:46:25 -0000	1.1
+++ mono/metadata/environment.c	23 Apr 2004 20:00:01 -0000
@@ -1,16 +1,24 @@
 /*
  * environment.c: System.Environment support internal calls
  *
- * Author:
+ * Authors:
  *	Dick Porter (dick@ximian.com)
+ *	Sebastien Pouliot (sebastien@ximian.com)
  *
  * (C) 2002 Ximian, Inc.
+ * (C) 2004 Novell (http://www.novell.com)
  */
 
 #include <config.h>
 #include <glib.h>
 
+#include <mono/metadata/appdomain.h>
 #include <mono/metadata/environment.h>
+#include <mono/metadata/exception.h>
+
+#ifndef PLATFORM_WIN32
+#include <sys/utsname.h>
+#endif
 
 static gint32 exitcode=0;
 
@@ -22,4 +30,36 @@
 void mono_environment_exitcode_set (gint32 value)
 {
 	exitcode=value;
+}
+
+/* note: we better manipulate the string in managed code (easier and safer) */
+MonoString*
+ves_icall_System_Environment_GetOSVersionString (void)
+{
+#ifdef PLATFORM_WIN32
+	OSVERSIONINFO verinfo;
+
+	MONO_ARCH_SAVE_REGS;
+
+	verinfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+	if (GetVersionEx (&verinfo)) {
+		char version [64];
+		// maximum string length is 35 bytes
+		// 3 x 10 bytes per number, 1 byte for 0, 3 x 1 byte for dots, 1 for NULL
+		sprintf (version, "%ld.%ld.%ld.0", 
+			verinfo.dwMajorVersion,
+			verinfo.dwMinorVersion,
+			verinfo.dwBuildNumber);
+		return mono_string_new (mono_domain_get (), version);
+	}
+#else
+	struct utsname name;
+
+	MONO_ARCH_SAVE_REGS;
+
+	if (uname (&name) == 0) {
+		return mono_string_new (mono_domain_get (), name.release);
+	}
+#endif
+	return mono_string_new (mono_domain_get (), "0.0.0.0");
 }
Index: mono/metadata/environment.h
===================================================================
RCS file: /cvs/public/mono/mono/metadata/environment.h,v
retrieving revision 1.1
diff -u -r1.1 environment.h
--- mono/metadata/environment.h	23 Jan 2003 17:46:25 -0000	1.1
+++ mono/metadata/environment.h	23 Apr 2004 20:00:01 -0000
@@ -13,4 +13,6 @@
 extern gint32 mono_environment_exitcode_get (void);
 extern void mono_environment_exitcode_set (gint32 value);
 
+extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
+
 #endif /* _MONO_METADATA_ENVIRONMENT_H_ */
Index: mono/metadata/icall.c
===================================================================
RCS file: /cvs/public/mono/mono/metadata/icall.c,v
retrieving revision 1.466
diff -u -r1.466 icall.c
--- mono/metadata/icall.c	23 Apr 2004 14:58:44 -0000	1.466
+++ mono/metadata/icall.c	23 Apr 2004 20:00:02 -0000
@@ -4959,7 +4959,8 @@
 	{"GetCommandLineArgs", mono_runtime_get_main_args},
 	{"GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable},
 	{"GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames},
-	{"GetMachineConfigPath",	ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+	{"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+	{"GetOSVersionString", ves_icall_System_Environment_GetOSVersionString},
 	{"GetWindowsFolderPath", ves_icall_System_Environment_GetWindowsFolderPath},
 	{"get_ExitCode", mono_environment_exitcode_get},
 	{"get_HasShutdownStarted", ves_icall_System_Environment_get_HasShutdownStarted},
