| 181 | } |
| 182 | |
| 183 | double |
| 184 | rte_drand(void) |
| 185 | { |
| 186 | static const uint64_t denom = (uint64_t)1 << 53; |
| 187 | uint64_t rand64 = rte_rand(); |
| 188 | |
| 189 | /* |
| 190 | * The double mantissa only has 53 bits, so we uniformly mask off the |
| 191 | * high 11 bits and then floating-point divide by 2^53 to achieve a |
| 192 | * result in [0, 1). |
| 193 | * |
| 194 | * We are not allowed to emit 1.0, so denom must be one greater than |
| 195 | * the possible range of the preceding step. |
| 196 | */ |
| 197 | |
| 198 | rand64 &= denom - 1; |
| 199 | return (double)rand64 / denom; |
| 200 | } |
| 201 | |
| 202 | static uint64_t |
| 203 | __rte_random_initial_seed(void) |