Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
e03e20b7
Commit
e03e20b7
authored
10 years ago
by
René Kijewski
Browse files
Options
Downloads
Patches
Plain Diff
core: simplify mutex initializer
parent
e5d61428
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/include/mutex.h
+13
-5
13 additions, 5 deletions
core/include/mutex.h
core/include/queue.h
+6
-0
6 additions, 0 deletions
core/include/queue.h
core/mutex.c
+0
-9
0 additions, 9 deletions
core/mutex.c
with
19 additions
and
14 deletions
core/include/mutex.h
+
13
−
5
View file @
e03e20b7
...
...
@@ -43,15 +43,23 @@ typedef struct mutex_t {
queue_node_t
queue
;
}
mutex_t
;
/**
* @brief Static initializer for mutex_t.
* @details This initializer is preferrable to mutex_init().
*/
#define MUTEX_INIT { 0, QUEUE_NODE_INIT }
/**
* @brief Initializes a mutex object.
*
* @details For intialization of variables use MUTEX_INIT instead.
* Only use the function call for dynamically allocated mutexes.
* @param[out] mutex pre-allocated mutex structure, must not be NULL.
*
* @return Always returns 1, always succeeds.
*/
int
mutex_init
(
mutex_t
*
mutex
);
static
inline
void
mutex_init
(
mutex_t
*
mutex
)
{
mutex_t
empty_mutex
=
MUTEX_INIT
;
*
mutex
=
empty_mutex
;
}
/**
* @brief Tries to get a mutex, non-blocking.
...
...
This diff is collapsed.
Click to expand it.
core/include/queue.h
+
6
−
0
View file @
e03e20b7
...
...
@@ -20,6 +20,7 @@
#ifndef __QUEUE_H
#define __QUEUE_H
#include
<stddef.h>
#include
<stdint.h>
#include
<inttypes.h>
...
...
@@ -41,6 +42,11 @@ typedef struct queue_node_t {
uint32_t
priority
;
/**< queue node priority */
}
queue_node_t
;
/**
* @brief Static initializer for queue_node_t.
*/
#define QUEUE_NODE_INIT { NULL, 0, 0 }
/**
* @brief attach `new_obj` to the tail of the queue (identified
* `root`)
...
...
This diff is collapsed.
Click to expand it.
core/mutex.c
+
0
−
9
View file @
e03e20b7
...
...
@@ -35,15 +35,6 @@
static
void
mutex_wait
(
struct
mutex_t
*
mutex
);
void
mutex_init
(
struct
mutex_t
*
mutex
)
{
mutex
->
val
=
0
;
mutex
->
queue
.
priority
=
0
;
mutex
->
queue
.
data
=
0
;
mutex
->
queue
.
next
=
NULL
;
}
int
mutex_trylock
(
struct
mutex_t
*
mutex
)
{
DEBUG
(
"%s: trylocking to get mutex. val: %u
\n
"
,
sched_active_thread
->
name
,
mutex
->
val
);
...
...
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