void Server::requestWork(){ #ifdef __linux__ int randomData = open("/dev/urandom", O_RDONLY); read(randomData, &work, sizeof(work)); close(randomData); #else uchar rnd[4]; rnd[0]=rand_c(); rnd[1]=rand_c(); rnd[2]=rand_c(); rnd[3]=rand_c(); memcpy(&work, rnd, 4); //copy a 4 byte char array into a 4 byte integer #endif }
// Create a new vehicle_t object vehicle_t *new_v(int i, struct bs_t *bs, pthread_t pt) { vehicle_t *vtype = malloc(sizeof(vehicle_t)); vtype->id = i + 1; vtype->bs = bs; vtype->c = rand_c(); vtype->d = rand_d(); return vtype; }