Re: git: 1cc5f5584961 - main - graphics/geeqie: don't try to get number of cpu cores from /proc
Date: Wed, 24 Nov 2021 17:39:11 UTC
## Dmitry Marakasov (amdmi3@FreeBSD.org): > graphics/geeqie: don't try to get number of cpu cores from /proc Sometimes it's very obvious that nobody reads APUE anymore. How about this? It's POSIX and not more wrong as the original. (And 5 lines, two of which are blank). --- src/misc.c.orig 2021-11-24 18:28:48.794664000 +0100 +++ src/misc.c 2021-11-24 18:31:07.753874000 +0100 @@ -378,29 +378,11 @@ gint get_cpu_cores(void) { - FILE *cpuinfo = fopen("/proc/cpuinfo", "rb"); - char *arg = 0; - size_t size = 0; - int cores = 1; - gchar *siblings_line; - gchar *siblings_str; + long cores; - while(getline(&arg, &size, cpuinfo) != -1) - { - siblings_line = g_strrstr(arg, "siblings"); - if (siblings_line) - { - siblings_str = g_strrstr(siblings_line, ":"); - if (siblings_str) - { - cores = g_ascii_strtoll(siblings_str + 1, NULL, 0); - } - } - } - free(arg); - fclose(cpuinfo); + cores = sysconf(_SC_NPROCESSORS_ONLN); - return cores; + return cores > 0 ? (gint) cores : 1; } void tree_path_free_wrapper(void *data, void *useradata) Regards, Christoph -- Spare Space