add message.h and message.c, mscp_set|get_error()

Instead of pr_err(), libmscp uses mscp_set_error() and
applications use mscp_get_errror() to get error message.
This commit is contained in:
Ryo Nakamura
2023-03-03 21:29:43 +09:00
parent c5aa70d9c9
commit 1b9ae51974
11 changed files with 191 additions and 120 deletions

View File

@@ -10,6 +10,7 @@
#include <util.h>
#include <platform.h>
#include <message.h>
#ifdef __APPLE__
int nr_cpus()
@@ -18,7 +19,7 @@ int nr_cpus()
size_t size = sizeof(n);
if (sysctlbyname("machdep.cpu.core_count", &n, &size, NULL, 0) != 0) {
pr_err("failed to get number of cpu cores: %s\n", strerrno());
mscp_set_error("failed to get number of cpu cores: %s", strerrno());
return -1;
}
@@ -51,8 +52,8 @@ int set_thread_affinity(pthread_t tid, int core)
CPU_SET(core, &target_cpu_set);
ret = pthread_setaffinity_np(tid, sizeof(target_cpu_set), &target_cpu_set);
if (ret < 0)
pr_err("failed to set thread/cpu affinity for core %d: %s",
core, strerrno());
mscp_set_error("failed to set thread/cpu affinity for core %d: %s",
core, strerrno());
return ret;
}
#endif