Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
PolyORB-HI-C
Commits
6b918336
Commit
6b918336
authored
Mar 13, 2017
by
yoogx
Browse files
* Reorganize usage of clock_gettime()
For issue
#17
parent
559fb158
Changes
2
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
6b918336
...
...
@@ -59,7 +59,7 @@ SIMULINK_LDFLAGS=""
case ${host_os} in
*darwin*)
NATIVE_CFLAGS="${NATIVE_CFLAGS} -DPOSIX -D
NEED_CLOCK_GETTIM
E"
NATIVE_CFLAGS="${NATIVE_CFLAGS} -DPOSIX -D
_XOPEN_SOURC
E"
NATIVE_LDFLAGS="${NATIVE_LDFLAGS} -lpthread"
;;
*solaris*10*)
...
...
src/po_hi_time.c
View file @
6b918336
...
...
@@ -33,10 +33,23 @@
#include
<mach/mach.h>
#endif
#if defined (POSIX) && defined (
NEED
_CLOCK_GETTIME)
#if defined (POSIX) &&
!
defined (
HAVE
_CLOCK_GETTIME)
#include
<sys/time.h>
int
clock_gettime
(
int
clk_id
,
struct
timespec
*
tp
)
{
#ifdef __MACH__
/* OS X prior to Sierra (10.12) does not have clock_gettime, use
clock_get_time
*/
clock_serv_t
cclock
;
mach_timespec_t
mts
;
host_get_clock_service
(
mach_host_self
(),
CALENDAR_CLOCK
,
&
cclock
);
clock_get_time
(
cclock
,
&
mts
);
mach_port_deallocate
(
mach_task_self
(),
cclock
);
ts
.
tv_sec
=
mts
.
tv_sec
;
ts
.
tv_nsec
=
mts
.
tv_nsec
;
#else
struct
timeval
now
;
int
rv
=
gettimeofday
(
&
now
,
NULL
);
...
...
@@ -47,6 +60,7 @@ int clock_gettime(int clk_id, struct timespec *tp)
tp
->
tv_sec
=
now
.
tv_sec
;
tp
->
tv_nsec
=
now
.
tv_usec
*
1000
;
#endif
return
0
;
}
...
...
@@ -82,22 +96,10 @@ int __po_hi_get_time (__po_hi_time_t* mytime)
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
struct
timespec
ts
;
#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
clock_serv_t
cclock
;
mach_timespec_t
mts
;
host_get_clock_service
(
mach_host_self
(),
CALENDAR_CLOCK
,
&
cclock
);
clock_get_time
(
cclock
,
&
mts
);
mach_port_deallocate
(
mach_task_self
(),
cclock
);
ts
.
tv_sec
=
mts
.
tv_sec
;
ts
.
tv_nsec
=
mts
.
tv_nsec
;
#else
if
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
)
!=
0
)
{
return
(
__PO_HI_ERROR_CLOCK
);
}
#endif
mytime
->
sec
=
ts
.
tv_sec
;
mytime
->
nsec
=
ts
.
tv_nsec
;
...
...
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