]> git.ipfire.org Git - people/arne_f/kernel.git/blobdiff - include/linux/sched.h
Merge branch 'linus' into sched/core, to pick up fixes
[people/arne_f/kernel.git] / include / linux / sched.h
index c05ac5f5aa034db128e9abcdd02e176f21904b8b..2a65eebadf63301ca03e09a5b883778b401484f8 100644 (file)
@@ -1232,6 +1232,19 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
        return task_pgrp_nr_ns(tsk, &init_pid_ns);
 }
 
+static inline char task_state_to_char(struct task_struct *task)
+{
+       const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
+       unsigned long state = task->state;
+
+       state = state ? __ffs(state) + 1 : 0;
+
+       /* Make sure the string lines up properly with the number of task states: */
+       BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);
+
+       return state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?';
+}
+
 /**
  * is_global_init - check if a task structure is init. Since init
  * is free to have sub-threads we need to check tgid.