| 68 | } |
| 69 | |
| 70 | int pthread_setaffinity_np(pthread_t thread, size_t cpu_size, |
| 71 | cpu_set_t *cpu_set) |
| 72 | { |
| 73 | thread_port_t mach_thread; |
| 74 | int core = 0; |
| 75 | |
| 76 | for (core = 0; core < 8 * (int)cpu_size; core++) { |
| 77 | if (CPU_ISSET(core, cpu_set)) break; |
| 78 | } |
| 79 | |
| 80 | thread_affinity_policy_data_t policy = { core }; |
| 81 | mach_thread = pthread_mach_thread_np(thread); |
| 82 | thread_policy_set(mach_thread, THREAD_AFFINITY_POLICY, |
| 83 | (thread_policy_t)&policy, 1); |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | size_t getProcessorCount() |
no test coverage detected