Use more portable random seed generation.
The new function md_random_seed() has replaced time() + getpid() and similar methods. Putting everything in mdport.c slightly reduces the warnings and workarounds.
This commit is contained in:
parent
c194ec3dc9
commit
62047972cc
29 changed files with 123 additions and 81 deletions
|
|
@ -102,6 +102,7 @@
|
|||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#define NOOP(x) (x += 0)
|
||||
|
||||
|
|
@ -415,16 +416,6 @@ md_getuid(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
pid_t
|
||||
md_getpid(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return( _getpid() );
|
||||
#else
|
||||
return( getpid() );
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
md_getusername(void)
|
||||
{
|
||||
|
|
@ -1612,3 +1603,16 @@ md_unlockfile(FILE *fp)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
md_random_seed(void)
|
||||
{
|
||||
unsigned int seed;
|
||||
seed = (unsigned int) time((time_t *) NULL);
|
||||
#ifdef _WIN32
|
||||
seed += _getpid();
|
||||
#else
|
||||
seed += getpid();
|
||||
#endif
|
||||
return seed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue