-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Enable mono cross-build on SunOS-like OS #37560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -805,6 +805,15 @@ mono_thread_internal_set_priority (MonoInternalThread *internal, MonoThreadPrior | |
| break; | ||
| #ifdef SCHED_BATCH | ||
| case SCHED_BATCH: | ||
| #endif | ||
| #ifdef SCHED_IA | ||
| case SCHED_IA: | ||
| #endif | ||
| #ifdef SCHED_FSS | ||
| case SCHED_FSS: | ||
| #endif | ||
| #ifdef SCHED_FX | ||
| case SCHED_FX: | ||
|
||
| #endif | ||
| case SCHED_OTHER: | ||
| param.sched_priority = 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||
| /** | ||||||||
| * \file | ||||||||
| */ | ||||||||
|
|
||||||||
| #include <config.h> | ||||||||
|
|
||||||||
| #if defined(__sun__) | ||||||||
|
|
||||||||
| #include <mono/utils/mono-threads.h> | ||||||||
| #include <pthread.h> | ||||||||
| #include <sys/syscall.h> | ||||||||
|
|
||||||||
| void | ||||||||
| mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) | ||||||||
| { | ||||||||
| pthread_attr_t attr; | ||||||||
| gint res; | ||||||||
|
|
||||||||
| *staddr = NULL; | ||||||||
| *stsize = (size_t)-1; | ||||||||
|
|
||||||||
| res = pthread_attr_init (&attr); | ||||||||
| if (G_UNLIKELY (res != 0)) | ||||||||
| g_error ("%s: pthread_attr_init failed with \"%s\" (%d)", __func__, g_strerror (res), res); | ||||||||
|
|
||||||||
| res = pthread_attr_get_np (pthread_self (), &attr); | ||||||||
| if (G_UNLIKELY (res != 0)) | ||||||||
| g_error ("%s: pthread_getattr_np failed with \"%s\" (%d)", __func__, g_strerror (res), res); | ||||||||
|
|
||||||||
| res = pthread_attr_getstack (&attr, (void**)staddr, stsize); | ||||||||
| if (G_UNLIKELY (res != 0)) | ||||||||
| g_error ("%s: pthread_attr_getstack failed with \"%s\" (%d)", __func__, g_strerror (res), res); | ||||||||
|
|
||||||||
| res = pthread_attr_destroy (&attr); | ||||||||
| if (G_UNLIKELY (res != 0)) | ||||||||
| g_error ("%s: pthread_attr_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res); | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| guint64 | ||||||||
| mono_native_thread_os_id_get (void) | ||||||||
| { | ||||||||
| // TODO: investigate whether to use light weight process lwp ID of keep pthread_self() | ||||||||
| // after the libraries and SDK ports are completed on illumos and/or Solaris platform. | ||||||||
| return (guint64)pthread_self (); | ||||||||
|
||||||||
| #else | |
| #define PlatformGetCurrentThreadId() (SIZE_T)pthread_self() | |
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. And I guess the value from thr_self () is no better than the POSIX thread ID... What a mess. Can you leave a comment so it's clear this isn't just a mistake? Otherwise I suspect I'll see this code 6 months down the line and, having forgotten about this conversation, look into it all over again. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CoffeeFlux, I understand your position. and tbh, I am also not 100% sure whether to use light weight process (lwp) ID or pthread_self in this case as we are doing different things with this returned value at the call site (some places are using pthread library, others are making syscalls etc.). As far as I have read, POSIX does not provide strict specifications for process/thread related IDs and their relation with platform native threads, hence the disparity across all platforms and makes it difficult for devs to figure out the exact semantics (which we can see in all mono-threads-{platform}.c files). I only made sure that the hello world is working without violating any assertion i.e. changes in threads.c were the result of assertion violation on run time.
It is not exactly straight-forward to port dotnet/runtime to a new Unix platform, and test it all in one go. The eng side is quite a work to pull and lots of (ever changing) moving parts to learn. That's the reason why I am currently pushing changes to get this semi-ready state checked, to be able to get SDK to work, and then port libraries and run tests on the host Sun-like platforms.
Added a TODO comment to that effect. So far, this is just-working. We will get more information, when we will be able to execute related libraries tests to exercise this code thoroughly, and it might get changed to lwpId, something else or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, and thanks for the detailed response. I'm happy with a just-working state on this PR; I just want to make sure we're attempting to capture that context somewhere in the code instead of buried in a Github issue. Appreciate your efforts to get this working!
As far as I have read, POSIX does not provide strict specifications for process/thread related IDs and their relation with platform native threads, hence the disparity across all platforms
Yep. 😢
Uh oh!
There was an error while loading. Please reload this page.