Unified · Split
| @@ -162,37 +162,25 @@ procwakeup(Proc *p) · 161 unmodified lines | ||
| 162 | 162 | pthread_mutex_unlock(&op->mutex); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | −int randfd; | |
| 165 | +static int randfd; | |
| 166 | 166 | #undef open |
| 167 | 167 | void |
| 168 | 168 | randominit(void) |
| 169 | 169 | { |
| 170 | −#ifdef USE_RANDOM | |
| 171 | − srandom(getpid()+fastticks(nil)+ticks()); | |
| 172 | −#else | |
| 173 | 170 | if((randfd = open("/dev/urandom", OREAD)) < 0) |
| 174 | 171 | if((randfd = open("/dev/random", OREAD)) < 0) |
| 175 | 172 | panic("open /dev/random: %r"); |
| 176 | −#endif | |
| 177 | 173 | } |
| 178 | 174 | |
| 179 | 175 | #undef read |
| 180 | 176 | ulong |
| 181 | 177 | randomread(void *v, ulong n) |
| 182 | 178 | { |
| 183 | −#ifdef USE_RANDOM | |
| 184 | − int i; | |
| 185 | − | |
| 186 | − for(i=0; i<n; i++) | |
| 187 | − ((uchar*)v)[i] = random(); | |
| 188 | − return n; | |
| 189 | −#else | |
| 190 | 179 | int m; |
| 191 | 180 | |
| 192 | 181 | if((m = read(randfd, v, n)) != n) |
| 193 | 182 | panic("short read from /dev/random: %d but %d", n, m); |
| 194 | 183 | return m; |
| 195 | −#endif | |
| 196 | 184 | } |
| 197 | 185 | |
| 198 | 186 | #undef time |