CPU affinity and backtrace upport or SunOS ##port (#17288)
* Backtrace is supported w/o external lib. * Thread affinity implementation.
This commit is contained in:
parent
4b8525759f
commit
320c001c4c
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue