Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
8c478912
Commit
8c478912
authored
Apr 28, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed annoying bug on MacOS X
parent
23b3dee4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
src/fiber.cpp
src/fiber.cpp
+19
-9
No files found.
src/fiber.cpp
View file @
8c478912
...
...
@@ -138,12 +138,22 @@ struct fiber_impl
void
*
m_stack
;
void
(
*
m_func
)(
void
*
);
void
*
m_arg
;
# ifdef __APPLE__
// ucontext implementation on macosx kinda sucks
static
constexpr
size_t
ucontext_size
=
sizeof
(
ucontext_t
)
+
60
;
char
m_ctx_storage
[
sizeof
(
ucontext_t
)
+
60
];
inline
ucontext_t
*
ctx
()
{
return
reinterpret_cast
<
ucontext_t
*>
(
m_ctx_storage
);
}
# else
static
constexpr
size_t
ucontext_size
=
sizeof
(
ucontext_t
);
ucontext_t
m_ctx
;
inline
ucontext_t
*
ctx
()
{
return
&
m_ctx
;
}
# endif
fiber_impl
()
throw
()
:
m_initialized
(
true
),
m_stack
(
0
),
m_func
(
0
),
m_arg
(
0
)
{
memset
(
&
m_ctx
,
0
,
sizeof
(
ucontext_t
)
);
getcontext
(
&
m_ctx
);
memset
(
ctx
(),
0
,
ucontext_size
);
getcontext
(
ctx
()
);
}
fiber_impl
(
void
(
*
func
)(
void
*
),
void
*
arg
)
...
...
@@ -156,19 +166,19 @@ struct fiber_impl
inline
void
swap
(
fiber_impl
*
to
)
{
swapcontext
(
&
(
m_ctx
),
&
(
to
->
m_ctx
));
swapcontext
(
ctx
(),
to
->
ctx
(
));
}
void
initialize
()
{
m_initialized
=
true
;
memset
(
&
m_ctx
,
0
,
sizeof
(
ucontext_t
)
);
getcontext
(
&
m_ctx
);
memset
(
ctx
(),
0
,
ucontext_size
);
getcontext
(
ctx
()
);
m_stack
=
get_stack
();
m_ctx
.
uc_stack
.
ss_sp
=
m_stack
;
m_ctx
.
uc_stack
.
ss_size
=
s_stack_size
;
m_ctx
.
uc_link
=
nullptr
;
trampoline
<
sizeof
(
void
*
)
>::
prepare
(
&
m_ctx
,
m_func
,
m_arg
);
ctx
()
->
uc_stack
.
ss_sp
=
m_stack
;
ctx
()
->
uc_stack
.
ss_size
=
s_stack_size
;
ctx
()
->
uc_link
=
nullptr
;
trampoline
<
sizeof
(
void
*
)
>::
prepare
(
ctx
()
,
m_func
,
m_arg
);
}
inline
void
lazy_init
()
...
...
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