| 191 | } // namespace |
| 192 | |
| 193 | void RandAddDynamicEnv(CSHA512& hasher) |
| 194 | { |
| 195 | // Various clocks |
| 196 | #ifdef WIN32 |
| 197 | FILETIME ftime; |
| 198 | GetSystemTimeAsFileTime(&ftime); |
| 199 | hasher << ftime; |
| 200 | #else |
| 201 | struct timespec ts = {}; |
| 202 | # ifdef CLOCK_MONOTONIC |
| 203 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 204 | hasher << ts; |
| 205 | # endif |
| 206 | # ifdef CLOCK_REALTIME |
| 207 | clock_gettime(CLOCK_REALTIME, &ts); |
| 208 | hasher << ts; |
| 209 | # endif |
| 210 | # ifdef CLOCK_BOOTTIME |
| 211 | clock_gettime(CLOCK_BOOTTIME, &ts); |
| 212 | hasher << ts; |
| 213 | # endif |
| 214 | // gettimeofday is available on all UNIX systems, but only has microsecond precision. |
| 215 | struct timeval tv = {}; |
| 216 | gettimeofday(&tv, nullptr); |
| 217 | hasher << tv; |
| 218 | #endif |
| 219 | // Probably redundant, but also use all the standard library clocks: |
| 220 | hasher << std::chrono::system_clock::now().time_since_epoch().count(); |
| 221 | hasher << std::chrono::steady_clock::now().time_since_epoch().count(); |
| 222 | hasher << std::chrono::high_resolution_clock::now().time_since_epoch().count(); |
| 223 | |
| 224 | #ifndef WIN32 |
| 225 | // Current resource usage. |
| 226 | struct rusage usage = {}; |
| 227 | if (getrusage(RUSAGE_SELF, &usage) == 0) hasher << usage; |
| 228 | #endif |
| 229 | |
| 230 | #ifdef __linux__ |
| 231 | AddFile(hasher, "/proc/diskstats"); |
| 232 | AddFile(hasher, "/proc/vmstat"); |
| 233 | AddFile(hasher, "/proc/schedstat"); |
| 234 | AddFile(hasher, "/proc/zoneinfo"); |
| 235 | AddFile(hasher, "/proc/meminfo"); |
| 236 | AddFile(hasher, "/proc/softirqs"); |
| 237 | AddFile(hasher, "/proc/stat"); |
| 238 | AddFile(hasher, "/proc/self/schedstat"); |
| 239 | AddFile(hasher, "/proc/self/status"); |
| 240 | #endif |
| 241 | |
| 242 | #ifdef HAVE_SYSCTL |
| 243 | # ifdef CTL_KERN |
| 244 | # if defined(KERN_PROC) && defined(KERN_PROC_ALL) |
| 245 | AddSysctl<CTL_KERN, KERN_PROC, KERN_PROC_ALL>(hasher); |
| 246 | # endif |
| 247 | # endif |
| 248 | # ifdef CTL_HW |
| 249 | # ifdef HW_DISKSTATS |
| 250 | AddSysctl<CTL_HW, HW_DISKSTATS>(hasher); |
no test coverage detected