Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
28
Issues
28
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
d529ae44
Commit
d529ae44
authored
Apr 05, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include/wrc-task: add an helper for periodic tasks
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
ed59a870
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
wrc-task.h
include/wrc-task.h
+22
-1
No files found.
include/wrc-task.h
View file @
d529ae44
...
...
@@ -9,7 +9,7 @@
/*
* A task is a data structure, but currently suboptimal.
* FIXME: init must return int, and both should get a pointer to data
*
FIXME: provide a jiffy-based period
.
*
(but doing this is heavy, and forces to change the submodule too)
.
*/
struct
wrc_task
{
...
...
@@ -23,6 +23,27 @@ struct wrc_task {
unsigned
long
nanos
;
};
/* An helper for periodic tasks, relying on a static varible */
static
inline
int
__task_not_yet
(
uint32_t
*
lastt
,
unsigned
period
,
uint32_t
now
)
{
if
(
!*
lastt
)
{
*
lastt
=
now
;
return
0
;
}
if
(
time_before
(
now
,
*
lastt
+
period
))
return
1
;
/* not yet */
*
lastt
+=
period
;
return
0
;
}
static
inline
int
task_not_yet
(
uint32_t
*
lastt
,
unsigned
period
)
{
return
__task_not_yet
(
lastt
,
period
,
timer_get_tics
());
}
/* Put the tasks in their own section */
#define DEFINE_WRC_TASK(_name) \
static struct wrc_task __task_ ## _name \
...
...
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