| 709 | } |
| 710 | |
| 711 | static unsigned |
| 712 | malloc_ncpus(void) { |
| 713 | long result; |
| 714 | |
| 715 | #ifdef _WIN32 |
| 716 | SYSTEM_INFO si; |
| 717 | GetSystemInfo(&si); |
| 718 | result = si.dwNumberOfProcessors; |
| 719 | #elif defined(JEMALLOC_GLIBC_MALLOC_HOOK) && defined(CPU_COUNT) |
| 720 | /* |
| 721 | * glibc >= 2.6 has the CPU_COUNT macro. |
| 722 | * |
| 723 | * glibc's sysconf() uses isspace(). glibc allocates for the first time |
| 724 | * *before* setting up the isspace tables. Therefore we need a |
| 725 | * different method to get the number of CPUs. |
| 726 | */ |
| 727 | { |
| 728 | cpu_set_t set; |
| 729 | |
| 730 | pthread_getaffinity_np(pthread_self(), sizeof(set), &set); |
| 731 | result = CPU_COUNT(&set); |
| 732 | } |
| 733 | #else |
| 734 | result = sysconf(_SC_NPROCESSORS_ONLN); |
| 735 | #endif |
| 736 | return ((result == -1) ? 1 : (unsigned)result); |
| 737 | } |
| 738 | |
| 739 | static void |
| 740 | init_opt_stats_print_opts(const char *v, size_t vlen) { |
no outgoing calls
no test coverage detected