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
2731a442
Commit
2731a442
authored
4 years ago
by
Federico
Browse files
Options
Downloads
Patches
Plain Diff
Optimized ll2timespec
parent
cdee3527
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miosix/stdlib_integration/libc_integration.cpp
+17
-2
17 additions, 2 deletions
miosix/stdlib_integration/libc_integration.cpp
with
17 additions
and
2 deletions
miosix/stdlib_integration/libc_integration.cpp
+
17
−
2
View file @
2731a442
...
@@ -929,8 +929,23 @@ inline long long timespec2ll(const struct timespec *tp)
...
@@ -929,8 +929,23 @@ inline long long timespec2ll(const struct timespec *tp)
*/
*/
inline
void
ll2timespec
(
long
long
tick
,
struct
timespec
*
tp
)
inline
void
ll2timespec
(
long
long
tick
,
struct
timespec
*
tp
)
{
{
#ifdef __ARM_EABI__
// Despite there being a single intrinsic, __aeabi_ldivmod, that computes
// both the result of the / and % operator, GCC 9.2.0 isn't smart enough and
// calls the intrinsic twice. This asm implementation saves ~115 cycles
// by calling it once. Sadly, I had to use asm as the calling conventions
// of the intrinsic appear to be nonstandard.
// NOTE: actually a and b, by being 64 bit numbers, occupy register pairs
register
long
long
a
asm
(
"r0"
)
=
tick
;
register
long
long
b
asm
(
"r2"
)
=
miosix
::
TICK_FREQ
;
// NOTE: clobbering lr to mark function not leaf due to the bl
asm
volatile
(
"bl __aeabi_ldivmod"
:
"+r"
(
a
),
"+r"
(
b
)
::
"lr"
);
tp
->
tv_sec
=
a
;
tp
->
tv_nsec
=
static_cast
<
long
>
(
b
)
*
tickNsFactor
;
#else //__ARM_EABI__
tp
->
tv_sec
=
tick
/
miosix
::
TICK_FREQ
;
tp
->
tv_sec
=
tick
/
miosix
::
TICK_FREQ
;
tp
->
tv_nsec
=
static_cast
<
long
>
(
tick
%
miosix
::
TICK_FREQ
)
*
tickNsFactor
;
tp
->
tv_nsec
=
static_cast
<
long
>
(
tick
%
miosix
::
TICK_FREQ
)
*
tickNsFactor
;
#endif //__ARM_EABI__
}
}
int
clock_gettime
(
clockid_t
clock_id
,
struct
timespec
*
tp
)
int
clock_gettime
(
clockid_t
clock_id
,
struct
timespec
*
tp
)
...
...
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