Merge branch 'xbuild_improvements' of github.com:knocte/mono into xbuild_improvements
[mono.git] / eglib / src / gfile-posix.c
index cefbe4e0b966058e73e8a253f5cc479818f0c422..48a9192ab69fad8ea0d2ce2d195549af6442982e 100644 (file)
 #include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
 
 #ifdef _MSC_VER
 #include <direct.h>
+#endif
+#ifdef G_OS_WIN32
 int mkstemp (char *tmp_template);
 #endif
 
@@ -162,6 +167,9 @@ g_get_current_dir (void)
                }
        } while (fail);
 
-       return r;
+       /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer
+        * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
+        * so we return the buffer here since it has a pointer to the valid string
+        */
+       return buffer;
 }
-