random_seed est un peu plus random

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4652 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2002-04-15 11:41:55 +00:00
parent 2ed36730d1
commit 94acce074f
1 changed files with 7 additions and 2 deletions

View File

@ -302,13 +302,18 @@ CAMLprim value sys_time(value unit)
CAMLprim value sys_random_seed (value unit)
{
long seed;
#ifdef HAS_GETTIMEOFDAY
struct timeval tv;
gettimeofday(&tv, NULL);
return Val_int(tv.tv_sec ^ tv.tv_usec);
seed = tv.tv_sec ^ tv.tv_usec;
#else
return Val_int(time (NULL));
seed = time (NULL);
#endif
#ifdef HAS_UNISTD
seed ^= getppid() << 16 | getpid();
#endif
return Val_long(seed);
}
CAMLprim value sys_get_config(value unit)