summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorRuslan Mustakov <r.mustakov@gmail.com>2017-07-19 18:49:19 +0700
committerRuslan Mustakov <r.mustakov@gmail.com>2017-07-25 10:53:31 +0700
commit3b88476130aa2fe1af7d089cd18a9abc72e23678 (patch)
treecdd2b6c92cef2b8816a30aa86880125135b6d866 /modules/gdnative
parentb31973b64de038a1d2dfaa1fcea0c72ee5ce012b (diff)
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 'modules/gdnative')
-rw-r--r--modules/gdnative/godot/gdnative.cpp5
-rw-r--r--modules/gdnative/godot/gdnative.h4
2 files changed, 9 insertions, 0 deletions
diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/godot/gdnative.cpp
index 7b94b75a52..29b499ebab 100644
--- a/modules/gdnative/godot/gdnative.cpp
+++ b/modules/gdnative/godot/gdnative.cpp
@@ -33,6 +33,7 @@
#include "error_macros.h"
#include "gdnative.h"
#include "global_constants.h"
+#include "os/os.h"
#include "project_settings.h"
#include "variant.h"
@@ -89,6 +90,10 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name) {
return (godot_object *)ProjectSettings::get_singleton()->get_singleton_object(String(p_name));
} // result shouldn't be freed
+void GDAPI *godot_get_stack_bottom() {
+ return OS::get_singleton()->get_stack_bottom();
+}
+
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h
index 4b79706b52..510bf36cd4 100644
--- a/modules/gdnative/godot/gdnative.h
+++ b/modules/gdnative/godot/gdnative.h
@@ -245,6 +245,10 @@ void GDAPI godot_object_destroy(godot_object *p_o);
godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed
+////// OS API
+
+void GDAPI *godot_get_stack_bottom(); // returns stack bottom of the main thread
+
////// MethodBind API
typedef struct {