aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_compat.h
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-08-23 20:13:07 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-08-23 20:13:07 +0000
commita3fc78c87acc9a411959115c071f60adf54a2e11 (patch)
treefe7b9954ef4c3d2aba9be1eb1430f5adee8a8e2c /src/microhttpd/mhd_compat.h
parent47bfec25d8fabfa4cc118e094a08101655d63d65 (diff)
downloadlibmicrohttpd-a3fc78c87acc9a411959115c071f60adf54a2e11.tar.gz
libmicrohttpd-a3fc78c87acc9a411959115c071f60adf54a2e11.zip
Emulate random() on platforms without random(), but with rand() function.
Diffstat (limited to 'src/microhttpd/mhd_compat.h')
-rw-r--r--src/microhttpd/mhd_compat.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/microhttpd/mhd_compat.h b/src/microhttpd/mhd_compat.h
index 7fe3c735..3f88055f 100644
--- a/src/microhttpd/mhd_compat.h
+++ b/src/microhttpd/mhd_compat.h
@@ -35,6 +35,7 @@
35#define MHD_COMPAT_H 1 35#define MHD_COMPAT_H 1
36 36
37#include "mhd_options.h" 37#include "mhd_options.h"
38#include <stdlib.h>
38 39
39/* Platform-independent snprintf name */ 40/* Platform-independent snprintf name */
40#if defined(HAVE_SNPRINTF) 41#if defined(HAVE_SNPRINTF)
@@ -49,19 +50,20 @@ int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ..
49#endif /* ! _WIN32*/ 50#endif /* ! _WIN32*/
50#endif /* ! HAVE_SNPRINTF */ 51#endif /* ! HAVE_SNPRINTF */
51 52
52#if !defined(_WIN32) || defined(__CYGWIN__) 53#ifdef HAVE_RANDOM
54/**
55 * Generate pseudo random number at least 30-bit wide.
56 * @return pseudo random number at least 30-bit wide.
57 */
53#define MHD_random_() random() 58#define MHD_random_() random()
54#else /* _WIN32 && !__CYGWIN__ */ 59#else /* HAVE_RANDOM */
55#define MHD_random_() MHD_W32_random_() 60#ifdef HAVE_RAND
56
57/** 61/**
58 * Generate 31-bit pseudo random number. 62 * Generate pseudo random number at least 30-bit wide.
59 * Function initialize itself at first call to current time. 63 * @return pseudo random number at least 30-bit wide.
60 * @return 31-bit pseudo random number.
61 */ 64 */
62int MHD_W32_random_(void); 65#define MHD_random_() ( (((long)rand()) << 15) + (long)rand() )
63#endif /* _WIN32 && !__CYGWIN__ */ 66#endif /* HAVE_RAND */
64 67#endif /* HAVE_RANDOM */
65
66 68
67#endif /* MHD_COMPAT_H */ 69#endif /* MHD_COMPAT_H */