Skip to content

Commit cbe157b

Browse files
committed
Cleaning.
1 parent badb6ee commit cbe157b

File tree

5 files changed

+43
-40
lines changed

5 files changed

+43
-40
lines changed

include/ewah/boolarray.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ template <class uword = uint32_t> class BoolArray {
139139
void set(const size_t pos) {
140140
if (pos >= sizeinbits)
141141
padWithZeroes(pos + 1);
142-
buffer[pos / wordinbits] |= (static_cast<uword>(1) << (pos % wordinbits));
142+
buffer[pos / wordinbits] |= static_cast<uword>((static_cast<uword>(1) << (pos % wordinbits)));
143143
}
144144

145145
/**
@@ -215,7 +215,7 @@ template <class uword = uint32_t> class BoolArray {
215215
size_t upto = out.buffer.size() < ba.buffer.size() ? out.buffer.size()
216216
: ba.buffer.size();
217217
for (size_t i = 0; i < upto; ++i)
218-
out.buffer[i] = buffer[i] & (~ba.buffer[i]);
218+
out.buffer[i] = static_cast<uword>(buffer[i] & (~ba.buffer[i]));
219219
for (size_t i = upto; i < out.buffer.size(); ++i)
220220
out.buffer[i] = buffer[i];
221221
out.clearBogusBits();
@@ -434,7 +434,7 @@ template <class uword = uint32_t> class BoolArray {
434434
void clearBogusBits() {
435435
if ((sizeinbits % wordinbits) != 0) {
436436
const uword maskbogus =
437-
(static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1;
437+
static_cast<uword>((static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1);
438438
buffer[buffer.size() - 1] &= maskbogus;
439439
}
440440
}

include/ewah/ewah-inl.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ template <class uword> class EWAHBoolArraySetBitForwardIterator {
193193
}
194194
wordPosition++; // point to first literal word
195195
wordLength =
196-
wordPosition + RunningLengthWord<uword>::getNumberOfLiteralWords(rlw);
196+
static_cast<uword>(wordPosition + RunningLengthWord<uword>::getNumberOfLiteralWords(rlw));
197197
}
198198

199199
inline bool moveToNext() {
@@ -212,7 +212,7 @@ template <class uword> class EWAHBoolArraySetBitForwardIterator {
212212
if (runningHasNext())
213213
return;
214214
} else {
215-
uword t = word & (~word + 1);
215+
uword t = static_cast<uword>(word & (~word + 1));
216216
answer = literalPosition + countOnes((uword)(t - 1));
217217
word ^= t;
218218
}
@@ -308,7 +308,7 @@ template <class uword> void EWAHBoolArray<uword>::inplace_logicalnot() {
308308
if (sizeinbits % wordinbits != 0) {
309309
RunningLengthWord<uword> rlw(buffer[lastrlw]);
310310
const uword maskbogus =
311-
(static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1;
311+
static_cast<uword>((static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1);
312312
if (rlw.getNumberOfLiteralWords() > 0) { // easy case
313313
buffer[lastrlw + 1 + rlw.getNumberOfLiteralWords() - 1] &= maskbogus;
314314
} else {
@@ -439,7 +439,7 @@ void EWAHBoolArray<uword>::logicalnot(EWAHBoolArray &x) const {
439439
x.fastaddStreamOfEmptyWords(!rlw.getRunningBit(),
440440
rlw.getRunningLength() - 1);
441441
const uword maskbogus =
442-
(static_cast<uword>(1) << (this->sizeinbits % wordinbits)) - 1;
442+
static_cast<uword>((static_cast<uword>(1) << (this->sizeinbits % wordinbits)) - 1);
443443
x.addLiteralWord(maskbogus);
444444
break;
445445
} else {
@@ -458,9 +458,9 @@ void EWAHBoolArray<uword>::logicalnot(EWAHBoolArray &x) const {
458458
}
459459
const uword maskbogus =
460460
(this->sizeinbits % wordinbits != 0)
461-
? (static_cast<uword>(1) << (this->sizeinbits % wordinbits)) - 1
461+
? static_cast<uword>((static_cast<uword>(1) << (this->sizeinbits % wordinbits)) - 1)
462462
: ~static_cast<uword>(0);
463-
x.addLiteralWord((~dw[rlw.getNumberOfLiteralWords() - 1]) & maskbogus);
463+
x.addLiteralWord(static_cast<uword>((~dw[rlw.getNumberOfLiteralWords() - 1]) & maskbogus));
464464
break;
465465
}
466466
}
@@ -744,7 +744,7 @@ bool EWAHBoolArray<uword>::operator==(const EWAHBoolArray &x) const {
744744
}
745745
predator.discardRunningWordsWithReload();
746746
}
747-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
747+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
748748
rlwj.getNumberOfLiteralWords());
749749
if (nbre_literal > 0) {
750750
for (size_t k = 0; k < nbre_literal; ++k)
@@ -862,7 +862,7 @@ void EWAHBoolArray<uword>::appendSetBits(container &out,
862862
for (uword k = 0; k < rlwlw; ++k) {
863863
uword currentword = buffer[pointer];
864864
while (currentword != 0) {
865-
uint64_t t = currentword & -currentword;
865+
uword t = static_cast<uword>(currentword & (~currentword+1));
866866
uint32_t r = numberOfTrailingZeros(t);
867867
out.push_back(currentoffset + r);
868868
currentword ^= t;
@@ -1005,7 +1005,7 @@ size_t EWAHBoolArray<uword>::addStreamOfDirtyWords(const uword *v,
10051005
if (NumberOfLiteralWords + number <=
10061006
RunningLengthWord<uword>::largestliteralcount) {
10071007
RunningLengthWord<uword>::setNumberOfLiteralWords(
1008-
rlw, NumberOfLiteralWords + number);
1008+
rlw, static_cast<uword>(NumberOfLiteralWords + number));
10091009
buffer[lastRLW] = rlw;
10101010
sizeinbits += number * wordinbits;
10111011
buffer.insert(buffer.end(), v, v + number);
@@ -1039,7 +1039,7 @@ void EWAHBoolArray<uword>::fastaddStreamOfDirtyWords(const uword *v,
10391039
if (NumberOfLiteralWords + number <=
10401040
RunningLengthWord<uword>::largestliteralcount) {
10411041
RunningLengthWord<uword>::setNumberOfLiteralWords(
1042-
rlw, NumberOfLiteralWords + number);
1042+
rlw, static_cast<uword>(NumberOfLiteralWords + number));
10431043
buffer[lastRLW] = rlw;
10441044
for (size_t i = 0; i < number; ++i)
10451045
buffer.push_back(v[i]);
@@ -1072,7 +1072,7 @@ size_t EWAHBoolArray<uword>::addStreamOfNegatedDirtyWords(const uword *v,
10721072
if (NumberOfLiteralWords + number <=
10731073
RunningLengthWord<uword>::largestliteralcount) {
10741074
RunningLengthWord<uword>::setNumberOfLiteralWords(
1075-
rlw, NumberOfLiteralWords + number);
1075+
rlw, static_cast<uword>(NumberOfLiteralWords + number));
10761076
buffer[lastRLW] = rlw;
10771077
sizeinbits += number * wordinbits;
10781078
for (size_t k = 0; k < number; ++k)
@@ -1218,7 +1218,7 @@ void EWAHBoolArray<uword>::logicalor(const EWAHBoolArray &a,
12181218
predator.discardRunningWordsWithReload();
12191219
}
12201220

1221-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1221+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
12221222
rlwj.getNumberOfLiteralWords());
12231223
if (nbre_literal > 0) {
12241224
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1263,7 +1263,7 @@ size_t EWAHBoolArray<uword>::logicalorcount(const EWAHBoolArray &a) const {
12631263
predator.discardRunningWordsWithReload();
12641264
}
12651265

1266-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1266+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
12671267
rlwj.getNumberOfLiteralWords());
12681268
if (nbre_literal > 0) {
12691269
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1308,7 +1308,7 @@ void EWAHBoolArray<uword>::logicalxor(const EWAHBoolArray &a,
13081308
predator.getRunningLength() - index);
13091309
predator.discardRunningWordsWithReload();
13101310
}
1311-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1311+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
13121312
rlwj.getNumberOfLiteralWords());
13131313
if (nbre_literal > 0) {
13141314
for (size_t k = 0; k < nbre_literal; ++k)
@@ -1356,7 +1356,7 @@ size_t EWAHBoolArray<uword>::logicalxorcount(const EWAHBoolArray &a) const {
13561356

13571357
predator.discardRunningWordsWithReload();
13581358
}
1359-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1359+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
13601360
rlwj.getNumberOfLiteralWords());
13611361
if (nbre_literal > 0) {
13621362
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1406,7 +1406,7 @@ void EWAHBoolArray<uword>::logicaland(const EWAHBoolArray &a,
14061406
}
14071407
predator.discardRunningWordsWithReload();
14081408
}
1409-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1409+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
14101410
rlwj.getNumberOfLiteralWords());
14111411
if (nbre_literal > 0) {
14121412
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1469,11 +1469,11 @@ void EWAHBoolArray<uword>::logicalandnot(const EWAHBoolArray &a,
14691469
}
14701470
predator.discardRunningWordsWithReload();
14711471
}
1472-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1472+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
14731473
rlwj.getNumberOfLiteralWords());
14741474
if (nbre_literal > 0) {
14751475
for (size_t k = 0; k < nbre_literal; ++k) {
1476-
container.addWord(rlwi.getLiteralWordAt(k) & ~rlwj.getLiteralWordAt(k));
1476+
container.addWord(static_cast<uword>(rlwi.getLiteralWordAt(k) & ~rlwj.getLiteralWordAt(k)));
14771477
}
14781478
rlwi.discardLiteralWordsWithReload(nbre_literal);
14791479
rlwj.discardLiteralWordsWithReload(nbre_literal);
@@ -1524,7 +1524,7 @@ size_t EWAHBoolArray<uword>::logicalandnotcount(const EWAHBoolArray &a) const {
15241524
}
15251525
predator.discardRunningWordsWithReload();
15261526
}
1527-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1527+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
15281528
rlwj.getNumberOfLiteralWords());
15291529
if (nbre_literal > 0) {
15301530
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1567,7 +1567,7 @@ size_t EWAHBoolArray<uword>::logicalandcount(const EWAHBoolArray &a) const {
15671567
}
15681568
predator.discardRunningWordsWithReload();
15691569
}
1570-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1570+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
15711571
rlwj.getNumberOfLiteralWords());
15721572
if (nbre_literal > 0) {
15731573
for (size_t k = 0; k < nbre_literal; ++k) {
@@ -1608,7 +1608,7 @@ bool EWAHBoolArray<uword>::intersects(const EWAHBoolArray &a) const {
16081608
}
16091609
predator.discardRunningWordsWithReload();
16101610
}
1611-
const size_t nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
1611+
const uword nbre_literal = std::min(rlwi.getNumberOfLiteralWords(),
16121612
rlwj.getNumberOfLiteralWords());
16131613
if (nbre_literal > 0) {
16141614
for (size_t k = 0; k < nbre_literal; ++k) {

include/ewah/runninglengthword.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
340340
size_t pd = getNumberOfLiteralWords();
341341
if (pd > 0)
342342
return true;
343-
discardFirstWordsWithReload(pl + pd);
343+
discardFirstWordsWithReload(static_cast<uword>(pl + pd));
344344
}
345345
return false;
346346
}
@@ -352,7 +352,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
352352
if (index + RunningLength > max) {
353353
const size_t offset = max - index;
354354
container.fastaddStreamOfEmptyWords(getRunningBit(), offset);
355-
RunningLength -= offset;
355+
RunningLength = static_cast<uword>(RunningLength - offset);
356356
return max;
357357
}
358358
container.fastaddStreamOfEmptyWords(getRunningBit(), RunningLength);
@@ -361,7 +361,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
361361
const size_t offset = max - index;
362362
writeLiteralWords(offset, container);
363363
RunningLength = 0;
364-
NumberOfLiteralWords -= offset;
364+
NumberOfLiteralWords = static_cast<uword>(NumberOfLiteralWords - offset);
365365
return max;
366366
}
367367
writeLiteralWords(NumberOfLiteralWords, container);
@@ -389,7 +389,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
389389
}
390390
if (pd > 0)
391391
return true;
392-
discardFirstWordsWithReload(pl + pd);
392+
discardFirstWordsWithReload(static_cast<uword>(pl + pd));
393393
}
394394
return false;
395395
}
@@ -411,7 +411,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
411411
pd = max - index;
412412
}
413413
writeNegatedLiteralWords(pd, container);
414-
discardFirstWordsWithReload(pl + pd);
414+
discardFirstWordsWithReload(static_cast<uword>(pl + pd));
415415
index += pd;
416416
}
417417
return index;
@@ -432,7 +432,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
432432
}
433433
if (pd > 0)
434434
return true;
435-
discardFirstWordsWithReload(pl + pd);
435+
discardFirstWordsWithReload(static_cast<uword>(pl + pd));
436436
index += pd;
437437
}
438438
return false;
@@ -532,7 +532,7 @@ template <class uword = uint32_t> class BufferedRunningLengthWord {
532532
size_t toDiscard = x > NumberOfLiteralWords ? NumberOfLiteralWords : x;
533533
NumberOfLiteralWords =
534534
static_cast<uword>(NumberOfLiteralWords - toDiscard);
535-
x -= toDiscard;
535+
x = static_cast<uword>(x - toDiscard);
536536
if ((x > 0) || (size() == 0)) {
537537
if (!next())
538538
break;

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function(add_cpp_test TEST_NAME)
1111
if(NOT MSVC)
1212
target_compile_options(
1313
${TEST_NAME} PUBLIC
14-
-Werror -Wall -Wextra -Weffc++ -Wsign-compare -Wshadow -Wwrite-strings
14+
-Wall -Wextra -Weffc++ -Wsign-compare -Wshadow -Wwrite-strings
1515
-Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion
1616
)
1717
endif()

tests/unit.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,14 +1454,17 @@ template <class uword> bool dataindexingtest(std::string path) {
14541454
return true;
14551455
}
14561456

1457-
typedef struct {
1458-
EWAHBoolArray<uint32_t> gpr[32][4];
1459-
} vcpu_ctx;
1460-
1461-
typedef struct {
1462-
vcpu_ctx vcpu;
1463-
void *uval;
1464-
} thread_ctx_t;
1457+
struct vcpu_ctx {
1458+
EWAHBoolArray<uint32_t> gpr[32][4]{};
1459+
};
1460+
1461+
struct thread_ctx_t {
1462+
thread_ctx_t() = default;
1463+
thread_ctx_t(const thread_ctx_t& t) = delete;
1464+
thread_ctx_t& operator=(const thread_ctx_t&) = delete;
1465+
vcpu_ctx vcpu{};
1466+
void *uval{nullptr};
1467+
};
14651468

14661469
bool funnytest() {
14671470
cout << "[funnytest] checking funnytest" << endl;

0 commit comments

Comments
 (0)