base: fix location_of_index affinity calculation

Take care that ypos parameter is smaller than height().
If it is not - wrap around.

Issue #1412.
This commit is contained in:
Alexander Boettcher 2015-02-18 12:06:40 +01:00 committed by Christian Helmuth
parent babe1d1026
commit a594ae703d
1 changed files with 8 additions and 2 deletions

View File

@ -75,7 +75,13 @@ namespace Genode {
}
/**
* Return location of a single CPU of specified index
* Return the location of the Nth CPU within the affinity
* space
*
* This function returns a valid location even if the index
* is larger than the number of CPUs in the space. In this
* case, the x and y coordinates are wrapped by the bounds
* of the space.
*/
inline Location location_of_index(int index);
};
@ -178,7 +184,7 @@ namespace Genode {
Affinity::Location Affinity::Space::location_of_index(int index)
{
return Location(index % _width, index / _width, 1, 1);
return Location(index % _width, (index / _width) % _height, 1, 1);
}
}