use correct PRNG initializer
authorNils Durner <durner@gnunet.org>
Thu, 24 Sep 2009 19:19:28 +0000 (19:19 +0000)
committerNils Durner <durner@gnunet.org>
Thu, 24 Sep 2009 19:19:28 +0000 (19:19 +0000)
src/include/plibc.h
src/util/test_container_bloomfilter.c

index 51d78fc7ebf7e03026d54cc4344adbb1eb7f2d2b..6d02323aafee7449ae1e4cea37d5f1bfe4215cd6 100644 (file)
@@ -22,7 +22,7 @@
  * @brief PlibC header
  * @attention This file is usually not installed under Unix,
  *            so ship it with your application
- * @version $Revision: 39 $
+ * @version $Revision: 44 $
  */
 
 #ifndef _PLIBC_H_
@@ -379,6 +379,7 @@ int _win_access( const char *path, int mode );
 int _win_chmod(const char *filename, int pmode);
 char *realpath(const char *file_name, char *resolved_name);
 long _win_random(void);
+void _win_srandom(unsigned seed);
 int _win_remove(const char *path);
 int _win_rename(const char *oldname, const char *newname);
 int _win_stat(const char *path, struct stat *buffer);
@@ -492,6 +493,7 @@ size_t strnlen (const char *str, size_t maxlen);
  #define MUNMAP(s, l) munmap(s, l)
  #define STRERROR(i) strerror(i)
  #define RANDOM() random()
+ #define SRANDOM(s) srandom(s)
  #define READLINK(p, b, s) readlink(p, b, s)
  #define LSTAT(p, b) lstat(p, b)
  #define LSTAT64(p, b) lstat64(p, b)
@@ -570,6 +572,7 @@ size_t strnlen (const char *str, size_t maxlen);
  #define CHMOD(f, p) _win_chmod(f, p)
  #define PIPE(h) _win_pipe(h)
  #define RANDOM() _win_random()
+ #define SRANDOM(s) _win_srandom()
  #define REMOVE(p) _win_remove(p)
  #define RENAME(o, n) _win_rename(o, n)
  #define STAT(p, b) _win_stat(p, b)
index 012d3f954144e413d4701e846713b438ca7d0f2d..2e7fb2e280a812108e6bcaa01be23f9389471e87 100644 (file)
@@ -69,7 +69,7 @@ main (int argc, char *argv[])
   struct stat sbuf;
 
   GNUNET_log_setup ("test-container-bloomfilter", "WARNING", NULL);
-  srand (1);
+  SRANDOM (1);
   if (0 == stat (TESTFILE, &sbuf))
     if (0 != UNLINK (TESTFILE))
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", TESTFILE);
@@ -80,7 +80,7 @@ main (int argc, char *argv[])
       nextHC (&tmp);
       GNUNET_CONTAINER_bloomfilter_add (bf, &tmp);
     }
-  srand (1);
+  SRANDOM (1);
   ok1 = 0;
   for (i = 0; i < 200; i++)
     {
@@ -108,7 +108,7 @@ main (int argc, char *argv[])
   bfi = GNUNET_CONTAINER_bloomfilter_init (buf, SIZE, K);
   GNUNET_assert (bfi != NULL);
 
-  srand (1);
+  SRANDOM (1);
   ok1 = 0;
   ok2 = 0;
   for (i = 0; i < 200; i++)
@@ -137,7 +137,7 @@ main (int argc, char *argv[])
       return -1;
     }
 
-  srand (1);
+  SRANDOM (1);
   for (i = 0; i < 100; i++)
     {
       nextHC (&tmp);
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
       GNUNET_CONTAINER_bloomfilter_remove (bfi, &tmp);
     }
 
-  srand (1);
+  SRANDOM (1);
 
   ok1 = 0;
   ok2 = 0;
@@ -177,7 +177,7 @@ main (int argc, char *argv[])
       return -1;
     }
 
-  srand (3);
+  SRANDOM (3);
 
   GNUNET_CONTAINER_bloomfilter_clear (bf);
   falseok = 0;
@@ -201,14 +201,14 @@ main (int argc, char *argv[])
       return -1;
     }
 
-  srand (2);
+  SRANDOM (2);
   i = 20;
   GNUNET_CONTAINER_bloomfilter_resize (bfi, &add_iterator, &i, SIZE * 2, K);
 
-  srand (2);
+  SRANDOM (2);
   i = 20;
   GNUNET_CONTAINER_bloomfilter_resize (bf, &add_iterator, &i, SIZE * 2, K);
-  srand (2);
+  SRANDOM (2);
 
   ok1 = 0;
   ok2 = 0;