Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michel Tallon
tao-rt-test-doxygen
Commits
20dd01d6
Commit
20dd01d6
authored
Dec 15, 2021
by
Éric Thiébaut
Browse files
Use inline functions
parent
eeb1b751
Changes
1
Hide whitespace changes
Inline
Side-by-side
base/utils.c
View file @
20dd01d6
...
...
@@ -155,7 +155,7 @@ tao_status tao_parse_double(
#if defined(CLOCK_REALTIME) && defined(CLOCK_MONOTONIC)
static
tao_status
get_time
(
static
inline
tao_status
get_time
(
int
id
,
tao_time
*
t
)
{
...
...
@@ -175,7 +175,7 @@ static tao_status get_time(
// Use gettimeofday as an ersatz for clock_gettime.
# define CLOCK_REALTIME 0
# define CLOCK_MONOTONIC 1
static
tao_status
get_time
(
static
inline
tao_status
get_time
(
int
id
,
tao_time
*
t
)
{
...
...
@@ -204,9 +204,7 @@ static tao_status get_time(
}
#else
# error CLOCK_REALTIME and CLOCK_MONOTONIC not both defined nor both undefined
# error CLOCK_REALTIME and CLOCK_MONOTONIC not both defined nor both undefined
#endif
tao_status
tao_get_monotonic_time
(
...
...
@@ -265,61 +263,76 @@ tao_time* tao_subtract_times(
return
dest
;
}
#define TO_SECONDS( s, ns) ( (double)(s) + 1E-9*(double)(ns))
#define TO_MILLISECONDS(s, ns) (1E3*(double)(s) + 1E-6*(double)(ns))
#define TO_MICROSECONDS(s, ns) (1E6*(double)(s) + 1E-3*(double)(ns))
#define TO_NANOSECONDS( s, ns) (1E9*(double)(s) + (double)(ns))
static
inline
double
to_seconds
(
double
s
,
double
ns
)
{
return
s
+
1E-9
*
ns
;
}
static
inline
double
to_milliseconds
(
double
s
,
double
ns
)
{
return
1E3
*
s
+
1E-6
*
ns
;
}
static
inline
double
to_microseconds
(
double
s
,
double
ns
)
{
return
1E6
*
s
+
1E-3
*
ns
;
}
static
inline
double
to_nanoseconds
(
double
s
,
double
ns
)
{
return
1E9
*
s
+
ns
;
}
double
tao_time_to_seconds
(
const
tao_time
*
t
)
{
return
TO_SECONDS
(
t
->
sec
,
t
->
nsec
);
return
to_seconds
(
t
->
sec
,
t
->
nsec
);
}
double
tao_time_to_milliseconds
(
const
tao_time
*
t
)
{
return
TO_MILLISECONDS
(
t
->
sec
,
t
->
nsec
);
return
to_milliseconds
(
t
->
sec
,
t
->
nsec
);
}
double
tao_time_to_microseconds
(
const
tao_time
*
t
)
{
return
TO_MICROSECONDS
(
t
->
sec
,
t
->
nsec
);
return
to_microseconds
(
t
->
sec
,
t
->
nsec
);
}
double
tao_time_to_nanoseconds
(
const
tao_time
*
t
)
{
return
TO_NANOSECONDS
(
t
->
sec
,
t
->
nsec
);
return
to_nanoseconds
(
t
->
sec
,
t
->
nsec
);
}
double
tao_elapsed_seconds
(
const
tao_time
*
t
,
const
tao_time
*
t0
)
{
return
TO_SECONDS
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
return
to_seconds
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
}
double
tao_elapsed_milliseconds
(
const
tao_time
*
t
,
const
tao_time
*
t0
)
{
return
TO_MILLISECONDS
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
return
to_milliseconds
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
}
double
tao_elapsed_microseconds
(
const
tao_time
*
t
,
const
tao_time
*
t0
)
{
return
TO_MICROSECONDS
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
return
to_microseconds
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
}
double
tao_elapsed_nanoseconds
(
const
tao_time
*
t
,
const
tao_time
*
t0
)
{
return
TO_NANOSECONDS
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
return
to_nanoseconds
(
t
->
sec
-
t0
->
sec
,
t
->
nsec
-
t0
->
nsec
);
}
tao_time
*
tao_seconds_to_time
(
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment