zephyr/kernel
Andrew Boie 507852a4ad kernel: introduce opaque data type for stacks
Historically, stacks were just character buffers and could be treated
as such if the user wanted to look inside the stack data, and also
declared as an array of the desired stack size.

This is no longer the case. Certain architectures will create a memory
region much larger to account for MPU/MMU guard pages. Unfortunately,
the kernel interfaces treat both the declared stack, and the valid
stack buffer within it as the same char * data type, even though these
absolutely cannot be used interchangeably.

We introduce an opaque k_thread_stack_t which gets instantiated by
K_THREAD_STACK_DECLARE(), this is no longer treated by the compiler
as a character pointer, even though it really is.

To access the real stack buffer within, the result of
K_THREAD_STACK_BUFFER() can be used, which will return a char * type.

This should catch a bunch of programming mistakes at build time:

- Declaring a character array outside of K_THREAD_STACK_DECLARE() and
  passing it to K_THREAD_CREATE
- Directly examining the stack created by K_THREAD_STACK_DECLARE()
  which is not actually the memory desired and may trigger a CPU
  exception

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-01 16:43:15 -07:00
..
configs
include kernel: introduce opaque data type for stacks 2017-08-01 16:43:15 -07:00
Kconfig dts: Generate Kinetis adc settings from device tree 2017-07-19 14:28:08 -05:00
Kconfig.event_logger
Kconfig.power_mgmt doc: spelling fixes in Kconfig files 2017-06-12 19:40:51 -04:00
Makefile
alert.c kernel: make K_.*_INITIALIZER private to kernel 2017-07-10 11:44:56 -07:00
atomic_c.c
compiler_stack_protect.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
device.c
errno.c
idle.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
init.c x86: page-aligned stacks with guard page 2017-07-25 11:32:36 -04:00
int_latency_bench.c
mailbox.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
mem_slab.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
mempool.c mem_pool: Don't check level_empty() before breaking a block 2017-07-31 09:14:59 -07:00
msg_q.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
mutex.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
pipes.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
poll.c
queue.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
sched.c kernel: fix short time-slice reset 2017-06-02 14:47:01 -04:00
sem.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
stack.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
sys_clock.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
system_work_q.c kernel: introduce stack definition macros 2017-06-09 18:53:28 -04:00
thread.c kernel: introduce opaque data type for stacks 2017-08-01 16:43:15 -07:00
thread_abort.c linker: move all linker headers to include/linker 2017-06-18 09:24:04 -05:00
timer.c kernel: make sure that CONFIG_OBJECT_TRACING structs are properly ifdef'ed 2017-05-18 12:41:56 -05:00
version.c
work_q.c kernel: introduce opaque data type for stacks 2017-08-01 16:43:15 -07:00