diff options
| author | Ruslan Mustakov | 2017-07-19 18:49:19 +0700 |
|---|---|---|
| committer | Ruslan Mustakov | 2017-07-25 10:53:31 +0700 |
| commit | 3b88476130aa2fe1af7d089cd18a9abc72e23678 (patch) | |
| tree | cdd2b6c92cef2b8816a30aa86880125135b6d866 /core/os/os.cpp | |
| parent | b31973b64de038a1d2dfaa1fcea0c72ee5ce012b (diff) | |
| download | godot-3b88476130aa2fe1af7d089cd18a9abc72e23678.tar.gz godot-3b88476130aa2fe1af7d089cd18a9abc72e23678.tar.zst godot-3b88476130aa2fe1af7d089cd18a9abc72e23678.zip | |
Add a way to retrieve stack bottom of the main thread
I'm working on Nim bindings and Nim GC needs to know the stack
boundaries to check whether certain pointers are located on the stack
or in the heap. This commit adds godot_get_stack_bottom procedure
to gdnative module which returns pointer to the stack bottom of the
main thread. Later on this may be improved to return stack bottom of
the current thread.
Diffstat (limited to 'core/os/os.cpp')
| -rw-r--r-- | core/os/os.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index 5a9766891..8e4c35719 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -512,7 +512,13 @@ bool OS::check_feature_support(const String &p_feature) { return false; } +void *OS::get_stack_bottom() const { + return _stack_bottom; +} + OS::OS() { + void *volatile stack_bottom; + last_error = NULL; singleton = this; _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0. @@ -525,6 +531,7 @@ OS::OS() { _render_thread_mode = RENDER_THREAD_SAFE; _allow_hidpi = true; + _stack_bottom = (void *)(&stack_bottom); } OS::~OS() { |
