* configure.ac: Check for srand48 and drand48.

* src/misc/random.cc (srand, drand): Use srand48 and drand48 if
available.
This commit is contained in:
Alexandre Duret-Lutz 2004-11-12 18:27:09 +00:00
parent 5bcb6091fd
commit 4a7486bbff
3 changed files with 15 additions and 3 deletions

View file

@ -1,5 +1,9 @@
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.

View file

@ -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

View file

@ -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)
{