This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Fri, May 24, 2013 at 03:29:43PM +0100, Jonathan Wakely wrote:
> >> in the latter). And there is no conversion in between the two.
> >>
> >> Perhaps I'd have to do something like:
> >> return time_point(system_clock::now().time_since_epoch());
> >> ? Can try that.
> >
> > Ah, but the duration can be different depending on macros.
>
> You can convert between durations: with duration_cast:
>
> return time_point(duration_cast<duration>(system_clock::now().time_since_epoch()));
Actually return time_point(system_clock::now().time_since_epoch());
seems to work too, there is a ctor for that:
template<typename _Rep2, typename _Period2, typename = typename
enable_if<treat_as_floating_point<rep>::value
|| (ratio_divide<_Period2, period>::den == 1
&& !treat_as_floating_point<_Rep2>::value)>::type>
constexpr duration(const duration<_Rep2, _Period2>& __d)
: __r(duration_cast<duration>(__d).count()) { }
I've tried a configuration where system_clock::now() used gettimeofday
and system_clock duration was in microseconds and steady_clock was
the non-steady one, but with nanoseconds resolution, and system_clock::now()
then contains
call gettimeofday
movq (%rsp), %rax
imulq $1000000, %rax, %rax
addq 8(%rsp), %rax
(1000000 * tv.tv_sec + tv.tv_usec) and steady_clock::now()
call _ZNSt6chrono12system_clock3nowEv
imulq $1000, %rax, %rax
so it converts correctly.
So, adjusted patches attached, ok for trunk/4.8 if they pass
bootstrap/regtest? Guess Rainer will need to on top of that adjust
Solaris baseline_symbols.txt files.
Jakub
Attachment:
49
Description: Text document
Attachment:
48
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |