diff options
author | Calvin <calvin@openmailbox.org> | 2017-02-13 20:58:05 +0300 |
---|---|---|
committer | Calvin <calvin@openmailbox.org> | 2017-02-27 18:27:49 +0300 |
commit | 68c190b1d6a167e5255e4d6dce76683b40a62326 (patch) | |
tree | f77cf64c1c3da4407d98618408b2bfdb05e1b2a6 | |
parent | ce4977fd6ca732681d3e3c3932fff8f73e5a96b9 (diff) |
Get Mono running further on Haiku by fixing proclib/threads
* proclib: Adapted Andreas' code to the refactored proclib.
Allocates ahead of time.
* threads: pthread_setschedparam is semantically different on Haiku,
because it returns positive numbers on success. Handle this
difference.
With these changes, Mono can now get to the point Roslyn runs, and
fails immediately due to lack of stack walking.
-rw-r--r-- | mono/metadata/threads.c | 6 | ||||
-rw-r--r-- | mono/utils/mono-proclib.c | 20 |
2 files changed, 23 insertions, 3 deletions
diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index c756a06c940..14b6f54fd60 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -642,7 +642,13 @@ mono_thread_internal_set_priority (MonoInternalThread *internal, MonoThreadPrior } res = pthread_setschedparam (tid, policy, ¶m); +#if defined(__HAIKU__) + /* On Haiku, pthread_setschedparam returns a positive number on success, + which is the priority, or a negative number, which is the errno. */ + if (res < 0) { +#else if (res != 0) { +#endif if (res == EPERM) { g_warning ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res); return; diff --git a/mono/utils/mono-proclib.c b/mono/utils/mono-proclib.c index 2f7ef0cfadd..294e37a677a 100644 --- a/mono/utils/mono-proclib.c +++ b/mono/utils/mono-proclib.c @@ -33,6 +33,9 @@ #endif #include <sys/resource.h> #endif +#if defined(__HAIKU__) +#include <os/kernel/OS.h> +#endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #include <sys/proc.h> #if defined(__APPLE__) @@ -157,9 +160,20 @@ mono_process_list (int *size) *size = res; return buf; #elif defined(__HAIKU__) - /* FIXME: Add back the code from 9185fcc305e43428d0f40f3ee37c8a405d41c9ae */ - g_assert_not_reached (); - return NULL; + int32 cookie = 0; + int32 i = 0; + team_info ti; + system_info si; + + get_system_info(&si); + void **buf = g_calloc(si.used_teams, sizeof(void*)); + + while (get_next_team_info(&cookie, &ti) == B_OK && i < si.used_teams) { + buf[i++] = GINT_TO_POINTER (ti.team); + } + *size = i; + + return buf; #else const char *name; void **buf = NULL; |