diff options
Diffstat (limited to 'src/platform/w32functions.c')
-rw-r--r-- | src/platform/w32functions.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/platform/w32functions.c b/src/platform/w32functions.c index 34c5d73d..3c25e2b2 100644 --- a/src/platform/w32functions.c +++ b/src/platform/w32functions.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <winsock2.h> | 28 | #include <winsock2.h> |
29 | #include <string.h> | 29 | #include <string.h> |
30 | #include <stdint.h> | ||
31 | #include <time.h> | ||
30 | 32 | ||
31 | /** | 33 | /** |
32 | * Return errno equivalent of last winsock error | 34 | * Return errno equivalent of last winsock error |
@@ -618,3 +620,22 @@ int MHD_W32_pair_of_sockets_(SOCKET sockets_pair[2]) | |||
618 | sockets_pair[1] = INVALID_SOCKET; | 620 | sockets_pair[1] = INVALID_SOCKET; |
619 | return -1; | 621 | return -1; |
620 | } | 622 | } |
623 | |||
624 | /** | ||
625 | * Static variable used by pseudo random number generator | ||
626 | */ | ||
627 | static int32_t rnd_val = 0; | ||
628 | /** | ||
629 | * Generate 31-bit pseudo random number. | ||
630 | * Function initialize itself at first call to current time. | ||
631 | * @return 31-bit pseudo random number. | ||
632 | */ | ||
633 | int MHD_W32_random(void) | ||
634 | { | ||
635 | if (0 == rnd_val) | ||
636 | rnd_val = (int32_t)time(NULL); | ||
637 | /* stolen from winsup\cygwin\random.cc */ | ||
638 | rnd_val = (16807 * (rnd_val % 127773) - 2836 * (rnd_val / 127773)) | ||
639 | & 0x7fffffff; | ||
640 | return (int)rnd_val; | ||
641 | } | ||