| 167 | } |
| 168 | |
| 169 | rk_error rk_randomseed(rk_state *state) { |
| 170 | #ifndef _WIN32 |
| 171 | struct timeval tv; |
| 172 | #else |
| 173 | struct _timeb tv; |
| 174 | #endif |
| 175 | int i; |
| 176 | |
| 177 | if (rk_devfill(state->key, sizeof(state->key), 0) == RK_NOERR) { |
| 178 | /* ensures non-zero key */ |
| 179 | state->key[0] |= 0x80000000UL; |
| 180 | state->pos = RK_STATE_LEN; |
| 181 | state->gauss = 0; |
| 182 | state->has_gauss = 0; |
| 183 | state->has_binomial = 0; |
| 184 | |
| 185 | for (i = 0; i < 624; i++) { |
| 186 | state->key[i] &= 0xffffffffUL; |
| 187 | } |
| 188 | return RK_NOERR; |
| 189 | } |
| 190 | |
| 191 | #ifndef _WIN32 |
| 192 | gettimeofday(&tv, NULL); |
| 193 | rk_seed(rk_hash(getpid()) ^ rk_hash(tv.tv_sec) ^ rk_hash(tv.tv_usec) ^ |
| 194 | rk_hash(clock()), |
| 195 | state); |
| 196 | #else |
| 197 | _FTIME(&tv); |
| 198 | rk_seed(rk_hash(tv.time) ^ rk_hash(tv.millitm) ^ rk_hash(clock()), state); |
| 199 | #endif |
| 200 | |
| 201 | return RK_ENODEV; |
| 202 | } |
| 203 | |
| 204 | /* Magic Mersenne Twister constants */ |
| 205 | #define N 624 |
nothing calls this directly
no test coverage detected