Proposed method for dealing with stack locals which have non-local lifetime.

This commit is contained in:
Samuel Williams 2020-11-10 10:21:14 +13:00
parent 15e23312f6
commit 3b5b309b7b
Notes: git 2020-12-05 07:39:29 +09:00
4 changed files with 76 additions and 51 deletions

16
coroutine/Stack.h Normal file
View file

@ -0,0 +1,16 @@
/*
* This file is part of the "Coroutine" project and released under the MIT License.
*
* Created by Samuel Williams on 10/11/2020.
* Copyright, 2020, by Samuel Williams.
*/
#include COROUTINE_H
#ifdef COROUTINE_PRIVATE_STACK
#define COROUTINE_STACK_LOCAL(type, name) type *name = ruby_xmalloc(sizeof(type))
#define COROUTINE_STACK_FREE(name) ruby_xfree(name)
#else
#define COROUTINE_STACK_LOCAL(type, name) type name##_local; type * name = &name##_local
#define COROUTINE_STACK_FREE(name)
#endif