CPU affinity and backtrace upport or SunOS ##port (#17288)

* Backtrace is supported w/o external lib.
* Thread affinity implementation.
This commit is contained in:
David CARLIER 2020-07-17 01:07:18 +01:00 committed by GitHub
parent 4b8525759f
commit 320c001c4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -32,7 +32,7 @@
static char** env = NULL;
#if (__linux__ && __GNU_LIBRARY__) || defined(NETBSD_WITH_BACKTRACE) || \
defined(FREEBSD_WITH_BACKTRACE) || __DragonFly__
defined(FREEBSD_WITH_BACKTRACE) || __DragonFly__ || __sun
# include <execinfo.h>
#endif
#if __APPLE__
@ -300,7 +300,7 @@ R_API char *r_sys_cmd_strf(const char *fmt, ...) {
#if (__linux__ && __GNU_LIBRARY__) || (__APPLE__ && APPLE_WITH_BACKTRACE) || \
defined(NETBSD_WITH_BACKTRACE) || defined(FREEBSD_WITH_BACKTRACE) || \
__DragonFly__
__DragonFly__ || __sun
#define HAVE_BACKTRACE 1
#endif

View File

@ -9,6 +9,10 @@
#include <mach/thread_policy.h>
#endif
#if __sun
#include <sys/pset.h>
#endif
#if __HAIKU__
#include <kernel/scheduler.h>
#endif
@ -168,6 +172,19 @@ R_API bool r_th_setaffinity(RThread *th, int cpuid) {
eprintf ("Failed to set cpu affinity\n");
return false;
}
#elif __sun
psetid_t c;
pset_create (&c);
pset_assign (c, cpuid, NULL);
if (pset_bind (c, P_PID, getpid (), NULL)) {
pset_destroy (c);
eprintf ("Failed to set cpu affinity\n");
return false;
}
pset_destroy (c);
#else
#pragma message("warning r_th_setaffinity not implemented")
#endif