if MKSH_SMALL and HAVE_ARC4RANDOM, there is no need to use rand()/srand(3)

ever, since MKSH_SMALL is not required to be as close to compatibility as
normal/generic shells; we can also get rid of time(3) calls
This commit is contained in:
tg
2008-11-30 10:33:40 +00:00
parent abb6bea6d8
commit c0703f5f26
4 changed files with 26 additions and 6 deletions

4
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.113 2008/11/15 09:00:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.114 2008/11/30 10:33:39 tg Exp $");
extern char **environ;
@ -227,8 +227,10 @@ main(int argc, const char *argv[])
setstr(pwd_v, current_wd, KSH_RETURN_ERROR);
}
ppid = getppid();
#if !HAVE_ARC4RANDOM || !defined(MKSH_SMALL)
change_random(((unsigned long)kshname) ^
((unsigned long)time(NULL) * kshpid * ppid));
#endif
#if HAVE_ARC4RANDOM
Flag(FARC4RANDOM) = 2; /* use arc4random(3) until $RANDOM is written */
#endif