util/misc_math.h: remove abs function

Fixes #4766
This commit is contained in:
Norman Feske 2023-02-21 14:42:07 +01:00 committed by Christian Helmuth
parent e09941f310
commit b0e52ba7d4
5 changed files with 8 additions and 3 deletions

View File

@ -22,9 +22,6 @@ namespace Genode {
template <typename T1, typename T2>
static constexpr T1 min(T1 v1, T2 v2) { return v1 < v2 ? v1 : v2; }
template <typename T>
static constexpr T abs(T value) { return value >= 0 ? value : -value; }
/*
* Alignment to the power of two

View File

@ -84,6 +84,8 @@ void Avl_node_base::_rebalance_subtree(Avl_node_base *node, Policy &policy)
{
int v = node->_child_depth(RIGHT) - node->_child_depth(LEFT);
auto abs = [] (auto v) { return v >= 0 ? v : -v; };
/* return if subtree is in balance */
if (abs(v) < 2) return;

View File

@ -139,6 +139,8 @@ struct Line_painter
long const dx_f = x2.value - x1.value,
dy_f = y2.value - y1.value;
auto abs = [] (auto v) { return v >= 0 ? v : -v; };
long const num_steps = max(abs(dx_f) + 127, abs(dy_f) + 127) >> 8;
if (num_steps == 0)

View File

@ -672,6 +672,8 @@ struct Menu_view::Depgraph_widget : Widget
x4 = p2.x(),
y4 = p2.y();
auto abs = [] (auto v) { return v >= 0 ? v : -v; };
/* subdivide the curve depending on the size of its bounding box */
unsigned const levels = (unsigned)max(log2(max(abs(x4 - x1), abs(y4 - y1)) >> 2), 3);

View File

@ -66,6 +66,8 @@ class Genode::Point
void print(Output &out) const
{
auto abs = [] (auto v) { return v >= 0 ? v : -v; };
Genode::print(out, _x >= 0 ? "+" : "-", abs(_x),
_y >= 0 ? "+" : "-", abs(_y));
}