File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 5858#define DISPATCH_WORKQ_MAX_PTHREAD_COUNT 255
5959#endif
6060
61- #include "shims/hw_config.h"
62- #include "shims/priority.h"
63-
6461#if HAVE_PTHREAD_NP_H
6562#include <pthread_np.h>
6663#endif
6966#include <pthread/private.h>
7067#endif
7168
69+ #include "shims/hw_config.h"
70+ #include "shims/priority.h"
71+
7272#if !HAVE_DECL_FD_COPY
7373#define FD_COPY (f , t ) (void)(*(t) = *(f))
7474#endif
Original file line number Diff line number Diff line change @@ -102,14 +102,14 @@ static inline uint32_t
102102_dispatch_hw_get_config (_dispatch_hw_config_t c )
103103{
104104 uint32_t val = 1 ;
105- #if defined(__linux__ ) && HAVE_SYSCONF
105+ #if defined(__FreeBSD__ ) || (defined( __linux__ ) && HAVE_SYSCONF )
106106 switch (c ) {
107107 case _dispatch_hw_config_logical_cpus :
108108 case _dispatch_hw_config_physical_cpus :
109109 return (uint32_t )sysconf (_SC_NPROCESSORS_CONF );
110110 case _dispatch_hw_config_active_cpus :
111111 {
112- #ifdef __USE_GNU
112+ #if defined( __FreeBSD__ ) || __USE_GNU
113113 // Prefer pthread_getaffinity_np because it considers
114114 // scheduler cpu affinity. This matters if the program
115115 // is restricted to a subset of the online cpus (eg via numactl).
Original file line number Diff line number Diff line change 44#if defined(__linux__ )
55// For pthread_getaffinity_np()
66#include <pthread.h>
7+ #elif defined(__FreeBSD__ )
8+ // for pthread_getaffinity_np / cpu_set_t
9+ #include <pthread.h>
10+ #include <pthread_np.h>
711#endif
812
913struct test_context {
@@ -37,11 +41,11 @@ spin(void *context)
3741static uint32_t
3842activecpu (void )
3943{
40- uint32_t activecpu ;
41- #if defined(__linux__ ) || defined(__OpenBSD__ )
44+ uint32_t activecpu = 0xa1a1a1 ;
45+ #if defined(__linux__ ) || defined(__OpenBSD__ ) || defined( __FreeBSD__ )
4246 activecpu = (uint32_t )sysconf (_SC_NPROCESSORS_ONLN );
4347
44- #if defined(__linux__ ) && __USE_GNU
48+ #if defined(__FreeBSD__ ) || (defined( __linux__ ) && __USE_GNU )
4549 cpu_set_t cpuset ;
4650 if (pthread_getaffinity_np (pthread_self (),
4751 sizeof (cpu_set_t ),
You can’t perform that action at this time.
0 commit comments