mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 09:58:16 +00:00
Timer: Switch from gettimeofday() to clock_gettime() to workaround problems on cygwin
This commit is contained in:
parent
494c2724f5
commit
bbe9b723e1
@ -42,6 +42,7 @@
|
||||
- Self Test: Skip self-test for mode 8900 user-configurable scrypt settings are incompatible to fixed settings in the self-test hash
|
||||
- Self Test: Skip self-test for mode 15700 because settings are too high and create a too long startup time
|
||||
- Terminal: Send clear line code to the same output stream as the next message following
|
||||
- Timer: Switch from gettimeofday() to clock_gettime() to workaround problems on cygwin
|
||||
|
||||
* changes v4.0.0 -> v4.0.1:
|
||||
|
||||
|
@ -56,7 +56,7 @@ typedef time_t hc_time_t;
|
||||
#if defined (_WIN)
|
||||
typedef LARGE_INTEGER hc_timer_t;
|
||||
#else
|
||||
typedef struct timeval hc_timer_t;
|
||||
typedef struct timespec hc_timer_t;
|
||||
#endif
|
||||
|
||||
// thread
|
||||
|
21
src/timer.c
21
src/timer.c
@ -24,14 +24,16 @@ inline double hc_timer_get (hc_timer_t a)
|
||||
|
||||
hc_timer_set (&hr_tmp);
|
||||
|
||||
return (double) ((double) (hr_tmp.QuadPart - a.QuadPart) / (double) (hr_freq.QuadPart / 1000));
|
||||
double r = ((double) hr_tmp.QuadPart - (double) a.QuadPart) / ((double) hr_freq.QuadPart / 1000);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void hc_timer_set (hc_timer_t* a)
|
||||
{
|
||||
gettimeofday (a, NULL);
|
||||
clock_gettime (CLOCK_MONOTONIC, a);
|
||||
}
|
||||
|
||||
inline double hc_timer_get (hc_timer_t a)
|
||||
@ -40,7 +42,20 @@ inline double hc_timer_get (hc_timer_t a)
|
||||
|
||||
hc_timer_set (&hr_tmp);
|
||||
|
||||
return (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000));
|
||||
hc_timer_t s;
|
||||
|
||||
s.tv_sec = hr_tmp.tv_sec - a.tv_sec;
|
||||
s.tv_nsec = hr_tmp.tv_nsec - a.tv_nsec;
|
||||
|
||||
if (s.tv_nsec < 0)
|
||||
{
|
||||
s.tv_sec -= 1;
|
||||
s.tv_nsec += 1000000000;
|
||||
}
|
||||
|
||||
double r = ((double) s.tv_sec * 1000) + ((double) s.tv_nsec / 1000000);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user