* Generates pseudo-random numbers. * This function is only quoted for boundary string generation for multipart * content. * @param max Maximum range of random numbers to be generated. * @return A generated random number. */
| 492 | * @return A generated random number. |
| 493 | */ |
| 494 | long ESP32WebCam::_random(long max) { |
| 495 | uint32_t x = esp_random(); |
| 496 | uint64_t m = uint64_t(x) * uint64_t(max); |
| 497 | uint32_t l = uint32_t(m); |
| 498 | if (l < max) { |
| 499 | uint32_t t = -max; |
| 500 | if (t >= max) { |
| 501 | t -= max; |
| 502 | if (t >= max) |
| 503 | t %= max; |
| 504 | } |
| 505 | while (l < t) { |
| 506 | x = esp_random(); |
| 507 | m = uint64_t(x) * uint64_t(max); |
| 508 | l = uint32_t(m); |
| 509 | } |
| 510 | } |
| 511 | return m >> 32; |
| 512 | } |
nothing calls this directly
no outgoing calls
no test coverage detected