Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
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
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
Avionics
Software Development
Miosix Kernel
Commits
243f0470
Commit
243f0470
authored
4 years ago
by
Federico
Browse files
Options
Downloads
Patches
Plain Diff
Added support for clock_getres
parent
00f033b2
Branches
Branches containing commit
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miosix/stdlib_integration/libc_integration.cpp
+10
-2
10 additions, 2 deletions
miosix/stdlib_integration/libc_integration.cpp
with
10 additions
and
2 deletions
miosix/stdlib_integration/libc_integration.cpp
+
10
−
2
View file @
243f0470
...
...
@@ -47,7 +47,7 @@
//// kernel interface
#include
"kernel/kernel.h"
#include
"interfaces/bsp.h"
#include
"interfaces/
delays
.h"
#include
"interfaces/
cstimer
.h"
#include
"board_settings.h"
using
namespace
std
;
...
...
@@ -935,6 +935,7 @@ inline void ll2timespec(long long ns, struct timespec *tp)
tp
->
tv_sec
=
a
;
tp
->
tv_nsec
=
static_cast
<
long
>
(
b
);
#else //__ARM_EABI__
#warning Warning POSIX time API not optimized for this platform
tp
->
tv_sec
=
ns
/
nsPerSec
;
tp
->
tv_nsec
=
static_cast
<
long
>
(
ns
%
nsPerSec
);
#endif //__ARM_EABI__
...
...
@@ -957,8 +958,15 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
int
clock_getres
(
clockid_t
clock_id
,
struct
timespec
*
res
)
{
if
(
res
==
nullptr
)
return
-
1
;
//TODO: support CLOCK_REALTIME
//Integer division with round-to-nearest for better accuracy
auto
&
timer
=
miosix
::
ContextSwitchTimer
::
instance
();
int
resolution
=
2
*
nsPerSec
/
timer
.
getTimerFrequency
();
resolution
=
(
resolution
&
1
)
?
resolution
/
2
+
1
:
resolution
/
2
;
res
->
tv_sec
=
0
;
res
->
tv_nsec
=
1
;
//TODO: get resolution from hardware timer
res
->
tv_nsec
=
resolution
;
return
0
;
}
...
...
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