float qansel_hardware_getseed()
{
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- float seed = (float)((unsigned long)ts.tv_sec * 1000000000LL + ts.tv_nsec);
+ #if defined(_WIN32) || defined(_WIN64)
+ #error "implement windows seed"
+ #elif defined(__linux__)
+ unsigned long long int tsi = 0;
+ FILE* f = fopen("/proc/uptime", "r");
+ int c;
+ char ts[128];
+ int tsl = 0;
+ while ( (c = fgetc(f)) != EOF )
+ {
+ if ((c >= '0' && c <= '9') || c == '.')
+ {
+ ts[tsl++] = c;
+ }
+ else
+ {
+ break;
+ }
+ }
+ ts[tsl++] = 0;
+ fclose(f);
+ float seed = atof(ts);
return seed;
+ #else
+ #error "Uknown platform"
+ return 0;
+ #endif
+
+ //struct timespec ts;
+ //clock_gettime(CLOCK_MONOTONIC, &ts);
+ //float seed = (float)((unsigned long)ts.tv_sec * 1000000000LL + ts.tv_nsec);
+ //return seed;
+
}