Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
abb682ea
Commit
abb682ea
authored
Jun 17, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2401 from take-cheeze/fixed_state_atexit_stack
Add fixed state atexit stack feature.
parents
d9985631
62f41ddd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
include/mrbconf.h
include/mrbconf.h
+6
-0
include/mruby.h
include/mruby.h
+8
-0
src/state.c
src/state.c
+8
-0
No files found.
include/mrbconf.h
View file @
abb682ea
...
@@ -59,6 +59,12 @@
...
@@ -59,6 +59,12 @@
/* fixed size GC arena */
/* fixed size GC arena */
//#define MRB_GC_FIXED_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 */
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
//#define DISABLE_STDIO /* use of stdio */
...
...
include/mruby.h
View file @
abb682ea
...
@@ -52,6 +52,10 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
...
@@ -52,6 +52,10 @@ typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
#define MRB_GC_ARENA_SIZE 100
#define MRB_GC_ARENA_SIZE 100
#endif
#endif
#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
#endif
typedef
struct
{
typedef
struct
{
mrb_sym
mid
;
mrb_sym
mid
;
struct
RProc
*
proc
;
struct
RProc
*
proc
;
...
@@ -173,7 +177,11 @@ typedef struct mrb_state {
...
@@ -173,7 +177,11 @@ typedef struct mrb_state {
void
*
ud
;
/* auxiliary data */
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
;
mrb_atexit_func
*
atexit_stack
;
#endif
mrb_int
atexit_stack_len
;
mrb_int
atexit_stack_len
;
}
mrb_state
;
}
mrb_state
;
...
...
src/state.c
View file @
abb682ea
...
@@ -226,7 +226,9 @@ mrb_close(mrb_state *mrb)
...
@@ -226,7 +226,9 @@ mrb_close(mrb_state *mrb)
for
(
i
=
mrb
->
atexit_stack_len
;
i
>
0
;
--
i
)
{
for
(
i
=
mrb
->
atexit_stack_len
;
i
>
0
;
--
i
)
{
mrb
->
atexit_stack
[
i
-
1
](
mrb
);
mrb
->
atexit_stack
[
i
-
1
](
mrb
);
}
}
#ifndef MRB_FIXED_STATE_ATEXIT_STACK
mrb_free
(
mrb
,
mrb
->
atexit_stack
);
mrb_free
(
mrb
,
mrb
->
atexit_stack
);
#endif
}
}
/* free */
/* free */
...
@@ -268,6 +270,11 @@ mrb_top_self(mrb_state *mrb)
...
@@ -268,6 +270,11 @@ mrb_top_self(mrb_state *mrb)
void
void
mrb_state_atexit
(
mrb_state
*
mrb
,
mrb_atexit_func
f
)
mrb_state_atexit
(
mrb_state
*
mrb
,
mrb_atexit_func
f
)
{
{
#ifdef MRB_FIXED_STATE_ATEXIT_STACK
if
(
mrb
->
atexit_stack_len
+
1
>
MRB_FIXED_STATE_ATEXIT_STACK_SIZE
)
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"exceeded fixed state atexit stack limit"
);
}
#else
size_t
stack_size
;
size_t
stack_size
;
stack_size
=
sizeof
(
mrb_atexit_func
)
*
(
mrb
->
atexit_stack_len
+
1
);
stack_size
=
sizeof
(
mrb_atexit_func
)
*
(
mrb
->
atexit_stack_len
+
1
);
...
@@ -276,6 +283,7 @@ mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f)
...
@@ -276,6 +283,7 @@ mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f)
}
else
{
}
else
{
mrb
->
atexit_stack
=
(
mrb_atexit_func
*
)
mrb_realloc
(
mrb
,
mrb
->
atexit_stack
,
stack_size
);
mrb
->
atexit_stack
=
(
mrb_atexit_func
*
)
mrb_realloc
(
mrb
,
mrb
->
atexit_stack
,
stack_size
);
}
}
#endif
mrb
->
atexit_stack
[
mrb
->
atexit_stack_len
++
]
=
f
;
mrb
->
atexit_stack
[
mrb
->
atexit_stack_len
++
]
=
f
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment