Mercurial > octave
changeset 21928:315f4ba604c8
* randmtzig.cc: Use octave::sys::time.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 16 Jun 2016 13:07:34 -0400 |
parents | 6f62bd248919 |
children | 7ab7cd327257 |
files | liboctave/numeric/randmtzig.cc |
diffstat | 1 files changed, 9 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/numeric/randmtzig.cc Thu Jun 16 10:43:27 2016 -0400 +++ b/liboctave/numeric/randmtzig.cc Thu Jun 16 13:07:34 2016 -0400 @@ -157,13 +157,9 @@ #endif #include <cstdio> -#include <ctime> - -#if defined (HAVE_GETTIMEOFDAY) -# include <sys/time.h> -#endif #include "lo-math.h" +#include "oct-time.h" #include "randmtzig.h" /* FIXME: may want to suppress X86 if sizeof(long) > 4 */ @@ -275,18 +271,18 @@ } /* If there isn't enough entropy, gather some from various sources */ + + octave::sys::time now; + if (n < MT_N) - entropy[n++] = time (0); /* Current time in seconds */ + entropy[n++] = now.unix_time (); /* Current time in seconds */ + if (n < MT_N) entropy[n++] = clock (); /* CPU time used (usec) */ -#if defined (HAVE_GETTIMEOFDAY) + if (n < MT_N) - { - struct timeval tv; - if (gnulib::gettimeofday (&tv, 0) != -1) - entropy[n++] = tv.tv_usec; /* Fractional part of current time */ - } -#endif + entropy[n++] = now.usec (); /* Fractional part of current time */ + /* Send all the entropy into the initial state vector */ oct_init_by_array (entropy,n); }