summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authortake_cheeze <[email protected]>2014-06-16 16:03:35 +0900
committertake_cheeze <[email protected]>2014-06-16 16:03:35 +0900
commit62f41ddd3bf8a1afa3d7ed94081835f8996ecbc4 (patch)
tree75942827a4f3092792834d6ff0d5bad4db3ca2ec /include
parent0042e586db875fca2631c243cb41599e9782b05a (diff)
downloadmruby-62f41ddd3bf8a1afa3d7ed94081835f8996ecbc4.tar.gz
mruby-62f41ddd3bf8a1afa3d7ed94081835f8996ecbc4.zip
Add fixed state atexit stack feature.
Adds following macros: * MRB_FIXED_STATE_ATEXIT_STACK (not defined by default) * When defined enables fixed state atexit stack. * MRB_FIXED_STATE_ATEXIT_STACK_SIZE (default value: 5) * This macro will be ignored when `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined. * When `mrb_state_atexit` is called more than this value it will raise runtime error.
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h6
-rw-r--r--include/mruby.h8
2 files changed, 14 insertions, 0 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index c84b32cd8..ac33ff0bf 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -59,6 +59,12 @@
/* fixed size GC arena */
//#define MRB_GC_FIXED_ARENA
+/* state atexit stack size */
+//#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
+
+/* fixed size state atexit stack */
+//#define MRB_FIXED_STATE_ATEXIT_STACK
+
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
diff --git a/include/mruby.h b/include/mruby.h
index dcc01b2dd..7b9f1b428 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -52,6 +52,10 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
#define MRB_GC_ARENA_SIZE 100
#endif
+#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
+#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
+#endif
+
typedef struct {
mrb_sym mid;
struct RProc *proc;
@@ -173,7 +177,11 @@ typedef struct mrb_state {
void *ud; /* auxiliary data */
+#ifdef MRB_FIXED_STATE_ATEXIT_STACK
+ mrb_atexit_func atexit_stack[MRB_FIXED_STATE_ATEXIT_STACK_SIZE];
+#else
mrb_atexit_func *atexit_stack;
+#endif
mrb_int atexit_stack_len;
} mrb_state;