refactor error message-related functions

split message print fuctions (mpr_*), strerrno, and mscp_get/set_error
into print.c/h and strerrno.c/h.

ToDo: revise usages of priv_set_errv and pr_* functions.
This commit is contained in:
Ryo Nakamura
2024-02-06 21:54:04 +09:00
parent 76892a69f9
commit 4f0669f8f8
18 changed files with 268 additions and 292 deletions

View File

@@ -22,9 +22,9 @@
#error unsupported platform
#endif
#include <util.h>
#include <platform.h>
#include <message.h>
#include <strerrno.h>
#include <print.h>
#ifdef __APPLE__
@@ -34,7 +34,7 @@ int nr_cpus()
size_t size = sizeof(n);
if (sysctlbyname("machdep.cpu.core_count", &n, &size, NULL, 0) != 0) {
mscp_set_error("failed to get number of cpu cores: %s", strerrno());
priv_set_errv("failed to get number of cpu cores: %s", strerrno());
return -1;
}
@@ -43,7 +43,7 @@ int nr_cpus()
int set_thread_affinity(pthread_t tid, int core)
{
pr_warn("setting thread afinity is not implemented on apple\n");
pr_warn("setting thread afinity is not implemented on apple");
return 0;
}
@@ -124,8 +124,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)
mscp_set_error("failed to set thread/cpu affinity for core %d: %s",
core, strerrno());
priv_set_errv("failed to set thread/cpu affinity for core %d: %s",
core, strerrno());
return ret;
}