4 Commits
v1.3 ... v1.3.1

View File

@@ -28,7 +28,7 @@ static inline ull pow2_ceil(ull x) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
// return the result if no input // return the result if no input
if (argc <= 1) return printf("%s\n", (rand() & 1) ? "heads" : "tails"); if (argc <= 1) return printf("%s\n", (clock() & 1) ? "heads" : "tails");
dynrdat* rdat = NULL; dynrdat* rdat = NULL;
@@ -57,7 +57,8 @@ int main(int argc, char** argv) {
} }
// populate the array with random data // populate the array with random data
getrandom(rdat->dat, c + !!mod, 0); if (getrandom(rdat->dat, (c + !!mod) * sizeof(ull), 0) < 0)
error(1, "failed to acquire random data!\n", );
// perform for the input count // perform for the input count
ull headsc = 0; // amount of heads ull headsc = 0; // amount of heads
@@ -76,7 +77,7 @@ int main(int argc, char** argv) {
ull msk = (1 << mod) - 1; // get a mask with the set word size ull msk = (1 << mod) - 1; // get a mask with the set word size
int cnt = __builtin_popcountll(*n & msk); int cnt = __builtin_popcountll(*n & msk);
headsc += cnt; headsc += cnt;
tailsc += c - cnt; tailsc += mod - cnt;
} }
// print the results of this cycle // print the results of this cycle