Before we only checked if IntPtr.Size == 8, but this returns false for a 32bit Mono running on a 64bit OS.
Added an icall that gets the correct value from the runtime instead.
Note: this currently only whitelists x86_64, aarch64 and ppc64 as 64-bit platforms.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=37414
throw new NotImplementedException ();
}
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static bool GetIs64BitOperatingSystem ();
+
public static bool Is64BitOperatingSystem {
- get { return IntPtr.Size == 8; } // FIXME: is this good enough?
+ get { return GetIs64BitOperatingSystem (); }
}
public static int SystemPageSize {
ICALL(ENV_1, "Exit", ves_icall_System_Environment_Exit)
ICALL(ENV_2, "GetCommandLineArgs", mono_runtime_get_main_args)
ICALL(ENV_3, "GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames)
+ICALL(ENV_31, "GetIs64BitOperatingSystem", ves_icall_System_Environment_GetIs64BitOperatingSystem)
ICALL(ENV_4, "GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives )
ICALL(ENV_5, "GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path)
ICALL(ENV_51, "GetNewLine", ves_icall_System_Environment_get_NewLine)
#include "decimal-ms.h"
#include "number-ms.h"
+#if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
+#include <sys/utsname.h>
+#endif
+
extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
#endif
}
+ICALL_EXPORT MonoBoolean
+ves_icall_System_Environment_GetIs64BitOperatingSystem (void)
+{
+#if SIZEOF_VOID_P == 8
+ return TRUE;
+#else
+#ifdef HOST_WIN32
+ gboolean isWow64Process = FALSE;
+ if (IsWow64Process (GetCurrentProcess (), &isWow64Process)) {
+ return (MonoBoolean)isWow64Process;
+ }
+#elif defined(HAVE_SYS_UTSNAME_H)
+ struct utsname name;
+
+ if (uname (&name) >= 0) {
+ return strcmp (name.machine, "x86_64") == 0 || strncmp (name.machine, "aarch64", 7) == 0 || strncmp (name.machine, "ppc64", 5) == 0;
+ }
+#endif
+ return FALSE;
+#endif
+}
+
ICALL_EXPORT MonoString *
ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
{