comparison arogue7/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 f9ef86cf22b2
children d3968e9cb98d
comparison
equal deleted inserted replaced
251:e7862a021609 252:3d4252fa2ed3
69 #include <string.h> 69 #include <string.h>
70 #include <fcntl.h> 70 #include <fcntl.h>
71 #include <limits.h> 71 #include <limits.h>
72 #include <sys/stat.h> 72 #include <sys/stat.h>
73 #include <signal.h> 73 #include <signal.h>
74 #include <time.h>
74 75
75 #define MOD_MOVE(c) (toupper(c) ) 76 #define MOD_MOVE(c) (toupper(c) )
76 77
77 void 78 void
78 md_init(void) 79 md_init(void)
1212 nocbreak(); /* disable halfdelay mode if on */ 1213 nocbreak(); /* disable halfdelay mode if on */
1213 raw(); 1214 raw();
1214 1215
1215 return(ch & 0x7F); 1216 return(ch & 0x7F);
1216 } 1217 }
1218
1219 unsigned int
1220 md_random_seed(void)
1221 {
1222 unsigned int seed;
1223 seed = (unsigned int) time((time_t *) NULL);
1224 #ifdef _WIN32
1225 seed += _getpid();
1226 #else
1227 seed += getpid();
1228 #endif
1229 return seed;
1230 }