From f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:52 -0500 Subject: build: Build mlibc + add distclean target Signed-off-by: Ian Moffett --- lib/mlibc/options/linux/generic/cpuset.cpp | 71 ------------------------------ 1 file changed, 71 deletions(-) delete mode 100644 lib/mlibc/options/linux/generic/cpuset.cpp (limited to 'lib/mlibc/options/linux/generic/cpuset.cpp') diff --git a/lib/mlibc/options/linux/generic/cpuset.cpp b/lib/mlibc/options/linux/generic/cpuset.cpp deleted file mode 100644 index d0292b7..0000000 --- a/lib/mlibc/options/linux/generic/cpuset.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include - -cpu_set_t *__mlibc_cpu_alloc(int num_cpus) { - return reinterpret_cast(calloc(1, CPU_ALLOC_SIZE(num_cpus))); -} - -#define CPU_MASK_BITS (CHAR_BIT * sizeof(__cpu_mask)) - -size_t __mlibc_cpu_alloc_size(int num_cpus) { - /* calculate the (unaligned) remainder that doesn't neatly fit in one __cpu_mask; 0 or 1 */ - size_t remainder = ((num_cpus % CPU_MASK_BITS) + CPU_MASK_BITS - 1) / CPU_MASK_BITS; - return sizeof(__cpu_mask) * (num_cpus / CPU_MASK_BITS + remainder); -} - -void __mlibc_cpu_zero(const size_t setsize, cpu_set_t *set) { - memset(set, 0, CPU_ALLOC_SIZE(setsize)); -} - -void __mlibc_cpu_set(const int cpu, const size_t setsize, cpu_set_t *set) { - if(cpu >= static_cast(setsize * CHAR_BIT)) { - return; - } - - unsigned char *ptr = reinterpret_cast(set); - size_t off = cpu / CHAR_BIT; - size_t mask = 1 << (cpu % CHAR_BIT); - - ptr[off] |= mask; -} - -void __mlibc_cpu_clear(const int cpu, const size_t setsize, cpu_set_t *set) { - if(cpu >= static_cast(setsize * CHAR_BIT)) { - return; - } - - unsigned char *ptr = reinterpret_cast(set); - size_t off = cpu / CHAR_BIT; - size_t mask = 1 << (cpu % CHAR_BIT); - - ptr[off] &= ~mask; -} - - -int __mlibc_cpu_isset(const int cpu, const size_t setsize, const cpu_set_t *set) { - if(cpu >= static_cast(setsize * CHAR_BIT)) { - return false; - } - - const unsigned char *ptr = reinterpret_cast(set); - size_t off = cpu / CHAR_BIT; - size_t mask = 1 << (cpu % CHAR_BIT); - - return (ptr[off] & mask); -} - -int __mlibc_cpu_count(const size_t setsize, const cpu_set_t *set) { - size_t count = 0; - const unsigned char *ptr = reinterpret_cast(set); - - for(size_t i = 0; i < setsize; i++) { - for(size_t bit = 0; bit < CHAR_BIT; bit++) { - if((1 << bit) & ptr[i]) - count++; - } - } - - return count; -} -- cgit v1.2.3