MCPcopy Create free account
hub / github.com/F-Stack/f-stack / malloc_ncpus

Function malloc_ncpus

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:711–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709}
710
711static unsigned
712malloc_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
739static void
740init_opt_stats_print_opts(const char *v, size_t vlen) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected