From 7469011f4f4bd42c5270e919e88ac6eefc06fe67 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sat, 24 Feb 2024 05:02:46 +0100 Subject: [PATCH] Correct syscall name SYS_get_cpu used with old glibc where getcpu() is missing. Handle both SYS_get_cpu and SYS_getcpu, even though I am unsure if both ever existed, and make sure to error out if neither of them are available. Fixes #1894. --- ggml.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ggml.c b/ggml.c index d710fe702dd..8241843ca01 100644 --- a/ggml.c +++ b/ggml.c @@ -2084,8 +2084,17 @@ void ggml_numa_init(enum ggml_numa_strategy numa_flag) { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 28) getcpu_ret = getcpu(¤t_cpu, &g_state.numa.current_node); #else - // old glibc doesn't have a wrapper for this call. Fall back on direct syscall - getcpu_ret = syscall(SYS_getcpu,¤t_cpu,&g_state.numa.current_node); + // old glibc doesn't have a wrapper for this call. Fall back on + // direct syscall + getcpu_ret = syscall( +# if defined(SYS_getcpu) + SYS_getcpu, +# elif defined(SYS_get_cpu) + SYS_get_cpu, +# else +# error "Unable fo find getcpu syscall define" +# endif /* SYS_getcpu */ + ¤t_cpu,&g_state.numa.current_node); #endif if (g_state.numa.n_nodes < 1 || g_state.numa.total_cpus < 1 || getcpu_ret != 0) {