Commit 4a7486bb authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* configure.ac: Check for srand48 and drand48.

* src/misc/random.cc (srand, drand): Use srand48 and drand48 if
available.
parent 5bcb6091
2004-11-12 Alexandre Duret-Lutz <adl@src.lip6.fr>
* configure.ac: Check for srand48 and drand48.
* src/misc/random.cc (srand, drand): Use srand48 and drand48 if
available.
* src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh: New files.
* src/tgbaalgos/Makefile.am (tgbaalgos_HEADERS)
(libtgbaalgos_la_SOURCES): Add them.
......
......@@ -45,6 +45,8 @@ AX_CHECK_BUDDY
AX_CHECK_LBTT
AX_CHECK_GSPNLIB
AC_CHECK_FUNCS([srand48 drand48])
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
......
......@@ -27,24 +27,30 @@ namespace spot
void
srand(unsigned int seed)
{
#if HAVE_SRAND48 && HAVE_DRAND48
::srand48(seed);
#else
::srand(seed);
#endif
}
double
drand()
{
#if HAVE_SRAND48 && HAVE_DRAND48
return ::drand48();
#else
double r = ::rand();
return r / (1.0 + RAND_MAX);
#endif
}
int
mrand(int max)
{
int res = static_cast<int>(max * drand());
return res;
return static_cast<int>(max * drand());
}
int
rrand(int min, int max)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment