]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
618234a5 LP |
2 | #pragma once |
3 | ||
618234a5 LP |
4 | #include <sched.h> |
5 | ||
6 | #include "macro.h" | |
7 | ||
501941aa YW |
8 | #ifdef __NCPUBITS |
9 | #define CPU_SIZE_TO_NUM(n) ((n) * __NCPUBITS) | |
10 | #else | |
11 | #define CPU_SIZE_TO_NUM(n) ((n) * sizeof(cpu_set_t) * 8) | |
12 | #endif | |
13 | ||
618234a5 LP |
14 | DEFINE_TRIVIAL_CLEANUP_FUNC(cpu_set_t*, CPU_FREE); |
15 | #define _cleanup_cpu_free_ _cleanup_(CPU_FREEp) | |
16 | ||
a9a2ed3f YW |
17 | static inline cpu_set_t* cpu_set_mfree(cpu_set_t *p) { |
18 | if (p) | |
19 | CPU_FREE(p); | |
20 | return NULL; | |
21 | } | |
22 | ||
618234a5 LP |
23 | cpu_set_t* cpu_set_malloc(unsigned *ncpus); |
24 | ||
6d8a29b2 YW |
25 | int parse_cpu_set_internal(const char *rvalue, cpu_set_t **cpu_set, bool warn, const char *unit, const char *filename, unsigned line, const char *lvalue); |
26 | ||
27 | static inline int parse_cpu_set_and_warn(const char *rvalue, cpu_set_t **cpu_set, const char *unit, const char *filename, unsigned line, const char *lvalue) { | |
28 | assert(lvalue); | |
29 | ||
30 | return parse_cpu_set_internal(rvalue, cpu_set, true, unit, filename, line, lvalue); | |
31 | } | |
32 | ||
33 | static inline int parse_cpu_set(const char *rvalue, cpu_set_t **cpu_set){ | |
34 | return parse_cpu_set_internal(rvalue, cpu_set, false, NULL, NULL, 0, NULL); | |
35 | } |