kernel: make k_is_pre_kernel safe to call from user mode

Make k_is_pre_kernel safe to call from user mode. Since
z_sys_post_kernel memory is not accessible to user threads, calling
k_is_pre_kernel would result in a memory access fault.

This change adds k_is_user_context guard. It can be assumed the system
is post-kernel if k_is_user_context is true.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2 files changed