2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef _LIBROOT_TIME_PRIVATE_H
6 #define _LIBROOT_TIME_PRIVATE_H
10 #include <sys/cdefs.h>
14 #include <SupportDefs.h>
18 #define CLOCKS_PER_SEC_BEOS 1000
19 #define CLK_TCK_BEOS CLOCKS_PER_SEC_BEOS
21 #define MICROSECONDS_PER_CLOCK_TICK (1000000 / CLOCKS_PER_SEC)
22 #define MICROSECONDS_PER_CLOCK_TICK_BEOS (1000000 / CLOCKS_PER_SEC_BEOS)
29 void SetTo(int32 id
, thread_id thread
)
32 this->thread
= thread
;
38 bigtime_to_timespec(bigtime_t time
, timespec
& spec
)
40 spec
.tv_sec
= time
/ 1000000;
41 spec
.tv_nsec
= (time
% 1000000) * 1000;
46 timespec_to_bigtime(const timespec
& spec
, bigtime_t
& _time
)
48 if (spec
.tv_sec
< 0 || spec
.tv_nsec
< 0 || spec
.tv_nsec
>= 1000000000)
51 _time
= (bigtime_t
)spec
.tv_sec
* 1000000 + (spec
.tv_nsec
+ 999) / 1000;
58 timeval_to_timespec(const timeval
& val
, timespec
& spec
)
60 if (val
.tv_sec
< 0 || val
.tv_usec
< 0 || val
.tv_usec
>= 1000000)
63 spec
.tv_sec
= val
.tv_sec
;
64 spec
.tv_nsec
= val
.tv_usec
* 1000;
71 timespec_to_timeval(const timespec
& spec
, timeval
& val
)
73 val
.tv_sec
= spec
.tv_sec
;
74 val
.tv_usec
= spec
.tv_nsec
/ 1000;
81 clock_t __clock_beos(void);
82 clock_t __clock(void);
88 #endif // _LIBROOT_TIME_PRIVATE_H