Fix the build on windows
[mono.git] / mono / metadata / process.c
index 347958e6eb655c7d0b1553467d8aeebeecdba746..01a29bcd74a83afc292bad48ff59aadc27fd2624 100644 (file)
@@ -13,7 +13,7 @@
 #include <glib.h>
 #include <string.h>
 
-#include <mono/metadata/object.h>
+#include <mono/metadata/object-internals.h>
 #include <mono/metadata/process.h>
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/appdomain.h>
@@ -65,7 +65,11 @@ void ves_icall_System_Diagnostics_Process_Process_free_internal (MonoObject *thi
        g_message ("%s: Closing process %p, handle %p", __func__, this, process);
 #endif
 
+#if TARGET_WIN32
        CloseHandle (process);
+#else
+       CloseProcess (process);
+#endif
 }
 
 #define STASH_SYS_ASS(this) \
@@ -450,7 +454,7 @@ static gchar *
 quote_path (const gchar *path)
 {
        gchar *res = g_shell_quote (path);
-#ifdef PLATFORM_WIN32
+#ifdef TARGET_WIN32
        {
        gchar *q = res;
        while (*q) {
@@ -471,7 +475,7 @@ complete_path (const gunichar2 *appname, gchar **completed)
        gchar *found;
 
        utf8appmemory = utf8app = g_utf16_to_utf8 (appname, -1, NULL, NULL, NULL);
-#ifdef PLATFORM_WIN32 // Should this happen on all platforms? 
+#ifdef TARGET_WIN32 // Should this happen on all platforms? 
        {
                // remove the quotes around utf8app.
                size_t len;
@@ -510,9 +514,13 @@ complete_path (const gunichar2 *appname, gchar **completed)
        return TRUE;
 }
 
+#if defined (MINGW_CROSS_COMPILE) && defined (HAVE_GETPROCESSID)
+#undef HAVE_GETPROCESSID
+#endif
+
 #ifndef HAVE_GETPROCESSID
 /* Run-time GetProcessId detection for Windows */
-#ifdef PLATFORM_WIN32
+#ifdef TARGET_WIN32
 #define HAVE_GETPROCESSID
 
 typedef DWORD (WINAPI *GETPROCESSID_PROC) (HANDLE);
@@ -577,7 +585,7 @@ static DWORD WINAPI GetProcessId_detect (HANDLE process)
        GetProcessId = &GetProcessId_stub;
        return GetProcessId (process);
 }
-#endif /* PLATFORM_WIN32 */
+#endif /* HOST_WIN32 */
 #endif /* !HAVE_GETPROCESSID */
 
 MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoProcessStartInfo *proc_start_info, MonoProcInfo *process_info)
@@ -624,7 +632,7 @@ MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoPr
                /* It appears that there's no way to get the pid from a
                 * process handle before windows xp.  Really.
                 */
-#ifdef HAVE_GETPROCESSID
+#if defined(HAVE_GETPROCESSID) && !defined(MONO_CROSS_COMPILE)
                process_info->pid = GetProcessId (shellex.hProcess);
 #else
                process_info->pid = 0;
@@ -664,7 +672,7 @@ MonoBoolean ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoPro
                process_info->pid = -ERROR_FILE_NOT_FOUND;
                return FALSE;
        }
-#ifdef PLATFORM_WIN32
+#ifdef TARGET_WIN32
        /* Seems like our CreateProcess does not work as the windows one.
         * This hack is needed to deal with paths containing spaces */
        shell_path = NULL;