Debian Codegraph @

src/include/override/sched.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 /* sched.h includes linux/sched/types.h since glibc-2.41 (21571ca0d70302909cf72707b2a7736cf12190a0),
5 * to make struct sched_attr being defined.
6 * Note, this must be included before sched.h, otherwise the headers conflict with each other. */
7 #include <linux/sched.h> /* IWYU pragma: export */
8 #include <linux/sched/types.h> /* IWYU pragma: export */
9
10 #include_next <sched.h> /* IWYU pragma: export */
11
12 #include <assert.h>
13
14 /* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8),
15 * defined in sched.h since glibc-2.36. */
16 #ifndef CLONE_NEWTIME
17 # define CLONE_NEWTIME 0x00000080
18 #else
19 static_assert(CLONE_NEWTIME == 0x00000080, "");
20 #endif
21
22 /* Not exposed yet. Defined at include/linux/sched.h */
23 #ifndef PF_KTHREAD
24 # define PF_KTHREAD 0x00200000
25 #else
26 static_assert(PF_KTHREAD == 0x00200000, "");
27 #endif
28
29 /* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of
30 * the same name, which we need in userspace at various places but is not defined in userspace currently,
31 * neither under this name nor any other.
32 *
33 * Not exposed yet. Defined at include/linux/sched.h */
34 #ifndef TASK_COMM_LEN
35 # define TASK_COMM_LEN 16
36 #else
37 static_assert(TASK_COMM_LEN == 16, "");
38 #endif
39
40 /* glibc does not provide clone() on ia64, only clone2(). Not only that, but it also doesn't provide a
41 * prototype, only the symbol in the shared library (it provides a prototype for clone(), but not the
42 * symbol in the shared library). */
43 #if defined(__ia64__)
44 int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg);
45 #define HAVE_CLONE 0
46 #else
47 /* We know that everywhere else clone() is available, so we don't bother with a meson check (that takes time
48 * at build time) and just define it. Once the kernel drops ia64 support, we can drop this too. */
49 #define HAVE_CLONE 1
50 #endif
51
52 /* Defined since glibc-2.41.
53 * Supported since kernel 3.14 (e6cfc0295c7d51b008999a8b13a44fb43f8685ea). */
54 int sched_setattr_shim(pid_t pid, struct sched_attr *attr, unsigned flags);
55 #define sched_setattr sched_setattr_shim
56
57 /* f0e1a0643a59bf1f922fa209cec86a170b784f3f (6.12),
58 * defined in sched.h in glibc since glibc-2.41. */
59 #ifndef SCHED_EXT
60 # define SCHED_EXT 7
61 #else
62 static_assert(SCHED_EXT == 7, "");
63 #endif