Skip to content
Snippets Groups Projects
Commit 4f24cb04 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

BugID: 738

Make default alignment max 8
parent 544d5c5b
No related branches found
No related tags found
No related merge requests found
...@@ -158,7 +158,8 @@ namespace LOFAR { ...@@ -158,7 +158,8 @@ namespace LOFAR {
// Return the greatest power of 2 that divides the value. // Return the greatest power of 2 that divides the value.
// It is used to make the default alignment a power of 2. // It is used to make the default alignment a power of 2.
static uint p2divider (uint value); // It the result exceeds the maximum, it is set to the maximum.
static uint p2divider (uint value, uint maxval=8);
// Helper functions for BlobFieldSet. // Helper functions for BlobFieldSet.
// <group> // <group>
...@@ -237,6 +238,7 @@ namespace LOFAR { ...@@ -237,6 +238,7 @@ namespace LOFAR {
// that is a power of 2. E.g. for an array of structs containing 3 floats, // that is a power of 2. E.g. for an array of structs containing 3 floats,
// the element size is 12, but the basic element size is 4. // the element size is 12, but the basic element size is 4.
// For a struct containing 2 floats the basic element size would be 8. // For a struct containing 2 floats the basic element size would be 8.
// The default alignment is maximum 8.
// //
// Because a blob can be used to exchange data between different systems, // Because a blob can be used to exchange data between different systems,
// it must be possible to convert data as needed (for instance from big to // it must be possible to convert data as needed (for instance from big to
......
...@@ -161,7 +161,7 @@ namespace LOFAR { ...@@ -161,7 +161,7 @@ namespace LOFAR {
} }
} }
uint BlobFieldBase::p2divider (uint value) uint BlobFieldBase::p2divider (uint value, uint maxval)
{ {
if ((value & (value-1)) != 0) { if ((value & (value-1)) != 0) {
// No power of 2, so find greatest power of 2 that divides value. // No power of 2, so find greatest power of 2 that divides value.
...@@ -172,7 +172,7 @@ namespace LOFAR { ...@@ -172,7 +172,7 @@ namespace LOFAR {
v /= 2; v /= 2;
} }
} }
return value; return std::min (value, maxval);
} }
} // end namespace } // end namespace
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment