comparison rogue4/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 b24545357d2e
children d3968e9cb98d
comparison
equal deleted inserted replaced
251:e7862a021609 252:3d4252fa2ed3
80 #include <stdio.h> 80 #include <stdio.h>
81 #include <fcntl.h> 81 #include <fcntl.h>
82 #include <limits.h> 82 #include <limits.h>
83 #include <sys/stat.h> 83 #include <sys/stat.h>
84 #include <signal.h> 84 #include <signal.h>
85 #include <time.h>
85 86
86 #define MOD_MOVE(c) (toupper(c) ) 87 #define MOD_MOVE(c) (toupper(c) )
87 88
88 void 89 void
89 md_init(void) 90 md_init(void)
1311 1312
1312 uindex = -1; 1313 uindex = -1;
1313 1314
1314 return(ch & 0x7F); 1315 return(ch & 0x7F);
1315 } 1316 }
1317
1318 unsigned int
1319 md_random_seed(void)
1320 {
1321 unsigned int seed;
1322 seed = (unsigned int) time((time_t *) NULL);
1323 #ifdef _WIN32
1324 seed += _getpid();
1325 #else
1326 seed += getpid();
1327 #endif
1328 return seed;
1329 }