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