comparison arogue5/mdport.c @ 252:3d4252fa2ed3

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.
author John "Elwin" Edwards
date Sat, 28 Jan 2017 15:49:41 -0500
parents 56e748983fa8
children d3968e9cb98d
comparison
equal deleted inserted replaced
251:e7862a021609 252:3d4252fa2ed3
76 #include <stdio.h> 76 #include <stdio.h>
77 #include <fcntl.h> 77 #include <fcntl.h>
78 #include <limits.h> 78 #include <limits.h>
79 #include <sys/stat.h> 79 #include <sys/stat.h>
80 #include <signal.h> 80 #include <signal.h>
81 #include <time.h>
81 82
82 #define MOD_MOVE(c) (toupper(c) ) 83 #define MOD_MOVE(c) (toupper(c) )
83 84
84 void 85 void
85 md_init(void) 86 md_init(void)
1230 nocbreak(); /* disable halfdelay mode if on */ 1231 nocbreak(); /* disable halfdelay mode if on */
1231 raw(); 1232 raw();
1232 1233
1233 return(ch & 0x7F); 1234 return(ch & 0x7F);
1234 } 1235 }
1236
1237 unsigned int
1238 md_random_seed(void)
1239 {
1240 unsigned int seed;
1241 seed = (unsigned int) time((time_t *) NULL);
1242 #ifdef _WIN32
1243 seed += _getpid();
1244 #else
1245 seed += getpid();
1246 #endif
1247 return seed;
1248 }