string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends

Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
This commit is contained in:
Daan De Meyer
2026-01-02 04:05:45 +09:00
committed by Yu Watanabe
parent daff8ea8bb
commit aec52c1e6e
139 changed files with 351 additions and 589 deletions
+2 -5
View File
@@ -107,11 +107,8 @@ const char* personality_to_string(unsigned long);
int safe_personality(unsigned long p);
int opinionated_personality(unsigned long *ret);
const char* sigchld_code_to_string(int i) _const_;
int sigchld_code_from_string(const char *s) _pure_;
int sched_policy_to_string_alloc(int i, char **ret);
int sched_policy_from_string(const char *s);
DECLARE_STRING_TABLE_LOOKUP(sigchld_code, int);
DECLARE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int);
static inline pid_t PTR_TO_PID(const void *p) {
return (pid_t) ((uintptr_t) p);