void try_one_crash(int try_num) { long int sysno, arg1, arg2, arg3, arg4, arg5, arg6, arg7; do { sysno = rand() % sysno_max; } while (in_blacklist(sysno)); arg1 = rand_long(); arg2 = rand_long(); arg3 = rand_long(); arg4 = rand_long(); arg5 = rand_long(); arg6 = rand_long(); arg7 = rand_long(); if (x_opt) { if (verbose_level >= 1) printf("%04d: syscall(%ld, %#lx, %#lx, %#lx, %#lx, " "%#lx, %#lx, %#lx)\n", try_num, sysno, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } else { syscall(sysno, arg1, arg2, arg3, arg4, arg5, arg6, arg7); record_errno(errno); } }
unsigned char rand_byte() { unsigned char t = 0; unsigned long v = rand_long(); for(int i=0; i<sizeof(unsigned long);i++) { t ^= v & 0xff; v >>= 8; } return t; }
/* Fisher-Yates shuffle */ void shuffle(CREC *array, long n) { long i, j; CREC tmp; for (i = n - 1; i > 0; i--) { j = rand_long(i + 1); tmp = array[j]; array[j] = array[i]; array[i] = tmp; } }
void shuffle_long(long *array, long elements) /* shuffle a long array in place * Fisher-Yates algorithm, see `perldoc -q shuffle` :-) */ { long i, j, temp; for (i = elements-1; i > 0; i--) { j=rand_long(i); /* pick element */ temp = array[i]; /* swap elements */ array[i] = array[j]; array[j] = temp; } }
void move_random (piece_info_t *obj) { long loc_list[8]; int i, nloc; long loc; nloc = 0; for (i = 0; i < 8; i++) { loc = obj->loc + dir_offset[i]; if (good_loc (obj, loc)) { loc_list[nloc] = loc; /* remember this location */ nloc++; /* count locations we can move to */ } } if (nloc == 0) return; /* no legal move */ i = rand_long ((long)nloc-1); /* choose random direction */ move_obj (obj, loc_list[i]); /* move the piece */ }