Implement print and min/max for Microseconds and Milliseconds
Ref #3050
This commit is contained in:
parent
8f43a1303b
commit
9c7d5b2a66
|
@ -360,7 +360,7 @@ _ZNK6Genode6Thread4nameEv T
|
||||||
_ZNK6Genode6Thread9stack_topEv T
|
_ZNK6Genode6Thread9stack_topEv T
|
||||||
_ZNK6Genode8Duration17trunc_to_plain_msEv T
|
_ZNK6Genode8Duration17trunc_to_plain_msEv T
|
||||||
_ZNK6Genode8Duration17trunc_to_plain_usEv T
|
_ZNK6Genode8Duration17trunc_to_plain_usEv T
|
||||||
_ZNK6Genode8Duration9less_thanERS0_ T
|
_ZNK6Genode8Duration9less_thanERKS0_ T
|
||||||
_ZNKSt13bad_exception4whatEv T
|
_ZNKSt13bad_exception4whatEv T
|
||||||
_ZNKSt9exception4whatEv T
|
_ZNKSt9exception4whatEv T
|
||||||
_ZNSt13bad_exceptionD0Ev T
|
_ZNSt13bad_exceptionD0Ev T
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/stdint.h>
|
#include <base/stdint.h>
|
||||||
#include <base/exception.h>
|
#include <base/exception.h>
|
||||||
|
#include <base/output.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
|
@ -34,6 +35,12 @@ struct Genode::Microseconds
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
explicit Microseconds(unsigned long value) : value(value) { }
|
explicit Microseconds(unsigned long value) : value(value) { }
|
||||||
|
|
||||||
|
void print(Output &out) const
|
||||||
|
{
|
||||||
|
Genode::print(out, value);
|
||||||
|
out.out_string(" us");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +52,12 @@ struct Genode::Milliseconds
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
explicit Milliseconds(unsigned long value) : value(value) { }
|
explicit Milliseconds(unsigned long value) : value(value) { }
|
||||||
|
|
||||||
|
void print(Output &out) const
|
||||||
|
{
|
||||||
|
Genode::print(out, value);
|
||||||
|
out.out_string(" ms");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +87,7 @@ struct Genode::Duration
|
||||||
void add(Microseconds us);
|
void add(Microseconds us);
|
||||||
void add(Milliseconds ms);
|
void add(Milliseconds ms);
|
||||||
|
|
||||||
bool less_than(Duration &other) const;
|
bool less_than(Duration const &other) const;
|
||||||
|
|
||||||
explicit Duration(Milliseconds ms) { add(ms); }
|
explicit Duration(Milliseconds ms) { add(ms); }
|
||||||
explicit Duration(Microseconds us) { add(us); }
|
explicit Duration(Microseconds us) { add(us); }
|
||||||
|
@ -83,4 +96,23 @@ struct Genode::Duration
|
||||||
Milliseconds trunc_to_plain_ms() const;
|
Milliseconds trunc_to_plain_ms() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace Genode
|
||||||
|
{
|
||||||
|
static inline
|
||||||
|
Microseconds min(Microseconds const x, Microseconds const y) {
|
||||||
|
return (x.value < y.value) ? x : y; }
|
||||||
|
|
||||||
|
static inline
|
||||||
|
Microseconds max(Microseconds const x, Microseconds const y) {
|
||||||
|
return (x.value > y.value) ? x : y; }
|
||||||
|
|
||||||
|
static inline
|
||||||
|
Milliseconds min(Milliseconds const x, Milliseconds const y) {
|
||||||
|
return (x.value < y.value) ? x : y; }
|
||||||
|
|
||||||
|
static inline
|
||||||
|
Milliseconds max(Milliseconds const x, Milliseconds const y) {
|
||||||
|
return (x.value > y.value) ? x : y; }
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _OS__DURATION_H_ */
|
#endif /* _OS__DURATION_H_ */
|
||||||
|
|
|
@ -66,7 +66,7 @@ void Duration::add(Milliseconds ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Duration::less_than(Duration &other) const
|
bool Duration::less_than(Duration const &other) const
|
||||||
{
|
{
|
||||||
if (_hours != other._hours) {
|
if (_hours != other._hours) {
|
||||||
return _hours < other._hours; }
|
return _hours < other._hours; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user