Merge pull request #1319 from directhex/systemwide-per-arch-aot-cache
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixEnvironment.cs
index 4144c13317fc17f674cb6876df0e763866f75923..e400aaac1e2972a88d70f849b36776096bbf5d3d 100644 (file)
@@ -48,17 +48,10 @@ namespace Mono.Unix {
 
                public static string MachineName {
                        get {
-                               StringBuilder buf = new StringBuilder (8);
-                               int r = 0;
-                               Native.Errno e = (Native.Errno) 0;
-                               do {
-                                       buf.Capacity *= 2;
-                                       r = Native.Syscall.gethostname (buf);
-                               } while (r == (-1) && ((e = Native.Stdlib.GetLastError()) == Native.Errno.EINVAL) || 
-                                               (e == Native.Errno.ENAMETOOLONG));
-                               if (r == (-1))
-                                       UnixMarshal.ThrowExceptionForLastError ();
-                               return buf.ToString ();
+                               Native.Utsname buf;
+                               if (Native.Syscall.uname (out buf) != 0)
+                                       throw UnixMarshal.CreateExceptionForLastError ();
+                               return buf.nodename;
                        }
                        set {
                                int r = Native.Syscall.sethostname (value);