coroutine: Stack allocation
authorDavid Gibson <david@gibson.dropbear.id.au>
Fri, 20 Jan 2017 12:49:43 +0000 (23:49 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 24 Jan 2017 10:22:27 +0000 (21:22 +1100)
commitb4f0767d388c7f3629666400f48ede1a7b4be7f5
tree641a3c8d0eec913d57a55feb7650a24237438365
parentfe3995b4e626466ab211e37392f8500f1fffb5c7
coroutine: Stack allocation

At present, coroutine stacks must be allocated explicitly by the user,
then initialized with coroutine_stack_init().  This adds a new
coroutine_stack_alloc() function which allocates a stack, making life
easier for users.  coroutine_stack_release() will automatically determine
if the given stack was set up with _init() or alloc() and act
accordingly.

The stacks are allocate with mmap() rather than a plain malloc(), and a
guard page is added, so an overflow of the stack should result in a
relatively debuggable SEGV instead of random data corruption.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/coroutine/coroutine.c
ccan/coroutine/coroutine.h
ccan/coroutine/test/api-1.c
ccan/coroutine/test/api-2.c
ccan/coroutine/test/api-3.c