basic/missing_*.h: add asserts that the values are as expected

It's great that we provide fallback values, but if we got one of those wrong,
it could be a long time before anyone noticed. So let's add asserts that the
our internal defines actually match the official ones, when the latter are
available.

I did not add '#include "macro.h"' to missing_{audit,capability}, because
those are processed by an awk script that would need additional include
directories and could be confused by the additional lines. We don't include
those headers standalone anyway, so this is not necessary anyway.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-03-20 12:26:16 +01:00
parent 7258971b13
commit 4d6437d33c
17 changed files with 370 additions and 124 deletions
+14 -4
View File
@@ -3,18 +3,26 @@
#include <sched.h>
#include "macro.h"
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
# define CLONE_NEWCGROUP 0x02000000
#else
assert_cc(CLONE_NEWCGROUP == 0x02000000);
#endif
/* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8) */
#ifndef CLONE_NEWTIME
#define CLONE_NEWTIME 0x00000080
# define CLONE_NEWTIME 0x00000080
#else
assert_cc(CLONE_NEWTIME == 0x00000080);
#endif
/* Not exposed yet. Defined at include/linux/sched.h */
#ifndef PF_KTHREAD
#define PF_KTHREAD 0x00200000
# define PF_KTHREAD 0x00200000
#else
assert_cc(PF_KTHREAD == 0x00200000);
#endif
/* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same
@@ -22,5 +30,7 @@
* name nor any other. */
/* Not exposed yet. Defined at include/linux/sched.h */
#ifndef TASK_COMM_LEN
#define TASK_COMM_LEN 16
# define TASK_COMM_LEN 16
#else
assert_cc(TASK_COMM_LEN == 16);
#endif