to use the one from glibc.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4130
#undef SORT
}
+static UInt seed = 0;
+
+void VG_(srandom)(UInt s)
+{
+ seed = s;
+}
+
+// This random number generator is based on the one suggested in Kernighan
+// and Ritchie's "The C Programming Language".
+UInt VG_(random)(void)
+{
+ seed = (1103515245*seed + 12345);
+ return seed;
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
#include "pub_core_mallocfree.h"
#include "pub_core_skiplist.h"
-#include <stdlib.h>
-
#define SKIPLIST_DEBUG 0
#define SK_MAXHEIGHT 20 /* 2^20 elements */
{
UInt ret = 0;
- while((ret < SK_MAXHEIGHT - 1) && (random() & 1))
+ while((ret < SK_MAXHEIGHT - 1) && (VG_(random)() & 1))
ret++;
return ret;
/* Returns the base-2 logarithm of x. */
extern Int VG_(log2) ( Int x );
+// A pseudo-random number generator returning a random UInt, and its
+// seed function.
+extern void VG_(srandom) ( UInt seed );
+extern UInt VG_(random) ( void );
+
#endif // __PUB_TOOL_LIBCBASE_H
/*--------------------------------------------------------------------*/