Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pico-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microcontroller
pico-sdk
Commits
d06ebe16
Commit
d06ebe16
authored
3 years ago
by
graham sanderson
Browse files
Options
Downloads
Patches
Plain Diff
fix auto_init_recursive_mutex in c++
parent
33818dd0
Branches
recursive_mutex_cxx
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/pico_sync/include/pico/mutex.h
+4
-0
4 additions, 0 deletions
src/common/pico_sync/include/pico/mutex.h
test/kitchen_sink/kitchen_sink.c
+9
-0
9 additions, 0 deletions
test/kitchen_sink/kitchen_sink.c
with
13 additions
and
0 deletions
src/common/pico_sync/include/pico/mutex.h
+
4
−
0
View file @
d06ebe16
...
...
@@ -289,7 +289,11 @@ static inline bool recursive_mutex_is_initialized(recursive_mutex_t *mtx) {
*
* But the initialization of the mutex is performed automatically during runtime initialization
*/
#ifdef __cplusplus
#define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { (spin_lock_t *)1 };
#else
#define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core.spin_lock = (spin_lock_t *)1
/* marker for runtime_init */
}
#endif
#ifdef __cplusplus
}
...
...
This diff is collapsed.
Click to expand it.
test/kitchen_sink/kitchen_sink.c
+
9
−
0
View file @
d06ebe16
...
...
@@ -110,6 +110,9 @@ __force_inline int something_inlined(int x) {
return
x
*
2
;
}
auto_init_mutex
(
mutex
);
auto_init_recursive_mutex
(
recursive_mutex
);
int
main
(
void
)
{
spiggle
();
...
...
@@ -118,6 +121,12 @@ int main(void) {
printf
(
"HI %d
\n
"
,
something_inlined
((
int
)
time_us_32
()));
puts
(
"Hello Everything!"
);
puts
(
"Hello Everything2!"
);
assert
(
mutex_try_enter
(
&
mutex
,
NULL
));
assert
(
!
mutex_try_enter
(
&
mutex
,
NULL
));
assert
(
recursive_mutex_try_enter
(
&
recursive_mutex
,
NULL
));
assert
(
recursive_mutex_try_enter
(
&
recursive_mutex
,
NULL
));
// this should compile as we are Cortex M0+
__asm
volatile
(
"SVC #3"
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment