mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 17:06:39 +09:00
Then, make parse_cpu_set() as a tiny wrapper of it. Note, previously when an invalid CPU range, e.g. "3-0", is specified, we ignore the range but allocate an empty set. But, with this commit, now the conf parser simply ignore it without no side effect. This potentially changes behavior of a system with such invalid setting, but the change should be favorable for consistency with other parsers.
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
#include <sched.h>
|
|
|
|
#include "conf-parser-forward.h"
|
|
#include "forward.h"
|
|
|
|
/* This wraps the libc interface with a variable to keep the allocated size. */
|
|
typedef struct CPUSet {
|
|
cpu_set_t *set;
|
|
size_t allocated; /* in bytes */
|
|
} CPUSet;
|
|
|
|
void cpu_set_done(CPUSet *c);
|
|
#define cpu_set_done_and_replace(a, b) \
|
|
({ \
|
|
CPUSet *_a = &(a), *_b = &(b); \
|
|
cpu_set_done(_a); \
|
|
*_a = TAKE_STRUCT(*_b); \
|
|
0; \
|
|
})
|
|
|
|
int cpu_set_realloc(CPUSet *c, size_t n);
|
|
int cpu_set_add(CPUSet *c, size_t i);
|
|
int cpu_set_add_set(CPUSet *c, const CPUSet *src);
|
|
int cpu_set_add_all(CPUSet *c);
|
|
|
|
char* cpu_set_to_string(const CPUSet *c);
|
|
char* cpu_set_to_range_string(const CPUSet *c);
|
|
char* cpu_set_to_mask_string(const CPUSet *c);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_cpu_set);
|
|
int parse_cpu_set(const char *s, CPUSet *ret);
|
|
|
|
int cpu_set_to_dbus(const CPUSet *c, uint8_t **ret, size_t *ret_size);
|
|
int cpu_set_from_dbus(const uint8_t *bits, size_t size, CPUSet *ret);
|
|
|
|
int cpus_in_affinity_mask(void);
|