diff --git a/repos/base/lib/symbols/ld b/repos/base/lib/symbols/ld index 2fb4e1f0a..6117c6056 100644 --- a/repos/base/lib/symbols/ld +++ b/repos/base/lib/symbols/ld @@ -360,7 +360,7 @@ _ZNK6Genode6Thread4nameEv T _ZNK6Genode6Thread9stack_topEv T _ZNK6Genode8Duration17trunc_to_plain_msEv T _ZNK6Genode8Duration17trunc_to_plain_usEv T -_ZNK6Genode8Duration9less_thanERS0_ T +_ZNK6Genode8Duration9less_thanERKS0_ T _ZNKSt13bad_exception4whatEv T _ZNKSt9exception4whatEv T _ZNSt13bad_exceptionD0Ev T diff --git a/repos/os/include/os/duration.h b/repos/os/include/os/duration.h index f9517a19d..b134b75e9 100644 --- a/repos/os/include/os/duration.h +++ b/repos/os/include/os/duration.h @@ -17,6 +17,7 @@ /* Genode includes */ #include #include +#include namespace Genode { @@ -34,6 +35,12 @@ struct Genode::Microseconds unsigned long 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; 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(Milliseconds ms); - bool less_than(Duration &other) const; + bool less_than(Duration const &other) const; explicit Duration(Milliseconds ms) { add(ms); } explicit Duration(Microseconds us) { add(us); } @@ -83,4 +96,23 @@ struct Genode::Duration 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_ */ diff --git a/repos/os/src/lib/timeout/duration.cc b/repos/os/src/lib/timeout/duration.cc index eb49173d9..62ee629ee 100644 --- a/repos/os/src/lib/timeout/duration.cc +++ b/repos/os/src/lib/timeout/duration.cc @@ -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) { return _hours < other._hours; }