gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37765 - in libmicrohttpd: . src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r37765 - in libmicrohttpd: . src/microhttpd
Date: Tue, 23 Aug 2016 22:13:07 +0200

Author: Karlson2k
Date: 2016-08-23 22:13:07 +0200 (Tue, 23 Aug 2016)
New Revision: 37765

Modified:
   libmicrohttpd/configure.ac
   libmicrohttpd/src/microhttpd/Makefile.am
   libmicrohttpd/src/microhttpd/mhd_compat.c
   libmicrohttpd/src/microhttpd/mhd_compat.h
Log:
Emulate random() on platforms without random(), but with rand() function.

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2016-08-23 20:13:03 UTC (rev 37764)
+++ libmicrohttpd/configure.ac  2016-08-23 20:13:07 UTC (rev 37765)
@@ -551,6 +551,9 @@
   sockLib.h inetLib.h net/if.h])
 AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"])
 
+# Check for generic functions
+AC_CHECK_FUNCS([rand random])
+
 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
    [ AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1, [Do we have sockaddr_in.sin_len?])
    ],

Modified: libmicrohttpd/src/microhttpd/Makefile.am
===================================================================
--- libmicrohttpd/src/microhttpd/Makefile.am    2016-08-23 20:13:03 UTC (rev 
37764)
+++ libmicrohttpd/src/microhttpd/Makefile.am    2016-08-23 20:13:07 UTC (rev 
37765)
@@ -167,7 +167,7 @@
   $(top_builddir)/src/microhttpd/libmicrohttpd.la
 
 test_postprocessor_SOURCES = \
-  test_postprocessor.c mhd_compat.c
+  test_postprocessor.c
 test_postprocessor_CPPFLAGS = \
   $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS)
 test_postprocessor_LDADD = \
@@ -181,7 +181,7 @@
   $(top_builddir)/src/microhttpd/libmicrohttpd.la
 
 test_postprocessor_large_SOURCES = \
-  test_postprocessor_large.c mhd_compat.c
+  test_postprocessor_large.c
 test_postprocessor_large_CPPFLAGS = \
   $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS)
 test_postprocessor_large_LDADD = \

Modified: libmicrohttpd/src/microhttpd/mhd_compat.c
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_compat.c   2016-08-23 20:13:03 UTC (rev 
37764)
+++ libmicrohttpd/src/microhttpd/mhd_compat.c   2016-08-23 20:13:07 UTC (rev 
37765)
@@ -46,27 +46,7 @@
 }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-/**
- * Static variable used by pseudo random number generator
- */
-static int32_t rnd_val = 0;
 
-/**
- * Generate 31-bit pseudo random number.
- * Function initialize itself at first call to current time.
- * @return 31-bit pseudo random number.
- */
-int MHD_W32_random_(void)
-{
-  if (0 == rnd_val)
-    rnd_val = (int32_t)time(NULL);
-  /* stolen from winsup\cygwin\random.cc */
-  rnd_val = (16807 * (rnd_val % 127773) - 2836 * (rnd_val / 127773))
-               & 0x7fffffff;
-  return (int)rnd_val;
-}
-
-
 #ifndef HAVE_SNPRINTF
 /* Emulate snprintf function on W32 */
 int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, 
...)

Modified: libmicrohttpd/src/microhttpd/mhd_compat.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_compat.h   2016-08-23 20:13:03 UTC (rev 
37764)
+++ libmicrohttpd/src/microhttpd/mhd_compat.h   2016-08-23 20:13:07 UTC (rev 
37765)
@@ -35,6 +35,7 @@
 #define MHD_COMPAT_H 1
 
 #include "mhd_options.h"
+#include <stdlib.h>
 
 /* Platform-independent snprintf name */
 #if defined(HAVE_SNPRINTF)
@@ -49,19 +50,20 @@
 #endif /* ! _WIN32*/
 #endif /* ! HAVE_SNPRINTF */
 
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#ifdef HAVE_RANDOM
+/**
+ * Generate pseudo random number at least 30-bit wide.
+ * @return pseudo random number at least 30-bit wide.
+ */
 #define MHD_random_() random()
-#else  /* _WIN32 && !__CYGWIN__ */
-#define MHD_random_() MHD_W32_random_()
-
+#else  /* HAVE_RANDOM */
+#ifdef HAVE_RAND
 /**
- * Generate 31-bit pseudo random number.
- * Function initialize itself at first call to current time.
- * @return 31-bit pseudo random number.
+ * Generate pseudo random number at least 30-bit wide.
+ * @return pseudo random number at least 30-bit wide.
  */
-int MHD_W32_random_(void);
-#endif /* _WIN32 && !__CYGWIN__ */
+#define MHD_random_() ( (((long)rand()) << 15) + (long)rand() )
+#endif /* HAVE_RAND */
+#endif /* HAVE_RANDOM */
 
-
-
 #endif /* MHD_COMPAT_H */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]