** Use 'time' and 'clock' as sources of "randomness". Because we don't ** know the types 'clock_t' and 'time_t', we cannot cast them to ** anything without risking overflows. A safe way to use their values ** is to copy them to an array of a known type and use the array values. */
| 256 | ** is to copy them to an array of a known type and use the array values. |
| 257 | */ |
| 258 | static unsigned int l_randomizePivot (void) { |
| 259 | clock_t c = clock(); |
| 260 | time_t t = time(NULL); |
| 261 | unsigned int buff[sof(c) + sof(t)]; |
| 262 | unsigned int i, rnd = 0; |
| 263 | memcpy(buff, &c, sof(c) * sizeof(unsigned int)); |
| 264 | memcpy(buff + sof(c), &t, sof(t) * sizeof(unsigned int)); |
| 265 | for (i = 0; i < sof(buff); i++) |
| 266 | rnd += buff[i]; |
| 267 | return rnd; |
| 268 | } |
| 269 | |
| 270 | #endif /* } */ |
| 271 |