Skip to content
Snippets Groups Projects
Commit 1c5718b3 authored by dmitriy.gerasimov's avatar dmitriy.gerasimov
Browse files

[+] BSD variant of set/get cpu affinity calls

parent dfc53020
No related branches found
No related tags found
No related merge requests found
Pipeline #7175 passed with stage
in 11 seconds
...@@ -50,6 +50,13 @@ ...@@ -50,6 +50,13 @@
#include <sys/timerfd.h> #include <sys/timerfd.h>
#endif #endif
#include <pthread.h>
#ifdef DAP_OS_BSD
#include <pthread_np.h>
typedef cpuset_t cpu_set_t; // Adopt BSD CPU setstructure to POSIX variant
#endif
#if defined(DAP_OS_ANDROID) #if defined(DAP_OS_ANDROID)
#define NO_POSIX_SHED #define NO_POSIX_SHED
#define NO_TIMER #define NO_TIMER
...@@ -62,7 +69,7 @@ ...@@ -62,7 +69,7 @@
#include <mswsock.h> #include <mswsock.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <io.h> #include <io.h>
#include <pthread.h>
#endif #endif
#include <utlist.h> #include <utlist.h>
...@@ -93,7 +100,11 @@ uint32_t dap_get_cpu_count( ) ...@@ -93,7 +100,11 @@ uint32_t dap_get_cpu_count( )
#ifndef NO_POSIX_SHED #ifndef NO_POSIX_SHED
cpu_set_t cs; cpu_set_t cs;
CPU_ZERO( &cs ); CPU_ZERO( &cs );
#if defined (DAP_OS_ANDROID)
sched_getaffinity( 0, sizeof(cs), &cs ); sched_getaffinity( 0, sizeof(cs), &cs );
#else
pthread_getaffinity_np(pthread_self(), sizeof(cs), &cs);
#endif
uint32_t count = 0; uint32_t count = 0;
for ( int i = 0; i < 32; i++ ){ for ( int i = 0; i < 32; i++ ){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment