On 2015-12-01 at 14:40 'Davide Libenzi' via Akaros wrote:
> Now try with something that emulates a bit more reality (cold
> branch), in making that front branch be random, instead of scorching
> hot towards a single hint.
This is pretty cool. Couple questions for my own knowledge:
> [main_test.c]
> #include <stddef.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> extern int testovf(size_t a, size_t b);
> extern size_t base(void);
>
> size_t num_values = 100000;
>
> size_t qrand(void)
> {
> return ((size_t) rand() << 4) ^ rand();
Was this to make it possible to get rands > (1 << 32) (and thus capable
of overflow)?
> }
>
> int main(void)
> {
> size_t i, j, c;
> size_t *vals = calloc(num_values, sizeof(size_t));
>
> for (c = 0; c < num_values; c++) {
> do {
> vals[c] = qrand();
> } while (!vals[c]);
> }
> c = 0;
> for (i = 0; i < 4000; i++) {
> for (j = base(); j < num_values; j++) {
> c += testovf(vals[j - 1], vals[j]);
> }
> }
> printf("c = %zd\n", c);
What value of c did you get?
Barret
--
You received this message because you are subscribed to the Google Groups
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.