Date: Wed, 24 Nov 2021 18:39:11 +0100 From: Christoph Moench-Tegeder <cmt@burggraben.net> To: Dmitry Marakasov <amdmi3@freebsd.org> Cc: ports-committers@freebsd.org, dev-commits-ports-all@freebsd.org, dev-commits-ports-main@freebsd.org Subject: Re: git: 1cc5f5584961 - main - graphics/geeqie: don't try to get number of cpu cores from /proc Message-ID: <YZ54vy0GRbO%2B4oaD@elch.exwg.net> In-Reply-To: <202111241719.1AOHJQui087071@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
## 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
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YZ54vy0GRbO%2B4oaD>
